not-bulma 1.2.52 → 1.2.54
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
CHANGED
|
@@ -39,7 +39,7 @@ class notCRUD extends notController {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
static getMenu() {
|
|
42
|
+
static getMenu(itemCustomProps = {}) {
|
|
43
43
|
return [
|
|
44
44
|
{
|
|
45
45
|
section: this.MODULE_NAME,
|
|
@@ -47,6 +47,7 @@ class notCRUD extends notController {
|
|
|
47
47
|
url: `/${notCommon.lowerFirstLetter(
|
|
48
48
|
this.MODULE_NAME
|
|
49
49
|
)}/${notCommon.lowerFirstLetter(this.MODEL_NAME)}`,
|
|
50
|
+
...itemCustomProps,
|
|
50
51
|
},
|
|
51
52
|
];
|
|
52
53
|
}
|
|
@@ -220,8 +221,25 @@ class notCRUD extends notController {
|
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
getTitleFromLib(propName, id) {
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
const actionName = this.getCurrentAction();
|
|
225
|
+
this.debug(
|
|
226
|
+
"notCRUD.getTitleFromLib is obsolete, use notCRUD.getPreloadedVariantTitle(actionName, propName, id)"
|
|
227
|
+
);
|
|
228
|
+
return this.getPreloadedVariantTitle(actionName, propName, id);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
getPreloadedVariants(actionName, propName) {
|
|
232
|
+
return this.getOptions(`variants.${actionName}.${propName}`, []);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
getPreloadedVariantTitle(actionName, propName, id) {
|
|
236
|
+
const variants = this.getPreloadedVariants(actionName, propName);
|
|
237
|
+
const item = variants.find((item) => item.id === id);
|
|
238
|
+
if (item) {
|
|
239
|
+
return item.title;
|
|
240
|
+
} else {
|
|
241
|
+
return id;
|
|
242
|
+
}
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
getItemTitle(item) {
|
|
@@ -1,42 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import notCommon from '../common';
|
|
1
|
+
import notCommon from "../common";
|
|
3
2
|
|
|
4
|
-
const PRELOADABLE = [
|
|
3
|
+
const PRELOADABLE = ["create", "update", "list", "delete", "details"];
|
|
5
4
|
|
|
6
|
-
export default class CRUDVariantsPreloader{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
export default class CRUDVariantsPreloader {
|
|
6
|
+
static async preload(controller, type = "list") {
|
|
7
|
+
try {
|
|
8
|
+
if (!PRELOADABLE.includes(type)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let preload = controller.getOptions(`${type}.preload`, {});
|
|
12
|
+
if (Object.keys(preload).length == 0) {
|
|
13
|
+
preload = controller.getOptions(`preload`, {});
|
|
14
|
+
}
|
|
15
|
+
if (Object.keys(preload).length > 0) {
|
|
16
|
+
let libProps = Object.keys(preload);
|
|
17
|
+
let proms = [];
|
|
18
|
+
libProps.forEach((prop) => {
|
|
19
|
+
let modelName = notCommon.lowerFirstLetter(preload[prop]);
|
|
20
|
+
let Model = controller.make[modelName]({});
|
|
21
|
+
proms.push(Model.$listAll());
|
|
22
|
+
});
|
|
23
|
+
let results = await Promise.all(proms);
|
|
24
|
+
for (let i = 0; i < libProps.length; i++) {
|
|
25
|
+
const propName = libProps[i];
|
|
26
|
+
if (
|
|
27
|
+
results[i].status === "ok" &&
|
|
28
|
+
Array.isArray(results[i].result)
|
|
29
|
+
) {
|
|
30
|
+
const resultsList = results[i].result;
|
|
31
|
+
const variants = resultsList.map((item) => {
|
|
32
|
+
return {
|
|
33
|
+
id: item._id,
|
|
34
|
+
title: item.title,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
controller.setOptions(
|
|
38
|
+
`variants.${type}.${propName}`,
|
|
39
|
+
variants
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
controller.log("preload finished");
|
|
45
|
+
} catch (e) {
|
|
46
|
+
controller.report(e);
|
|
47
|
+
controller.showErrorMessage(e);
|
|
34
48
|
}
|
|
35
|
-
}
|
|
36
|
-
controller.log('preload finished');
|
|
37
|
-
}catch(e){
|
|
38
|
-
controller.report(e);
|
|
39
|
-
controller.showErrorMessage(e);
|
|
40
49
|
}
|
|
41
|
-
|
|
42
|
-
};
|
|
50
|
+
}
|