diff --git a/app/models/team.rb b/app/models/team.rb index 311fc27bb..ac4da78fc 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -221,6 +221,7 @@ class Team < ApplicationRecord def create_default_label_templates ZebraLabelTemplate.default.update(team: self, default: true) + ZebraLabelTemplate.default_203dpi.update(team: self, default: false) FluicsLabelTemplate.default.update(team: self, default: true) end end diff --git a/app/models/zebra_label_template.rb b/app/models/zebra_label_template.rb index a3174b05a..619271a2a 100644 --- a/app/models/zebra_label_template.rb +++ b/app/models/zebra_label_template.rb @@ -11,4 +11,15 @@ class ZebraLabelTemplate < LabelTemplate density: 12 ) end + + def self.default_203dpi + ZebraLabelTemplate.new( + name: I18n.t('label_templates.default_zebra_name_203dpi'), + width_mm: 25.4, + height_mm: 12.7, + content: Extends::DEFAULT_LABEL_TEMPLATE_203DPI[:zpl], + unit: 0, + density: 12 + ) + end end diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index e891e9749..1bae5cbbd 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -619,6 +619,24 @@ class Extends HEREDOC } + DEFAULT_LABEL_TEMPLATE_203DPI = { + zpl: + <<~HEREDOC + ^XA + ^MTT + ^MUD,200,200 + ^PR2 + ^MD30 + ^LH0,8 + ^PW180 + ^CF0,15 + ^FO0,5^FD{{ITEM_ID}}^FS + ^FO0,13^BQN,2,3^FDMA,{{ITEM_ID}}^FS + ^FO70,27^FB100,2,0,L^FD{{NAME}}^FS^FS + ^XZ + HEREDOC + } + LABEL_TEMPLATE_FORMAT_MAP = { 'ZebraLabelTemplate' => 'ZPL', 'FluicsLabelTemplate' => 'Fluics' diff --git a/config/locales/en.yml b/config/locales/en.yml index 17ecd6671..496297c9f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1045,7 +1045,8 @@ en: types: fluics_label_template: 'Fluics' zebra_label_template: 'ZPL' - default_zebra_name: 'SciNote Item (ZPL)' + default_zebra_name: 'SciNote Item (ZPL, 300dpi)' + default_zebra_name_203dpi: 'SciNote Item (ZPL, 203dpi)' default_fluics_name: 'SciNote Item (Fluics)' new_label_template: 'New label' fluics: diff --git a/db/migrate/20240718073215_add203_dpi_label_template.rb b/db/migrate/20240718073215_add203_dpi_label_template.rb new file mode 100644 index 000000000..7e9adc45f --- /dev/null +++ b/db/migrate/20240718073215_add203_dpi_label_template.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class Add203DpiLabelTemplate < ActiveRecord::Migration[7.0] + def up + Team.find_each do |team| + team.label_templates.find_by(type: 'ZebraLabelTemplate', name: 'SciNote Item (ZPL)')&.update(name: I18n.t('label_templates.default_zebra_name')) + team.label_templates.create!( + type: 'ZebraLabelTemplate', + name: I18n.t('label_templates.default_zebra_name_203dpi'), + default: false, + content: Extends::DEFAULT_LABEL_TEMPLATE_203DPI, + width_mm: 25.4, + height_mm: 12.7, + unit: 'in', + density: 12 + ) + end + end + + def down + Team.find_each do |team| + team.label_templates.find_by(type: 'ZebraLabelTemplate', name: I18n.t('label_templates.default_zebra_name'))&.update(name: 'SciNote Item (ZPL)') + team.label_templates.find_by(type: 'ZebraLabelTemplate', name: I18n.t('label_templates.default_zebra_name_203dpi'))&.destroy + end + end +end