From 1db70dfef6037d5af405ce8b98091d46040025a8 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 17 Feb 2023 21:05:06 +0530 Subject: [PATCH 1/7] feat: common form view --- schemas/types.ts | 2 + src/components/FormHeader.vue | 1 + src/pages/CommonForm/CommonForm.vue | 157 +++++++++++++++++++++ src/pages/CommonForm/CommonFormSection.vue | 42 ++++++ utils/translationHelpers.ts | 8 +- 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 src/pages/CommonForm/CommonForm.vue create mode 100644 src/pages/CommonForm/CommonFormSection.vue diff --git a/schemas/types.ts b/schemas/types.ts index 2cf49c28..ef028b26 100644 --- a/schemas/types.ts +++ b/schemas/types.ts @@ -64,6 +64,8 @@ export interface BaseField { inline?: boolean; // UI Facing config, whether to display doc inline. filter?: boolean; // UI Facing config, whether to be used to filter the List. computed?: boolean; // Computed values are not stored in the database. + section?: string; // UI Facing config, for grouping by sections + tab?: string; // UI Facing config, for grouping by tabs } export type SelectOption = { value: string; label: string }; diff --git a/src/components/FormHeader.vue b/src/components/FormHeader.vue index 7664dd0b..993f1919 100644 --- a/src/components/FormHeader.vue +++ b/src/components/FormHeader.vue @@ -8,6 +8,7 @@ justify-between h-row-large items-center + flex-shrink-0 " >

{{ formTitle }}

diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue new file mode 100644 index 00000000..6c6bcc86 --- /dev/null +++ b/src/pages/CommonForm/CommonForm.vue @@ -0,0 +1,157 @@ + + + diff --git a/src/pages/CommonForm/CommonFormSection.vue b/src/pages/CommonForm/CommonFormSection.vue new file mode 100644 index 00000000..89ef06b7 --- /dev/null +++ b/src/pages/CommonForm/CommonFormSection.vue @@ -0,0 +1,42 @@ + + diff --git a/utils/translationHelpers.ts b/utils/translationHelpers.ts index c354d7e5..36fbaf03 100644 --- a/utils/translationHelpers.ts +++ b/utils/translationHelpers.ts @@ -2,7 +2,13 @@ * Properties of a schema which are to be translated, * irrespective of nesting. */ -export const schemaTranslateables = ['label', 'description', 'placeholder']; +export const schemaTranslateables = [ + 'label', + 'description', + 'placeholder', + 'section', + 'tab', +]; export function getIndexFormat(inp: string | string[]) { /** From 7cfd0726d6c6d75659da1382d1d8a33fcecd6f42 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 17 Feb 2023 21:56:41 +0530 Subject: [PATCH 2/7] incr: add collapsible sections - table borders --- schemas/app/Payment.json | 114 +++++++++------- schemas/meta/base.json | 12 +- schemas/meta/submittable.json | 6 +- src/components/Controls/Table.vue | 149 +++++++++++---------- src/pages/CommonForm/CommonForm.vue | 8 +- src/pages/CommonForm/CommonFormSection.vue | 48 ++++--- 6 files changed, 191 insertions(+), 146 deletions(-) diff --git a/schemas/app/Payment.json b/schemas/app/Payment.json index c9e44c3e..fb9a2f34 100644 --- a/schemas/app/Payment.json +++ b/schemas/app/Payment.json @@ -11,7 +11,18 @@ "fieldname": "name", "fieldtype": "Data", "required": true, - "readOnly": true + "readOnly": true, + "section": "Default" + }, + { + "fieldname": "numberSeries", + "label": "Number Series", + "fieldtype": "Link", + "target": "NumberSeries", + "create": true, + "required": true, + "default": "PAY-", + "section": "Default" }, { "fieldname": "party", @@ -19,13 +30,15 @@ "fieldtype": "Link", "target": "Party", "create": true, - "required": true + "required": true, + "section": "Default" }, { "fieldname": "date", "label": "Posting Date", "fieldtype": "Date", - "required": true + "required": true, + "section": "Default" }, { "fieldname": "paymentType", @@ -42,16 +55,27 @@ "label": "Pay" } ], - "required": true + "required": true, + "section": "Default" }, { - "fieldname": "numberSeries", - "label": "Number Series", + "fieldname": "account", + "label": "From Account", "fieldtype": "Link", - "target": "NumberSeries", + "target": "Account", "create": true, "required": true, - "default": "PAY-" + "section": "Details" + }, + { + "fieldname": "paymentAccount", + "label": "To Account", + "placeholder": "To Account", + "fieldtype": "Link", + "target": "Account", + "create": true, + "required": true, + "section": "Details" }, { "fieldname": "paymentMethod", @@ -73,72 +97,64 @@ } ], "default": "Cash", - "required": true - }, - { - "fieldname": "account", - "label": "From Account", - "fieldtype": "Link", - "target": "Account", - "create": true, - "required": true - }, - { - "fieldname": "paymentAccount", - "label": "To Account", - "placeholder": "To Account", - "fieldtype": "Link", - "target": "Account", - "create": true, - "required": true - }, - { - "fieldname": "referenceId", - "label": "Ref. / Cheque No.", - "placeholder": "Ref. / Cheque No.", - "fieldtype": "Data" - }, - { - "fieldname": "referenceDate", - "label": "Ref. Date", - "placeholder": "Ref. Date", - "fieldtype": "Date" - }, - { - "fieldname": "clearanceDate", - "label": "Clearance Date", - "placeholder": "Clearance Date", - "fieldtype": "Date" + "required": true, + "section": "Details" }, { "fieldname": "amount", "label": "Amount", "fieldtype": "Currency", - "required": true + "required": true, + "section": "Amounts" }, { "fieldname": "writeoff", "label": "Write Off", - "fieldtype": "Currency" + "fieldtype": "Currency", + "section": "Amounts" }, { "fieldname": "amountPaid", "label": "Amount Paid", "fieldtype": "Currency", - "computed": true + "computed": true, + "section": "Amounts" + }, + { + "fieldname": "referenceId", + "label": "Ref. / Cheque No.", + "placeholder": "Ref. / Cheque No.", + "fieldtype": "Data", + "section": "References" + }, + { + "fieldname": "referenceDate", + "label": "Reference Date", + "placeholder": "Ref. Date", + "fieldtype": "Date", + "section": "References" + }, + { + "fieldname": "clearanceDate", + "label": "Clearance Date", + "placeholder": "Clearance Date", + "fieldtype": "Date", + "section": "References" }, { "fieldname": "for", "label": "Payment Reference", "fieldtype": "Table", "target": "PaymentFor", - "required": false + "required": false, + "section": "References" }, { "fieldname": "attachment", "placeholder": "Add attachment", "label": "Attachment", - "fieldtype": "Attachment" + "fieldtype": "Attachment", + "section": "References" } ], "quickEditFields": [ diff --git a/schemas/meta/base.json b/schemas/meta/base.json index c596594b..763a3dbe 100644 --- a/schemas/meta/base.json +++ b/schemas/meta/base.json @@ -6,28 +6,32 @@ "label": "Created By", "fieldtype": "Data", "required": true, - "meta": true + "meta": true, + "section": "System" }, { "fieldname": "modifiedBy", "label": "Modified By", "fieldtype": "Data", "required": true, - "meta": true + "meta": true, + "section": "System" }, { "fieldname": "created", "label": "Created", "fieldtype": "Datetime", "required": true, - "meta": true + "meta": true, + "section": "System" }, { "fieldname": "modified", "label": "Modified", "fieldtype": "Datetime", "required": true, - "meta": true + "meta": true, + "section": "System" } ] } diff --git a/schemas/meta/submittable.json b/schemas/meta/submittable.json index dbe6e524..f02772ac 100644 --- a/schemas/meta/submittable.json +++ b/schemas/meta/submittable.json @@ -6,14 +6,16 @@ "label": "Submitted", "fieldtype": "Check", "required": true, - "meta": true + "meta": true, + "section": "System" }, { "fieldname": "cancelled", "label": "Cancelled", "fieldtype": "Check", "required": true, - "meta": true + "meta": true, + "section": "System" } ] } diff --git a/src/components/Controls/Table.vue b/src/components/Controls/Table.vue index bc589188..d239542a 100644 --- a/src/components/Controls/Table.vue +++ b/src/components/Controls/Table.vue @@ -4,79 +4,84 @@ {{ df.label }} - - -
#
-
+ + - {{ df.label }} -
-
- - -
- -
- - - -
- -
-
-

- {{ t`Add Row` }} -

-

#

+
- {{ t`${value.length} rows` }} -

+ {{ df.label }} +
+
+ + +
+
- + + + +
+ +
+
+

+ {{ t`Add Row` }} +

+

+ {{ t`${value.length} rows` }} +

+
+
+ @@ -101,6 +106,10 @@ export default { type: Number, default: 3, }, + border: { + type: Boolean, + default: false, + }, }, components: { Row, diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index 6c6bcc86..539f6f0d 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -10,13 +10,14 @@
@@ -57,7 +58,6 @@ - From 01e197f4394af848a7d18913644d50b1d0edd795 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 20 Feb 2023 10:22:19 +0530 Subject: [PATCH 3/7] incr: status badge and action buttons --- src/components/Widgets/LinkedEntryWidget.vue | 14 ++- src/pages/CommonForm/CommonForm.vue | 111 ++++++++++++++----- src/pages/CommonForm/CommonFormSection.vue | 6 +- src/utils/types.ts | 22 ++-- src/utils/ui.ts | 40 ++++--- 5 files changed, 135 insertions(+), 58 deletions(-) diff --git a/src/components/Widgets/LinkedEntryWidget.vue b/src/components/Widgets/LinkedEntryWidget.vue index 6a39eecd..9289eb86 100644 --- a/src/components/Widgets/LinkedEntryWidget.vue +++ b/src/components/Widgets/LinkedEntryWidget.vue @@ -56,7 +56,7 @@ diff --git a/src/pages/CommonForm/CommonFormSection.vue b/src/pages/CommonForm/CommonFormSection.vue index 1820d7ae..22c9fe05 100644 --- a/src/pages/CommonForm/CommonFormSection.vue +++ b/src/pages/CommonForm/CommonFormSection.vue @@ -1,5 +1,5 @@ diff --git a/src/pages/CommonForm/CommonFormSection.vue b/src/pages/CommonForm/CommonFormSection.vue index 22c9fe05..9636c58f 100644 --- a/src/pages/CommonForm/CommonFormSection.vue +++ b/src/pages/CommonForm/CommonFormSection.vue @@ -24,6 +24,7 @@ :key="field.fieldname" :df="field" :value="doc[field.fieldname]" + @editrow="(doc:Doc) => $emit('editrow', doc)" @change="async (value) => await doc.set(field.fieldname, value)" /> @@ -37,6 +38,7 @@ import { evaluateHidden } from 'src/utils/doc'; import { defineComponent, PropType } from 'vue'; export default defineComponent({ + emits: ['editrow'], props: { title: String, showTitle: Boolean, @@ -48,9 +50,19 @@ export default defineComponent({ }, computed: { filteredFields(): Field[] { - return (this.fields ?? []).filter( - (f) => !evaluateHidden(f, this.doc) && !f.meta - ); + const fields: Field[] = []; + for (const field of this.fields ?? []) { + if (evaluateHidden(field, this.doc)) { + continue; + } + + if (field.meta) { + continue; + } + + fields.push(field); + } + return fields; }, }, components: { FormControl }, diff --git a/src/pages/ListView/List.vue b/src/pages/ListView/List.vue index db5dcc37..192328b2 100644 --- a/src/pages/ListView/List.vue +++ b/src/pages/ListView/List.vue @@ -9,7 +9,7 @@ >

#

@@ -45,7 +45,7 @@

From e0141b70d8bc823d428970e07f22e080026d19d0 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Tue, 21 Feb 2023 11:04:35 +0530 Subject: [PATCH 5/7] incr: use CommonForm for a few docs - show errors - shit setName to after validation --- fyo/core/docHandler.ts | 5 +- fyo/model/doc.ts | 2 +- models/baseModels/Item/Item.ts | 1 + models/baseModels/Payment/Payment.ts | 1 + models/inventory/StockMovement.ts | 1 + schemas/app/Item.json | 103 ++++++++++++--------- schemas/app/Payment.json | 42 ++++----- schemas/app/inventory/StockMovement.json | 44 +++++---- src/components/Controls/Link.vue | 2 +- src/pages/CommonForm/CommonForm.vue | 89 +++++++++++++++--- src/pages/CommonForm/CommonFormSection.vue | 56 +++++------ src/router.ts | 32 +++++++ src/utils/search.ts | 21 ++--- src/utils/ui.ts | 13 ++- 14 files changed, 262 insertions(+), 150 deletions(-) diff --git a/fyo/core/docHandler.ts b/fyo/core/docHandler.ts index 6026ae46..b8fded44 100644 --- a/fyo/core/docHandler.ts +++ b/fyo/core/docHandler.ts @@ -117,7 +117,10 @@ export class DocHandler { const idx = this.#temporaryNameCounters[schema.name]; this.#temporaryNameCounters[schema.name] = idx + 1; - return this.fyo.t`New ${schema.label ?? schema.name} - Temp No. ${idx}`; + return this.fyo.t`New ${schema.label ?? schema.name} ${String(idx).padStart( + 2, + '0' + )}`; } /** diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index 18128bfd..c5902c12 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -868,9 +868,9 @@ export class Doc extends Observable { } async _insert() { - await setName(this, this.fyo); this._setBaseMetaValues(); await this._preSync(); + await setName(this, this.fyo); const validDict = this.getValidDict(false, true); let data: DocValueMap; diff --git a/models/baseModels/Item/Item.ts b/models/baseModels/Item/Item.ts index 61db702b..58b80747 100644 --- a/models/baseModels/Item/Item.ts +++ b/models/baseModels/Item/Item.ts @@ -111,6 +111,7 @@ export class Item extends Doc { static getListViewSettings(): ListViewSettings { return { + formRoute: ({ name }) => `/edit/Item/${name}`, columns: ['name', 'unit', 'tax', 'rate'], }; } diff --git a/models/baseModels/Payment/Payment.ts b/models/baseModels/Payment/Payment.ts index 0f928138..176b7e95 100644 --- a/models/baseModels/Payment/Payment.ts +++ b/models/baseModels/Payment/Payment.ts @@ -617,6 +617,7 @@ export class Payment extends Transactional { static getListViewSettings(fyo: Fyo): ListViewSettings { return { + formRoute: ({ name }) => `/edit/Payment/${name}`, columns: ['name', getDocStatusListColumn(), 'party', 'date', 'amount'], }; } diff --git a/models/inventory/StockMovement.ts b/models/inventory/StockMovement.ts index 2a157e83..b6d19a65 100644 --- a/models/inventory/StockMovement.ts +++ b/models/inventory/StockMovement.ts @@ -75,6 +75,7 @@ export class StockMovement extends Transfer { static getListViewSettings(fyo: Fyo): ListViewSettings { return { + formRoute: ({ name }) => `/edit/StockMovement/${name}`, columns: [ 'name', getDocStatusListColumn(), diff --git a/schemas/app/Item.json b/schemas/app/Item.json index b9d81b9d..deb74828 100644 --- a/schemas/app/Item.json +++ b/schemas/app/Item.json @@ -4,50 +4,20 @@ "isSingle": false, "naming": "manual", "fields": [ + { + "fieldname": "image", + "label": "Image", + "section": "Default", + "fieldtype": "AttachImage" + }, { "fieldname": "name", "label": "Item Name", "fieldtype": "Data", "placeholder": "Item Name", + "section": "Default", "required": true }, - { - "fieldname": "image", - "label": "Image", - "fieldtype": "AttachImage" - }, - { - "fieldname": "description", - "label": "Description", - "placeholder": "Item Description", - "fieldtype": "Text" - }, - { - "fieldname": "unit", - "label": "Unit Type", - "fieldtype": "Link", - "target": "UOM", - "create": true, - "default": "Unit", - "placeholder": "Unit Type" - }, - { - "fieldname": "itemType", - "label": "Type", - "placeholder": "Type", - "fieldtype": "Select", - "default": "Product", - "options": [ - { - "value": "Product", - "label": "Product" - }, - { - "value": "Service", - "label": "Service" - } - ] - }, { "fieldname": "for", "label": "For", @@ -67,14 +37,57 @@ } ], "required": true, + "section": "Default", "default": "Both" }, + { + "fieldname": "itemType", + "label": "Type", + "placeholder": "Type", + "fieldtype": "Select", + "default": "Product", + "section": "Default", + "options": [ + { + "value": "Product", + "label": "Product" + }, + { + "value": "Service", + "label": "Service" + } + ] + }, + { + "fieldname": "unit", + "label": "Unit Type", + "fieldtype": "Link", + "target": "UOM", + "create": true, + "default": "Unit", + "section": "Details", + "placeholder": "Unit Type" + }, + { + "fieldname": "rate", + "label": "Rate", + "section": "Details", + "fieldtype": "Currency" + }, + { + "fieldname": "description", + "label": "Description", + "placeholder": "Item Description", + "section": "Details", + "fieldtype": "Text" + }, { "fieldname": "incomeAccount", "label": "Sales Acc.", "fieldtype": "Link", "target": "Account", "placeholder": "Income", + "section": "Accounts", "create": true, "required": true }, @@ -84,6 +97,7 @@ "fieldtype": "Link", "target": "Account", "placeholder": "Expense", + "section": "Accounts", "create": true, "required": true }, @@ -92,31 +106,30 @@ "label": "Tax", "fieldtype": "Link", "target": "Tax", + "section": "Accounts", "create": true, "placeholder": "Tax" }, - { - "fieldname": "rate", - "label": "Rate", - "fieldtype": "Currency" - }, { "fieldname": "hsnCode", "label": "HSN/SAC", "fieldtype": "Int", - "placeholder": "HSN/SAC Code" + "placeholder": "HSN/SAC Code", + "section": "Inventory" }, { "fieldname": "barcode", "label": "Barcode", "fieldtype": "Data", - "placeholder": "Barcode" + "placeholder": "Barcode", + "section": "Inventory" }, { "fieldname": "trackItem", "label": "Track Item", "fieldtype": "Check", - "default": false + "default": false, + "section": "Inventory" } ], "quickEditFields": [ diff --git a/schemas/app/Payment.json b/schemas/app/Payment.json index fb9a2f34..336a9e8c 100644 --- a/schemas/app/Payment.json +++ b/schemas/app/Payment.json @@ -100,6 +100,27 @@ "required": true, "section": "Details" }, + { + "fieldname": "clearanceDate", + "label": "Clearance Date", + "placeholder": "Clearance Date", + "fieldtype": "Date", + "section": "Details" + }, + { + "fieldname": "referenceId", + "label": "Ref. / Cheque No.", + "placeholder": "Ref. / Cheque No.", + "fieldtype": "Data", + "section": "Details" + }, + { + "fieldname": "referenceDate", + "label": "Reference Date", + "placeholder": "Ref. Date", + "fieldtype": "Date", + "section": "Details" + }, { "fieldname": "amount", "label": "Amount", @@ -120,27 +141,6 @@ "computed": true, "section": "Amounts" }, - { - "fieldname": "referenceId", - "label": "Ref. / Cheque No.", - "placeholder": "Ref. / Cheque No.", - "fieldtype": "Data", - "section": "References" - }, - { - "fieldname": "referenceDate", - "label": "Reference Date", - "placeholder": "Ref. Date", - "fieldtype": "Date", - "section": "References" - }, - { - "fieldname": "clearanceDate", - "label": "Clearance Date", - "placeholder": "Clearance Date", - "fieldtype": "Date", - "section": "References" - }, { "fieldname": "for", "label": "Payment Reference", diff --git a/schemas/app/inventory/StockMovement.json b/schemas/app/inventory/StockMovement.json index 99651250..9c6ed7cc 100644 --- a/schemas/app/inventory/StockMovement.json +++ b/schemas/app/inventory/StockMovement.json @@ -11,13 +11,18 @@ "fieldname": "name", "fieldtype": "Data", "required": true, - "readOnly": true + "readOnly": true, + "section": "Default" }, { - "fieldname": "date", - "label": "Date", - "fieldtype": "Datetime", - "required": true + "fieldname": "numberSeries", + "label": "Number Series", + "fieldtype": "Link", + "target": "NumberSeries", + "create": true, + "required": true, + "default": "SMOV-", + "section": "Default" }, { "fieldname": "movementType", @@ -41,29 +46,30 @@ "label": "Manufacture" } ], - "required": true - }, - { - "fieldname": "numberSeries", - "label": "Number Series", - "fieldtype": "Link", - "target": "NumberSeries", - "create": true, "required": true, - "default": "SMOV-" + "section": "Default" }, { - "fieldname": "amount", - "label": "Total Amount", - "fieldtype": "Currency", - "readOnly": true + "fieldname": "date", + "label": "Date", + "fieldtype": "Datetime", + "required": true, + "section": "Default" }, { "fieldname": "items", "label": "Items", "fieldtype": "Table", "target": "StockMovementItem", - "required": true + "required": true, + "section": "Items" + }, + { + "fieldname": "amount", + "label": "Total Amount", + "fieldtype": "Currency", + "readOnly": true, + "section": "Items" } ], "quickEditFields": [ diff --git a/src/components/Controls/Link.vue b/src/components/Controls/Link.vue index a6c73231..f654ee81 100644 --- a/src/components/Controls/Link.vue +++ b/src/components/Controls/Link.vue @@ -116,7 +116,7 @@ export default { }, async openNewDoc() { const schemaName = this.df.target; - const doc = await fyo.doc.getNewDoc(schemaName); + const doc = fyo.doc.getNewDoc(schemaName); const filters = await this.getCreateFilters(); diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index e4dd8511..5dd466d4 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -13,15 +13,12 @@

- - + diff --git a/src/pages/JournalEntryForm.vue b/src/pages/JournalEntryForm.vue deleted file mode 100644 index bc884acb..00000000 --- a/src/pages/JournalEntryForm.vue +++ /dev/null @@ -1,269 +0,0 @@ - - diff --git a/src/router.ts b/src/router.ts index d9e6aaad..987de9d4 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1,22 +1,21 @@ import { ModelNameEnum } from 'models/types'; import ChartOfAccounts from 'src/pages/ChartOfAccounts.vue'; +import CommonForm from 'src/pages/CommonForm/CommonForm.vue'; import Dashboard from 'src/pages/Dashboard/Dashboard.vue'; -import ImportWizard from 'src/pages/ImportWizard.vue'; import GeneralForm from 'src/pages/GeneralForm.vue'; import GetStarted from 'src/pages/GetStarted.vue'; +import ImportWizard from 'src/pages/ImportWizard.vue'; import InvoiceForm from 'src/pages/InvoiceForm.vue'; -import JournalEntryForm from 'src/pages/JournalEntryForm.vue'; import ListView from 'src/pages/ListView/ListView.vue'; import PrintView from 'src/pages/PrintView/PrintView.vue'; import QuickEditForm from 'src/pages/QuickEditForm.vue'; -import CommonForm from 'src/pages/CommonForm/CommonForm.vue'; import Report from 'src/pages/Report.vue'; import Settings from 'src/pages/Settings/Settings.vue'; import { createRouter, createWebHistory, RouteLocationRaw, - RouteRecordRaw, + RouteRecordRaw } from 'vue-router'; function getGeneralFormItems(): RouteRecordRaw[] { @@ -46,6 +45,7 @@ function getGeneralFormItems(): RouteRecordRaw[] { function getCommonFormItems(): RouteRecordRaw[] { return [ + ModelNameEnum.JournalEntry, ModelNameEnum.Payment, ModelNameEnum.StockMovement, ModelNameEnum.Item, @@ -82,25 +82,6 @@ const routes: RouteRecordRaw[] = [ }, ...getGeneralFormItems(), ...getCommonFormItems(), - { - path: '/edit/JournalEntry/:name', - name: 'JournalEntryForm', - components: { - default: JournalEntryForm, - edit: QuickEditForm, - }, - props: { - default: (route) => { - // for sidebar item active state - route.params.schemaName = 'JournalEntry'; - return { - schemaName: 'JournalEntry', - name: route.params.name, - }; - }, - edit: (route) => route.query, - }, - }, { path: '/edit/:schemaName/:name', name: 'InvoiceForm', From d946c960a07f7f3c4bdf12bfd0ba75717f881e8d Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Tue, 21 Feb 2023 12:12:06 +0530 Subject: [PATCH 7/7] incr: move Shipments and PRec to common form - remove GeneralForm.vue --- models/inventory/StockTransfer.ts | 16 +- schemas/app/inventory/PurchaseReceipt.json | 22 +- schemas/app/inventory/Shipment.json | 23 +- schemas/app/inventory/StockTransfer.json | 51 +++- schemas/types.ts | 1 + src/pages/CommonForm/CommonForm.vue | 1 - src/pages/GeneralForm.vue | 320 --------------------- src/router.ts | 31 +- 8 files changed, 80 insertions(+), 385 deletions(-) delete mode 100644 src/pages/GeneralForm.vue diff --git a/models/inventory/StockTransfer.ts b/models/inventory/StockTransfer.ts index ae0f992b..fce4f61e 100644 --- a/models/inventory/StockTransfer.ts +++ b/models/inventory/StockTransfer.ts @@ -1,7 +1,13 @@ import { Fyo, t } from 'fyo'; import { Attachment } from 'fyo/core/types'; import { Doc } from 'fyo/model/doc'; -import { Action, DefaultMap, FiltersMap, FormulaMap } from 'fyo/model/types'; +import { + Action, + DefaultMap, + FiltersMap, + FormulaMap, + HiddenMap, +} from 'fyo/model/types'; import { ValidationError } from 'fyo/utils/errors'; import { Defaults } from 'models/baseModels/Defaults/Defaults'; import { Invoice } from 'models/baseModels/Invoice/Invoice'; @@ -33,6 +39,14 @@ export abstract class StockTransfer extends Transfer { }, }; + hidden: HiddenMap = { + backReference: () => + !(this.backReference || !(this.isSubmitted || this.isCancelled)), + terms: () => !(this.terms || !(this.isSubmitted || this.isCancelled)), + attachment: () => + !(this.attachment || !(this.isSubmitted || this.isCancelled)), + }; + static defaults: DefaultMap = { numberSeries: (doc) => getNumberSeries(doc.schemaName, doc.fyo), terms: (doc) => { diff --git a/schemas/app/inventory/PurchaseReceipt.json b/schemas/app/inventory/PurchaseReceipt.json index 33fcebfa..7b051053 100644 --- a/schemas/app/inventory/PurchaseReceipt.json +++ b/schemas/app/inventory/PurchaseReceipt.json @@ -5,14 +5,6 @@ "naming": "numberSeries", "showTitle": true, "fields": [ - { - "fieldname": "items", - "label": "Items", - "fieldtype": "Table", - "target": "PurchaseReceiptItem", - "required": true, - "edit": true - }, { "fieldname": "numberSeries", "label": "Number Series", @@ -20,14 +12,24 @@ "target": "NumberSeries", "create": true, "required": true, - "default": "PREC-" + "default": "PREC-", + "section": "Default" }, { "fieldname": "backReference", "label": "Back Reference", "fieldtype": "Link", "target": "PurchaseInvoice", - "readOnly": true + "readOnly": true, + "section": "References" + }, + { + "fieldname": "items", + "label": "Items", + "fieldtype": "Table", + "target": "PurchaseReceiptItem", + "required": true, + "edit": true } ], "keywordFields": ["name", "party"] diff --git a/schemas/app/inventory/Shipment.json b/schemas/app/inventory/Shipment.json index 10df12dd..242a0d64 100644 --- a/schemas/app/inventory/Shipment.json +++ b/schemas/app/inventory/Shipment.json @@ -5,14 +5,6 @@ "naming": "numberSeries", "showTitle": true, "fields": [ - { - "fieldname": "items", - "label": "Items", - "fieldtype": "Table", - "target": "ShipmentItem", - "required": true, - "edit": true - }, { "fieldname": "numberSeries", "label": "Number Series", @@ -20,14 +12,25 @@ "target": "NumberSeries", "create": true, "required": true, - "default": "SHPM-" + "default": "SHPM-", + "section": "Default" }, { "fieldname": "backReference", "label": "Back Reference", "fieldtype": "Link", "target": "SalesInvoice", - "readOnly": true + "readOnly": true, + "section": "References" + }, + { + "fieldname": "items", + "label": "Items", + "fieldtype": "Table", + "target": "ShipmentItem", + "required": true, + "edit": true, + "section": "Items" } ], "keywordFields": ["name", "party"] diff --git a/schemas/app/inventory/StockTransfer.json b/schemas/app/inventory/StockTransfer.json index c2fa869a..de7f15c2 100644 --- a/schemas/app/inventory/StockTransfer.json +++ b/schemas/app/inventory/StockTransfer.json @@ -11,13 +11,13 @@ "fieldname": "name", "fieldtype": "Data", "required": true, - "readOnly": true + "readOnly": true, + "section": "Default" }, { - "fieldname": "date", - "label": "Date", - "fieldtype": "Datetime", - "required": true + "abstract": true, + "fieldname": "numberSeries", + "section": "Default" }, { "fieldname": "party", @@ -25,25 +25,46 @@ "fieldtype": "Link", "target": "Party", "create": true, - "required": true + "required": true, + "section": "Default" }, { - "fieldname": "terms", - "label": "Notes", - "placeholder": "Add transfer terms", - "fieldtype": "Text" + "fieldname": "date", + "label": "Date", + "fieldtype": "Datetime", + "required": true, + "section": "Default" }, { - "fieldname": "attachment", - "placeholder": "Add attachment", - "label": "Attachment", - "fieldtype": "Attachment" + "abstract": true, + "fieldname": "items", + "section": "Items" }, { "fieldname": "grandTotal", "label": "Grand Total", "fieldtype": "Currency", - "readOnly": true + "readOnly": true, + "section": "Items" + }, + { + "fieldname": "terms", + "label": "Notes", + "placeholder": "Add transfer terms", + "fieldtype": "Text", + "section": "References" + }, + { + "fieldname": "attachment", + "placeholder": "Add attachment", + "label": "Attachment", + "fieldtype": "Attachment", + "section": "References" + }, + { + "abstract": true, + "fieldname": "backReference", + "section": "References" } ], "keywordFields": ["name", "party"] diff --git a/schemas/types.ts b/schemas/types.ts index ef028b26..f542bdf3 100644 --- a/schemas/types.ts +++ b/schemas/types.ts @@ -66,6 +66,7 @@ export interface BaseField { computed?: boolean; // Computed values are not stored in the database. section?: string; // UI Facing config, for grouping by sections tab?: string; // UI Facing config, for grouping by tabs + abstract?: string; // Uused to mark the location of a field in an Abstract schema } export type SelectOption = { value: string; label: string }; diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index c3a48031..f40b4e20 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -289,7 +289,6 @@ export default defineComponent({ }, async onValueChange(field: Field, value: DocValue) { const { fieldname } = field; - console.log(fieldname, value); delete this.errors[fieldname]; try { diff --git a/src/pages/GeneralForm.vue b/src/pages/GeneralForm.vue deleted file mode 100644 index ed92a0b1..00000000 --- a/src/pages/GeneralForm.vue +++ /dev/null @@ -1,320 +0,0 @@ - - diff --git a/src/router.ts b/src/router.ts index 987de9d4..73d4370b 100644 --- a/src/router.ts +++ b/src/router.ts @@ -2,7 +2,6 @@ import { ModelNameEnum } from 'models/types'; import ChartOfAccounts from 'src/pages/ChartOfAccounts.vue'; import CommonForm from 'src/pages/CommonForm/CommonForm.vue'; import Dashboard from 'src/pages/Dashboard/Dashboard.vue'; -import GeneralForm from 'src/pages/GeneralForm.vue'; import GetStarted from 'src/pages/GetStarted.vue'; import ImportWizard from 'src/pages/ImportWizard.vue'; import InvoiceForm from 'src/pages/InvoiceForm.vue'; @@ -15,36 +14,13 @@ import { createRouter, createWebHistory, RouteLocationRaw, - RouteRecordRaw + RouteRecordRaw, } from 'vue-router'; -function getGeneralFormItems(): RouteRecordRaw[] { - return [ModelNameEnum.Shipment, ModelNameEnum.PurchaseReceipt].map( - (schemaName) => { - return { - path: `/edit/${schemaName}/:name`, - name: `${schemaName}Form`, - components: { - default: GeneralForm, - edit: QuickEditForm, - }, - props: { - default: (route) => { - route.params.schemaName = schemaName; - return { - schemaName, - name: route.params.name, - }; - }, - edit: (route) => route.query, - }, - }; - } - ); -} - function getCommonFormItems(): RouteRecordRaw[] { return [ + ModelNameEnum.Shipment, + ModelNameEnum.PurchaseReceipt, ModelNameEnum.JournalEntry, ModelNameEnum.Payment, ModelNameEnum.StockMovement, @@ -80,7 +56,6 @@ const routes: RouteRecordRaw[] = [ path: '/get-started', component: GetStarted, }, - ...getGeneralFormItems(), ...getCommonFormItems(), { path: '/edit/:schemaName/:name',