@followupus/common 0.9.10 → 0.9.12
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/dist/shared/shared.d.ts +16 -3
- package/dist/shared/shared.js +109 -7
- package/dist/shared/types.d.ts +21 -6
- package/package.json +1 -1
package/dist/shared/shared.d.ts
CHANGED
|
@@ -32,15 +32,17 @@ export declare const OP_TYPES: {
|
|
|
32
32
|
NOT_EQUAL: string;
|
|
33
33
|
LESS_EQUAL: string;
|
|
34
34
|
LESS: string;
|
|
35
|
+
BEFORE: string;
|
|
36
|
+
AFTER: string;
|
|
35
37
|
};
|
|
36
38
|
export declare const COLUMN_OP_TYPES: {
|
|
37
|
-
[x: string]: string[];
|
|
39
|
+
readonly [x: string]: readonly [string, string, string, string, string, string] | readonly [string, string, string, string] | readonly [string, string, string, string, string, string, string, string];
|
|
38
40
|
};
|
|
39
41
|
export declare const AUTOMATION_OP_TYPES: {
|
|
40
|
-
[x: string]: string[];
|
|
42
|
+
[x: string]: string[] | readonly [string, string, string, string, string, string] | readonly [string, string, string, string] | readonly [string, string, string, string, string, string, string, string];
|
|
41
43
|
};
|
|
42
44
|
export declare const DYNAMIC_VIEW_OP_TYPES: {
|
|
43
|
-
[x: string]: string[];
|
|
45
|
+
[x: string]: string[] | readonly [string, string, string, string, string, string] | readonly [string, string, string, string] | readonly [string, string, string, string, string, string, string, string];
|
|
44
46
|
};
|
|
45
47
|
export declare const THEMSELVES = "self";
|
|
46
48
|
export declare const DATE_GROUPS: {
|
|
@@ -52,9 +54,20 @@ export declare const DATE_GROUPS: {
|
|
|
52
54
|
THIS_MONTH: string;
|
|
53
55
|
FUTURE: string;
|
|
54
56
|
};
|
|
57
|
+
export declare const FILTER_DATE_GROUPS: {
|
|
58
|
+
TODAY: string;
|
|
59
|
+
THIS_WEEK: string;
|
|
60
|
+
THIS_MONTH: string;
|
|
61
|
+
};
|
|
62
|
+
export declare const DATE_VALUE_FORMAT = "YYYY-MM-DD";
|
|
63
|
+
export declare enum SpecialKeyInDateFilter {
|
|
64
|
+
SelectDate = "selectDate",
|
|
65
|
+
SelectRange = "selectRange"
|
|
66
|
+
}
|
|
55
67
|
export declare const isLinkedColumns: (columnType?: string) => boolean;
|
|
56
68
|
export declare const getColumnTypeFromId: (columnId: string) => string | undefined;
|
|
57
69
|
export declare const getColumnValueType: (columnType: string) => "string" | "number" | "object" | "stringArray" | "objectArray";
|
|
70
|
+
export declare const getFilterDateGroupKeys: (dateStr: string) => string[] | null;
|
|
58
71
|
export declare const getDateGroupKey: (dateStr: string) => string | null;
|
|
59
72
|
export declare const getValidConditions: (filter: IFilter, headers?: IBaseCustomColumn[], currentUserId?: string, escapeHeaderCheck?: boolean) => IFilterCondition[];
|
|
60
73
|
export declare const filterItemsByConditions: (groups: IBaseGroup[], filter: IFilter, headers?: IBaseCustomColumn[], currentUserId?: string) => IBaseGroup[];
|
package/dist/shared/shared.js
CHANGED
|
@@ -33,6 +33,8 @@ export const OP_TYPES = {
|
|
|
33
33
|
NOT_EQUAL: "neq",
|
|
34
34
|
LESS_EQUAL: "lte",
|
|
35
35
|
LESS: "lt",
|
|
36
|
+
BEFORE: "before",
|
|
37
|
+
AFTER: "after",
|
|
36
38
|
};
|
|
37
39
|
export const COLUMN_OP_TYPES = {
|
|
38
40
|
[COLUMN_TYPES.TEXT]: [
|
|
@@ -46,8 +48,8 @@ export const COLUMN_OP_TYPES = {
|
|
|
46
48
|
[COLUMN_TYPES.DATE]: [
|
|
47
49
|
OP_TYPES.IS,
|
|
48
50
|
OP_TYPES.IS_NOT,
|
|
49
|
-
OP_TYPES.
|
|
50
|
-
OP_TYPES.
|
|
51
|
+
OP_TYPES.BEFORE,
|
|
52
|
+
OP_TYPES.AFTER,
|
|
51
53
|
],
|
|
52
54
|
[COLUMN_TYPES.NUMBER]: [
|
|
53
55
|
OP_TYPES.EQUAL,
|
|
@@ -123,6 +125,17 @@ export const DATE_GROUPS = {
|
|
|
123
125
|
THIS_MONTH: "thisMonth",
|
|
124
126
|
FUTURE: "future",
|
|
125
127
|
};
|
|
128
|
+
export const FILTER_DATE_GROUPS = {
|
|
129
|
+
TODAY: "today",
|
|
130
|
+
THIS_WEEK: "thisWeek",
|
|
131
|
+
THIS_MONTH: "thisMonth",
|
|
132
|
+
};
|
|
133
|
+
export const DATE_VALUE_FORMAT = "YYYY-MM-DD";
|
|
134
|
+
export var SpecialKeyInDateFilter;
|
|
135
|
+
(function (SpecialKeyInDateFilter) {
|
|
136
|
+
SpecialKeyInDateFilter["SelectDate"] = "selectDate";
|
|
137
|
+
SpecialKeyInDateFilter["SelectRange"] = "selectRange";
|
|
138
|
+
})(SpecialKeyInDateFilter || (SpecialKeyInDateFilter = {}));
|
|
126
139
|
export const isLinkedColumns = (columnType) => {
|
|
127
140
|
if (!columnType)
|
|
128
141
|
return false;
|
|
@@ -151,6 +164,36 @@ export const getColumnValueType = (columnType) => {
|
|
|
151
164
|
return "string";
|
|
152
165
|
}
|
|
153
166
|
};
|
|
167
|
+
export const getFilterDateGroupKeys = (dateStr) => {
|
|
168
|
+
const keys = [];
|
|
169
|
+
if (!dateStr)
|
|
170
|
+
return null;
|
|
171
|
+
const current = dayjs();
|
|
172
|
+
const day = dayjs(dateStr);
|
|
173
|
+
if (current.isSame(day, "date")) {
|
|
174
|
+
keys.push(FILTER_DATE_GROUPS.TODAY);
|
|
175
|
+
keys.push(FILTER_DATE_GROUPS.THIS_WEEK);
|
|
176
|
+
keys.push(FILTER_DATE_GROUPS.THIS_MONTH);
|
|
177
|
+
return keys;
|
|
178
|
+
}
|
|
179
|
+
const startDayOfThisWeek = current.set("day", 0);
|
|
180
|
+
const endDayOfThisWeek = current.set("day", 6);
|
|
181
|
+
const startDayOfThisMonth = current.set("date", 1);
|
|
182
|
+
const endDayOfThisMonth = current.set("date", current.daysInMonth());
|
|
183
|
+
if ((day.isAfter(startDayOfThisWeek, "date") ||
|
|
184
|
+
day.isSame(startDayOfThisWeek, "date")) &&
|
|
185
|
+
(day.isBefore(endDayOfThisWeek, "date") ||
|
|
186
|
+
day.isSame(endDayOfThisWeek, "date"))) {
|
|
187
|
+
keys.push(FILTER_DATE_GROUPS.THIS_WEEK);
|
|
188
|
+
}
|
|
189
|
+
if ((day.isAfter(startDayOfThisMonth, "date") ||
|
|
190
|
+
day.isSame(startDayOfThisMonth, "date")) &&
|
|
191
|
+
(day.isBefore(endDayOfThisMonth, "date") ||
|
|
192
|
+
day.isSame(endDayOfThisMonth, "date"))) {
|
|
193
|
+
keys.push(FILTER_DATE_GROUPS.THIS_MONTH);
|
|
194
|
+
}
|
|
195
|
+
return keys;
|
|
196
|
+
};
|
|
154
197
|
export const getDateGroupKey = (dateStr) => {
|
|
155
198
|
if (!dateStr)
|
|
156
199
|
return null;
|
|
@@ -205,6 +248,9 @@ export const getValidConditions = (filter, headers, currentUserId, escapeHeaderC
|
|
|
205
248
|
c.value.splice(idx, 1, currentUserId);
|
|
206
249
|
}
|
|
207
250
|
}
|
|
251
|
+
if (checkHeader?.type === COLUMN_TYPES.DATE) {
|
|
252
|
+
_.remove(c.value, v => Object.values(SpecialKeyInDateFilter).includes(v));
|
|
253
|
+
}
|
|
208
254
|
});
|
|
209
255
|
// for dropdown, if set the option is in filter condition, and user delete the option. should ignore it or make the option can't be deleted
|
|
210
256
|
return newFilter.criteria.filter(c => {
|
|
@@ -229,6 +275,7 @@ export const getValidConditions = (filter, headers, currentUserId, escapeHeaderC
|
|
|
229
275
|
COLUMN_TYPES.PRIORITY,
|
|
230
276
|
COLUMN_TYPES.TAGS,
|
|
231
277
|
].includes(columnType);
|
|
278
|
+
const isDate = columnType === COLUMN_TYPES.DATE;
|
|
232
279
|
switch (c.op) {
|
|
233
280
|
case OP_TYPES.IS:
|
|
234
281
|
case OP_TYPES.IS_NOT:
|
|
@@ -250,6 +297,10 @@ export const getValidConditions = (filter, headers, currentUserId, escapeHeaderC
|
|
|
250
297
|
case OP_TYPES.LESS:
|
|
251
298
|
case OP_TYPES.LESS_EQUAL:
|
|
252
299
|
return !!c.value?.length;
|
|
300
|
+
case OP_TYPES.BEFORE:
|
|
301
|
+
case OP_TYPES.AFTER:
|
|
302
|
+
return (isDate &&
|
|
303
|
+
!!c.value?.filter(v => v === FILTER_DATE_GROUPS.TODAY || dayjs(v).isValid())?.length);
|
|
253
304
|
default:
|
|
254
305
|
return false;
|
|
255
306
|
}
|
|
@@ -277,12 +328,57 @@ const isInConditionValues = (itemVal, valueType, condition) => {
|
|
|
277
328
|
return false;
|
|
278
329
|
};
|
|
279
330
|
const isDateInConditionValues = (itemVal, condition) => {
|
|
280
|
-
if (
|
|
281
|
-
return true;
|
|
282
|
-
const groupKey = getDateGroupKey(itemVal);
|
|
283
|
-
if (!groupKey)
|
|
331
|
+
if (!itemVal || !dayjs(itemVal).isValid()) {
|
|
284
332
|
return !!condition.blank;
|
|
285
|
-
|
|
333
|
+
}
|
|
334
|
+
const itemDate = dayjs(itemVal);
|
|
335
|
+
return !!condition.value?.some(c => {
|
|
336
|
+
if (c && typeof c === "object") {
|
|
337
|
+
// range
|
|
338
|
+
const startDt = dayjs(c.start);
|
|
339
|
+
const endDt = dayjs(c.end);
|
|
340
|
+
return (startDt.isValid() &&
|
|
341
|
+
endDt.isValid() &&
|
|
342
|
+
(itemDate.isAfter(startDt, "date") ||
|
|
343
|
+
itemDate.isSame(startDt, "date")) &&
|
|
344
|
+
(itemDate.isBefore(endDt, "date") || itemDate.isSame(endDt, "date")));
|
|
345
|
+
}
|
|
346
|
+
else if (dayjs(c).isValid()) {
|
|
347
|
+
return itemDate.isSame(dayjs(c), "date");
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
const groupKeys = getFilterDateGroupKeys(itemVal);
|
|
351
|
+
return !!groupKeys?.includes(c);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
// if (!groupKey) return !!condition.blank;
|
|
355
|
+
// return !!condition.value?.find((dateGroup) => dateGroup === groupKey);
|
|
356
|
+
};
|
|
357
|
+
const isDateBeforeConditionValues = (itemVal, condition) => {
|
|
358
|
+
if (!itemVal || !dayjs(itemVal).isValid())
|
|
359
|
+
return false;
|
|
360
|
+
const itemDate = dayjs(itemVal);
|
|
361
|
+
return !!condition.value?.some(c => {
|
|
362
|
+
if (dayjs(c).isValid()) {
|
|
363
|
+
return itemDate.isBefore(dayjs(c));
|
|
364
|
+
}
|
|
365
|
+
else if (c === FILTER_DATE_GROUPS.TODAY) {
|
|
366
|
+
return itemDate.isBefore(dayjs(), "date");
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
const isDateAfterConditionValues = (itemVal, condition) => {
|
|
371
|
+
if (!itemVal || !dayjs(itemVal).isValid())
|
|
372
|
+
return false;
|
|
373
|
+
const itemDate = dayjs(itemVal);
|
|
374
|
+
return !!condition.value?.some(c => {
|
|
375
|
+
if (dayjs(c).isValid()) {
|
|
376
|
+
return itemDate.isAfter(dayjs(c));
|
|
377
|
+
}
|
|
378
|
+
else if (c === FILTER_DATE_GROUPS.TODAY) {
|
|
379
|
+
return itemDate.isAfter(dayjs(), "date");
|
|
380
|
+
}
|
|
381
|
+
});
|
|
286
382
|
};
|
|
287
383
|
const isEmpty = (itemVal, valueType) => {
|
|
288
384
|
switch (valueType) {
|
|
@@ -404,6 +500,12 @@ const checkItemMatched = (item, validConditions, headers) => {
|
|
|
404
500
|
? !isDateInConditionValues(itemVal, condition)
|
|
405
501
|
: !isInConditionValues(itemVal, valueType, condition);
|
|
406
502
|
break;
|
|
503
|
+
case OP_TYPES.BEFORE: // only for date type
|
|
504
|
+
match = isDate && isDateBeforeConditionValues(itemVal, condition);
|
|
505
|
+
break;
|
|
506
|
+
case OP_TYPES.AFTER:
|
|
507
|
+
match = isDate && isDateAfterConditionValues(itemVal, condition);
|
|
508
|
+
break;
|
|
407
509
|
case OP_TYPES.EMPTY:
|
|
408
510
|
match = isEmpty(itemVal, valueType);
|
|
409
511
|
break;
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface IBaseUser {
|
|
|
4
4
|
email: string;
|
|
5
5
|
firstname: string;
|
|
6
6
|
lastname: string;
|
|
7
|
+
displayName: string;
|
|
7
8
|
}
|
|
8
9
|
export interface ILinkedSource {
|
|
9
10
|
boardId: string;
|
|
@@ -15,8 +16,12 @@ export interface ILinkedSource {
|
|
|
15
16
|
dropdowns?: {
|
|
16
17
|
key: string;
|
|
17
18
|
value: string;
|
|
19
|
+
attr?: {
|
|
20
|
+
color?: string;
|
|
21
|
+
};
|
|
18
22
|
}[];
|
|
19
23
|
setting?: IColumnSetting;
|
|
24
|
+
linkedGroup?: string;
|
|
20
25
|
}
|
|
21
26
|
export interface IBaseItem {
|
|
22
27
|
itemId: string;
|
|
@@ -31,16 +36,20 @@ export interface IBaseItem {
|
|
|
31
36
|
export interface IColumnSetting {
|
|
32
37
|
currency?: string;
|
|
33
38
|
}
|
|
39
|
+
export interface IDropdownOption {
|
|
40
|
+
key: string;
|
|
41
|
+
value?: string;
|
|
42
|
+
index?: number;
|
|
43
|
+
attr?: {
|
|
44
|
+
color?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
34
47
|
export interface IBaseCustomColumn {
|
|
35
48
|
columnId: string;
|
|
36
49
|
type: string;
|
|
37
50
|
name: string;
|
|
38
51
|
description?: string;
|
|
39
|
-
dropdowns?:
|
|
40
|
-
key: string;
|
|
41
|
-
value: string;
|
|
42
|
-
}[];
|
|
43
|
-
linkedGroup?: string;
|
|
52
|
+
dropdowns?: IDropdownOption[];
|
|
44
53
|
linked?: ILinkedSource;
|
|
45
54
|
index?: number;
|
|
46
55
|
deleted?: boolean;
|
|
@@ -51,10 +60,12 @@ export interface IBaseGroup {
|
|
|
51
60
|
description?: string;
|
|
52
61
|
items?: IBaseItem[];
|
|
53
62
|
deleted?: boolean;
|
|
63
|
+
index?: number;
|
|
54
64
|
}
|
|
55
65
|
export interface IBaseBoard {
|
|
56
66
|
name: string;
|
|
57
67
|
boardId: string;
|
|
68
|
+
viewId?: string;
|
|
58
69
|
type?: "board";
|
|
59
70
|
folderId?: string;
|
|
60
71
|
policyId?: string;
|
|
@@ -78,7 +89,7 @@ export interface IFilterCondition {
|
|
|
78
89
|
conditionId?: string;
|
|
79
90
|
columnId: string;
|
|
80
91
|
op: string;
|
|
81
|
-
value:
|
|
92
|
+
value: any[];
|
|
82
93
|
blank?: boolean;
|
|
83
94
|
}
|
|
84
95
|
export interface IFilter {
|
|
@@ -94,3 +105,7 @@ export interface IDynamicView {
|
|
|
94
105
|
allowComment?: boolean;
|
|
95
106
|
step: "itemsSetting" | "customizeView" | "itemDetail" | "customizeForm" | "shareSetting";
|
|
96
107
|
}
|
|
108
|
+
export interface ActionEvent {
|
|
109
|
+
actionBy: "user" | "ai";
|
|
110
|
+
actionId?: string;
|
|
111
|
+
}
|