2023-03-04 22:38:38 +05:30
|
|
|
import { __, s__ } from '~/locale';
|
|
|
|
import { STATUS_LABELS } from './constants';
|
|
|
|
|
|
|
|
export const getStatusLabel = (status) => STATUS_LABELS[status] ?? s__('IncidentManagement|None');
|
2021-09-30 23:02:18 +05:30
|
|
|
|
|
|
|
export const todoLabel = (hasTodo) => {
|
|
|
|
return hasTodo ? __('Mark as done') : __('Add a to do');
|
|
|
|
};
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
export const updateGlobalTodoCount = (additionalTodoCount) => {
|
|
|
|
const countContainer = document.querySelector('.js-todos-count');
|
|
|
|
|
|
|
|
if (countContainer === null) return;
|
|
|
|
|
|
|
|
const currentCount = parseInt(countContainer.innerText, 10);
|
|
|
|
|
|
|
|
const todoToggleEvent = new CustomEvent('todo:toggle', {
|
|
|
|
detail: {
|
|
|
|
count: Math.max(currentCount + additionalTodoCount, 0),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
document.dispatchEvent(todoToggleEvent);
|
|
|
|
};
|