softdinlibreriajs 1.0.5 → 1.0.7
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/package.json +1 -1
- package/src/EnumRespuestaSINO.js +28 -2
package/package.json
CHANGED
package/src/EnumRespuestaSINO.js
CHANGED
|
@@ -3,8 +3,8 @@ class EnumRespuestaSINO {
|
|
|
3
3
|
static NO = 0;
|
|
4
4
|
|
|
5
5
|
static descriptions = [
|
|
6
|
-
{ id: EnumRespuestaSINO.SI, code: 'SI', description: 'Sí' },
|
|
7
|
-
{ id: EnumRespuestaSINO.NO, code: 'NO', description: 'No' },
|
|
6
|
+
{ id: EnumRespuestaSINO.SI, code: 'SI', description: 'Sí', description2: true },
|
|
7
|
+
{ id: EnumRespuestaSINO.NO, code: 'NO', description: 'No', description2: false },
|
|
8
8
|
];
|
|
9
9
|
|
|
10
10
|
static getById(id) {
|
|
@@ -18,6 +18,32 @@ class EnumRespuestaSINO {
|
|
|
18
18
|
static getByDescription(description) {
|
|
19
19
|
return EnumRespuestaSINO.descriptions.find(item => item.description === description) || null;
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
static colorMapping = [
|
|
23
|
+
{ 'success': EnumRespuestaSINO.SI },
|
|
24
|
+
{ 'danger': EnumRespuestaSINO.NO },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
static getColors(campo) {
|
|
28
|
+
const colorArray = {};
|
|
29
|
+
|
|
30
|
+
for (const color of EnumRespuestaSINO.colorMapping) {
|
|
31
|
+
const description = Object.values(color)[0];
|
|
32
|
+
const descriptionEntry = EnumRespuestaSINO.descriptions.find(item => item.id === description);
|
|
33
|
+
if (descriptionEntry) {
|
|
34
|
+
colorArray[Object.keys(color)[0]] = descriptionEntry[campo];
|
|
35
|
+
} else {
|
|
36
|
+
colorArray[Object.keys(color)[0]] = null; // Handle the case where the field does not exist
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return colorArray;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static getColorName(campo, valor) {
|
|
43
|
+
const colors = EnumRespuestaSINO.getColors(campo);
|
|
44
|
+
return Object.keys(colors).find(key => colors[key] === valor);
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
}
|
|
22
48
|
|
|
23
49
|
module.exports = EnumRespuestaSINO;
|