mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Select default label template based on selected pritner type [SCI-7268][7257] (#4475)
This commit is contained in:
parent
69bc48fef8
commit
103bdff654
3 changed files with 19 additions and 2 deletions
|
|
@ -36,6 +36,7 @@
|
|||
</label>
|
||||
|
||||
<DropdownSelector
|
||||
ref="labelTemplateDropdown"
|
||||
:disableSearch="true"
|
||||
:options="templates_dropdown"
|
||||
:selectorId="`LabelTemplateSelector`"
|
||||
|
|
@ -121,6 +122,7 @@
|
|||
mounted() {
|
||||
$.get(this.urls.labelTemplates, (result) => {
|
||||
this.templates = result.data
|
||||
this.selectDefaultLabelTemplate();
|
||||
})
|
||||
|
||||
$.get(this.urls.printers, (result) => {
|
||||
|
|
@ -172,8 +174,20 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
selectDefaultLabelTemplate() {
|
||||
if (this.selectedPrinter && this.templates) {
|
||||
let template = this.templates.find(i => i.attributes.default
|
||||
&& i.type.includes(this.selectedPrinter.attributes.type_of));
|
||||
if (template) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.labelTemplateDropdown.selectValues(template.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
selectPrinter(value) {
|
||||
this.selectedPrinter = this.printers.find(i => i.id === value);
|
||||
this.selectedPrinter = this.printers.find(i => i.id === value)
|
||||
this.selectDefaultLabelTemplate();
|
||||
},
|
||||
selectTemplate(value) {
|
||||
this.selectedTemplate = this.templates.find(i => i.id === value);
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@
|
|||
'dropdown:changed',
|
||||
value
|
||||
);
|
||||
},
|
||||
selectValues(value) {
|
||||
dropdownSelector.selectValues(`#${this.selectorId}`, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class LabelTemplateSerializer < ActiveModel::Serializer
|
|||
include Canaid::Helpers::PermissionsHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attributes :name, :description, :language_type, :icon_url, :urls, :content, :type
|
||||
attributes :name, :description, :language_type, :icon_url, :urls, :content, :type, :default
|
||||
|
||||
def icon_url
|
||||
ActionController::Base.helpers.image_path("label_template_icons/#{object.icon}.svg")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue