@followupus/common 0.8.6 → 0.8.7
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 +2 -1
- package/dist/shared/shared.js +18 -10
- package/package.json +1 -1
package/dist/shared/shared.d.ts
CHANGED
|
@@ -53,8 +53,9 @@ export declare const DATE_GROUPS: {
|
|
|
53
53
|
FUTURE: string;
|
|
54
54
|
};
|
|
55
55
|
export declare const isLinkedColumns: (columnType?: string) => boolean;
|
|
56
|
+
export declare const getColumnTypeFromId: (columnId: string) => string | undefined;
|
|
56
57
|
export declare const getColumnValueType: (columnType: string) => "string" | "number" | "object" | "stringArray" | "objectArray";
|
|
57
58
|
export declare const getDateGroupKey: (dateStr: string) => string | null;
|
|
58
|
-
export declare const getValidConditions: (filter: IFilter, headers?: IBaseCustomColumn[], currentUserId?: string) => IFilterCondition[];
|
|
59
|
+
export declare const getValidConditions: (filter: IFilter, headers?: IBaseCustomColumn[], currentUserId?: string, escapeHeaderCheck?: boolean) => IFilterCondition[];
|
|
59
60
|
export declare const filterItemsByConditions: (groups: IBaseGroup[], filter: IFilter, headers?: IBaseCustomColumn[], currentUserId?: string) => IBaseGroup[];
|
|
60
61
|
export declare const filterBoardTree: (board: IPureBoard, filter: IFilter, currentUserId?: string) => IPureBoard;
|
package/dist/shared/shared.js
CHANGED
|
@@ -121,6 +121,9 @@ export const isLinkedColumns = (columnType) => {
|
|
|
121
121
|
return false;
|
|
122
122
|
return [COLUMN_TYPES.LINKED_COLUMN, COLUMN_TYPES.REF_LINED_COLUMN].includes(columnType);
|
|
123
123
|
};
|
|
124
|
+
export const getColumnTypeFromId = (columnId) => {
|
|
125
|
+
return Object.values(COLUMN_TYPES).find(type => columnId.startsWith(type));
|
|
126
|
+
};
|
|
124
127
|
export const getColumnValueType = (columnType) => {
|
|
125
128
|
switch (columnType) {
|
|
126
129
|
case COLUMN_TYPES.PEOPLE:
|
|
@@ -174,7 +177,7 @@ export const getDateGroupKey = (dateStr) => {
|
|
|
174
177
|
}
|
|
175
178
|
return DATE_GROUPS.FUTURE;
|
|
176
179
|
};
|
|
177
|
-
export const getValidConditions = (filter, headers, currentUserId) => {
|
|
180
|
+
export const getValidConditions = (filter, headers, currentUserId, escapeHeaderCheck) => {
|
|
178
181
|
const newFilter = _.cloneDeep(filter);
|
|
179
182
|
if (!newFilter.criteria?.length || !headers?.length) {
|
|
180
183
|
return [];
|
|
@@ -185,9 +188,10 @@ export const getValidConditions = (filter, headers, currentUserId) => {
|
|
|
185
188
|
if (isLinkedColumns(validHeader?.type)) {
|
|
186
189
|
checkHeader = validHeader?.linked;
|
|
187
190
|
}
|
|
188
|
-
if (!checkHeader)
|
|
191
|
+
if (!checkHeader && !escapeHeaderCheck)
|
|
189
192
|
return;
|
|
190
|
-
if (checkHeader?.type === COLUMN_TYPES.PEOPLE
|
|
193
|
+
if (checkHeader?.type === COLUMN_TYPES.PEOPLE ||
|
|
194
|
+
c.columnId?.startsWith(COLUMN_TYPES.PEOPLE)) {
|
|
191
195
|
if (c.value?.find(val => val === THEMSELVES) && currentUserId) {
|
|
192
196
|
const idx = c.value.findIndex(val => val === THEMSELVES);
|
|
193
197
|
if (idx > -1)
|
|
@@ -198,15 +202,18 @@ export const getValidConditions = (filter, headers, currentUserId) => {
|
|
|
198
202
|
// 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
|
|
199
203
|
return newFilter.criteria.filter(c => {
|
|
200
204
|
const validHeader = headers.find(h => h.columnId === c.columnId);
|
|
201
|
-
if (!validHeader)
|
|
205
|
+
if (!validHeader && !escapeHeaderCheck)
|
|
202
206
|
return false;
|
|
203
207
|
let checkHeader = validHeader;
|
|
204
|
-
if (isLinkedColumns(validHeader
|
|
205
|
-
checkHeader = validHeader
|
|
208
|
+
if (isLinkedColumns(validHeader?.type)) {
|
|
209
|
+
checkHeader = validHeader?.linked;
|
|
206
210
|
}
|
|
207
|
-
if (!checkHeader)
|
|
211
|
+
if (!checkHeader && !escapeHeaderCheck)
|
|
212
|
+
return false;
|
|
213
|
+
const columnType = checkHeader?.type || getColumnTypeFromId(c.columnId);
|
|
214
|
+
if (!columnType)
|
|
208
215
|
return false;
|
|
209
|
-
const validOperate = COLUMN_OP_TYPES[
|
|
216
|
+
const validOperate = COLUMN_OP_TYPES[columnType]?.includes(c.op);
|
|
210
217
|
if (!validOperate)
|
|
211
218
|
return false;
|
|
212
219
|
const isDropdown = [
|
|
@@ -214,14 +221,15 @@ export const getValidConditions = (filter, headers, currentUserId) => {
|
|
|
214
221
|
COLUMN_TYPES.STATUS,
|
|
215
222
|
COLUMN_TYPES.PRIORITY,
|
|
216
223
|
COLUMN_TYPES.TAGS,
|
|
217
|
-
].includes(
|
|
224
|
+
].includes(columnType);
|
|
218
225
|
switch (c.op) {
|
|
219
226
|
case OP_TYPES.IS:
|
|
220
227
|
case OP_TYPES.IS_NOT:
|
|
221
228
|
return (c.blank ||
|
|
222
229
|
(!!c.value?.filter(v => !!v || v === 0)?.length &&
|
|
223
230
|
(!isDropdown ||
|
|
224
|
-
|
|
231
|
+
escapeHeaderCheck ||
|
|
232
|
+
c.value.some(v => checkHeader?.dropdowns?.find(d => d.key === v)))));
|
|
225
233
|
case OP_TYPES.EMPTY:
|
|
226
234
|
case OP_TYPES.NOT_EMPTY:
|
|
227
235
|
return true;
|