From 539157d12202de4352ca41f3b57e1741771bfb94 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 3 Mar 2023 17:50:16 +0530 Subject: [PATCH] feat: add link navigation - getCreateRoute -> getFormRoute - update formRoute listconfig --- fyo/model/types.ts | 2 +- models/baseModels/Item/Item.ts | 2 +- .../baseModels/JournalEntry/JournalEntry.ts | 2 +- models/baseModels/Payment/Payment.ts | 2 +- .../PurchaseInvoice/PurchaseInvoice.ts | 2 +- .../baseModels/SalesInvoice/SalesInvoice.ts | 2 +- models/inventory/PurchaseReceipt.ts | 2 +- models/inventory/Shipment.ts | 2 +- models/inventory/StockMovement.ts | 2 +- src/components/Controls/AutoComplete.vue | 6 ++-- src/components/Widgets/LinkedEntryWidget.vue | 5 ++-- src/pages/ListView/ListView.vue | 4 +-- src/router.ts | 22 -------------- src/utils/search.ts | 18 ++--------- src/utils/ui.ts | 30 +++++++++++++++++++ 15 files changed, 50 insertions(+), 53 deletions(-) diff --git a/fyo/model/types.ts b/fyo/model/types.ts index cb1b08bd..42814452 100644 --- a/fyo/model/types.ts +++ b/fyo/model/types.ts @@ -87,7 +87,7 @@ export interface ColumnConfig { export type ListViewColumn = string | ColumnConfig; export interface ListViewSettings { - formRoute?: (doc: Doc) => RouteLocationRaw; + formRoute?: (name: string) => RouteLocationRaw; columns?: ListViewColumn[]; } diff --git a/models/baseModels/Item/Item.ts b/models/baseModels/Item/Item.ts index b248476f..61e67796 100644 --- a/models/baseModels/Item/Item.ts +++ b/models/baseModels/Item/Item.ts @@ -112,7 +112,7 @@ export class Item extends Doc { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/Item/${name}`, + formRoute: (name) => `/edit/Item/${name}`, columns: ['name', 'unit', 'tax', 'rate'], }; } diff --git a/models/baseModels/JournalEntry/JournalEntry.ts b/models/baseModels/JournalEntry/JournalEntry.ts index 2a844ba3..7241d345 100644 --- a/models/baseModels/JournalEntry/JournalEntry.ts +++ b/models/baseModels/JournalEntry/JournalEntry.ts @@ -65,7 +65,7 @@ export class JournalEntry extends Transactional { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/JournalEntry/${name}`, + formRoute: (name) => `/edit/JournalEntry/${name}`, columns: [ 'name', { diff --git a/models/baseModels/Payment/Payment.ts b/models/baseModels/Payment/Payment.ts index 176b7e95..3a932387 100644 --- a/models/baseModels/Payment/Payment.ts +++ b/models/baseModels/Payment/Payment.ts @@ -617,7 +617,7 @@ export class Payment extends Transactional { static getListViewSettings(fyo: Fyo): ListViewSettings { return { - formRoute: ({ name }) => `/edit/Payment/${name}`, + formRoute: (name) => `/edit/Payment/${name}`, columns: ['name', getDocStatusListColumn(), 'party', 'date', 'amount'], }; } diff --git a/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts b/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts index 5a7e64fd..a8a7f8b0 100644 --- a/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts +++ b/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts @@ -37,7 +37,7 @@ export class PurchaseInvoice extends Invoice { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/PurchaseInvoice/${name}`, + formRoute: (name) => `/edit/PurchaseInvoice/${name}`, columns: [ 'name', getTransactionStatusColumn(), diff --git a/models/baseModels/SalesInvoice/SalesInvoice.ts b/models/baseModels/SalesInvoice/SalesInvoice.ts index 525faaf7..5064887f 100644 --- a/models/baseModels/SalesInvoice/SalesInvoice.ts +++ b/models/baseModels/SalesInvoice/SalesInvoice.ts @@ -37,7 +37,7 @@ export class SalesInvoice extends Invoice { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/SalesInvoice/${name}`, + formRoute: (name) => `/edit/SalesInvoice/${name}`, columns: [ 'name', getTransactionStatusColumn(), diff --git a/models/inventory/PurchaseReceipt.ts b/models/inventory/PurchaseReceipt.ts index 019c75b4..490e2af5 100644 --- a/models/inventory/PurchaseReceipt.ts +++ b/models/inventory/PurchaseReceipt.ts @@ -8,7 +8,7 @@ export class PurchaseReceipt extends StockTransfer { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/PurchaseReceipt/${name}`, + formRoute: (name) => `/edit/PurchaseReceipt/${name}`, columns: [ 'name', getTransactionStatusColumn(), diff --git a/models/inventory/Shipment.ts b/models/inventory/Shipment.ts index 20d7baaa..8411601c 100644 --- a/models/inventory/Shipment.ts +++ b/models/inventory/Shipment.ts @@ -8,7 +8,7 @@ export class Shipment extends StockTransfer { static getListViewSettings(): ListViewSettings { return { - formRoute: ({ name }) => `/edit/Shipment/${name}`, + formRoute: (name) => `/edit/Shipment/${name}`, columns: [ 'name', getTransactionStatusColumn(), diff --git a/models/inventory/StockMovement.ts b/models/inventory/StockMovement.ts index 7d05429c..9e203d55 100644 --- a/models/inventory/StockMovement.ts +++ b/models/inventory/StockMovement.ts @@ -81,7 +81,7 @@ export class StockMovement extends Transfer { static getListViewSettings(fyo: Fyo): ListViewSettings { return { - formRoute: ({ name }) => `/edit/StockMovement/${name}`, + formRoute: (name) => `/edit/StockMovement/${name}`, columns: [ 'name', getDocStatusListColumn(), diff --git a/src/components/Controls/AutoComplete.vue b/src/components/Controls/AutoComplete.vue index d5ac17c4..3c6ad2a0 100644 --- a/src/components/Controls/AutoComplete.vue +++ b/src/components/Controls/AutoComplete.vue @@ -68,6 +68,7 @@ import { getOptionList } from 'fyo/utils'; import { FieldTypeEnum } from 'schemas/types'; import Dropdown from 'src/components/Dropdown.vue'; import { fuzzyMatch } from 'src/utils'; +import { getFormRoute, routeTo } from 'src/utils/ui'; import Base from './Base.vue'; export default { @@ -138,7 +139,7 @@ export default { }, }, methods: { - routeToLinkedDoc() { + async routeToLinkedDoc() { let schemaName = this.df?.target; const name = this.value; @@ -151,7 +152,8 @@ export default { return; } - console.log(`routing to: ${schemaName}.${name}`); + const route = getFormRoute(schemaName, name); + await routeTo(route); }, setLinkValue(value) { this.linkValue = value; diff --git a/src/components/Widgets/LinkedEntryWidget.vue b/src/components/Widgets/LinkedEntryWidget.vue index 9289eb86..8de7d412 100644 --- a/src/components/Widgets/LinkedEntryWidget.vue +++ b/src/components/Widgets/LinkedEntryWidget.vue @@ -55,8 +55,7 @@