Merge pull request #7727 from artoscinote/ma_SCI_10901

Add 203dpi label template [SCI-10901]
This commit is contained in:
Martin Artnik 2024-11-07 12:31:27 +01:00 committed by GitHub
commit 8246eed23c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 58 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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:

View file

@ -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