mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Merge pull request #7727 from artoscinote/ma_SCI_10901
Add 203dpi label template [SCI-10901]
This commit is contained in:
commit
8246eed23c
5 changed files with 58 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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:
|
||||
|
|
26
db/migrate/20240718073215_add203_dpi_label_template.rb
Normal file
26
db/migrate/20240718073215_add203_dpi_label_template.rb
Normal 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
|
Loading…
Reference in a new issue