@topconsultnpm/sdkui-react 6.19.0-dev1.9 → 6.19.0-dev2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/base/Styled.d.ts +1 -0
- package/lib/components/base/Styled.js +40 -0
- package/lib/components/base/TMCustomButton.d.ts +11 -0
- package/lib/components/base/TMCustomButton.js +63 -0
- package/lib/components/base/TMFileManagerDataGridView.js +4 -1
- package/lib/components/base/TMLayout.d.ts +2 -1
- package/lib/components/base/TMLayout.js +2 -2
- package/lib/components/base/TMPopUp.js +5 -18
- package/lib/components/base/TMTreeView.js +3 -2
- package/lib/components/editors/TMHtmlEditor.d.ts +5 -0
- package/lib/components/editors/TMHtmlEditor.js +72 -12
- package/lib/components/editors/TMMetadataValues.js +90 -40
- package/lib/components/features/archive/TMArchive.d.ts +10 -0
- package/lib/components/features/archive/TMArchive.js +56 -25
- package/lib/components/features/blog/TMBlogCommentForm.d.ts +4 -4
- package/lib/components/features/blog/TMBlogCommentForm.js +76 -51
- package/lib/components/features/documents/TMDcmtBlog.d.ts +15 -0
- package/lib/components/features/documents/TMDcmtBlog.js +21 -33
- package/lib/components/features/documents/TMDcmtForm.d.ts +17 -3
- package/lib/components/features/documents/TMDcmtForm.js +205 -46
- package/lib/components/features/documents/TMDcmtTasks.d.ts +13 -0
- package/lib/components/features/documents/TMDcmtTasks.js +24 -0
- package/lib/components/features/documents/TMDragDropOverlay.js +2 -1
- package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +8 -1
- package/lib/components/features/documents/TMMasterDetailDcmts.js +6 -6
- package/lib/components/features/documents/TMRelationViewer.d.ts +53 -3
- package/lib/components/features/documents/TMRelationViewer.js +232 -85
- package/lib/components/features/search/TMSearch.d.ts +10 -1
- package/lib/components/features/search/TMSearch.js +14 -5
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -1
- package/lib/components/features/search/TMSearchQueryPanel.js +36 -7
- package/lib/components/features/search/TMSearchResult.d.ts +10 -1
- package/lib/components/features/search/TMSearchResult.js +140 -422
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +2 -2
- package/lib/components/features/search/TMSearchResultsMenuItems.js +33 -8
- package/lib/components/features/tasks/TMTaskForm.d.ts +38 -0
- package/lib/components/features/tasks/TMTaskForm.js +386 -0
- package/lib/components/features/tasks/TMTasksAgenda.d.ts +17 -0
- package/lib/components/features/tasks/TMTasksAgenda.js +107 -0
- package/lib/components/features/tasks/TMTasksCalendar.d.ts +21 -0
- package/lib/components/features/tasks/TMTasksCalendar.js +240 -0
- package/lib/components/features/tasks/TMTasksHeader.d.ts +14 -0
- package/lib/components/features/tasks/TMTasksHeader.js +37 -0
- package/lib/components/features/tasks/TMTasksPanelContent.d.ts +20 -0
- package/lib/components/features/tasks/TMTasksPanelContent.js +65 -0
- package/lib/components/features/tasks/TMTasksUtils.d.ts +132 -0
- package/lib/components/features/tasks/TMTasksUtils.js +634 -0
- package/lib/components/features/tasks/TMTasksUtilsView.d.ts +39 -0
- package/lib/components/features/tasks/TMTasksUtilsView.js +118 -0
- package/lib/components/features/tasks/TMTasksView.d.ts +40 -0
- package/lib/components/features/tasks/TMTasksView.js +560 -0
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +3 -1
- package/lib/components/features/workflow/TMWorkflowPopup.js +19 -6
- package/lib/components/features/workflow/diagram/RecipientList.js +4 -3
- package/lib/components/forms/Login/Chooser.js +1 -1
- package/lib/components/forms/TMChooserForm.d.ts +1 -1
- package/lib/components/forms/TMChooserForm.js +2 -2
- package/lib/components/grids/TMBlogAttachments.d.ts +42 -0
- package/lib/components/grids/TMBlogAttachments.js +43 -0
- package/lib/components/grids/TMBlogHeader.d.ts +31 -0
- package/lib/components/grids/TMBlogHeader.js +41 -0
- package/lib/components/grids/{TMBlogs.d.ts → TMBlogsPost.d.ts} +42 -58
- package/lib/components/grids/TMBlogsPost.js +628 -0
- package/lib/components/grids/{TMBlogsUtils.d.ts → TMBlogsPostUtils.d.ts} +61 -47
- package/lib/components/grids/{TMBlogsUtils.js → TMBlogsPostUtils.js} +146 -124
- package/lib/components/index.d.ts +14 -1
- package/lib/components/index.js +15 -1
- package/lib/components/layout/panelManager/TMPanelManagerContext.js +7 -0
- package/lib/components/settings/SettingsAppearance.js +8 -0
- package/lib/components/viewers/TMTidViewer.js +20 -2
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +4 -1
- package/lib/helper/SDKUI_Globals.js +10 -1
- package/lib/helper/SDKUI_Localizator.d.ts +62 -4
- package/lib/helper/SDKUI_Localizator.js +618 -25
- package/lib/helper/TMCustomSearchBar.d.ts +8 -0
- package/lib/helper/TMCustomSearchBar.js +54 -0
- package/lib/helper/TMIcons.d.ts +2 -0
- package/lib/helper/TMIcons.js +6 -0
- package/lib/helper/TMImageLibrary.d.ts +3 -2
- package/lib/helper/TMImageLibrary.js +230 -230
- package/lib/helper/TMToppyMessage.d.ts +7 -0
- package/lib/helper/TMToppyMessage.js +42 -0
- package/lib/helper/TMUtils.d.ts +10 -1
- package/lib/helper/TMUtils.js +42 -1
- package/lib/helper/dcmtsHelper.d.ts +2 -0
- package/lib/helper/dcmtsHelper.js +18 -0
- package/lib/helper/helpers.js +1 -0
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/hooks/useRelatedDocuments.d.ts +72 -0
- package/lib/hooks/useRelatedDocuments.js +655 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/ts/types.d.ts +14 -0
- package/lib/ts/types.js +15 -0
- package/lib/utils/theme.d.ts +1 -0
- package/lib/utils/theme.js +1 -0
- package/package.json +7 -7
- package/lib/components/grids/TMBlogs.js +0 -721
- package/lib/stories/TMButton.stories.d.ts +0 -4
- package/lib/stories/TMButton.stories.js +0 -29
- package/lib/stories/TMDataGrid.stories.d.ts +0 -9
- package/lib/stories/TMDataGrid.stories.js +0 -310
- package/lib/stories/TMHtmlContentDisplay.stories.d.ts +0 -6
- package/lib/stories/TMHtmlContentDisplay.stories.js +0 -45
- package/lib/stories/TMHtmlEditor.stories.d.ts +0 -6
- package/lib/stories/TMHtmlEditor.stories.js +0 -49
- package/lib/stories/TMIcons.stories.d.ts +0 -4
- package/lib/stories/TMIcons.stories.js +0 -13
- package/lib/stories/TMSDKUI_Localizator.stories.d.ts +0 -4
- package/lib/stories/TMSDKUI_Localizator.stories.js +0 -123
- package/lib/stories/TMStoriesUtils.d.ts +0 -1
- package/lib/stories/TMStoriesUtils.js +0 -10
- package/lib/stories/TMUserAvatar.stories.d.ts +0 -6
- package/lib/stories/TMUserAvatar.stories.js +0 -20
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import { Task_States, PdGs, Priorities, ValidationItem, SDK_Localizator, ResultTypes, SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
2
|
+
import { TMColors } from '../../../utils/theme';
|
|
3
|
+
import { SDKUI_Localizator } from '../../../helper';
|
|
4
|
+
import { FormModes } from '../../../ts';
|
|
5
|
+
export const TEXT_SELECTED_COLOR = "#ff5e1a";
|
|
6
|
+
export const BG_COLOR_INACTIVE_WIDGET = "#fff";
|
|
7
|
+
export const BG_COLOR_ACTIVE_WIDGET = "#fff0b7";
|
|
8
|
+
export const TEXT_NOT_SELECTED_COLOR = "#2559A5";
|
|
9
|
+
export const TODAY_ROW_HIGHLIGHT_BG_COLOR = "#ffb74d";
|
|
10
|
+
export const NOT_TODAY_ROW_HIGHLIGHT_COLOR = "#ff0000";
|
|
11
|
+
export const NOT_TODAY_ROW_HIGHLIGHT_BG_COLOR = "#81d7fe";
|
|
12
|
+
export const START_DATE_MUST_BE_BEFORE_END_DATE = "StartDateMustBeBeforeEndDate";
|
|
13
|
+
export const REMINDER_TIME_MUST_BE_BEFORE_END_TIME = "ReminderTimeMustBeBeforeEndTime";
|
|
14
|
+
export var AssignedTab;
|
|
15
|
+
(function (AssignedTab) {
|
|
16
|
+
AssignedTab[AssignedTab["AssignedToMe"] = 0] = "AssignedToMe";
|
|
17
|
+
AssignedTab[AssignedTab["AssignedByMe"] = 1] = "AssignedByMe";
|
|
18
|
+
AssignedTab[AssignedTab["All"] = 2] = "All";
|
|
19
|
+
AssignedTab[AssignedTab["TaskNotPersonalAssignedToMe"] = 3] = "TaskNotPersonalAssignedToMe";
|
|
20
|
+
AssignedTab[AssignedTab["TaskPersonalAssignedToMe"] = 4] = "TaskPersonalAssignedToMe";
|
|
21
|
+
})(AssignedTab || (AssignedTab = {}));
|
|
22
|
+
const sortByEndTimeAndName = (tasks) => {
|
|
23
|
+
return tasks.sort((a, b) => {
|
|
24
|
+
// If both tasks have `endTime`
|
|
25
|
+
if (a.endTime && b.endTime) {
|
|
26
|
+
// Compare `endTime` in descending order (newest first)
|
|
27
|
+
const endTimeComparison = new Date(b.endTime).getTime() - new Date(a.endTime).getTime();
|
|
28
|
+
// If `endTime` is the same, compare `name` in ascending alphabetical order
|
|
29
|
+
return endTimeComparison !== 0
|
|
30
|
+
? endTimeComparison
|
|
31
|
+
: (a.name ?? '').localeCompare(b.name ?? '');
|
|
32
|
+
}
|
|
33
|
+
// If only `a` has `endTime`, it should come before `b`
|
|
34
|
+
if (a.endTime)
|
|
35
|
+
return -1;
|
|
36
|
+
// If only `b` has `endTime`, it should come before `a`
|
|
37
|
+
if (b.endTime)
|
|
38
|
+
return 1;
|
|
39
|
+
// If neither has `endTime`, compare by `name` in ascending alphabetical order
|
|
40
|
+
return (a.name ?? '').localeCompare(b.name ?? '');
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export const sortTasks = (tasks) => {
|
|
44
|
+
const newTasks = tasks.filter(task => checkIfNew(task.fromID, task.isNew));
|
|
45
|
+
const oldTasks = tasks.filter(task => !checkIfNew(task.fromID, task.isNew));
|
|
46
|
+
const sortedNewTasks = sortByEndTimeAndName(newTasks);
|
|
47
|
+
const sortedOldTasks = sortByEndTimeAndName(oldTasks);
|
|
48
|
+
return [...sortedNewTasks, ...sortedOldTasks];
|
|
49
|
+
};
|
|
50
|
+
export const taskIsToday = (startTime, endTime) => {
|
|
51
|
+
const currentDate = new Date(); // Get the current date
|
|
52
|
+
const todayDay = currentDate.getDate();
|
|
53
|
+
const todayMonth = currentDate.getMonth(); // Months are 0-indexed
|
|
54
|
+
const todayYear = currentDate.getFullYear();
|
|
55
|
+
// Convert startTime and endTime to Date objects
|
|
56
|
+
const startDate = new Date(startTime);
|
|
57
|
+
const endDate = new Date(endTime);
|
|
58
|
+
// Extract day, month, and year for startDate and endDate
|
|
59
|
+
const startDay = startDate.getDate();
|
|
60
|
+
const startMonth = startDate.getMonth();
|
|
61
|
+
const startYear = startDate.getFullYear();
|
|
62
|
+
const endDay = endDate.getDate();
|
|
63
|
+
const endMonth = endDate.getMonth();
|
|
64
|
+
const endYear = endDate.getFullYear();
|
|
65
|
+
// Check if both startDate and endDate match today's day, month, and year
|
|
66
|
+
if ((startYear < todayYear || (startYear === todayYear && startMonth < todayMonth) || (startYear === todayYear && startMonth === todayMonth && startDay <= todayDay)) &&
|
|
67
|
+
(endYear > todayYear || (endYear === todayYear && endMonth > todayMonth) || (endYear === todayYear && endMonth === todayMonth && endDay >= todayDay))) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
export const taskIsExpiringSoon = (endTime, remTime) => {
|
|
73
|
+
const now = new Date();
|
|
74
|
+
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
75
|
+
// Set endTime to midnight for date-only comparison
|
|
76
|
+
const endDate = new Date(endTime.getFullYear(), endTime.getMonth(), endTime.getDate());
|
|
77
|
+
// Condition 1: Check if today is exactly one day before endTime
|
|
78
|
+
const oneDayBeforeEnd = new Date(endDate);
|
|
79
|
+
oneDayBeforeEnd.setDate(endDate.getDate() - 1);
|
|
80
|
+
const isOneDayBeforeEndTime = startOfToday.getTime() === oneDayBeforeEnd.getTime();
|
|
81
|
+
// Condition 2: Check if endTime is today
|
|
82
|
+
const isEndTimeToday = startOfToday.getTime() === endDate.getTime();
|
|
83
|
+
// Set remTime to midnight for date-only comparison if defined
|
|
84
|
+
const remDate = remTime ? new Date(remTime.getFullYear(), remTime.getMonth(), remTime.getDate()) : null;
|
|
85
|
+
// Condition 3: Check if remTime is defined and today is between remTime and endTime (inclusive)
|
|
86
|
+
const isBetweenRemAndEnd = remDate
|
|
87
|
+
? startOfToday >= remDate && startOfToday <= endDate
|
|
88
|
+
: false;
|
|
89
|
+
// Return true if any condition is met
|
|
90
|
+
return isOneDayBeforeEndTime || isEndTimeToday || isBetweenRemAndEnd;
|
|
91
|
+
};
|
|
92
|
+
export const appointmentBackgroundColorFn = (startTime, endTime) => {
|
|
93
|
+
return taskIsToday(startTime, endTime) ? TODAY_ROW_HIGHLIGHT_BG_COLOR : NOT_TODAY_ROW_HIGHLIGHT_BG_COLOR;
|
|
94
|
+
};
|
|
95
|
+
export const getPriorityLocalizatorValues = () => {
|
|
96
|
+
// Filtered enum for Low and High values
|
|
97
|
+
const filteredPriorities = { Low: Priorities.Low, High: Priorities.High };
|
|
98
|
+
return Object.values(filteredPriorities).map(priority => {
|
|
99
|
+
switch (priority) {
|
|
100
|
+
case Priorities.High:
|
|
101
|
+
return ({ value: priority, display: SDKUI_Localizator.High });
|
|
102
|
+
default:
|
|
103
|
+
return ({ value: priority, display: SDKUI_Localizator.Low });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export const getPriorityId = (priority) => {
|
|
108
|
+
switch (priority) {
|
|
109
|
+
case Priorities.High:
|
|
110
|
+
return 2;
|
|
111
|
+
default:
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export const getPriorityColor = (priority) => {
|
|
116
|
+
switch (priority) {
|
|
117
|
+
case Priorities.High:
|
|
118
|
+
return LIGTH_RED_ORGANGE;
|
|
119
|
+
default:
|
|
120
|
+
return LIGTH_CYAN;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export const LIGTH_CYAN = '#80DEEA';
|
|
124
|
+
export const LIGTH_RED_ORGANGE = '#FFAB91';
|
|
125
|
+
export const prioritiesResourceData = [
|
|
126
|
+
{ text: SDKUI_Localizator.Low, id: getPriorityId(Priorities.Low), color: LIGTH_CYAN }, // Light Cyan
|
|
127
|
+
{ text: SDKUI_Localizator.High, id: getPriorityId(Priorities.High), color: LIGTH_RED_ORGANGE } // Light Red-Orange
|
|
128
|
+
];
|
|
129
|
+
export const getStatusLocalizatorValues = () => {
|
|
130
|
+
return Object.values(Task_States)
|
|
131
|
+
.filter(status => status !== Task_States.None) // Remove the "None" status
|
|
132
|
+
.map(status => {
|
|
133
|
+
switch (status) {
|
|
134
|
+
case Task_States.Completed:
|
|
135
|
+
return ({ value: status, display: SDKUI_Localizator.Completed });
|
|
136
|
+
case Task_States.Deferred:
|
|
137
|
+
return ({ value: status, display: SDKUI_Localizator.Postponed });
|
|
138
|
+
case Task_States.InProgress:
|
|
139
|
+
return ({ value: status, display: SDKUI_Localizator.InProgress });
|
|
140
|
+
case Task_States.NotStarted:
|
|
141
|
+
return ({ value: status, display: SDKUI_Localizator.NewFemale });
|
|
142
|
+
case Task_States.Waiting:
|
|
143
|
+
return ({ value: status, display: SDKUI_Localizator.Pending });
|
|
144
|
+
default:
|
|
145
|
+
return ({ value: status, display: "" }); // Just in case, though it won't be hit
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export const getStatusLocalizatorValue = (status) => {
|
|
150
|
+
switch (status) {
|
|
151
|
+
case Task_States.Completed:
|
|
152
|
+
return SDKUI_Localizator.Completed;
|
|
153
|
+
case Task_States.Deferred:
|
|
154
|
+
return SDKUI_Localizator.Postponed;
|
|
155
|
+
case Task_States.InProgress:
|
|
156
|
+
return SDKUI_Localizator.InProgress;
|
|
157
|
+
case Task_States.Waiting:
|
|
158
|
+
return SDKUI_Localizator.Pending;
|
|
159
|
+
default:
|
|
160
|
+
return SDKUI_Localizator.NewFemale;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
export const getPriorityLocalizatorValue = (priority) => {
|
|
164
|
+
switch (priority) {
|
|
165
|
+
case Priorities.High:
|
|
166
|
+
return SDKUI_Localizator.High;
|
|
167
|
+
default:
|
|
168
|
+
return SDKUI_Localizator.Low;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
export const getTaskAssignedToMe = (tasks) => {
|
|
172
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
173
|
+
return tasks.filter((task) => task.fromID !== undefined && task.toID === userID);
|
|
174
|
+
};
|
|
175
|
+
export const getTaskNotPersonalAssignedToMe = (tasks) => {
|
|
176
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
177
|
+
return tasks
|
|
178
|
+
.filter((task) => task.fromID !== undefined &&
|
|
179
|
+
task.fromID !== userID &&
|
|
180
|
+
task.toID === userID &&
|
|
181
|
+
task.state !== Task_States.Completed)
|
|
182
|
+
.sort((a, b) => {
|
|
183
|
+
if (!a.endTime && !b.endTime)
|
|
184
|
+
return 0;
|
|
185
|
+
if (!a.endTime)
|
|
186
|
+
return 1;
|
|
187
|
+
if (!b.endTime)
|
|
188
|
+
return -1;
|
|
189
|
+
return a.endTime.getTime() - b.endTime.getTime();
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
export const getTaskPersonalAssignedToMe = (tasks) => {
|
|
193
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
194
|
+
return tasks
|
|
195
|
+
.filter((task) => task.fromID !== undefined &&
|
|
196
|
+
task.fromID === userID &&
|
|
197
|
+
task.toID === userID &&
|
|
198
|
+
task.state !== Task_States.Completed)
|
|
199
|
+
.sort((a, b) => {
|
|
200
|
+
if (!a.endTime && !b.endTime)
|
|
201
|
+
return 0;
|
|
202
|
+
if (!a.endTime)
|
|
203
|
+
return 1;
|
|
204
|
+
if (!b.endTime)
|
|
205
|
+
return -1;
|
|
206
|
+
return a.endTime.getTime() - b.endTime.getTime();
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
export const getTaskAssignedByMe = (tasks) => {
|
|
210
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
211
|
+
return tasks.filter((task) => task.toID !== undefined && task.toID !== userID);
|
|
212
|
+
};
|
|
213
|
+
export const getHeaderStatusFilterConfig = () => ({
|
|
214
|
+
enabled: true,
|
|
215
|
+
dataSource: getStatusLocalizatorValues().map(item => ({
|
|
216
|
+
text: item.display,
|
|
217
|
+
value: item.value,
|
|
218
|
+
})),
|
|
219
|
+
});
|
|
220
|
+
export const getHeaderPriorityFilterConfig = () => ({
|
|
221
|
+
enabled: true,
|
|
222
|
+
dataSource: getPriorityLocalizatorValues().map(item => ({
|
|
223
|
+
text: item.display,
|
|
224
|
+
value: item.value,
|
|
225
|
+
})),
|
|
226
|
+
});
|
|
227
|
+
export const TaskView = {
|
|
228
|
+
LIST_TASK: 'LIST_TASK',
|
|
229
|
+
AGENDA_TASK: 'AGENDA_TASK',
|
|
230
|
+
CALENDAR_TASK: 'CALENDAR_TASK'
|
|
231
|
+
};
|
|
232
|
+
export var Extended_Task_States;
|
|
233
|
+
(function (Extended_Task_States) {
|
|
234
|
+
Extended_Task_States["Init"] = "Init";
|
|
235
|
+
Extended_Task_States["Expiring"] = "Expiring";
|
|
236
|
+
Extended_Task_States["AssignedToMe"] = "AssignedToMe";
|
|
237
|
+
Extended_Task_States["AssignedByMe"] = "AssignedByMe";
|
|
238
|
+
Extended_Task_States["NewAssignedActivities"] = "NewAssignedActivities";
|
|
239
|
+
})(Extended_Task_States || (Extended_Task_States = {}));
|
|
240
|
+
export const getTaskColor = (taskState) => {
|
|
241
|
+
let color;
|
|
242
|
+
switch (taskState) {
|
|
243
|
+
case Task_States.Completed:
|
|
244
|
+
color = TMColors.success;
|
|
245
|
+
break;
|
|
246
|
+
case Task_States.Deferred:
|
|
247
|
+
color = TMColors.error;
|
|
248
|
+
break;
|
|
249
|
+
case Task_States.InProgress:
|
|
250
|
+
color = TMColors.secondary;
|
|
251
|
+
break;
|
|
252
|
+
case Task_States.NotStarted:
|
|
253
|
+
color = TMColors.primary;
|
|
254
|
+
break;
|
|
255
|
+
case Task_States.Waiting:
|
|
256
|
+
color = TMColors.tertiary;
|
|
257
|
+
break;
|
|
258
|
+
default:
|
|
259
|
+
color = TMColors.secondary;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
return { color };
|
|
263
|
+
};
|
|
264
|
+
export const mergeUniqueTasks = (existing, // Array of existing tasks
|
|
265
|
+
newTasks // Array of new tasks to merge
|
|
266
|
+
) => {
|
|
267
|
+
const taskMap = new Map(); // Create a map to hold tasks by ID
|
|
268
|
+
// Add existing tasks to the map, checking that the ID is defined
|
|
269
|
+
existing.forEach(task => {
|
|
270
|
+
if (task.id !== undefined) {
|
|
271
|
+
taskMap.set(task.id, task);
|
|
272
|
+
} // Store the existing task in the map
|
|
273
|
+
});
|
|
274
|
+
// Add new tasks to the map, overriding existing tasks with the same ID
|
|
275
|
+
newTasks.forEach(task => {
|
|
276
|
+
if (task.id !== undefined) {
|
|
277
|
+
taskMap.set(task.id, task);
|
|
278
|
+
} // Store the new task, replacing existing ones with the same ID
|
|
279
|
+
});
|
|
280
|
+
// Return the values of the map as an array, which contains unique tasks
|
|
281
|
+
return Array.from(taskMap.values());
|
|
282
|
+
};
|
|
283
|
+
export const getOriginLabel = (pdg, ID1Name) => {
|
|
284
|
+
return pdg ? (ID1Name ?? '') : SDKUI_Localizator.NoSource;
|
|
285
|
+
};
|
|
286
|
+
export const taskValidatorAsync = async (taskDescriptor) => {
|
|
287
|
+
let vil = [];
|
|
288
|
+
// Validate task name
|
|
289
|
+
if (!taskDescriptor.name || taskDescriptor.name === "")
|
|
290
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.Name, `${SDK_Localizator.RequiredField}`));
|
|
291
|
+
// Validate name length (max 100)
|
|
292
|
+
if (taskDescriptor.name && taskDescriptor.name.length > 100) {
|
|
293
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.Name, `${SDKUI_Localizator.NameTooLong.replaceParams(100)}`));
|
|
294
|
+
}
|
|
295
|
+
// Validate description length (max 200)
|
|
296
|
+
if (taskDescriptor.description && taskDescriptor.description.length > 200) {
|
|
297
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.Description, `${SDKUI_Localizator.DescriptionTooLongMessage.replaceParams(200)}`));
|
|
298
|
+
}
|
|
299
|
+
// Validate toID
|
|
300
|
+
if (!taskDescriptor.toID || taskDescriptor.toID <= 0)
|
|
301
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.AssignedTo, `${SDK_Localizator.RequiredField}`));
|
|
302
|
+
// Validate that startTime is less than or equal to endTime
|
|
303
|
+
if (taskDescriptor.startTime && taskDescriptor.endTime) {
|
|
304
|
+
if (taskDescriptor.startTime > taskDescriptor.endTime) {
|
|
305
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.ErrorStartEndDate, `${SDKUI_Localizator.StartDateMustBeBeforeEndDate}`));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// Validate that reminderTime is less than endTime
|
|
309
|
+
if (taskDescriptor.remTime && taskDescriptor.endTime) {
|
|
310
|
+
if (taskDescriptor.remTime >= taskDescriptor.endTime) {
|
|
311
|
+
vil.push(new ValidationItem(ResultTypes.ERROR, SDKUI_Localizator.ErrorEndRemDate, `${SDKUI_Localizator.ReminderDateMustBeBeforeEndDate}`));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return vil;
|
|
315
|
+
};
|
|
316
|
+
const getPDGExtended = (pdg) => {
|
|
317
|
+
switch (pdg) {
|
|
318
|
+
case PdGs.WG:
|
|
319
|
+
return SDKUI_Localizator.WorkGroup;
|
|
320
|
+
case PdGs.CF:
|
|
321
|
+
return SDKUI_Localizator.Practice;
|
|
322
|
+
case PdGs.DT:
|
|
323
|
+
return SDKUI_Localizator.Document;
|
|
324
|
+
case PdGs.WF:
|
|
325
|
+
return SDKUI_Localizator.Workflow;
|
|
326
|
+
default:
|
|
327
|
+
return pdg;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
export const gotoPDGExtendedLabel = (gotoVisible, pdg, iD1Name) => {
|
|
331
|
+
return (gotoVisible ? (SDKUI_Localizator.GoTo + ' ') : '') + getPDGExtended(pdg) + ': ' + (iD1Name ?? '-');
|
|
332
|
+
};
|
|
333
|
+
const subtractMinutes = (date, minutes) => {
|
|
334
|
+
const result = new Date(date);
|
|
335
|
+
result.setMinutes(result.getMinutes() - minutes);
|
|
336
|
+
return result;
|
|
337
|
+
};
|
|
338
|
+
export const convertToSchedulerAppointments = (tasks) => {
|
|
339
|
+
const adjustEndTime = (endTime) => {
|
|
340
|
+
if (!endTime)
|
|
341
|
+
return undefined;
|
|
342
|
+
const date = new Date(endTime);
|
|
343
|
+
// Check if time is exactly 00:00
|
|
344
|
+
if (date.getHours() === 0 && date.getMinutes() === 0) {
|
|
345
|
+
date.setDate(date.getDate() - 1); // Move to the previous day
|
|
346
|
+
date.setHours(23, 59, 0, 0); // Set time to 23:59:00
|
|
347
|
+
}
|
|
348
|
+
return date;
|
|
349
|
+
};
|
|
350
|
+
if (tasks.length === 0)
|
|
351
|
+
return [];
|
|
352
|
+
const appointments = [];
|
|
353
|
+
tasks.forEach((task, index) => {
|
|
354
|
+
if (task.startTime !== undefined || task.endTime !== undefined) {
|
|
355
|
+
appointments.push({
|
|
356
|
+
key: `${task.id}-${index}`,
|
|
357
|
+
id: task.id,
|
|
358
|
+
text: task.name,
|
|
359
|
+
startDate: task.startTime ? task.startTime : (task.endTime ? subtractMinutes(task.endTime, 30) : undefined),
|
|
360
|
+
endDate: adjustEndTime(task.endTime),
|
|
361
|
+
priority: getPriorityId(task.priority ?? Priorities.Low)
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return appointments;
|
|
366
|
+
};
|
|
367
|
+
export const formatDate = (date) => {
|
|
368
|
+
// Get the month, day, hours, and minutes from the date
|
|
369
|
+
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
|
|
370
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
371
|
+
const year = date.getFullYear();
|
|
372
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
373
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
374
|
+
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
375
|
+
// Return the formatted date string
|
|
376
|
+
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
|
|
377
|
+
};
|
|
378
|
+
export const areDifferentIDs = (fromID, userID) => {
|
|
379
|
+
if (fromID && userID) {
|
|
380
|
+
return fromID !== userID;
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
};
|
|
384
|
+
export const createTasksMenuItems = (taskDescriptor, showId, setShowId, showSearch, setShowSearch, openTaskForm, openEditTaskForm, openDuplicateTaskForm, onDeleteCallback, markAsStatus, getAllTasks, fromWG, showContextualWG, setShowContextualWG, fromDossier, showContextualDossier, setShowContextualDossier, fromDocument, showContextualDocument, setShowContextualDocument, showGoToToday, handleGoToToday, fromDatagrid = true) => {
|
|
385
|
+
const isTaskDescriptorDefined = taskDescriptor !== undefined;
|
|
386
|
+
const isTaskFromAnotherUser = isTaskDescriptorDefined && areDifferentIDs(taskDescriptor.fromID, SDK_Globals.tmSession?.SessionDescr?.userID);
|
|
387
|
+
const menuItems = [
|
|
388
|
+
{
|
|
389
|
+
id: 'createContextualTask',
|
|
390
|
+
text: SDKUI_Localizator.CreateContextualTask,
|
|
391
|
+
icon: 'plus',
|
|
392
|
+
onClick: () => { openTaskForm(FormModes.Create, undefined, true); },
|
|
393
|
+
disabled: false
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
text: SDKUI_Localizator.Create,
|
|
397
|
+
icon: 'plus',
|
|
398
|
+
onClick: () => { openTaskForm(FormModes.Create, undefined, false); },
|
|
399
|
+
disabled: false
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
text: SDKUI_Localizator.Update,
|
|
403
|
+
icon: 'edit',
|
|
404
|
+
onClick: openEditTaskForm,
|
|
405
|
+
operationType: 'singleRow',
|
|
406
|
+
disabled: fromDatagrid ? false : !isTaskDescriptorDefined
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
text: SDKUI_Localizator.Duplicate,
|
|
410
|
+
icon: 'copy',
|
|
411
|
+
onClick: openDuplicateTaskForm,
|
|
412
|
+
operationType: 'singleRow',
|
|
413
|
+
disabled: fromDatagrid ? isTaskFromAnotherUser : !isTaskDescriptorDefined || isTaskFromAnotherUser
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
text: SDKUI_Localizator.Delete,
|
|
417
|
+
icon: 'trash',
|
|
418
|
+
onClick: onDeleteCallback,
|
|
419
|
+
operationType: 'multiRow',
|
|
420
|
+
disabled: fromDatagrid ? isTaskFromAnotherUser : !isTaskDescriptorDefined || isTaskFromAnotherUser
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
icon: 'optionsgear',
|
|
424
|
+
text: SDKUI_Localizator.MarkAs,
|
|
425
|
+
id: "markAs",
|
|
426
|
+
operationType: 'multiRow',
|
|
427
|
+
disabled: fromDatagrid ? false : !isTaskDescriptorDefined,
|
|
428
|
+
items: [
|
|
429
|
+
{ icon: 'isblank', text: SDKUI_Localizator.NewFemale, operationType: 'multiRow', onClick: (rowIds) => markAsStatus(rowIds, Task_States.NotStarted) },
|
|
430
|
+
{ icon: 'refresh', text: SDKUI_Localizator.InProgress, operationType: 'multiRow', onClick: (rowIds) => markAsStatus(rowIds, Task_States.InProgress) },
|
|
431
|
+
{ icon: 'check', text: SDKUI_Localizator.Completed, operationType: 'multiRow', onClick: (rowIds) => markAsStatus(rowIds, Task_States.Completed) },
|
|
432
|
+
{ icon: 'taskstop', text: SDKUI_Localizator.Pending, operationType: 'multiRow', onClick: (rowIds) => markAsStatus(rowIds, Task_States.Waiting) },
|
|
433
|
+
{ icon: 'clock', text: SDKUI_Localizator.Postponed, operationType: 'multiRow', onClick: (rowIds) => markAsStatus(rowIds, Task_States.Deferred) }
|
|
434
|
+
]
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: 'wgContextFilter',
|
|
438
|
+
text: showContextualWG ? SDKUI_Localizator.RemoveContextualFilter : SDKUI_Localizator.ApplyContextualFilter,
|
|
439
|
+
icon: 'filter',
|
|
440
|
+
onClick: () => { setShowContextualWG(prev => !prev); },
|
|
441
|
+
disabled: false,
|
|
442
|
+
beginGroup: true,
|
|
443
|
+
visible: fromWG
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: 'dossierContextFilter',
|
|
447
|
+
text: showContextualDossier ? SDKUI_Localizator.RemoveContextualFilter : SDKUI_Localizator.ApplyContextualFilter,
|
|
448
|
+
icon: 'filter',
|
|
449
|
+
onClick: () => { setShowContextualDossier(prev => !prev); },
|
|
450
|
+
disabled: false,
|
|
451
|
+
beginGroup: !fromWG && !fromDocument,
|
|
452
|
+
visible: fromDossier
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
id: 'documentContextFilter',
|
|
456
|
+
text: showContextualDocument ? SDKUI_Localizator.RemoveContextualFilter : SDKUI_Localizator.ApplyContextualFilter,
|
|
457
|
+
icon: 'filter',
|
|
458
|
+
onClick: () => { setShowContextualDocument(prev => !prev); },
|
|
459
|
+
disabled: false,
|
|
460
|
+
beginGroup: !fromDossier && !fromWG,
|
|
461
|
+
visible: fromDocument
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
icon: "event",
|
|
465
|
+
onClick: () => { if (handleGoToToday) {
|
|
466
|
+
handleGoToToday();
|
|
467
|
+
} },
|
|
468
|
+
text: SDKUI_Localizator.GoToToday,
|
|
469
|
+
disabled: false,
|
|
470
|
+
beginGroup: true,
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
beginGroup: true,
|
|
474
|
+
icon: showSearch ? "eyeclose" : "eyeopen",
|
|
475
|
+
onClick: () => setShowSearch(prevShowSearch => !prevShowSearch),
|
|
476
|
+
text: showSearch ? SDKUI_Localizator.HideSearch : SDKUI_Localizator.ShowSearch,
|
|
477
|
+
disabled: false
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
icon: showId ? "eyeclose" : "eyeopen",
|
|
481
|
+
onClick: () => setShowId(prevShowId => !prevShowId),
|
|
482
|
+
text: showId ? SDKUI_Localizator.ID_Hide : SDKUI_Localizator.ID_Show,
|
|
483
|
+
disabled: false
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
text: SDKUI_Localizator.Refresh,
|
|
487
|
+
icon: 'refresh',
|
|
488
|
+
onClick: () => getAllTasks(),
|
|
489
|
+
disabled: false,
|
|
490
|
+
},
|
|
491
|
+
];
|
|
492
|
+
// Apply filters
|
|
493
|
+
let filteredMenuItems = [...menuItems];
|
|
494
|
+
// Show "CreateContextualTask" only if we are in a WG or Dossier context
|
|
495
|
+
if (fromWG === false && fromDossier === false && fromDocument === false) {
|
|
496
|
+
filteredMenuItems = filteredMenuItems.filter(item => item.id !== 'createContextualTask');
|
|
497
|
+
}
|
|
498
|
+
// Remove WG contextual filter menu if not in WG context
|
|
499
|
+
if (fromWG === false) {
|
|
500
|
+
filteredMenuItems = filteredMenuItems.filter(item => item.id !== 'wgContextFilter' ||
|
|
501
|
+
item.visible !== true ||
|
|
502
|
+
item.visible === undefined);
|
|
503
|
+
}
|
|
504
|
+
// Remove Dossier contextual filter menu if not in Dossier context
|
|
505
|
+
if (fromDossier === false) {
|
|
506
|
+
filteredMenuItems = filteredMenuItems.filter(item => item.id !== 'dossierContextFilter' ||
|
|
507
|
+
item.visible !== true ||
|
|
508
|
+
item.visible === undefined);
|
|
509
|
+
}
|
|
510
|
+
// Remove Document contextual filter menu if not in Document context
|
|
511
|
+
if (fromDocument === false) {
|
|
512
|
+
filteredMenuItems = filteredMenuItems.filter(item => item.id !== 'documentContextFilter' ||
|
|
513
|
+
item.visible !== true ||
|
|
514
|
+
item.visible === undefined);
|
|
515
|
+
}
|
|
516
|
+
if (showGoToToday === false) {
|
|
517
|
+
filteredMenuItems = filteredMenuItems.filter(item => item.text !== SDKUI_Localizator.GoToToday);
|
|
518
|
+
}
|
|
519
|
+
return filteredMenuItems;
|
|
520
|
+
};
|
|
521
|
+
export const checkIfNew = (fromId, isNew) => {
|
|
522
|
+
return fromId && fromId !== SDK_Globals.tmSession?.SessionDescr?.userID && isNew ? isNew === 1 : false;
|
|
523
|
+
};
|
|
524
|
+
export const getNewTaskCount = (tasks) => {
|
|
525
|
+
return tasks.filter(task => checkIfNew(task.fromID, task.isNew)).length;
|
|
526
|
+
};
|
|
527
|
+
export const isTaskAssignedToAnotherUser = (task) => {
|
|
528
|
+
const userID = SDK_Globals.tmSession?.SessionDescr?.userID;
|
|
529
|
+
return task.toID !== userID;
|
|
530
|
+
};
|
|
531
|
+
export const getMondayOfCurrentWeek = (date) => {
|
|
532
|
+
const dayOfWeek = date.getDay(); // Sunday = 0, Monday = 1, ..., Saturday = 6
|
|
533
|
+
const differenceToMonday = (dayOfWeek === 0 ? 6 : dayOfWeek - 1); // Calculate difference to previous Monday
|
|
534
|
+
date.setDate(date.getDate() - differenceToMonday); // Adjust the date to Monday
|
|
535
|
+
date.setHours(0, 0, 0, 0); // Reset the time part of the date
|
|
536
|
+
return date;
|
|
537
|
+
};
|
|
538
|
+
export const getSundayOfCurrentWeek = (date) => {
|
|
539
|
+
const result = new Date(date);
|
|
540
|
+
const dayOfWeek = result.getDay(); // Sunday = 0, Monday = 1, ..., Saturday = 6
|
|
541
|
+
const differenceToSunday = 7 - dayOfWeek; // Calculate days to next Sunday
|
|
542
|
+
result.setDate(result.getDate() + differenceToSunday); // Adjust the date to Sunday
|
|
543
|
+
result.setHours(0, 0, 0, 0); // Reset the time part of the date
|
|
544
|
+
return result;
|
|
545
|
+
};
|
|
546
|
+
export const getFirstDayOfMonth = (date) => {
|
|
547
|
+
const result = new Date(date);
|
|
548
|
+
result.setMonth(result.getMonth() - 2); // Move to the previous month
|
|
549
|
+
result.setDate(1); // Set the date to the first day of the previous month
|
|
550
|
+
result.setHours(0, 0, 0, 0); // Reset the time part to midnight
|
|
551
|
+
return result;
|
|
552
|
+
};
|
|
553
|
+
export const getLastDayOfMonth = (date) => {
|
|
554
|
+
const result = new Date(date);
|
|
555
|
+
result.setMonth(result.getMonth() + 2); // Move to the next month
|
|
556
|
+
result.setDate(0); // Set the date to the last day of the current month
|
|
557
|
+
result.setHours(0, 0, 0, 0); // Reset the time part to midnight
|
|
558
|
+
return result;
|
|
559
|
+
};
|
|
560
|
+
export const findTasksBySearch = (visualizedTasks, searchText) => {
|
|
561
|
+
const searchTextLower = searchText.toLowerCase();
|
|
562
|
+
return visualizedTasks
|
|
563
|
+
.filter(task => {
|
|
564
|
+
const stateLabel = getStatusLocalizatorValue(task.state ?? Task_States.None);
|
|
565
|
+
const priorityLabel = getPriorityLocalizatorValue(task.priority ?? Priorities.None);
|
|
566
|
+
return ((task.id && task.id.toString().toLowerCase().includes(searchTextLower)) ||
|
|
567
|
+
(task.name && task.name.toLowerCase().includes(searchTextLower)) ||
|
|
568
|
+
(task.description && task.description.toLowerCase().includes(searchTextLower)) ||
|
|
569
|
+
(stateLabel && stateLabel.toLowerCase().includes(searchTextLower)) ||
|
|
570
|
+
(task.fromName && task.fromName.toLowerCase().includes(searchTextLower)) ||
|
|
571
|
+
(task.toName && task.toName.toLowerCase().includes(searchTextLower)) ||
|
|
572
|
+
(task.priority && priorityLabel.toLowerCase().includes(searchTextLower)));
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
export var FilterCategoryId;
|
|
576
|
+
(function (FilterCategoryId) {
|
|
577
|
+
FilterCategoryId[FilterCategoryId["AllStates"] = 1] = "AllStates";
|
|
578
|
+
FilterCategoryId[FilterCategoryId["AllPriorities"] = 2] = "AllPriorities";
|
|
579
|
+
FilterCategoryId[FilterCategoryId["NewAssignedActivities"] = 1.05] = "NewAssignedActivities";
|
|
580
|
+
FilterCategoryId[FilterCategoryId["Expiring"] = 1.1] = "Expiring";
|
|
581
|
+
FilterCategoryId[FilterCategoryId["New"] = 1.2] = "New";
|
|
582
|
+
FilterCategoryId[FilterCategoryId["InProgress"] = 1.3] = "InProgress";
|
|
583
|
+
FilterCategoryId[FilterCategoryId["Completed"] = 1.4] = "Completed";
|
|
584
|
+
FilterCategoryId[FilterCategoryId["Pending"] = 1.5] = "Pending";
|
|
585
|
+
FilterCategoryId[FilterCategoryId["Postponed"] = 1.6] = "Postponed";
|
|
586
|
+
FilterCategoryId[FilterCategoryId["Low"] = 2.1] = "Low";
|
|
587
|
+
FilterCategoryId[FilterCategoryId["Normal"] = 2.2] = "Normal";
|
|
588
|
+
FilterCategoryId[FilterCategoryId["High"] = 2.3] = "High";
|
|
589
|
+
})(FilterCategoryId || (FilterCategoryId = {}));
|
|
590
|
+
export const filterTreeTask = (tasks, filtersApplied) => {
|
|
591
|
+
const filters = {
|
|
592
|
+
[FilterCategoryId.AllStates]: (task) => !task.state || (Object.values(Task_States).includes(task.state)),
|
|
593
|
+
[FilterCategoryId.AllPriorities]: (task) => !task.priority || (Object.values(Priorities).includes(task.priority)),
|
|
594
|
+
[FilterCategoryId.NewAssignedActivities]: (task) => checkIfNew(task.fromID, task.isNew),
|
|
595
|
+
[FilterCategoryId.Expiring]: (task) => task.state !== Task_States.Completed && task.endTime && taskIsExpiringSoon(task.endTime, task.remTime),
|
|
596
|
+
[FilterCategoryId.New]: (task) => task.state === undefined || task.state === Task_States.NotStarted,
|
|
597
|
+
[FilterCategoryId.InProgress]: (task) => task.state === Task_States.InProgress,
|
|
598
|
+
[FilterCategoryId.Completed]: (task) => task.state === Task_States.Completed,
|
|
599
|
+
[FilterCategoryId.Pending]: (task) => task.state === Task_States.Waiting,
|
|
600
|
+
[FilterCategoryId.Postponed]: (task) => task.state === Task_States.Deferred,
|
|
601
|
+
// Low = Low + Normal: Merged 'Low' and 'Normal' filters for backwards compatibility
|
|
602
|
+
[FilterCategoryId.Low]: (task) => task.priority === undefined || task.priority === Priorities.None || task.priority === Priorities.Low || task.priority === Priorities.Normal,
|
|
603
|
+
[FilterCategoryId.Normal]: (task) => task.priority === undefined || task.priority === Priorities.None || task.priority === Priorities.Low || task.priority === Priorities.Normal,
|
|
604
|
+
[FilterCategoryId.High]: (task) => task.priority === Priorities.High,
|
|
605
|
+
};
|
|
606
|
+
// Separate filters into levels
|
|
607
|
+
const stateFilters = filtersApplied.filter(filter => filter < 2); // Level 1: AllStates and task state-related filters
|
|
608
|
+
const priorityFilters = filtersApplied.filter(filter => filter >= 2); // Level 2: AllPriorities and task priority-related filters
|
|
609
|
+
const filteredTasks = tasks.filter((task) => {
|
|
610
|
+
// OR logic within the state filter level
|
|
611
|
+
const matchesStateFilters = stateFilters.length === 0 || stateFilters.some((filterApplied) => filters[filterApplied] && filters[filterApplied](task));
|
|
612
|
+
// OR logic within the priority filter level
|
|
613
|
+
const matchesPriorityFilters = priorityFilters.length === 0 || priorityFilters.some((filterApplied) => filters[filterApplied] && filters[filterApplied](task));
|
|
614
|
+
// AND logic between state and priority filter levels
|
|
615
|
+
return matchesStateFilters && matchesPriorityFilters;
|
|
616
|
+
});
|
|
617
|
+
return filteredTasks;
|
|
618
|
+
};
|
|
619
|
+
export const applyContextFilters = (allTasks, showContextualWG, showContextualDossier, showContextualDocument, taskContext) => {
|
|
620
|
+
if (taskContext === undefined)
|
|
621
|
+
return allTasks;
|
|
622
|
+
let filtered = allTasks;
|
|
623
|
+
if (showContextualWG && taskContext.workingGroup?.id) {
|
|
624
|
+
filtered = filtered.filter(t => t.iD1?.toString() === taskContext.workingGroup?.id.toString());
|
|
625
|
+
}
|
|
626
|
+
if (showContextualDossier && taskContext.dossier?.id) {
|
|
627
|
+
filtered = filtered.filter(t => t.iD1?.toString() === taskContext.dossier?.id.toString());
|
|
628
|
+
}
|
|
629
|
+
if (showContextualDocument && taskContext.document?.tid && taskContext?.document?.did) {
|
|
630
|
+
filtered = filtered.filter(t => t.iD1?.toString() === taskContext.document?.tid.toString() &&
|
|
631
|
+
t.iD2?.toString() === taskContext.document?.did.toString());
|
|
632
|
+
}
|
|
633
|
+
return filtered;
|
|
634
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { PdGs, Task_States, TaskDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import { FormModes } from "../../../ts";
|
|
4
|
+
export declare const taskStateIconMap: (fontSize?: number) => Map<Task_States, JSX.Element>;
|
|
5
|
+
export declare const calculateNumberOfDays: (startTime: Date | undefined, endTime: Date | undefined) => number;
|
|
6
|
+
export declare const renderTaskIcons: (taskData: {
|
|
7
|
+
stateLabel: Task_States;
|
|
8
|
+
stateTooltipLabel: string;
|
|
9
|
+
pdg: PdGs | undefined;
|
|
10
|
+
ID1Name: string;
|
|
11
|
+
endTime: Date | undefined;
|
|
12
|
+
remTime: Date | undefined;
|
|
13
|
+
isNew: boolean;
|
|
14
|
+
numberOfDays: number;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
interface TMActionCalendarProps {
|
|
17
|
+
currentTask: TaskDescriptor;
|
|
18
|
+
openTaskForm: (formMode: FormModes, task?: TaskDescriptor) => void;
|
|
19
|
+
onDeleteCallback: (rowIds: Array<number>) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const TMActionCalendar: (props: TMActionCalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const priorityLegend: () => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const highlightTaskText: (text: string, search: string, taskId: number) => string | (string | import("react/jsx-runtime").JSX.Element)[];
|
|
24
|
+
export declare const treeFilterDataSource: (allTasks: Array<TaskDescriptor>) => Array<{
|
|
25
|
+
id: number;
|
|
26
|
+
label: string;
|
|
27
|
+
value: string;
|
|
28
|
+
categoryId?: number;
|
|
29
|
+
expanded?: boolean;
|
|
30
|
+
tooltipContent?: ReactNode;
|
|
31
|
+
}>;
|
|
32
|
+
type RenderContextBlockParams = {
|
|
33
|
+
condition: boolean;
|
|
34
|
+
pdg: PdGs;
|
|
35
|
+
label: string | undefined;
|
|
36
|
+
isMobile: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare const renderContextBlock: ({ condition, pdg, label, isMobile }: RenderContextBlockParams) => JSX.Element | null;
|
|
39
|
+
export {};
|