diff --git a/ui/components/controls/Link.vue b/ui/components/controls/Link.vue index e3a6696b..2b57aea1 100644 --- a/ui/components/controls/Link.vue +++ b/ui/components/controls/Link.vue @@ -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