@gudhub/core 1.1.7 → 1.1.10
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/field_processor.md +0 -1
- package/GUDHUB/Utils/Utils.js +0 -5
- package/GUDHUB/Utils/json_constructor/json_constructor.js +34 -19
- package/GUDHUB/gudhub.js +0 -4
- package/GUDHUB/gudhub.test.js +0 -10
- package/Readme.md +0 -2
- package/package.json +1 -1
- package/umd/library.min.js +4 -6
- package/umd/library.min.js.map +1 -1
- package/GUDHUB/Utils/interpretation/interpretation.js +0 -100
- package/GUDHUB/Utils/interpretation/interpretation.test.js +0 -11
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
export async function getInterpretedValue(gudhub, app_id, item_id, field_id) {
|
|
2
|
-
const fieldModel = await gudhub.getField(app_id, field_id);
|
|
3
|
-
const fieldValue = await gudhub.getFieldValue(app_id, item_id, field_id);
|
|
4
|
-
|
|
5
|
-
if (!fieldModel || !fieldModel.data_type || !fieldValue) return "";
|
|
6
|
-
|
|
7
|
-
const fieldsValueArray = fieldValue.split(",");
|
|
8
|
-
|
|
9
|
-
switch (fieldModel.data_type) {
|
|
10
|
-
case "radio_button":
|
|
11
|
-
case "text_opt":
|
|
12
|
-
case "tag":
|
|
13
|
-
const fieldNames = fieldsValueArray
|
|
14
|
-
.map((value) => {
|
|
15
|
-
const option = fieldModel.data_model.options.find(
|
|
16
|
-
(modelOption) => modelOption.value == value
|
|
17
|
-
);
|
|
18
|
-
return option ? option.name : "";
|
|
19
|
-
})
|
|
20
|
-
.join(",");
|
|
21
|
-
return fieldNames;
|
|
22
|
-
|
|
23
|
-
case 'file':
|
|
24
|
-
case "image":
|
|
25
|
-
let fileUrl = '';
|
|
26
|
-
if(fieldModel.data_model.display_mode == 'multiple') {
|
|
27
|
-
await gudhub.getFiles(app_id, fieldsValueArray).then(
|
|
28
|
-
files =>
|
|
29
|
-
{
|
|
30
|
-
files.forEach(file => {
|
|
31
|
-
return fileUrl += file.url + ',';
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
err => {return 'no img'}
|
|
35
|
-
)
|
|
36
|
-
fileUrl = fileUrl.slice(0,-1)
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
fileUrl = await gudhub.getFile(app_id, fieldValue).then(
|
|
40
|
-
file => {
|
|
41
|
-
return file.url;
|
|
42
|
-
},
|
|
43
|
-
err => {return 'no img'}
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
return fileUrl;
|
|
47
|
-
|
|
48
|
-
case "text_editor":
|
|
49
|
-
case 'tinymse':
|
|
50
|
-
case 'code_editor':
|
|
51
|
-
case 'grapes_html_editor':
|
|
52
|
-
let htmlUrl = await gudhub.getFile(app_id, fieldValue).then(
|
|
53
|
-
file => {
|
|
54
|
-
return file.url + '?timestamp=' + file.last_update;
|
|
55
|
-
},
|
|
56
|
-
err => {return 'no text'}
|
|
57
|
-
)
|
|
58
|
-
return htmlUrl;
|
|
59
|
-
|
|
60
|
-
case "item_ref":
|
|
61
|
-
const interpretedValue = [];
|
|
62
|
-
for (const field of fieldsValueArray) {
|
|
63
|
-
for (const ref of fieldModel.data_model.refs) {
|
|
64
|
-
const [appId, itemId] = field.split(".");
|
|
65
|
-
const value = await this.getInterpretedValue(
|
|
66
|
-
appId,
|
|
67
|
-
itemId,
|
|
68
|
-
ref.field_id
|
|
69
|
-
);
|
|
70
|
-
interpretedValue.push(value);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return interpretedValue.join(", ");
|
|
74
|
-
|
|
75
|
-
case "data_ref":
|
|
76
|
-
for (const caseItem of fieldModel.data_model.cases) {
|
|
77
|
-
const [appId, itemId] = fieldValue.split(".");
|
|
78
|
-
if (caseItem.app_id == appId) {
|
|
79
|
-
const value = await this.getInterpretedValue(
|
|
80
|
-
appId,
|
|
81
|
-
itemId,
|
|
82
|
-
caseItem.field_id
|
|
83
|
-
);
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return "";
|
|
88
|
-
case "field":
|
|
89
|
-
const fieldsName = [];
|
|
90
|
-
for (const value of fieldsValueArray) {
|
|
91
|
-
const model = await gudhub.getField(app_id, value);
|
|
92
|
-
if (model.field_name != undefined) {
|
|
93
|
-
fieldsName.push(model.field_name);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return fieldsName.join(" ");
|
|
97
|
-
default:
|
|
98
|
-
return fieldValue;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import should from "should";
|
|
2
|
-
import {GudHub} from '../../gudhub.js';
|
|
3
|
-
|
|
4
|
-
describe("CHECK INTERPRETATION", function () {
|
|
5
|
-
const gudhub = new GudHub();
|
|
6
|
-
|
|
7
|
-
it("Check radio_button interpretation", async function () {
|
|
8
|
-
let interpretationValue = await gudhub.getInterpretedValue(16259,1064673,270607);
|
|
9
|
-
interpretationValue.should.equal("Normal");
|
|
10
|
-
});
|
|
11
|
-
});
|