@outliant/sunrise-utils 1.1.3 → 1.1.5
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/.eslintrc +1 -0
- package/CHANGELOG.md +16 -0
- package/constants.js +18 -0
- package/helpers/projectFilter/index.js +8 -0
- package/helpers/projectFilter/onHoldFilter.js +2 -2
- package/helpers/projectFilter/projectFieldFilter.js +0 -1
- package/helpers/projectFilter/projectFilter.js +77 -13
- package/helpers/sortScript.js +4 -2
- package/helpers/taskFilter/index.js +8 -0
- package/helpers/taskFilter/taskFieldFilter.js +36 -12
- package/lib/fieldConditions.js +18 -0
- package/package.json +1 -1
- package/test/helpers/projectFilter/projectFieldFilter.spec.js +36 -5
- package/test/lib/taskPipeline.spec.js +1 -1
package/.eslintrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [1.1.5](https://github.com/outliant/sunrise-utils/compare/1.1.4...1.1.5)
|
|
8
|
+
|
|
9
|
+
- Task/project banner #866a3c0ug [`#9`](https://github.com/outliant/sunrise-utils/pull/9)
|
|
10
|
+
- chore: filter checkbox [`fb8d601`](https://github.com/outliant/sunrise-utils/commit/fb8d6015b1ee2092fc69b64d10b0a26b59958574)
|
|
11
|
+
- chore: update spec [`bcbfd9a`](https://github.com/outliant/sunrise-utils/commit/bcbfd9ad5a21b412c160a85b05d63a43771bc084)
|
|
12
|
+
- chore: add checkbox filter [`dba4385`](https://github.com/outliant/sunrise-utils/commit/dba43855f8d9665325f5ba2dbec17f50abb3bb0b)
|
|
13
|
+
|
|
14
|
+
#### [1.1.4](https://github.com/outliant/sunrise-utils/compare/1.1.3...1.1.4)
|
|
15
|
+
|
|
16
|
+
> 8 May 2023
|
|
17
|
+
|
|
18
|
+
- chore: support user field type project fields #860qfghzp [`7f4688b`](https://github.com/outliant/sunrise-utils/commit/7f4688b270fe8734153613650c87eef28483068a)
|
|
19
|
+
- chore(release): 1.1.4 [`e3a9285`](https://github.com/outliant/sunrise-utils/commit/e3a9285af6da87760a8c1487542d2473bd3ee2ac)
|
|
20
|
+
|
|
7
21
|
#### [1.1.3](https://github.com/outliant/sunrise-utils/compare/1.1.2...1.1.3)
|
|
8
22
|
|
|
23
|
+
> 28 April 2023
|
|
24
|
+
|
|
9
25
|
- Task/project filter #860qjddeg [`#8`](https://github.com/outliant/sunrise-utils/pull/8)
|
|
10
26
|
- wip: project filter [`0dec4e1`](https://github.com/outliant/sunrise-utils/commit/0dec4e1830bab4470c0b2d23bdfd8cbafe8fc6a7)
|
|
11
27
|
- chore: fix specs [`4d0474c`](https://github.com/outliant/sunrise-utils/commit/4d0474c74bb6a545b66a821cf63376b323393e58)
|
package/constants.js
ADDED
|
@@ -5,6 +5,7 @@ const buildIsGeneratedFilter = require('./isGeneratedFilter');
|
|
|
5
5
|
const buildTagFilter = require('./tagFilter');
|
|
6
6
|
const buildProjectFieldFilter = require('./projectFieldFilter');
|
|
7
7
|
const buildProjectFilter = require('./projectFilter');
|
|
8
|
+
const { PROJECT_BANNERS } = require('../../constants');
|
|
8
9
|
|
|
9
10
|
module.exports.defaultCustomColumns = [
|
|
10
11
|
{
|
|
@@ -72,6 +73,13 @@ module.exports.defaultCustomColumns = [
|
|
|
72
73
|
value: 'updated_at',
|
|
73
74
|
type: 'updated_at',
|
|
74
75
|
field_type: 'date'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Notable',
|
|
79
|
+
value: 'banner',
|
|
80
|
+
type: 'banner',
|
|
81
|
+
field_type: 'checkbox',
|
|
82
|
+
options: PROJECT_BANNERS
|
|
75
83
|
}
|
|
76
84
|
];
|
|
77
85
|
|
|
@@ -9,7 +9,7 @@ module.exports = (filter) => {
|
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
module.exports.isEqual = (
|
|
12
|
+
module.exports.isEqual = () => {
|
|
13
13
|
return {
|
|
14
14
|
match: {
|
|
15
15
|
on_hold: true
|
|
@@ -17,7 +17,7 @@ module.exports.isEqual = (filter) => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
module.exports.isNotEqual = (
|
|
20
|
+
module.exports.isNotEqual = () => {
|
|
21
21
|
return {
|
|
22
22
|
bool: {
|
|
23
23
|
should: [
|
|
@@ -35,13 +35,24 @@ module.exports.isEmpty = (filter) => {
|
|
|
35
35
|
|
|
36
36
|
return {
|
|
37
37
|
bool: {
|
|
38
|
-
|
|
38
|
+
should: [
|
|
39
39
|
{
|
|
40
40
|
term: {
|
|
41
41
|
[filter.type]: {
|
|
42
42
|
value: ''
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
bool: {
|
|
48
|
+
must_not: [
|
|
49
|
+
{
|
|
50
|
+
exists: {
|
|
51
|
+
field: filter.type
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
]
|
|
47
58
|
}
|
|
@@ -63,6 +74,13 @@ module.exports.isNotEmpty = (filter) => {
|
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
}
|
|
77
|
+
],
|
|
78
|
+
must: [
|
|
79
|
+
{
|
|
80
|
+
exists: {
|
|
81
|
+
field: filter.type
|
|
82
|
+
}
|
|
83
|
+
}
|
|
66
84
|
]
|
|
67
85
|
}
|
|
68
86
|
};
|
|
@@ -108,21 +126,34 @@ module.exports.isEqual = (filter) => {
|
|
|
108
126
|
}
|
|
109
127
|
|
|
110
128
|
if (filter.field_type === 'checkbox') {
|
|
111
|
-
const value =
|
|
112
|
-
|
|
129
|
+
const value = typeof filter.value === 'string'
|
|
130
|
+
? filter.value.split(';')
|
|
131
|
+
: filter.value;
|
|
132
|
+
|
|
133
|
+
const should = [];
|
|
134
|
+
|
|
135
|
+
value.forEach((x) => {
|
|
136
|
+
should.push({
|
|
137
|
+
match: {
|
|
138
|
+
[`${filter.type}.analyzed`]: {
|
|
139
|
+
query: x,
|
|
140
|
+
operator: 'and'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
should.push({
|
|
146
|
+
term: {
|
|
147
|
+
[filter.type]: {
|
|
148
|
+
value: x
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
113
153
|
|
|
114
154
|
return {
|
|
115
155
|
bool: {
|
|
116
|
-
should
|
|
117
|
-
return {
|
|
118
|
-
match: {
|
|
119
|
-
[`${filter.type}.analyzed`]: {
|
|
120
|
-
query: x,
|
|
121
|
-
operator: 'and'
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
})
|
|
156
|
+
should
|
|
126
157
|
}
|
|
127
158
|
};
|
|
128
159
|
}
|
|
@@ -350,6 +381,39 @@ module.exports.isNotEqual = (filter) => {
|
|
|
350
381
|
};
|
|
351
382
|
}
|
|
352
383
|
|
|
384
|
+
if (filter.field_type === 'checkbox') {
|
|
385
|
+
const value = typeof filter.value === 'string'
|
|
386
|
+
? filter.value.split(';')
|
|
387
|
+
: filter.value;
|
|
388
|
+
|
|
389
|
+
const should = [];
|
|
390
|
+
|
|
391
|
+
value.forEach((x) => {
|
|
392
|
+
should.push({
|
|
393
|
+
match: {
|
|
394
|
+
[`${filter.type}.analyzed`]: {
|
|
395
|
+
query: x,
|
|
396
|
+
operator: 'and'
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
should.push({
|
|
402
|
+
term: {
|
|
403
|
+
[filter.type]: {
|
|
404
|
+
value: x
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
bool: {
|
|
412
|
+
should
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
353
417
|
return {
|
|
354
418
|
term: {
|
|
355
419
|
[filter.type]: {
|
package/helpers/sortScript.js
CHANGED
|
@@ -335,10 +335,12 @@ module.exports.projectFieldText = (order, value) => {
|
|
|
335
335
|
if (fields[i].number != null) {
|
|
336
336
|
return '';
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
textInfo = fields[i].text == null ? '' : fields[i].text;
|
|
340
|
+
if (fields[i].containsKey('computedText')) {
|
|
341
|
+
textInfo = fields[i].computedText == null ? textInfo : fields[i].computedText;
|
|
342
|
+
}
|
|
340
343
|
}
|
|
341
|
-
|
|
342
344
|
}
|
|
343
345
|
|
|
344
346
|
return textInfo;
|
|
@@ -7,6 +7,7 @@ const buildCriticalPathFilter = require('./criticalPathFilter');
|
|
|
7
7
|
const buildOnHoldFilter = require('./onHoldFilter');
|
|
8
8
|
const buildAgeColorFilter = require('./buildAgeColorFilter');
|
|
9
9
|
const buildProjectFieldFilter = require('../projectFilter/projectFieldFilter');
|
|
10
|
+
const { PROJECT_BANNERS } = require('../../constants');
|
|
10
11
|
|
|
11
12
|
module.exports.taskStatusOptions = [
|
|
12
13
|
{
|
|
@@ -177,6 +178,13 @@ module.exports.defaultCustomColumns = [
|
|
|
177
178
|
value: 'marked_incomplete_at',
|
|
178
179
|
type: 'marked_incomplete_at',
|
|
179
180
|
field_type: 'date'
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'Notable',
|
|
184
|
+
value: 'project_banner',
|
|
185
|
+
type: 'project_banner',
|
|
186
|
+
field_type: 'checkbox',
|
|
187
|
+
options: PROJECT_BANNERS
|
|
180
188
|
}
|
|
181
189
|
];
|
|
182
190
|
|
|
@@ -227,7 +227,9 @@ module.exports.isEqual = (filter) => {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (filter.field_type === 'textarea') {
|
|
231
233
|
return {
|
|
232
234
|
query_string: {
|
|
233
235
|
fields: [filter.type],
|
|
@@ -236,6 +238,39 @@ module.exports.isEqual = (filter) => {
|
|
|
236
238
|
};
|
|
237
239
|
}
|
|
238
240
|
|
|
241
|
+
if (filter.field_type === 'checkbox') {
|
|
242
|
+
const value = typeof filter.value === 'string'
|
|
243
|
+
? filter.value.split(';')
|
|
244
|
+
: filter.value;
|
|
245
|
+
|
|
246
|
+
const should = [];
|
|
247
|
+
|
|
248
|
+
value.forEach((x) => {
|
|
249
|
+
should.push({
|
|
250
|
+
match: {
|
|
251
|
+
[`${filter.type}.analyzed`]: {
|
|
252
|
+
query: x,
|
|
253
|
+
operator: 'and'
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
should.push({
|
|
259
|
+
term: {
|
|
260
|
+
[filter.type]: {
|
|
261
|
+
value: x
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
bool: {
|
|
269
|
+
should
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
239
274
|
return {
|
|
240
275
|
bool: {
|
|
241
276
|
must: [
|
|
@@ -328,17 +363,6 @@ module.exports.lastNDays = (filter) => {
|
|
|
328
363
|
.subtract(filter.value, 'd')
|
|
329
364
|
.endOf('day');
|
|
330
365
|
|
|
331
|
-
const info = {
|
|
332
|
-
today: {
|
|
333
|
-
format: today.format('YYYY-MM-DD'),
|
|
334
|
-
value: today.valueOf()
|
|
335
|
-
},
|
|
336
|
-
lastNDays: {
|
|
337
|
-
format: lastNDays.format('YYYY-MM-DD'),
|
|
338
|
-
value: lastNDays.valueOf()
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
366
|
return {
|
|
343
367
|
range: {
|
|
344
368
|
[filter.type]: {
|
package/lib/fieldConditions.js
CHANGED
|
@@ -174,6 +174,24 @@ module.exports.conditions = {
|
|
|
174
174
|
label: 'In The Last N Days',
|
|
175
175
|
value: 'last_n_days'
|
|
176
176
|
}
|
|
177
|
+
],
|
|
178
|
+
user_select: [
|
|
179
|
+
{
|
|
180
|
+
label: 'Equals',
|
|
181
|
+
value: 'is_equal'
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: "Doesn't Equal",
|
|
185
|
+
value: 'not_equal'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
label: 'Is Empty',
|
|
189
|
+
value: 'is_empty'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
label: 'Is Not Empty',
|
|
193
|
+
value: 'is_not_empty'
|
|
194
|
+
}
|
|
177
195
|
]
|
|
178
196
|
};
|
|
179
197
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
/* eslint-env node, mocha */
|
|
4
4
|
const { expect } = require('chai');
|
|
5
5
|
|
|
6
|
+
const moment = require('moment');
|
|
7
|
+
|
|
6
8
|
// To test
|
|
7
9
|
const projectFieldFilter = require('../../../helpers/projectFilter/projectFieldFilter');
|
|
8
10
|
const projectFilter = require('../../../helpers/projectFilter/projectFilter');
|
|
@@ -1016,8 +1018,13 @@ describe('projectFilter/projectFilter', () => {
|
|
|
1016
1018
|
{
|
|
1017
1019
|
range: {
|
|
1018
1020
|
created_at: {
|
|
1019
|
-
gt:
|
|
1020
|
-
|
|
1021
|
+
gt: moment()
|
|
1022
|
+
.startOf('day')
|
|
1023
|
+
.valueOf(),
|
|
1024
|
+
lt: moment()
|
|
1025
|
+
.add(5, 'd')
|
|
1026
|
+
.endOf('day')
|
|
1027
|
+
.valueOf()
|
|
1021
1028
|
}
|
|
1022
1029
|
}
|
|
1023
1030
|
}
|
|
@@ -1040,8 +1047,13 @@ describe('projectFilter/projectFilter', () => {
|
|
|
1040
1047
|
{
|
|
1041
1048
|
range: {
|
|
1042
1049
|
created_at: {
|
|
1043
|
-
lt:
|
|
1044
|
-
|
|
1050
|
+
lt: moment()
|
|
1051
|
+
.startOf('day')
|
|
1052
|
+
.valueOf(),
|
|
1053
|
+
gt: moment()
|
|
1054
|
+
.subtract(3, 'd')
|
|
1055
|
+
.endOf('day')
|
|
1056
|
+
.valueOf()
|
|
1045
1057
|
}
|
|
1046
1058
|
}
|
|
1047
1059
|
}
|
|
@@ -1060,13 +1072,24 @@ describe('projectFilter/projectFilter', () => {
|
|
|
1060
1072
|
},
|
|
1061
1073
|
output: {
|
|
1062
1074
|
bool: {
|
|
1063
|
-
|
|
1075
|
+
should: [
|
|
1064
1076
|
{
|
|
1065
1077
|
term: {
|
|
1066
1078
|
created_at: {
|
|
1067
1079
|
value: ""
|
|
1068
1080
|
}
|
|
1069
1081
|
}
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
bool: {
|
|
1085
|
+
must_not: [
|
|
1086
|
+
{
|
|
1087
|
+
exists: {
|
|
1088
|
+
field: "created_at"
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
]
|
|
1092
|
+
}
|
|
1070
1093
|
}
|
|
1071
1094
|
]
|
|
1072
1095
|
}
|
|
@@ -1091,6 +1114,13 @@ describe('projectFilter/projectFilter', () => {
|
|
|
1091
1114
|
}
|
|
1092
1115
|
}
|
|
1093
1116
|
}
|
|
1117
|
+
],
|
|
1118
|
+
must: [
|
|
1119
|
+
{
|
|
1120
|
+
exists: {
|
|
1121
|
+
field: "created_at"
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1094
1124
|
]
|
|
1095
1125
|
}
|
|
1096
1126
|
}
|
|
@@ -1101,6 +1131,7 @@ describe('projectFilter/projectFilter', () => {
|
|
|
1101
1131
|
it(`${filter.input.condition}: ${JSON.stringify(
|
|
1102
1132
|
filter.input.value
|
|
1103
1133
|
)}`, (done) => {
|
|
1134
|
+
|
|
1104
1135
|
const observed = projectFilter(filter.input);
|
|
1105
1136
|
|
|
1106
1137
|
expect(observed).to.deep.equal(filter.output);
|
|
@@ -367,7 +367,7 @@ describe('taskPipeline', function () {
|
|
|
367
367
|
script: {
|
|
368
368
|
lang: 'painless',
|
|
369
369
|
source:
|
|
370
|
-
"\n try {\n String textInfo = '';\n def fields = params._source.fields;\n\n for (int i=0; i<fields.size(); i++) {\n if (fields[i].id.equals(params.value)) {\n\n if (fields[i].number != null) {\n return '';\n }\n
|
|
370
|
+
"\n try {\n String textInfo = '';\n def fields = params._source.fields;\n\n for (int i=0; i<fields.size(); i++) {\n if (fields[i].id.equals(params.value)) {\n\n if (fields[i].number != null) {\n return '';\n }\n\n textInfo = fields[i].text == null ? '' : fields[i].text;\n if (fields[i].containsKey('computedText')) {\n textInfo = fields[i].computedText == null ? textInfo : fields[i].computedText;\n }\n }\n }\n\n return textInfo;\n } catch (Exception err) {\n return '';\n }\n ",
|
|
371
371
|
params: { value: '38d423bf-fc24-4183-b8b7-15420c89e318' }
|
|
372
372
|
},
|
|
373
373
|
order: 'desc'
|