2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 19:29:02 +00:00

Link Modal

- Reset modal state when it is hidden
- Reset link value if new doc was not created
- Set link value if new doc was created
This commit is contained in:
Faris Ansari 2018-07-09 15:48:09 +05:30
parent a8416dc4fe
commit 42320a39bf
2 changed files with 28 additions and 1 deletions

View File

@ -78,9 +78,19 @@ export default {
});
newDoc.on('afterInsert', (data) => {
// if new doc was created
// then set the name of the doc in input
this.handleChange(newDoc.name);
this.$modal.hide();
});
this.$modal.observable().on('modal.hide', () => {
// if new doc was not created
// then reset the input value
if (this.value === '__newItem') {
this.handleChange('');
}
})
}
})
}

View File

@ -14,6 +14,10 @@ export default {
hide() {
Bus.trigger('hideModal');
},
observable() {
return Bus;
}
}
@ -22,9 +26,21 @@ export default {
return {
registered: false,
modalVisible: false,
modalOptions: {}
modalOptions: {},
modalListeners: {}
}
},
watch: {
modalVisible(value) {
if (value === true) {
Bus.trigger('modal.show');
} else {
Bus.trigger('modal.hide');
}
}
},
created: function () {
if (this.registered) return;
@ -35,6 +51,7 @@ export default {
Bus.on('hideModal', () => {
this.modalVisible = false;
this.modalOptions = {};
});
this.registered = true;