From eb2b6f4727d8bb80ba0486963c75d8b4503d9bba Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 24 Apr 2023 13:05:50 +0530 Subject: [PATCH] fix: replace path after a doc has been inserted - reword "Features Flags" to "Features" - reword "Save to database" - fix "New Entry" display - fix address sectioning --- schemas/app/AccountingSettings.json | 4 ++-- schemas/app/Address.json | 12 ++++++++---- schemas/app/inventory/InventorySettings.json | 6 +++--- schemas/regional/in/Address.json | 3 ++- src/pages/CommonForm/CommonForm.vue | 14 +++++++++++++- src/pages/ListView/ListView.vue | 5 ----- src/utils/ui.ts | 6 +++++- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/schemas/app/AccountingSettings.json b/schemas/app/AccountingSettings.json index 7bf9cddc..b7c4557b 100644 --- a/schemas/app/AccountingSettings.json +++ b/schemas/app/AccountingSettings.json @@ -70,14 +70,14 @@ "label": "Enable Discount Accounting", "fieldtype": "Check", "default": false, - "section": "Feature Flags" + "section": "Features" }, { "fieldname": "enableInventory", "label": "Enable Inventory", "fieldtype": "Check", "default": false, - "section": "Feature Flags" + "section": "Features" }, { "fieldname": "fiscalYearStart", diff --git a/schemas/app/Address.json b/schemas/app/Address.json index 30d1c150..6589b110 100644 --- a/schemas/app/Address.json +++ b/schemas/app/Address.json @@ -55,24 +55,28 @@ "fieldname": "emailAddress", "label": "Email Address", "placeholder": "Email Address", - "fieldtype": "Data" + "fieldtype": "Data", + "section": "Contacts" }, { "fieldname": "phone", "label": "Phone", "placeholder": "Phone", - "fieldtype": "Data" + "fieldtype": "Data", + "section": "Contacts" }, { "fieldname": "fax", "label": "Fax", - "fieldtype": "Data" + "fieldtype": "Data", + "section": "Contacts" }, { "fieldname": "addressDisplay", "fieldtype": "Text", "label": "Address Display", - "readOnly": true + "readOnly": true, + "section": "Miscellaneous" } ], "quickEditFields": [ diff --git a/schemas/app/inventory/InventorySettings.json b/schemas/app/inventory/InventorySettings.json index 811db4a4..1347d5a9 100644 --- a/schemas/app/inventory/InventorySettings.json +++ b/schemas/app/inventory/InventorySettings.json @@ -55,19 +55,19 @@ "fieldname": "enableBarcodes", "label": "Enable Barcodes", "fieldtype": "Check", - "section": "Feature Flags" + "section": "Features" }, { "fieldname": "enableBatches", "label": "Enable Batches", "fieldtype": "Check", - "section": "Feature Flags" + "section": "Features" }, { "fieldname": "enableUomConversions", "label": "Enable UOM Conversion", "fieldtype": "Check", - "section": "Feature Flags" + "section": "Features" } ] } diff --git a/schemas/regional/in/Address.json b/schemas/regional/in/Address.json index 376ae771..2a0460a0 100644 --- a/schemas/regional/in/Address.json +++ b/schemas/regional/in/Address.json @@ -5,7 +5,8 @@ "fieldname": "pos", "label": "Place of Supply", "fieldtype": "AutoComplete", - "placeholder": "Place of Supply" + "placeholder": "Place of Supply", + "section": "Miscellaneous" } ], "quickEditFields": [ diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index 0403b3c1..4c5454c4 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -168,6 +168,7 @@ import { commonDocSync, getDocFromNameIfExistsElseNew, getFieldsGroupedByTabAndSection, + getFormRoute, getGroupedActionsForDoc, isPrintable, routeTo, @@ -227,6 +228,7 @@ export default defineComponent({ } await this.setDoc(); + this.replacePathAfterSync(); this.updateGroupedFields(); if (this.groupedFields) { this.activeTab = [...this.groupedFields.keys()][0]; @@ -340,7 +342,7 @@ export default defineComponent({ return this.t`New Entry`; } - return this.docOrNull?.name! ?? this.t`New Entry`; + return this.docOrNull?.name || this.t`New Entry`; }, schema(): Schema { const schema = this.fyo.schemaMap[this.schemaName]; @@ -403,6 +405,16 @@ export default defineComponent({ this.name ); }, + async replacePathAfterSync() { + if (!this.hasDoc || this.doc.inserted) { + return; + } + + this.doc.once('afterSync', () => { + const route = getFormRoute(this.schemaName, this.doc.name!); + this.$router.replace(route); + }); + }, async showRowEditForm(doc: Doc) { if (this.showLinks) { this.showLinks = false; diff --git a/src/pages/ListView/ListView.vue b/src/pages/ListView/ListView.vue index 2c92c862..07660f90 100644 --- a/src/pages/ListView/ListView.vue +++ b/src/pages/ListView/ListView.vue @@ -144,11 +144,6 @@ export default defineComponent({ const doc = fyo.doc.getNewDoc(this.schemaName, filters); const route = getFormRoute(this.schemaName, doc.name!); await routeTo(route); - - doc.on('afterSync', () => { - const route = getFormRoute(this.schemaName, doc.name!); - this.$router.replace(route); - }); }, applyFilter(filters: QueryFilter) { this.list?.updateData(filters); diff --git a/src/utils/ui.ts b/src/utils/ui.ts index dbd8f307..70b75471 100644 --- a/src/utils/ui.ts +++ b/src/utils/ui.ts @@ -550,7 +550,11 @@ async function showSubmitOrSyncDialog(doc: Doc, type: 'submit' | 'sync') { title = t`Save ${label}?`; } - let detail = t`Save ${doc.schema.label} to database.`; + let detail = t`Create new ${doc.schema.label} entry.`; + if (type === 'sync' && doc.inserted) { + detail = t`Save changes made to ${label}.`; + } + if (type === 'submit') { detail = getDocSubmitMessage(doc); }