Added utility function getPropertyValueByAlias

for reuse across the Document Collection Views.
This commit is contained in:
leekelleher
2024-02-19 16:20:51 +00:00
parent e8754a7a49
commit b2de46dd3c

View File

@@ -1 +1,24 @@
import type { UmbDocumentCollectionItemModel } from '../types.js';
export { UMB_DOCUMENT_GRID_COLLECTION_VIEW_ALIAS, UMB_DOCUMENT_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js';
export function getPropertyValueByAlias(item: UmbDocumentCollectionItemModel, alias: string) {
switch (alias) {
case 'createDate':
return item.createDate.toLocaleString();
case 'entityName':
return item.name;
case 'entityState':
return item.state.replace(/([A-Z])/g, ' $1');
case 'owner':
return item.creator;
case 'published':
return item.state !== 'Draft' ? 'True' : 'False';
case 'updateDate':
return item.updateDate.toLocaleString();
case 'updater':
return item.updater;
default:
return item.values.find((value) => value.alias === alias)?.value ?? '';
}
}