Add icon and tooltip to label template dropdown [SCI-7259][SCI-7260]

This commit is contained in:
Anton 2022-09-28 11:32:14 +02:00
parent 31554d0fd9
commit 7e06f29a75
3 changed files with 34 additions and 1 deletions

View file

@ -42,4 +42,13 @@
min-height: 200px; min-height: 200px;
padding: .5em 0; padding: .5em 0;
} }
.label-template-option {
align-items: center;
display: flex;
img {
margin-right: .25em;
}
}
} }

View file

@ -39,6 +39,8 @@
:disableSearch="true" :disableSearch="true"
:options="templates_dropdown" :options="templates_dropdown"
:selectorId="`LabelTemplateSelector`" :selectorId="`LabelTemplateSelector`"
:optionLabel="templateOption"
:onOpen="initTooltip"
@dropdown:changed="selectTemplate" @dropdown:changed="selectTemplate"
/> />
<div v-if="labelTemplateError" class="label-template-warning"> <div v-if="labelTemplateError" class="label-template-warning">
@ -140,7 +142,14 @@
} }
return templates.map(i => { return templates.map(i => {
return {value: i.id, label: i.attributes.name} return {
value: i.id,
label: i.attributes.name,
params: {
icon: i.attributes.icon_url,
description: i.attributes.description || ''
}
}
}) })
}, },
printers_dropdown() { printers_dropdown() {
@ -217,6 +226,17 @@
}) })
} }
}); });
},
templateOption(option) {
return `
<div class="label-template-option" data-toggle="tooltip" data-placement="right" title="${option.params.description}">
<img src="${option.params.icon}"></img>
${option.label}
</div>
`
},
initTooltip() {
$('[data-toggle="tooltip"]').tooltip();
} }
} }
} }

View file

@ -93,6 +93,9 @@
optionLabel: { optionLabel: {
type: Function type: Function
}, },
onOpen: {
type: Function
},
inputTagMode: { inputTagMode: {
type: Boolean, type: Boolean,
default: false default: false
@ -114,6 +117,7 @@
closeOnSelect: this.closeOnSelect, closeOnSelect: this.closeOnSelect,
selectAppearance: this.selectAppearance, selectAppearance: this.selectAppearance,
disableSearch: this.disableSearch, disableSearch: this.disableSearch,
onOpen: this.onOpen,
onChange: () => { onChange: () => {
if (this.onChange) this.onChange(); if (this.onChange) this.onChange();
this.selectChanged(dropdownSelector.getValues(`#${this.selectorId}`)) this.selectChanged(dropdownSelector.getValues(`#${this.selectorId}`))