From 1f259524b9a424fbfea01fc3518c5904bc034d92 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Wed, 30 Nov 2022 12:29:52 +0530 Subject: [PATCH] incr: grouped action dropdowns --- fyo/model/types.ts | 2 ++ models/helpers.ts | 7 +++++-- src/pages/GeneralForm.vue | 17 ++++++++++++++--- src/pages/InvoiceForm.vue | 18 +++++++++++++---- src/pages/JournalEntryForm.vue | 31 ++++++++++++++++++++---------- src/utils/ui.ts | 35 ++++++++++++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 19 deletions(-) diff --git a/fyo/model/types.ts b/fyo/model/types.ts index 282f0571..d5d51fca 100644 --- a/fyo/model/types.ts +++ b/fyo/model/types.ts @@ -64,6 +64,8 @@ export interface Action { label: string; action: (doc: Doc, router: Router) => Promise | void; condition?: (doc: Doc) => boolean; + group?: string; + type?: 'primary' | 'secondary'; component?: { template?: string; }; diff --git a/models/helpers.ts b/models/helpers.ts index 514c6f13..d94edd22 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -26,7 +26,8 @@ export function getInvoiceActions(fyo: Fyo): Action[] { export function getMakeStockTransferAction(fyo: Fyo): Action { return { - label: fyo.t`Make Stock Transfer`, + label: fyo.t`Stock Transfer`, + group: fyo.t`Create`, condition: (doc: Doc) => doc.isSubmitted && !!doc.stockNotTransferred, action: async (doc: Doc) => { const transfer = await (doc as Invoice).getStockTransfer(); @@ -43,7 +44,8 @@ export function getMakeStockTransferAction(fyo: Fyo): Action { export function getMakePaymentAction(fyo: Fyo): Action { return { - label: fyo.t`Make Payment`, + label: fyo.t`Payment`, + group: fyo.t`Create`, condition: (doc: Doc) => doc.isSubmitted && !(doc.outstandingAmount as Money).isZero(), action: async (doc: Doc) => { @@ -79,6 +81,7 @@ export function getLedgerLinkAction( return { label, + group: fyo.t`View`, condition: (doc: Doc) => doc.isSubmitted, action: async (doc: Doc, router: Router) => { router.push({ diff --git a/src/pages/GeneralForm.vue b/src/pages/GeneralForm.vue index f74bce10..cbed23c5 100644 --- a/src/pages/GeneralForm.vue +++ b/src/pages/GeneralForm.vue @@ -3,7 +3,17 @@