mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Updated entity-selector-popup to reset on selection
Better links the core selector component to the popup version, with new public methods for direct controlling. For #3528
This commit is contained in:
@ -7,9 +7,9 @@ class EntitySelectorPopup {
|
||||
setup() {
|
||||
this.elem = this.$el;
|
||||
this.selectButton = this.$refs.select;
|
||||
this.searchInput = this.$refs.searchInput;
|
||||
|
||||
window.EntitySelectorPopup = this;
|
||||
this.selectorEl = this.$refs.selector;
|
||||
|
||||
this.callback = null;
|
||||
this.selection = null;
|
||||
@ -22,13 +22,17 @@ class EntitySelectorPopup {
|
||||
show(callback) {
|
||||
this.callback = callback;
|
||||
this.elem.components.popup.show();
|
||||
this.searchInput.focus();
|
||||
this.getSelector().focusSearch();
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.elem.components.popup.hide();
|
||||
}
|
||||
|
||||
getSelector() {
|
||||
return this.selectorEl.components['entity-selector'];
|
||||
}
|
||||
|
||||
onSelectButtonClick() {
|
||||
this.hide();
|
||||
if (this.selection !== null && this.callback) this.callback(this.selection);
|
||||
@ -36,6 +40,7 @@ class EntitySelectorPopup {
|
||||
|
||||
onSelectionConfirm(entity) {
|
||||
this.hide();
|
||||
this.getSelector().reset();
|
||||
if (this.callback && entity) this.callback(entity);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user