2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00

add enabeld state in listview

This commit is contained in:
zaqoutabed 2023-06-07 01:42:38 +03:00 committed by Alan
parent ff61e1b4c7
commit bed66cb67a
2 changed files with 22 additions and 2 deletions

View File

@ -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()],
};
}
}

View File

@ -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: `<Badge class="text-xs" color="${color}">${status}</Badge>`,
};
},
};
}
export async function getItemPrice(
doc: InvoiceItem | ItemPrice,
validFrom?: Date,