Allow to configure sidebar menu via the new settings system

This commit is contained in:
Jan Böhmer 2024-08-07 00:41:06 +02:00
parent 5e512f8935
commit 79da0518c2
15 changed files with 320 additions and 55 deletions

View file

@ -40,6 +40,7 @@ export default class extends Controller {
let settings = {
plugins: [],
allowEmptyOption: true,
selectOnTab: true,
maxOptions: null,
@ -50,7 +51,18 @@ export default class extends Controller {
}
};
//Load the drag_drop plugin if the select is ordered
if (this.element.dataset.orderedValue) {
settings.plugins.push('drag_drop');
}
this._tomSelect = new TomSelect(this.element, settings);
//If the select is ordered, we need to update the value field (with the decoded value from the orderedValue field)
if (this.element.dataset.orderedValue) {
const data = JSON.parse(this.element.dataset.orderedValue);
this._tomSelect.setValue(data);
}
}
getTomSelect() {