@gudhub/core 1.1.70 → 1.1.72
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/GUDHUB/FieldProcessor/FieldProcessor.test.js +3 -3
- package/GUDHUB/ItemProcessor/ItemProcessor.test.js +12 -12
- package/GUDHUB/Storage/ModulesList.js +3 -3
- package/GUDHUB/Utils/Utils.js +12 -11
- package/GUDHUB/Utils/filter/filter.js +66 -23
- package/GUDHUB/Utils/filter/filter.test.js +83 -0
- package/GUDHUB/Utils/filter/filterPreparation.js +27 -18
- package/GUDHUB/Utils/filter/mergeFilters.js +32 -0
- package/GUDHUB/Utils/json_constructor/json_constructor.js +29 -5
- package/GUDHUB/gudhub-https-service.js +16 -4
- package/GUDHUB/gudhub.js +6 -4
- package/package.json +1 -1
- package/umd/library.min.js +53 -49
- package/umd/library.min.js.map +1 -1
|
@@ -29,12 +29,12 @@ describe("FIELD PROCESSOR", async function() {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
it('CREATE ITEM AND SET IT VALUE / should return new value of new item', async () => {
|
|
32
|
-
let items = await gudhub.addNewItems(
|
|
32
|
+
let items = await gudhub.addNewItems(214, newItems);
|
|
33
33
|
let item_id = items[0].item_id;
|
|
34
34
|
|
|
35
|
-
await gudhub.setFieldValue(
|
|
35
|
+
await gudhub.setFieldValue(214, item_id, 254056, 'Big Fish Tank');
|
|
36
36
|
|
|
37
|
-
let value = await gudhub.getFieldValue(
|
|
37
|
+
let value = await gudhub.getFieldValue(214, item_id, 254056);
|
|
38
38
|
|
|
39
39
|
value.should.equal('Big Fish Tank');
|
|
40
40
|
});
|
|
@@ -7,52 +7,52 @@ describe("ITEM PROCESSOR", async function () {
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
it("GET ITEM / should return an item", async () => {
|
|
10
|
-
let item = await gudhub.getItem(
|
|
11
|
-
item.item_id.should.equal(
|
|
10
|
+
let item = await gudhub.getItem(214, 1175);
|
|
11
|
+
item.item_id.should.equal(1175)
|
|
12
12
|
let itemType = typeof item;
|
|
13
13
|
itemType.should.equal('object');
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it("ADD ITEM AND GET IT / should return new item twice", async () => {
|
|
17
|
-
let items = await gudhub.addNewItems(
|
|
17
|
+
let items = await gudhub.addNewItems(214, newItems);
|
|
18
18
|
|
|
19
19
|
let isItemsArray = Array.isArray(items);
|
|
20
20
|
|
|
21
21
|
isItemsArray.should.equal(true);
|
|
22
22
|
items[0].fields[0].field_value.should.equal('Big Fish Tank');
|
|
23
23
|
|
|
24
|
-
let item = await gudhub.getItem(
|
|
24
|
+
let item = await gudhub.getItem(214, items[0].item_id);
|
|
25
25
|
|
|
26
26
|
item.fields[0].field_value.should.equal('Big Fish Tank');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it("ADD NEW ITEM AND GET ITS VALUE / should return new item's value", async () => {
|
|
30
|
-
let items = await gudhub.addNewItems(
|
|
30
|
+
let items = await gudhub.addNewItems(214, newItems);
|
|
31
31
|
let item_id = items[0].item_id;
|
|
32
32
|
|
|
33
|
-
let value = await gudhub.getFieldValue(
|
|
33
|
+
let value = await gudhub.getFieldValue(214, item_id, 254056);
|
|
34
34
|
|
|
35
35
|
value.should.equal('Big Fish Tank');
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it("ADD NEW ITEM, UPDATE ITS VALUE AND GET IT / should return updated value of new item", async () => {
|
|
39
|
-
let items = await gudhub.addNewItems(
|
|
39
|
+
let items = await gudhub.addNewItems(214, newItems);
|
|
40
40
|
let item_id = items[0].item_id;
|
|
41
41
|
|
|
42
|
-
await gudhub.setFieldValue(
|
|
42
|
+
await gudhub.setFieldValue(214, item_id, 254056, 'Updated value');
|
|
43
43
|
|
|
44
|
-
let value = await gudhub.getFieldValue(
|
|
44
|
+
let value = await gudhub.getFieldValue(214, item_id, 254056);
|
|
45
45
|
|
|
46
46
|
value.should.equal('Updated value');
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it("ADD NEW ITEM, THEN DELETE IT / should return null", async () => {
|
|
50
|
-
let items = await gudhub.addNewItems(
|
|
50
|
+
let items = await gudhub.addNewItems(214, newItems);
|
|
51
51
|
let item_id = items[0].item_id;
|
|
52
52
|
|
|
53
|
-
await gudhub.deleteItems(
|
|
53
|
+
await gudhub.deleteItems(214, [item_id]);
|
|
54
54
|
|
|
55
|
-
let value = await gudhub.getFieldValue(
|
|
55
|
+
let value = await gudhub.getFieldValue(214, item_id, 254056);
|
|
56
56
|
|
|
57
57
|
let isValueNull = value === null ? true : false;
|
|
58
58
|
|
|
@@ -911,10 +911,10 @@ export default function generateModulesList(async_modules_path, file_server_url,
|
|
|
911
911
|
},
|
|
912
912
|
{
|
|
913
913
|
data_type: 'static_nested_list',
|
|
914
|
-
name: '
|
|
914
|
+
name: 'Nested Filter',
|
|
915
915
|
icon: 'scheduling',
|
|
916
|
-
js: 'https://gudhub.com/modules/nested-filter/dist/main.js',
|
|
917
|
-
css: 'https://gudhub.com/modules/nested-filter/dist/style.css',
|
|
916
|
+
js: 'https://gudhub.com/modules/nested-filter/dist/main.js?t=1',
|
|
917
|
+
css: 'https://gudhub.com/modules/nested-filter/dist/style.css?t=1',
|
|
918
918
|
type: 'gh_element',
|
|
919
919
|
technology: 'class'
|
|
920
920
|
},
|
package/GUDHUB/Utils/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { filterPreparation } from "./filter/filterPreparation.js";
|
|
2
2
|
import filter from "./filter/filter.js";
|
|
3
|
+
import { mergeFilters } from "./filter/mergeFilters.js";
|
|
3
4
|
import { jsonToItems } from "./json_to_items/json_to_items.js";
|
|
4
5
|
import {
|
|
5
6
|
mergeItems,
|
|
@@ -32,12 +33,9 @@ export class Utils {
|
|
|
32
33
|
this.FileHelper = new FileHelper(gudhub);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
prefilter(filters_list,
|
|
36
|
+
prefilter(filters_list, variables = {}) {
|
|
36
37
|
return filterPreparation(
|
|
37
38
|
filters_list,
|
|
38
|
-
element_app_id,
|
|
39
|
-
app_id,
|
|
40
|
-
item_id,
|
|
41
39
|
this.gudhub.storage,
|
|
42
40
|
this.gudhub.pipeService,
|
|
43
41
|
variables
|
|
@@ -48,6 +46,10 @@ export class Utils {
|
|
|
48
46
|
return filter(items, filter_list);
|
|
49
47
|
}
|
|
50
48
|
|
|
49
|
+
mergeFilters(src, dest) {
|
|
50
|
+
return mergeFilters(src, dest);
|
|
51
|
+
}
|
|
52
|
+
|
|
51
53
|
group(fieldGroup, items) {
|
|
52
54
|
return group(fieldGroup, items);
|
|
53
55
|
}
|
|
@@ -64,14 +66,13 @@ export class Utils {
|
|
|
64
66
|
) {
|
|
65
67
|
const modified_filters_list = await this.prefilter(
|
|
66
68
|
filters_list,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
{
|
|
70
|
+
element_app_id,
|
|
71
|
+
app_id,
|
|
72
|
+
item_id
|
|
73
|
+
}
|
|
70
74
|
);
|
|
71
|
-
const itemsList = this.filter(items,
|
|
72
|
-
...filters_list,
|
|
73
|
-
...modified_filters_list,
|
|
74
|
-
]);
|
|
75
|
+
const itemsList = this.filter(items, modified_filters_list);
|
|
75
76
|
const newItems = this.group(field_group, itemsList);
|
|
76
77
|
return newItems
|
|
77
78
|
.filter((newItem) => {
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import { getDate, getDistanceFromLatLonInKm, isSimilarStrings } from "./utils.js";
|
|
2
2
|
|
|
3
3
|
export default function (items, filters) {
|
|
4
|
-
const
|
|
5
|
-
const filterChecker = new Checker();
|
|
4
|
+
const itemsFilter = new ItemsFilter();
|
|
6
5
|
|
|
7
6
|
if (!items || !items.length) {
|
|
8
7
|
return [];
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
return
|
|
12
|
-
return filters
|
|
13
|
-
.filter(function (filter) {
|
|
14
|
-
return filter.valuesArray.length;
|
|
15
|
-
})
|
|
16
|
-
.every(function (filter) {
|
|
17
|
-
var currField = item.fields.find(function (itemField) {
|
|
18
|
-
return filter.field_id == itemField.field_id;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
filterAggregate
|
|
22
|
-
.setStrategy(filter.search_type)
|
|
23
|
-
.setEntity(
|
|
24
|
-
currField && currField.field_value != undefined
|
|
25
|
-
? currField.field_value
|
|
26
|
-
: null
|
|
27
|
-
)
|
|
28
|
-
.setFilterValues(filter.valuesArray);
|
|
29
|
-
return filterChecker.check(filterAggregate);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
10
|
+
return itemsFilter.filter(filters, items);
|
|
32
11
|
}
|
|
33
12
|
|
|
34
13
|
class Checker {
|
|
@@ -326,3 +305,67 @@ class Aggregate {
|
|
|
326
305
|
return this._checkOption;
|
|
327
306
|
}
|
|
328
307
|
}
|
|
308
|
+
|
|
309
|
+
class ItemsFilter {
|
|
310
|
+
constructor() {
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
filter(filters, items) {
|
|
315
|
+
|
|
316
|
+
const filteredItems = [];
|
|
317
|
+
const activeFilters = filters.filter(function (filter) {
|
|
318
|
+
return filter.valuesArray.length;
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
for(let item of items) {
|
|
322
|
+
let result = true;
|
|
323
|
+
|
|
324
|
+
for(let i = 0; i < activeFilters.length; i++) {
|
|
325
|
+
const filter = activeFilters[i];
|
|
326
|
+
|
|
327
|
+
const currField = item.fields.find(function (itemField) {
|
|
328
|
+
return filter.field_id == itemField.field_id;
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const filterAggregate = new Aggregate();
|
|
332
|
+
const filterChecker = new Checker();
|
|
333
|
+
|
|
334
|
+
filterAggregate
|
|
335
|
+
.setStrategy(filter.search_type)
|
|
336
|
+
.setEntity(
|
|
337
|
+
currField && currField.field_value != undefined
|
|
338
|
+
? currField.field_value
|
|
339
|
+
: null
|
|
340
|
+
)
|
|
341
|
+
.setFilterValues(filter.valuesArray);
|
|
342
|
+
|
|
343
|
+
switch(filter.boolean_strategy) {
|
|
344
|
+
case 'and':
|
|
345
|
+
result = result && filterChecker.check(filterAggregate);
|
|
346
|
+
break;
|
|
347
|
+
|
|
348
|
+
case 'or':
|
|
349
|
+
result = result || filterChecker.check(filterAggregate);
|
|
350
|
+
break;
|
|
351
|
+
|
|
352
|
+
default:
|
|
353
|
+
result = result && filterChecker.check(filterAggregate);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if(result) {
|
|
359
|
+
filteredItems.push(item);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if(filteredItems.length || filters.length && !filteredItems.length) {
|
|
364
|
+
return filteredItems;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
return items;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import should from 'should';
|
|
2
2
|
import {GudHub} from './../../gudhub.js';
|
|
3
3
|
|
|
4
|
+
import { app_8263 } from '../../../fake_server/fake_server_data/app_8263.js';
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
describe('Filter', function() {
|
|
@@ -9,6 +11,87 @@ import {GudHub} from './../../gudhub.js';
|
|
|
9
11
|
it('Should return one Item', function(){
|
|
10
12
|
gudhub.filter(items, filters).length.should.equal(1);
|
|
11
13
|
});
|
|
14
|
+
|
|
15
|
+
it('FILTER AND / should return items matching first AND second filter', function() {
|
|
16
|
+
const filters = [
|
|
17
|
+
{
|
|
18
|
+
"field_id": 96606,
|
|
19
|
+
"data_type": "text",
|
|
20
|
+
"valuesArray": [
|
|
21
|
+
"Dothan"
|
|
22
|
+
],
|
|
23
|
+
"search_type": "contain_or",
|
|
24
|
+
"boolean_strategy": "and",
|
|
25
|
+
"selected_search_option_variable": "Value"
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
"field_id": 96608,
|
|
30
|
+
"data_type": "phone",
|
|
31
|
+
"valuesArray": [
|
|
32
|
+
"677"
|
|
33
|
+
],
|
|
34
|
+
"search_type": "contain_or",
|
|
35
|
+
"boolean_strategy": "and",
|
|
36
|
+
"selected_search_option_variable": "Value"
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const filteredItems = gudhub.filter(app_8263.items_list, filters);
|
|
41
|
+
filteredItems.length.should.equal(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('FILTER OR / should return items matching first OR second filter', function() {
|
|
45
|
+
const filters = [
|
|
46
|
+
{
|
|
47
|
+
"field_id": 96606,
|
|
48
|
+
"data_type": "text",
|
|
49
|
+
"valuesArray": [
|
|
50
|
+
"Distributors"
|
|
51
|
+
],
|
|
52
|
+
"search_type": "contain_or",
|
|
53
|
+
"boolean_strategy": "and",
|
|
54
|
+
"selected_search_option_variable": "Value"
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
"field_id": 96608,
|
|
59
|
+
"data_type": "phone",
|
|
60
|
+
"valuesArray": [
|
|
61
|
+
"353"
|
|
62
|
+
],
|
|
63
|
+
"search_type": "contain_or",
|
|
64
|
+
"boolean_strategy": "or",
|
|
65
|
+
"selected_search_option_variable": "Value"
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const filteredItems = gudhub.filter(app_8263.items_list, filters);
|
|
70
|
+
filteredItems.length.should.equal(8);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('PREFILTER WITH VARIABLES / should return variables values instead of names', async () => {
|
|
74
|
+
const filters = [
|
|
75
|
+
{
|
|
76
|
+
"field_id": 96606,
|
|
77
|
+
"data_type": "text",
|
|
78
|
+
"input_type": "variable",
|
|
79
|
+
"input_value": "current_app,boolean",
|
|
80
|
+
"search_type": "contain_or"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
const variables = {
|
|
85
|
+
current_app_id: 1,
|
|
86
|
+
boolean: true
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const filter = await gudhub.prefilter(filters, variables);
|
|
90
|
+
|
|
91
|
+
filter[0].valuesArray[0].should.equal(1);
|
|
92
|
+
filter[0].valuesArray[1].should.equal(true);
|
|
93
|
+
|
|
94
|
+
});
|
|
12
95
|
|
|
13
96
|
});
|
|
14
97
|
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
export async function filterPreparation(
|
|
2
2
|
filters_list,
|
|
3
|
-
element_app_id,
|
|
4
|
-
current_app_id,
|
|
5
|
-
item_id,
|
|
6
3
|
storage,
|
|
7
4
|
pipeService,
|
|
8
|
-
variables =
|
|
5
|
+
variables = {}
|
|
9
6
|
) {
|
|
10
7
|
const filterArray = [];
|
|
11
8
|
|
|
12
9
|
const objectMethod = {
|
|
13
10
|
variableMethodcurrent_app() {
|
|
14
|
-
return [current_app_id];
|
|
11
|
+
return [variables.current_app_id];
|
|
15
12
|
},
|
|
16
13
|
variableMethodelement_app() {
|
|
17
|
-
return [element_app_id];
|
|
14
|
+
return [variables.element_app_id];
|
|
18
15
|
},
|
|
19
16
|
|
|
20
17
|
variableMethodcurrent_item() {
|
|
21
|
-
const currentValue = `${current_app_id}.${item_id}`;
|
|
18
|
+
const currentValue = `${variables.current_app_id || variables.app_id}.${variables.item_id}`;
|
|
22
19
|
return [currentValue];
|
|
23
20
|
},
|
|
24
21
|
|
|
@@ -48,29 +45,41 @@ export async function filterPreparation(
|
|
|
48
45
|
start_date.valueOf().toString() + ":" + end_date.valueOf().toString();
|
|
49
46
|
return [result];
|
|
50
47
|
},
|
|
51
|
-
variableMethodvariable() {
|
|
52
|
-
return variables;
|
|
48
|
+
variableMethodvariable(property) {
|
|
49
|
+
return [variables[property]];
|
|
53
50
|
},
|
|
54
51
|
};
|
|
55
52
|
if (filters_list) {
|
|
56
53
|
for (const filter of filters_list) {
|
|
57
54
|
if (filter) {
|
|
55
|
+
// ---------------------- WARNING !!! -------------------------------
|
|
56
|
+
// Should be fixed: modification of filters_list valuesArray
|
|
58
57
|
switch (filter.input_type) {
|
|
59
58
|
case "variable":
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
for(const filterValue of filter?.input_value.split(',')) {
|
|
60
|
+
const functionName =
|
|
61
|
+
filter.input_type + "Method" + filterValue;
|
|
62
|
+
const func = objectMethod[functionName];
|
|
63
|
+
if (typeof func === "function") {
|
|
64
|
+
if(!filter.valuesArray) {
|
|
65
|
+
filter.valuesArray = func();
|
|
66
|
+
} else {
|
|
67
|
+
filter.valuesArray.push(...func());
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
if(!filter.valuesArray) {
|
|
71
|
+
filter.valuesArray = objectMethod.variableMethodvariable(filterValue);
|
|
72
|
+
} else {
|
|
73
|
+
filter.valuesArray.push(...objectMethod.variableMethodvariable(filterValue));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
filterArray.push(filter);
|
|
69
78
|
break;
|
|
70
79
|
case "field":
|
|
71
80
|
const field_value = await fieldMethod({
|
|
72
|
-
app_id: current_app_id,
|
|
73
|
-
item_id: item_id,
|
|
81
|
+
app_id: variables.current_app_id,
|
|
82
|
+
item_id: variables.item_id,
|
|
74
83
|
field_id: filter.input_value,
|
|
75
84
|
});
|
|
76
85
|
if(field_value != null){
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function mergeFilters(srcFilters, destFilters) {
|
|
2
|
+
const mergedFieldIds = [];
|
|
3
|
+
let filters = [];
|
|
4
|
+
|
|
5
|
+
if(srcFilters.length > 0) {
|
|
6
|
+
srcFilters.forEach(filter => {
|
|
7
|
+
filters.push(filter);
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
filters = destFilters;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if(filters.length > 0) {
|
|
14
|
+
|
|
15
|
+
filters.forEach((filter, index) => {
|
|
16
|
+
for(let i = 0; i < destFilters.length; i++) {
|
|
17
|
+
if(filter.field_id == destFilters[i].field_id) {
|
|
18
|
+
mergedFieldIds.push(filter.field_id);
|
|
19
|
+
filters[index] = gudhub.mergeObjects(destFilters[i], filter);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
for(let k = 0; k < destFilters.length; k++) {
|
|
25
|
+
if(!mergedFieldIds.includes(destFilters[k].field_id)) {
|
|
26
|
+
filters.push(destFilters[k]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
return filters;
|
|
32
|
+
}
|
|
@@ -68,6 +68,28 @@ export function compiler(scheme, item, util, variables, appId) {
|
|
|
68
68
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
if(scheme.offset) {
|
|
72
|
+
let offset;
|
|
73
|
+
if(scheme.use_variables_for_limit_and_offset && variables) {
|
|
74
|
+
offset = variables[scheme.offset];
|
|
75
|
+
} else {
|
|
76
|
+
offset = /^[0-9]+$/.test(scheme.offset) ? scheme.offset : 0;
|
|
77
|
+
}
|
|
78
|
+
filteredItems = filteredItems.slice(offset);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(scheme.limit) {
|
|
82
|
+
let limit;
|
|
83
|
+
if(scheme.use_variables_for_limit_and_offset && variables) {
|
|
84
|
+
limit = variables[scheme.limit];
|
|
85
|
+
} else {
|
|
86
|
+
limit = /^[0-9]+$/.test(scheme.limit) || 0;
|
|
87
|
+
}
|
|
88
|
+
if(limit !== 0) {
|
|
89
|
+
filteredItems = filteredItems.slice(0, limit);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
71
93
|
const arrayOfItemsWithProperties = filteredItems.map(async (item) => {
|
|
72
94
|
return getChildsPropertiesObject(scheme.childs, item, app.app_id);
|
|
73
95
|
});
|
|
@@ -140,10 +162,12 @@ export function compiler(scheme, item, util, variables, appId) {
|
|
|
140
162
|
async function getFilteredItems(filtersList, element_app_id, app_id, item_id, itemsList) {
|
|
141
163
|
const modified_filters_list = await util.gudhub.prefilter(
|
|
142
164
|
JSON.parse(JSON.stringify(filtersList)),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
165
|
+
{
|
|
166
|
+
element_app_id,
|
|
167
|
+
app_id,
|
|
168
|
+
item_id,
|
|
169
|
+
...variables
|
|
170
|
+
}
|
|
147
171
|
);
|
|
148
172
|
return util.gudhub.filter(itemsList, [...modified_filters_list, ...filtersList]);
|
|
149
173
|
}
|
|
@@ -164,5 +188,5 @@ export function compiler(scheme, item, util, variables, appId) {
|
|
|
164
188
|
) : [...itemsList ];
|
|
165
189
|
}
|
|
166
190
|
|
|
167
|
-
return schemeCompiler(scheme, item, appId);
|
|
191
|
+
return schemeCompiler(scheme, item, appId, variables);
|
|
168
192
|
}
|
|
@@ -39,13 +39,19 @@ export class GudHubHttpsService {
|
|
|
39
39
|
/\?/.test(url) ? "&" : "?"
|
|
40
40
|
}token=${accessToken}${convertObjToUrlParams(request.params)}`;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
axios.get(url, {
|
|
43
|
+
validateStatus: function (status) {
|
|
44
|
+
return status < 400; // Resolve only if the status code is less than 400
|
|
45
|
+
}
|
|
46
|
+
}).then(function (response) {
|
|
47
|
+
if(response.status != 200) {
|
|
48
|
+
console.error(`GUDHUB HTTP SERVICE: GET ERROR: ${response.status}`, response);
|
|
49
|
+
}
|
|
44
50
|
// handle success
|
|
45
51
|
resolve(response.data);
|
|
46
52
|
})
|
|
47
53
|
.catch(function (err) {
|
|
48
|
-
console.
|
|
54
|
+
console.error(`GUDHUB HTTP SERVICE: GET ERROR: ${err.response.status}\n`, err);
|
|
49
55
|
console.log("Request message: ", request);
|
|
50
56
|
if(err.response && err.response.data) {
|
|
51
57
|
console.log('Error response data: ', err.response.data);
|
|
@@ -79,12 +85,18 @@ export class GudHubHttpsService {
|
|
|
79
85
|
headers: request.headers || {
|
|
80
86
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
81
87
|
},
|
|
88
|
+
validateStatus: function (status) {
|
|
89
|
+
return status < 400; // Resolve only if the status code is less than 400
|
|
90
|
+
}
|
|
82
91
|
}
|
|
83
92
|
).then(function (response) {
|
|
93
|
+
if(response.status != 200) {
|
|
94
|
+
console.error(`GUDHUB HTTP SERVICE: POST ERROR: ${response.status}`, response);
|
|
95
|
+
}
|
|
84
96
|
// handle success
|
|
85
97
|
resolve(response.data);
|
|
86
98
|
}).catch(function (error) {
|
|
87
|
-
console.
|
|
99
|
+
console.error(`GUDHUB HTTP SERVICE: POST ERROR: ${error.response.status}\n`, error);
|
|
88
100
|
console.log("Request message: ", request);
|
|
89
101
|
reject(error);
|
|
90
102
|
});
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -141,12 +141,9 @@ export class GudHub {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
//************************* FILTERATION ****************************//
|
|
144
|
-
prefilter(filters_list,
|
|
144
|
+
prefilter(filters_list, variables) {
|
|
145
145
|
return this.util.prefilter(
|
|
146
146
|
filters_list,
|
|
147
|
-
element_app_id,
|
|
148
|
-
app_id,
|
|
149
|
-
item_id,
|
|
150
147
|
variables
|
|
151
148
|
);
|
|
152
149
|
}
|
|
@@ -176,6 +173,11 @@ export class GudHub {
|
|
|
176
173
|
return this.util.filter(items, filter_list);
|
|
177
174
|
}
|
|
178
175
|
|
|
176
|
+
//============ MERGE FILTERS ==========//
|
|
177
|
+
mergeFilters(source, destination) {
|
|
178
|
+
return this.util.mergeFilters(source, destination);
|
|
179
|
+
}
|
|
180
|
+
|
|
179
181
|
//============ GROUP ==========//
|
|
180
182
|
group(fieldGroup, items) {
|
|
181
183
|
return this.util.group(fieldGroup, items);
|