mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
New Item defaults are set according to filters
This commit is contained in:
parent
31129a04c2
commit
5eae951c92
@ -42,6 +42,7 @@ export default {
|
||||
}))
|
||||
.concat({
|
||||
label: plusIcon + ' New ' + this.getTarget(),
|
||||
filters,
|
||||
value: '__newItem'
|
||||
});
|
||||
},
|
||||
@ -138,18 +139,23 @@ export default {
|
||||
},
|
||||
onItemClick(item) {
|
||||
if (item.value === '__newItem') {
|
||||
this.openFormModal();
|
||||
this.openFormModal(item.filters);
|
||||
} else {
|
||||
this.handleChange(item.value);
|
||||
}
|
||||
},
|
||||
async openFormModal() {
|
||||
async openFormModal(filters) {
|
||||
const input = this.$refs.input;
|
||||
const newDoc = await frappe.getNewDoc(this.getTarget());
|
||||
let defaultValues = {};
|
||||
if (filters) {
|
||||
for (let key of Object.keys(filters)) {
|
||||
defaultValues[key] = filters[key];
|
||||
}
|
||||
}
|
||||
defaultValues.name = input.value !== '__newItem' ? input.value : null;
|
||||
this.$formModal.open(newDoc, {
|
||||
defaultValues: {
|
||||
name: input.value !== '__newItem' ? input.value : null
|
||||
},
|
||||
defaultValues,
|
||||
onClose: () => {
|
||||
// if new doc was not created
|
||||
// then reset the input value
|
||||
|
Loading…
Reference in New Issue
Block a user