@gudhub/core 1.1.26 → 1.1.27
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.js +7 -2
- package/GUDHUB/GHConstructor/ghconstructor.js +14 -19
- package/GUDHUB/GHConstructor/interpritate.js +19 -16
- package/GUDHUB/Storage/Storage.js +5 -1
- package/GUDHUB/gudhub.js +2 -2
- package/package.json +1 -1
- package/umd/library.min.js +8 -8
- package/umd/library.min.js.map +1 -1
|
@@ -89,8 +89,13 @@ export class FieldProcessor {
|
|
|
89
89
|
|
|
90
90
|
async getField(app_id, field_id) {
|
|
91
91
|
const app = await this.appProcessor.getApp(app_id);
|
|
92
|
-
if(!app) return null
|
|
93
|
-
|
|
92
|
+
if(!app) return null;
|
|
93
|
+
for(let i = 0; i < app.field_list.length; i++) {
|
|
94
|
+
if(app.field_list[i].field_id == field_id) {
|
|
95
|
+
return app.field_list[i];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
//!!!!! Shou Be Renamed to getFields() !!!!!!!
|
|
@@ -4,7 +4,7 @@ import createClassInstance from './createClassInstance.js';
|
|
|
4
4
|
export class GHConstructor {
|
|
5
5
|
constructor(gudhub) {
|
|
6
6
|
this.gudhub = gudhub;
|
|
7
|
-
this.cache =
|
|
7
|
+
this.cache = {};
|
|
8
8
|
this.modulesQueue = {};
|
|
9
9
|
this.angularInjector;
|
|
10
10
|
this.nodeWindow;
|
|
@@ -16,34 +16,29 @@ export class GHConstructor {
|
|
|
16
16
|
// If yes, return module from cache.
|
|
17
17
|
|
|
18
18
|
async getInstance(module_id) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
resolve(this.getCached(module_id));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
19
|
+
if(this.getCached(module_id)) {
|
|
20
|
+
return this.getCached(module_id);
|
|
21
|
+
} else if (this.modulesQueue[module_id]) {
|
|
22
|
+
await this.modulesQueue[module_id];
|
|
23
|
+
} else {
|
|
24
|
+
this.modulesQueue[module_id] = this.createInstance(module_id);
|
|
25
|
+
await this.modulesQueue[module_id];
|
|
26
|
+
}
|
|
27
|
+
return this.getCached(module_id);
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
/*************** PUT TO CACHE ***************/
|
|
36
31
|
// Just pushing module to cache.
|
|
37
32
|
|
|
38
|
-
pupToCache(module) {
|
|
39
|
-
this.cache
|
|
33
|
+
pupToCache(module_id, module) {
|
|
34
|
+
this.cache[module_id] = module;
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
/*************** GET CACHED ***************/
|
|
43
38
|
// Find module in cache and return it.
|
|
44
39
|
|
|
45
40
|
getCached(module_id) {
|
|
46
|
-
return this.cache
|
|
41
|
+
return this.cache[module_id];
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
/*************** INIT ANGULAR INJECTOR ***************/
|
|
@@ -83,7 +78,7 @@ export class GHConstructor {
|
|
|
83
78
|
}
|
|
84
79
|
|
|
85
80
|
if(result) {
|
|
86
|
-
this.pupToCache(result);
|
|
81
|
+
this.pupToCache(module_id, result);
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
return result;
|
|
@@ -72,22 +72,25 @@ export class Interpritate {
|
|
|
72
72
|
|
|
73
73
|
/********************* GET INTERPRETATION BY ID *********************/
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
// We add ability to pass value as argument, to reduce number of operations in this case (getFieldValue)
|
|
76
|
+
// This helps if you call method many times, for example in calculator sum and you already have field value
|
|
77
|
+
// By default, value is null, to not break old code working with this method
|
|
78
|
+
|
|
79
|
+
// For field same as above for value
|
|
80
|
+
async getInterpretationById(appId, itemId, fieldId, interpretationId, value = null, field = null) {
|
|
81
|
+
let fieldValue = value == null ? await this.gudhub.getFieldValue(appId, itemId, fieldId) : value;
|
|
82
|
+
let fieldModel = field == null ? await this.gudhub.getField(appId, fieldId) : field;
|
|
83
|
+
if(fieldModel == null) {
|
|
84
|
+
resolve('');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const instance = await this.gudhub.ghconstructor.getInstance(fieldModel.data_type);
|
|
88
|
+
const interpretatedValue = await instance.getInterpretation(fieldValue, interpretationId, fieldModel.data_type, fieldModel, itemId, appId);
|
|
89
|
+
if(interpretatedValue.html == '<span>no interpretation</span>') {
|
|
90
|
+
return fieldValue;
|
|
91
|
+
} else {
|
|
92
|
+
return interpretatedValue.html;
|
|
93
|
+
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
}
|
|
@@ -61,7 +61,11 @@ export class Storage {
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
getApp(app_id) {
|
|
64
|
-
|
|
64
|
+
for(let i = 0; i < this.apps_list.length; i++) {
|
|
65
|
+
if(this.apps_list[i].app_id == app_id) {
|
|
66
|
+
return this.apps_list[i];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
unsetApps() {
|
package/GUDHUB/gudhub.js
CHANGED
|
@@ -166,8 +166,8 @@ export class GudHub {
|
|
|
166
166
|
|
|
167
167
|
/******************* GET INTERPRETATION BY ID *******************/
|
|
168
168
|
|
|
169
|
-
getInterpretationById(appId, itemId, fieldId, interpretationId) {
|
|
170
|
-
return this.interpritate.getInterpretationById(appId, itemId, fieldId, interpretationId);
|
|
169
|
+
getInterpretationById(appId, itemId, fieldId, interpretationId, value, field) {
|
|
170
|
+
return this.interpritate.getInterpretationById(appId, itemId, fieldId, interpretationId, value, field);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
//============ FILTER ==========//
|