]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/user-select.js
Added method for using enity ownership in relation queries
[bookstack] / resources / js / components / user-select.js
index d4d88a633c115ab06a9bd718e32ca41090efc109..b383d7a6ff18966ccf1a9e4b0e05c978fbfd4899 100644 (file)
@@ -8,6 +8,9 @@ export class UserSelect extends Component {
         this.input = this.$refs.input;
         this.userInfoContainer = this.$refs.userInfo;
 
+        this.initialValue = this.input.value;
+        this.initialContent = this.userInfoContainer.innerHTML;
+
         onChildEvent(this.container, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
     }
 
@@ -19,6 +22,13 @@ export class UserSelect extends Component {
         this.hide();
     }
 
+    reset() {
+        this.input.value = this.initialValue;
+        this.userInfoContainer.innerHTML = this.initialContent;
+        this.input.dispatchEvent(new Event('change', {bubbles: true}));
+        this.hide();
+    }
+
     hide() {
         /** @var {Dropdown} **/
         const dropdown = window.$components.firstOnElement(this.container, 'dropdown');