@gudhub/core 1.0.63 → 1.0.64
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/GHConstructor/createAngularModuleInstance.js +212 -0
- package/GUDHUB/GHConstructor/createClassInstance.js +148 -0
- package/GUDHUB/GHConstructor/ghconstructor.js +11 -193
- package/GUDHUB/Storage/ModulesList.js +213 -104
- package/GUDHUB/Storage/Storage.js +1 -1
- package/package.json +1 -1
- package/umd/library.min.js +8 -4
- package/umd/library.min.js.map +1 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
/*************** FAKE ANGULAR $Q ***************/
|
|
4
|
+
// It's needed when we eval() angular code.
|
|
5
|
+
|
|
6
|
+
let $q = {
|
|
7
|
+
when: function (a) {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
resolve(a);
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*************** FAKE ANGULAR ***************/
|
|
15
|
+
// It's needed when we eval() angular code.
|
|
16
|
+
|
|
17
|
+
let factoryReturns = {};
|
|
18
|
+
|
|
19
|
+
let angular = {
|
|
20
|
+
module() {
|
|
21
|
+
return angular;
|
|
22
|
+
},
|
|
23
|
+
directive() {
|
|
24
|
+
return angular;
|
|
25
|
+
},
|
|
26
|
+
factory(name, args) {
|
|
27
|
+
try {
|
|
28
|
+
if (typeof args === 'object') {
|
|
29
|
+
factoryReturns[name] = args[args.length - 1]($q);
|
|
30
|
+
} else {
|
|
31
|
+
factoryReturns[name] = args($q);
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.log('Errror in data type: ', name);
|
|
35
|
+
console.log(error);
|
|
36
|
+
}
|
|
37
|
+
return angular;
|
|
38
|
+
},
|
|
39
|
+
service() {
|
|
40
|
+
return angular;
|
|
41
|
+
},
|
|
42
|
+
run() {
|
|
43
|
+
return angular;
|
|
44
|
+
},
|
|
45
|
+
filter() {
|
|
46
|
+
return angular;
|
|
47
|
+
},
|
|
48
|
+
controller() {
|
|
49
|
+
return angular;
|
|
50
|
+
},
|
|
51
|
+
value() {
|
|
52
|
+
return angular;
|
|
53
|
+
},
|
|
54
|
+
element() {
|
|
55
|
+
return angular;
|
|
56
|
+
},
|
|
57
|
+
injector() {
|
|
58
|
+
return angular;
|
|
59
|
+
},
|
|
60
|
+
invoke() {
|
|
61
|
+
return angular;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*************** CREATE INSTANCE ***************/
|
|
66
|
+
// Get angular module and module's code.
|
|
67
|
+
// Then eval() module's code.
|
|
68
|
+
// Finally, creating instance of module, using functions from angular module and evaled code.
|
|
69
|
+
|
|
70
|
+
export default async function createAngularModuleInstance(module_id, module_url, angularInjector) {
|
|
71
|
+
|
|
72
|
+
// If $injector don't have module with this id, than loadding this module using $oxLazyLoad
|
|
73
|
+
|
|
74
|
+
if (!angularInjector.has(module_id)) {
|
|
75
|
+
await angularInjector.get('$ocLazyLoad').load(module_url);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let angularModule = await angularInjector.get(module_id);
|
|
79
|
+
|
|
80
|
+
// Downloading module's code as text via axios and evaling it
|
|
81
|
+
// Result of eval will be in factory returns object, with key == module_id
|
|
82
|
+
|
|
83
|
+
let module = await axios.get(module_url);
|
|
84
|
+
module = module.data;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
eval(module);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error('ERROR WHILE EVAL() IN GHCONSTRUCTOR', error);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let result = {
|
|
93
|
+
type: module_id,
|
|
94
|
+
|
|
95
|
+
//*************** GET TEMPLATE ****************//
|
|
96
|
+
|
|
97
|
+
getTemplate: function (ref, changeFieldName, displayFieldName, field_model, appId, itemId) {
|
|
98
|
+
let displayFieldNameChecked = displayFieldName === 'false' ? false : true;
|
|
99
|
+
return angularModule.getTemplate(ref, changeFieldName, displayFieldNameChecked, field_model, appId, itemId);
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
//*************** GET DEFAULT VALUE ****************//
|
|
103
|
+
|
|
104
|
+
getDefaultValue: function (fieldModel, valuesArray, itemsList, currentAppId) {
|
|
105
|
+
return new Promise(async (resolve) => {
|
|
106
|
+
let getValueFunction = angularModule.getDefaultValue;
|
|
107
|
+
if (getValueFunction) {
|
|
108
|
+
let value = await getValueFunction(fieldModel, valuesArray, itemsList, currentAppId);
|
|
109
|
+
resolve(value);
|
|
110
|
+
} else {
|
|
111
|
+
resolve(null);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
//*************** GET SETTINGS ****************//
|
|
117
|
+
|
|
118
|
+
getSettings: function (scope, settingType, fieldModels) {
|
|
119
|
+
return angularModule.getSettings(scope, settingType, fieldModels);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
//*************** FILTER****************//
|
|
123
|
+
|
|
124
|
+
filter: {
|
|
125
|
+
getSearchOptions: function (fieldModel) {
|
|
126
|
+
let d_type = angularModule;
|
|
127
|
+
if (d_type.filter && d_type.filter.getSearchOptions) {
|
|
128
|
+
return angularModule.filter.getSearchOptions(fieldModel);
|
|
129
|
+
}
|
|
130
|
+
return [];
|
|
131
|
+
},
|
|
132
|
+
getDropdownValues: function () {
|
|
133
|
+
let d_type = angularModule;
|
|
134
|
+
if (d_type.filter && d_type.filter.getDropdownValues) {
|
|
135
|
+
return d_type.filter.getDropdownValues();
|
|
136
|
+
} else {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
//*************** GET INTERPRETATION ****************//
|
|
143
|
+
|
|
144
|
+
getInterpretation: function (value, interpretation_id, dataType, field, itemId, appId) {
|
|
145
|
+
return new Promise(async (resolve) => {
|
|
146
|
+
let currentDataType = factoryReturns[module_id];
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
let interpr_arr = await currentDataType.getInterpretation(value, appId, itemId, field, dataType);
|
|
150
|
+
let data = interpr_arr.find((item) => item.id == interpretation_id) || interpr_arr.find((item) => item.id == 'default');
|
|
151
|
+
|
|
152
|
+
let result = await data.content()
|
|
153
|
+
|
|
154
|
+
resolve({ html: result });
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.log(`ERROR IN ${module_id}`, error);
|
|
157
|
+
resolve({ html: '<span>no interpretation</span>' })
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
//*************** GET INTERPRETATIONS LIST ****************//
|
|
163
|
+
|
|
164
|
+
getInterpretationsList: function (field_value, appId, itemId, field) {
|
|
165
|
+
return factoryReturns[module_id].getInterpretation(field_value, appId, itemId, field);
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
//*************** GET INTERPRETATED VALUE ****************//
|
|
169
|
+
|
|
170
|
+
getInterpretatedValue: function (field_value, field_model, appId, itemId) {
|
|
171
|
+
return new Promise(async (resolve) => {
|
|
172
|
+
let getInterpretatedValueFunction = factoryReturns[module_id].getInterpretatedValue;
|
|
173
|
+
if (getInterpretatedValueFunction) {
|
|
174
|
+
let value = await getInterpretatedValueFunction(field_value, field_model, appId, itemId);
|
|
175
|
+
resolve(value);
|
|
176
|
+
} else {
|
|
177
|
+
resolve(field_value);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
//*************** EXTEND CONTROLLER ****************//
|
|
183
|
+
|
|
184
|
+
extendController: function (actionScope) {
|
|
185
|
+
angularModule.getActionScope(actionScope);
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
//*************** RUN ACTION ****************//
|
|
189
|
+
|
|
190
|
+
runAction: function (scope) {
|
|
191
|
+
try {
|
|
192
|
+
angularModule.runAction(scope);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
//*************** GET WINDOW SCOPE ****************//
|
|
199
|
+
|
|
200
|
+
getWindowScope: function (windowScope) {
|
|
201
|
+
return angularModule.getWindowScope(windowScope);
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
//*************** GET WINDOW HTML ****************//
|
|
205
|
+
|
|
206
|
+
getWindowHTML: function (scope) {
|
|
207
|
+
return angularModule.getWindowHTML(scope);
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export default async function createClassInstance(module_id, js_url, css_url) {
|
|
2
|
+
|
|
3
|
+
// Check if there is url to javascript file of module
|
|
4
|
+
|
|
5
|
+
if(!js_url) {
|
|
6
|
+
console.error(`JS link must be provided for this data type - ${module_id}`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Import module using dynamic import
|
|
10
|
+
|
|
11
|
+
let module = await import(/* webpackIgnore: true */js_url);
|
|
12
|
+
|
|
13
|
+
// Creating class from imported module
|
|
14
|
+
|
|
15
|
+
let importedClass = new module.default(module_id);
|
|
16
|
+
|
|
17
|
+
// Checl if there is url to css file of module
|
|
18
|
+
// If true, and there is no css for this data type, than create link tag to this css in head
|
|
19
|
+
|
|
20
|
+
if(css_url) {
|
|
21
|
+
const linkTag = document.createElement('link');
|
|
22
|
+
linkTag.href = css_url;
|
|
23
|
+
linkTag.setAttribute('data-module', module_id);
|
|
24
|
+
linkTag.setAttribute('rel', 'stylesheet');
|
|
25
|
+
document.getElementsByTagName('head')[0].appendChild(linkTag);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let result = {
|
|
29
|
+
type: module_id,
|
|
30
|
+
|
|
31
|
+
//*************** GET TEMPLATE ****************//
|
|
32
|
+
|
|
33
|
+
getTemplate: function (ref, changeFieldName, displayFieldName, field_model, appId, itemId) {
|
|
34
|
+
let displayFieldNameChecked = displayFieldName === 'false' ? false : true;
|
|
35
|
+
return importedClass.getTemplate(ref, changeFieldName, displayFieldNameChecked, field_model, appId, itemId);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
//*************** GET DEFAULT VALUE ****************//
|
|
39
|
+
|
|
40
|
+
getDefaultValue: function (fieldModel, valuesArray, itemsList, currentAppId) {
|
|
41
|
+
return new Promise(async (resolve) => {
|
|
42
|
+
let getValueFunction = importedClass.getDefaultValue;
|
|
43
|
+
if (getValueFunction) {
|
|
44
|
+
let value = await getValueFunction(fieldModel, valuesArray, itemsList, currentAppId);
|
|
45
|
+
resolve(value);
|
|
46
|
+
} else {
|
|
47
|
+
resolve(null);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
//*************** GET SETTINGS ****************//
|
|
53
|
+
|
|
54
|
+
getSettings: function (scope, settingType, fieldModels) {
|
|
55
|
+
return importedClass.getSettings(scope, settingType, fieldModels);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
//*************** FILTER****************//
|
|
59
|
+
|
|
60
|
+
filter: {
|
|
61
|
+
getSearchOptions: function (fieldModel) {
|
|
62
|
+
let d_type = importedClass;
|
|
63
|
+
if (d_type.filter && d_type.filter.getSearchOptions) {
|
|
64
|
+
return importedClass.filter.getSearchOptions(fieldModel);
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
},
|
|
68
|
+
getDropdownValues: function () {
|
|
69
|
+
let d_type = importedClass;
|
|
70
|
+
if (d_type.filter && d_type.filter.getDropdownValues) {
|
|
71
|
+
return d_type.filter.getDropdownValues();
|
|
72
|
+
} else {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
//*************** GET INTERPRETATION ****************//
|
|
79
|
+
|
|
80
|
+
getInterpretation: function (value, interpretation_id, dataType, field, itemId, appId) {
|
|
81
|
+
return new Promise(async (resolve) => {
|
|
82
|
+
let currentDataType = importedClass;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
let interpr_arr = await currentDataType.getInterpretation(value, appId, itemId, field, dataType);
|
|
86
|
+
let data = interpr_arr.find((item) => item.id == interpretation_id) || interpr_arr.find((item) => item.id == 'default');
|
|
87
|
+
|
|
88
|
+
let result = await data.content()
|
|
89
|
+
|
|
90
|
+
resolve({ html: result });
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.log(`ERROR IN ${module_id}`, error);
|
|
93
|
+
resolve({ html: '<span>no interpretation</span>' })
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
//*************** GET INTERPRETATIONS LIST ****************//
|
|
99
|
+
|
|
100
|
+
getInterpretationsList: function (field_value, appId, itemId, field) {
|
|
101
|
+
return importedClass.getInterpretation(field_value, appId, itemId, field);
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
//*************** GET INTERPRETATED VALUE ****************//
|
|
105
|
+
|
|
106
|
+
getInterpretatedValue: function (field_value, field_model, appId, itemId) {
|
|
107
|
+
return new Promise(async (resolve) => {
|
|
108
|
+
let getInterpretatedValueFunction = importedClass.getInterpretatedValue;
|
|
109
|
+
if (getInterpretatedValueFunction) {
|
|
110
|
+
let value = await getInterpretatedValueFunction(field_value, field_model, appId, itemId);
|
|
111
|
+
resolve(value);
|
|
112
|
+
} else {
|
|
113
|
+
resolve(field_value);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
//*************** EXTEND CONTROLLER ****************//
|
|
119
|
+
|
|
120
|
+
extendController: function (actionScope) {
|
|
121
|
+
importedClass.getActionScope(actionScope);
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
//*************** RUN ACTION ****************//
|
|
125
|
+
|
|
126
|
+
runAction: function (scope) {
|
|
127
|
+
try {
|
|
128
|
+
importedClass.runAction(scope);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
//*************** GET WINDOW SCOPE ****************//
|
|
135
|
+
|
|
136
|
+
getWindowScope: function (windowScope) {
|
|
137
|
+
return importedClass.getWindowScope(windowScope);
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
//*************** GET WINDOW HTML ****************//
|
|
141
|
+
|
|
142
|
+
getWindowHTML: function (scope) {
|
|
143
|
+
return importedClass.getWindowHTML(scope);
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
@@ -1,66 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/*************** FAKE ANGULAR $Q ***************/
|
|
4
|
-
// It's needed when we eval() angular code.
|
|
5
|
-
|
|
6
|
-
let $q = {
|
|
7
|
-
when: function (a) {
|
|
8
|
-
return new Promise(resolve => {
|
|
9
|
-
resolve(a);
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/*************** FAKE ANGULAR ***************/
|
|
15
|
-
// It's needed when we eval() angular code.
|
|
16
|
-
|
|
17
|
-
let factoryReturns = {};
|
|
18
|
-
|
|
19
|
-
let angular = {
|
|
20
|
-
module() {
|
|
21
|
-
return angular;
|
|
22
|
-
},
|
|
23
|
-
directive() {
|
|
24
|
-
return angular;
|
|
25
|
-
},
|
|
26
|
-
factory(name, args) {
|
|
27
|
-
try {
|
|
28
|
-
if(typeof args === 'object') {
|
|
29
|
-
factoryReturns[name] = args[args.length - 1]($q);
|
|
30
|
-
} else {
|
|
31
|
-
factoryReturns[name] = args($q);
|
|
32
|
-
}
|
|
33
|
-
} catch(error) {
|
|
34
|
-
console.log('Errror in data type: ', name);
|
|
35
|
-
console.log(error);
|
|
36
|
-
}
|
|
37
|
-
return angular;
|
|
38
|
-
},
|
|
39
|
-
service() {
|
|
40
|
-
return angular;
|
|
41
|
-
},
|
|
42
|
-
run() {
|
|
43
|
-
return angular;
|
|
44
|
-
},
|
|
45
|
-
filter() {
|
|
46
|
-
return angular;
|
|
47
|
-
},
|
|
48
|
-
controller() {
|
|
49
|
-
return angular;
|
|
50
|
-
},
|
|
51
|
-
value() {
|
|
52
|
-
return angular;
|
|
53
|
-
},
|
|
54
|
-
element() {
|
|
55
|
-
return angular;
|
|
56
|
-
},
|
|
57
|
-
injector() {
|
|
58
|
-
return angular;
|
|
59
|
-
},
|
|
60
|
-
invoke() {
|
|
61
|
-
return angular;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
import createAngularModuleInstance from './createAngularModuleInstance.js';
|
|
2
|
+
import createClassInstance from './createClassInstance.js';
|
|
64
3
|
|
|
65
4
|
export class GHConstructor {
|
|
66
5
|
constructor() {
|
|
@@ -114,139 +53,18 @@ export class GHConstructor {
|
|
|
114
53
|
}
|
|
115
54
|
|
|
116
55
|
/*************** CREATE INSTANCE ***************/
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// Finally,
|
|
56
|
+
// Check if module is "angular" or "class"
|
|
57
|
+
// Than, creating instance for that type of module
|
|
58
|
+
// Finally, returns the result (created instance) and puting it to the cache
|
|
120
59
|
|
|
121
60
|
async createInstance(module_id) {
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
if(!this.angularInjector.has(module_id)) {
|
|
125
|
-
await this.angularInjector.get('$ocLazyLoad').load(gudhub.storage.getModuleUrl(module_id));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let angularModule = await this.angularInjector.get(module_id);
|
|
129
|
-
|
|
130
|
-
let module = await axios.get(module_url);
|
|
131
|
-
module = module.data;
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
eval(module);
|
|
135
|
-
} catch(error) {
|
|
136
|
-
console.error('ERROR WHILE EVAL() IN GHCONSTRUCTOR', error);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
let result = {
|
|
140
|
-
type: module_id,
|
|
141
|
-
|
|
142
|
-
//*************** GET TEMPLATE ****************//
|
|
143
|
-
|
|
144
|
-
getTemplate: function (ref, changeFieldName, displayFieldName, field_model, appId, itemId) {
|
|
145
|
-
let displayFieldNameChecked = displayFieldName === 'false' ? false : true;
|
|
146
|
-
return angularModule.getTemplate(ref, changeFieldName, displayFieldNameChecked, field_model, appId, itemId);
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
//*************** GET DEFAULT VALUE ****************//
|
|
150
|
-
|
|
151
|
-
getDefaultValue: function (fieldModel, valuesArray, itemsList, currentAppId) {
|
|
152
|
-
return new Promise(async (resolve) => {
|
|
153
|
-
let getValueFunction = angularModule.getDefaultValue;
|
|
154
|
-
if (getValueFunction) {
|
|
155
|
-
let value = await getValueFunction(fieldModel, valuesArray, itemsList, currentAppId);
|
|
156
|
-
resolve(value);
|
|
157
|
-
} else {
|
|
158
|
-
resolve(null);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
//*************** GET SETTINGS ****************//
|
|
164
|
-
|
|
165
|
-
getSettings: function (scope, settingType, fieldModels) {
|
|
166
|
-
return angularModule.getSettings(scope, settingType, fieldModels);
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
//*************** FILTER****************//
|
|
170
|
-
|
|
171
|
-
filter: {
|
|
172
|
-
getSearchOptions: function (fieldModel) {
|
|
173
|
-
let d_type = angularModule;
|
|
174
|
-
if (d_type.filter && d_type.filter.getSearchOptions) {
|
|
175
|
-
return angularModule.filter.getSearchOptions(fieldModel);
|
|
176
|
-
}
|
|
177
|
-
return [];
|
|
178
|
-
},
|
|
179
|
-
getDropdownValues: function () {
|
|
180
|
-
let d_type = angularModule;
|
|
181
|
-
if (d_type.filter && d_type.filter.getDropdownValues) {
|
|
182
|
-
return d_type.filter.getDropdownValues();
|
|
183
|
-
} else {
|
|
184
|
-
return [];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
//*************** GET INTERPRETATION ****************//
|
|
190
|
-
|
|
191
|
-
getInterpretation: function(value, interpretation_id, dataType, field, itemId, appId) {
|
|
192
|
-
return new Promise(async (resolve) => {
|
|
193
|
-
let currentDataType = factoryReturns[module_id];
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
let interpr_arr = await currentDataType.getInterpretation(value, appId, itemId, field, dataType);
|
|
197
|
-
let data = interpr_arr.find((item) => item.id == interpretation_id) || interpr_arr.find((item) => item.id == 'default');
|
|
198
|
-
|
|
199
|
-
let result = await data.content()
|
|
200
|
-
|
|
201
|
-
resolve({ html: result });
|
|
202
|
-
} catch(error) {
|
|
203
|
-
console.log(`ERROR IN ${module_id}`, error);
|
|
204
|
-
resolve({ html: '<span>no interpretation</span>' })
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
//*************** GET INTERPRETATED VALUE ****************//
|
|
210
|
-
|
|
211
|
-
getInterpretatedValue: function (field_value, field_model, appId, itemId) {
|
|
212
|
-
return new Promise(async (resolve) => {
|
|
213
|
-
let getInterpretatedValueFunction = factoryReturns[module_id].getInterpretatedValue;
|
|
214
|
-
if (getInterpretatedValueFunction) {
|
|
215
|
-
let value = await getInterpretatedValueFunction(field_value, field_model, appId, itemId);
|
|
216
|
-
resolve(value);
|
|
217
|
-
} else {
|
|
218
|
-
resolve(field_value);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
//*************** EXTEND CONTROLLER ****************//
|
|
224
|
-
|
|
225
|
-
extendController: function (actionScope) {
|
|
226
|
-
angularModule.getActionScope(actionScope);
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
//*************** RUN ACTION ****************//
|
|
230
|
-
|
|
231
|
-
runAction: function (scope) {
|
|
232
|
-
try {
|
|
233
|
-
angularModule.runAction(scope);
|
|
234
|
-
} catch (e) {
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
//*************** GET WINDOW SCOPE ****************//
|
|
240
|
-
|
|
241
|
-
getWindowScope: function (windowScope) {
|
|
242
|
-
return angularModule.getWindowScope(windowScope);
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
//*************** GET WINDOW HTML ****************//
|
|
61
|
+
let module = gudhub.storage.getModuleUrl(module_id);
|
|
246
62
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
63
|
+
let result;
|
|
64
|
+
if (module.type === 'angular') {
|
|
65
|
+
result = await createAngularModuleInstance(module_id, module.url, this.angularInjector);
|
|
66
|
+
} else if(module.type === 'class') {
|
|
67
|
+
result = await createClassInstance(module_id, module.js, module.css);
|
|
250
68
|
}
|
|
251
69
|
|
|
252
70
|
this.pupToCache(result);
|