From bed66cb67a9bfece019251e5c2bea6dec2e70774 Mon Sep 17 00:00:00 2001 From: zaqoutabed Date: Wed, 7 Jun 2023 01:42:38 +0300 Subject: [PATCH] add enabeld state in listview --- models/baseModels/PriceList/PriceList.ts | 4 ++-- models/helpers.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/models/baseModels/PriceList/PriceList.ts b/models/baseModels/PriceList/PriceList.ts index 7eb2b88fd..5a3736331 100644 --- a/models/baseModels/PriceList/PriceList.ts +++ b/models/baseModels/PriceList/PriceList.ts @@ -1,7 +1,7 @@ import { Doc } from 'fyo/model/doc'; import { ListViewSettings } from 'fyo/model/types'; import { ItemPrice } from '../ItemPrice/ItemPrice'; -import { getPriceListStatusColumn } from 'models/helpers'; +import { getPriceListEnabledColumn, getPriceListStatusColumn } from 'models/helpers'; export class PriceList extends Doc { enabled?: boolean; @@ -12,7 +12,7 @@ export class PriceList extends Doc { static getListViewSettings(): ListViewSettings { return { - columns: ['name', getPriceListStatusColumn()], + columns: ['name', getPriceListEnabledColumn(), getPriceListStatusColumn()], }; } } diff --git a/models/helpers.ts b/models/helpers.ts index 8f25f9a2c..f56b0e8df 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -354,6 +354,26 @@ export function getPriceListStatusColumn(): ColumnConfig { }; } +export function getPriceListEnabledColumn(): ColumnConfig { + return { + label: t`Enabled`, + fieldname: 'enabled', + fieldtype: 'Data', + render(doc) { + let status = t`Unenabled`; + let color = 'orange'; + if (doc.enabled) { + status = t`Enabled`; + color = 'green'; + } + + return { + template: `${status}`, + }; + }, + }; +} + export async function getItemPrice( doc: InvoiceItem | ItemPrice, validFrom?: Date,