Skip to content

Commit

Permalink
add enabeld state in listview
Browse files Browse the repository at this point in the history
  • Loading branch information
zaqoutabed authored and 18alantom committed Jun 7, 2023
1 parent ff61e1b commit bed66cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/baseModels/PriceList/PriceList.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +12,7 @@ export class PriceList extends Doc {

static getListViewSettings(): ListViewSettings {
return {
columns: ['name', getPriceListStatusColumn()],
columns: ['name', getPriceListEnabledColumn(), getPriceListStatusColumn()],
};
}
}
20 changes: 20 additions & 0 deletions models/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bed66cb

Please sign in to comment.