mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Add 203dpi label templates [SCI-10901]
This commit is contained in:
parent
83150f59c0
commit
1a5530efde
5 changed files with 58 additions and 1 deletions
|
@ -221,6 +221,7 @@ class Team < ApplicationRecord
|
||||||
|
|
||||||
def create_default_label_templates
|
def create_default_label_templates
|
||||||
ZebraLabelTemplate.default.update(team: self, default: true)
|
ZebraLabelTemplate.default.update(team: self, default: true)
|
||||||
|
ZebraLabelTemplate.default_203dpi.update(team: self, default: false)
|
||||||
FluicsLabelTemplate.default.update(team: self, default: true)
|
FluicsLabelTemplate.default.update(team: self, default: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,15 @@ class ZebraLabelTemplate < LabelTemplate
|
||||||
density: 12
|
density: 12
|
||||||
)
|
)
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -619,6 +619,24 @@ class Extends
|
||||||
HEREDOC
|
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 = {
|
LABEL_TEMPLATE_FORMAT_MAP = {
|
||||||
'ZebraLabelTemplate' => 'ZPL',
|
'ZebraLabelTemplate' => 'ZPL',
|
||||||
'FluicsLabelTemplate' => 'Fluics'
|
'FluicsLabelTemplate' => 'Fluics'
|
||||||
|
|
|
@ -1045,7 +1045,8 @@ en:
|
||||||
types:
|
types:
|
||||||
fluics_label_template: 'Fluics'
|
fluics_label_template: 'Fluics'
|
||||||
zebra_label_template: 'ZPL'
|
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)'
|
default_fluics_name: 'SciNote Item (Fluics)'
|
||||||
new_label_template: 'New label'
|
new_label_template: 'New label'
|
||||||
fluics:
|
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…
Add table
Reference in a new issue