mirror of
https://github.com/frappe/books.git
synced 2024-11-10 15:50:56 +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:
parent
a8416dc4fe
commit
42320a39bf
@ -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('');
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user