b24-snippets/bx-custom-include/kanban-color/script.js

18 lines
684 B
JavaScript

BX.addCustomEvent('Kanban.Grid:onRender', grid => {
if (grid.getData().entityType != 'DYNAMIC_183')
return;
const items = grid.getItems();
for (let key in items) {
if (key < 1) continue;
const item = items[key];
if (!('data' in item) || !('dateCreate' in item.data)) continue;
const HOUR = 1000 * 60 * 60;
const pattern = /^(\d{2})\.(\d{2})\.(\d{4})\s(\d{2})\:(\d{2})\:(\d{2})$/;
const createdDate = new Date(item.data.dateCreate.replace(pattern,'$3-$2-$1 $4:$5:$6'));
if ((Date.now() - createdDate) >= HOUR * 48) {
BX.addClass(item.container, 'kanban-color-bg-animate');
}
}
});