Finished combobox integration!!!!!!

This commit is contained in:
Yaro Kasear 2025-08-14 11:46:29 -05:00
parent 1ea6cd9588
commit 7854e9c910
2 changed files with 16 additions and 0 deletions

View file

@ -36,6 +36,8 @@ function ComboBox(cfg) {
const id = this.editingOption.value; const id = this.editingOption.value;
const ok = await this._post(this.editUrl, { id, name }); const ok = await this._post(this.editUrl, { id, name });
if (ok) this.editingOption.textContent = name; if (ok) this.editingOption.textContent = name;
this.$dispatch('combobox:item-edited', { id, name, ...this.editingOption.dataset });
} else if (this.createUrl) { } else if (this.createUrl) {
const data = await this._post(this.createUrl, { name }, true); const data = await this._post(this.createUrl, { name }, true);
const id = (data && data.id) ? data.id : ('temp-' + Math.random().toString(36).slice(2)); const id = (data && data.id) ? data.id : ('temp-' + Math.random().toString(36).slice(2));

View file

@ -239,5 +239,19 @@
const roomEditorModal = new bootstrap.Modal(document.getElementById('roomEditor')); const roomEditorModal = new bootstrap.Modal(document.getElementById('roomEditor'));
roomEditorModal.show(); roomEditorModal.show();
}); });
container.addEventListener('combobox:item-edited', (e) => {
if (container.id !== 'room-container') return;
const { id, name, area_id, function_id } = e.detail;
console.log(id, name, area_id, function_id)
const prep = new CustomEvent('roomEditor:prepare', {
detail: { id, name, sectionId: area_id, functionId: function_id }
});
document.getElementById('roomEditor').dispatchEvent(prep);
const roomEditorModal = new bootstrap.Modal(document.getElementById('roomEditor'));
roomEditorModal.show();
});
})(); })();
{% endblock %} {% endblock %}