mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 14:46:47 +08:00
Merge pull request #4477 from okriuchykhin/ok_SCI_7258
Fix label printers dropdown on print modal [SCI-7258]
This commit is contained in:
commit
d70428c6fe
6 changed files with 84 additions and 24 deletions
|
@ -12,6 +12,30 @@
|
|||
.printers-container {
|
||||
margin-bottom: 1em;
|
||||
min-height: 4em;
|
||||
|
||||
.status-ready {
|
||||
|
||||
}
|
||||
|
||||
.status-ready {
|
||||
color: #2DBE61;
|
||||
}
|
||||
|
||||
.status-busy {
|
||||
color: #231F20;
|
||||
}
|
||||
|
||||
.status-out-of-labels {
|
||||
color: #231F20;
|
||||
}
|
||||
|
||||
.status-unreachable {
|
||||
color: #231F20;
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: #231F20;
|
||||
}
|
||||
}
|
||||
|
||||
.labels-container {
|
||||
|
|
|
@ -24,7 +24,10 @@
|
|||
</label>
|
||||
<DropdownSelector
|
||||
:disableSearch="true"
|
||||
:labelHTML="true"
|
||||
:options="printers_dropdown"
|
||||
:optionLabel="printerOptionLabel"
|
||||
:tagLabel="printerOptionLabel"
|
||||
:selectorId="`LabelPrinterSelector`"
|
||||
@dropdown:changed="selectPrinter"
|
||||
/>
|
||||
|
@ -157,7 +160,14 @@
|
|||
},
|
||||
printers_dropdown() {
|
||||
return this.printers.map(i => {
|
||||
return {value: i.id, label: i.attributes.name}
|
||||
return {
|
||||
value: i.id,
|
||||
label: i.attributes.display_name,
|
||||
params: {
|
||||
status: i.attributes.status,
|
||||
display_status: i.attributes.display_status
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -176,7 +186,7 @@
|
|||
methods: {
|
||||
selectDefaultLabelTemplate() {
|
||||
if (this.selectedPrinter && this.templates) {
|
||||
let template = this.templates.find(i => i.attributes.default
|
||||
let template = this.templates.find(i => i.attributes.default
|
||||
&& i.type.includes(this.selectedPrinter.attributes.type_of));
|
||||
if (template) {
|
||||
this.$nextTick(() => {
|
||||
|
@ -250,6 +260,9 @@
|
|||
</div>
|
||||
`
|
||||
},
|
||||
printerOptionLabel(option) {
|
||||
return `${option.label} <span class="status-${option.params.status}"> • ${option.params.display_status}`
|
||||
},
|
||||
initTooltip() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,13 @@
|
|||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
labelHTML: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
tagLabel: {
|
||||
type: Function
|
||||
},
|
||||
optionClass: {
|
||||
type: String,
|
||||
default: ''
|
||||
|
@ -117,6 +124,8 @@
|
|||
closeOnSelect: this.closeOnSelect,
|
||||
selectAppearance: this.selectAppearance,
|
||||
disableSearch: this.disableSearch,
|
||||
tagLabel: this.tagLabel,
|
||||
labelHTML: this.labelHTML,
|
||||
onOpen: this.onOpen,
|
||||
onChange: () => {
|
||||
if (this.onChange) this.onChange();
|
||||
|
|
|
@ -19,10 +19,6 @@ class LabelPrinter < ApplicationRecord
|
|||
validates :type_of, presence: true
|
||||
validates :language_type, presence: true
|
||||
|
||||
def display_name
|
||||
"#{name} • #{description}"
|
||||
end
|
||||
|
||||
def done?
|
||||
current_print_job_ids.blank? && ready?
|
||||
end
|
||||
|
|
|
@ -2,11 +2,24 @@
|
|||
|
||||
class LabelPrinterSerializer < ActiveModel::Serializer
|
||||
include Rails.application.routes.url_helpers
|
||||
include ApplicationHelper
|
||||
|
||||
attributes :name, :description, :type_of, :language_type, :status
|
||||
attributes :name, :display_name, :description, :type_of, :language_type, :status, :display_status
|
||||
|
||||
def urls
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
def display_name
|
||||
object.description.present? ? sanitize_input("#{object.name} • #{object.description}") : sanitize_input(object.name)
|
||||
end
|
||||
|
||||
def status
|
||||
object.status.dasherize
|
||||
end
|
||||
|
||||
def display_status
|
||||
I18n.t("label_printers.fluics.statuses.#{object.status}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -918,7 +918,28 @@ en:
|
|||
delete:
|
||||
success: "Successfully deleted %{printer_name}."
|
||||
error: "Could not delete %{printer_name}."
|
||||
|
||||
fluics:
|
||||
statuses:
|
||||
ready: 'Ready'
|
||||
busy: 'Busy'
|
||||
out_of_labels: 'Out of labels'
|
||||
unreachable: 'Offline'
|
||||
error: 'Error'
|
||||
modal_printing_status:
|
||||
printer_status:
|
||||
ready: "Ready"
|
||||
not_ready: "Not Ready"
|
||||
out_of_labels: "Out of labels"
|
||||
error: "Printer error"
|
||||
unreachable: "Printer offline"
|
||||
offline: "Offline"
|
||||
multiple_items: "%{item_count}/%{starting_item_count} labels"
|
||||
printing_status:
|
||||
done: "Done"
|
||||
printing: "Printing"
|
||||
out_of_labels: "Waiting for labels. Please, insert labels."
|
||||
error: "There is an issue with the printer."
|
||||
unreachable: "Printer is offline"
|
||||
|
||||
my_modules:
|
||||
details:
|
||||
|
@ -2041,22 +2062,6 @@ en:
|
|||
date_expiration_html: "This item is expiring in <strong>%{date_expiration}</strong>."
|
||||
item_expired: "This item has expired."
|
||||
day: "day"
|
||||
label_printers:
|
||||
modal_printing_status:
|
||||
printer_status:
|
||||
ready: "Ready"
|
||||
not_ready: "Not Ready"
|
||||
out_of_labels: "Out of labels"
|
||||
error: "Printer error"
|
||||
unreachable: "Printer offline"
|
||||
offline: "Offline"
|
||||
multiple_items: "%{item_count}/%{starting_item_count} labels"
|
||||
printing_status:
|
||||
done: "Done"
|
||||
printing: "Printing"
|
||||
out_of_labels: "Waiting for labels. Please, insert labels."
|
||||
error: "There is an issue with the printer."
|
||||
unreachable: "Printer is offline"
|
||||
activities:
|
||||
index:
|
||||
global_activities_title: "Global activities"
|
||||
|
|
Loading…
Add table
Reference in a new issue