adminizer 4.1.0-commit.d8a06d3 → 4.1.1
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/Readme.md +46 -0
- package/assets/{VanillaJSONEditor-D-Lx670g.js → VanillaJSONEditor-DfRefswH.js} +104 -104
- package/assets/add-CJ1-zeA1.js +1 -0
- package/assets/add-form-CbNl0wdS.js +1 -0
- package/assets/add-group-form-Bt_Dx9wm.js +1 -0
- package/assets/add-group-pIFJV5qL.js +1 -0
- package/assets/add-user-D2US8hL_.js +1 -0
- package/assets/add-user-form-Bt8Jy6S2.js +1 -0
- package/assets/{app-WTooYWC3.css → app-B6cCPfWk.css} +1 -1
- package/assets/app-layout-B86jl9bH.js +1 -0
- package/assets/app-shell-CiGyzQ0C.js +1 -0
- package/assets/app-sidebar-Bz-SRwBg.js +1 -0
- package/assets/app-sidebar-header-7CNCx7Rs.js +11 -0
- package/assets/app.js +45 -37
- package/assets/breadcrumbs-_jhtTcOi.js +1 -0
- package/assets/catalog-CON6moaA.js +16 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/checkbox-CQdZw5mb.js +1 -0
- package/assets/dashboard-es9ZT8qk.js +3 -0
- package/assets/{date-picker-DI1cCO7K.js → date-picker-Dz-d-YWX.js} +2 -2
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-D0mrZvki.js +11 -0
- package/assets/dialog-stack-BiMbfm58.js +1 -0
- package/assets/dropdown-menu-BSBcRiXx.js +1 -0
- package/assets/{field-renderer-DVHZF6HS.js → field-renderer-B6hFAeiU.js} +3 -3
- package/assets/form-Buslty7y.js +1 -0
- package/assets/form-aqiRmPix.js +1 -0
- package/assets/{geo-json-BjiyTtMu.js → geo-json-BKmYmu3d.js} +2 -2
- package/assets/{handsontable-4mjU_b0n.js → handsontable-B8xVeMAQ.js} +5 -5
- package/assets/home-Dr72Jk-w.js +2 -0
- package/assets/icon-B-a7xg54.js +1 -0
- package/assets/index-B68_akQe.js +1 -0
- package/assets/index-B7-xTDyy.js +1 -0
- package/assets/index-BJFFlCSo.js +1 -0
- package/assets/{index-Cw5o84pO.js → index-BOuMo_nl.js} +3 -3
- package/assets/index-BzOcGsBq.js +1 -0
- package/assets/index-CFbQ2Rv0.js +1 -0
- package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
- package/assets/{index-Cgp8OfuI.js → index-D5UDXTFs.js} +1 -1
- package/assets/index-oxIQWAdI.js +41 -0
- package/assets/init-user-5H689LP0.js +1 -0
- package/assets/input-CSJjrf2i.js +1 -0
- package/assets/input-error-CK92Shhm.js +1 -0
- package/assets/label-Muj0-Efy.js +1 -0
- package/assets/list-Cvh7zbyG.js +1 -0
- package/assets/list-table-Bs_vbQiV.js +52 -0
- package/assets/login-DliJrjMQ.js +6 -0
- package/assets/manifest.json +575 -673
- package/assets/material-icon-BRS58Qpk.js +1 -0
- package/assets/module-CjG21VCT.js +1 -0
- package/assets/{monaco-editor-CJs0_GlD.js → monaco-editor-9fDiyfuW.js} +2 -2
- package/assets/{multi-select-BvRpAW8r.js → multi-select-CMQIJ0JT.js} +2 -2
- package/assets/nav-footer-IGMn9NiE.js +1 -0
- package/assets/nav-main-DBE4rMiZ.js +1 -0
- package/assets/nav-user-CjyLRyq-.js +1 -0
- package/assets/pagination-render-DUAq2klc.js +1 -0
- package/assets/popover-C_cww-4_.js +1 -0
- package/assets/register-UzQn3J0g.js +1 -0
- package/assets/{select-BWepUw-9.js → select-DzBno-dc.js} +2 -2
- package/assets/{sidebar-CAHsHdjM.js → sidebar-Dc4iqfu-.js} +2 -2
- package/assets/skeleton-Dkmj2o2Z.js +1 -0
- package/assets/sonner-De1t71Gj.js +1 -0
- package/assets/{toast-editor-CMK7QtF1.js → toast-editor-1Pul3oMs.js} +2 -2
- package/assets/tooltip-CwPrC-HD.js +1 -0
- package/assets/use-appearance-J8J2w43p.js +1 -0
- package/assets/use-window-size-DLSEoR6e.js +1 -0
- package/assets/{user-info-DFrmpJ4y.js → user-info-8RyDk7qh.js} +2 -2
- package/assets/user-menu-content-CpxTLH56.js +6 -0
- package/assets/welcome-BYKI6yO-.js +1 -0
- package/controllers/add.js +8 -8
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +40 -35
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
- package/controllers/catalog/FrontentCatalogAdapter.js +71 -72
- package/controllers/edit.js +8 -11
- package/controllers/list.js +2 -2
- package/controllers/login.js +16 -7
- package/controllers/navigation/edit.js +1 -1
- package/controllers/remove.js +1 -1
- package/controllers/view.js +1 -1
- package/helpers/JsUtils.d.ts +1 -0
- package/helpers/JsUtils.js +3 -0
- package/helpers/accessRightsHelper.d.ts +3 -0
- package/helpers/accessRightsHelper.js +27 -4
- package/helpers/controllerHelper.js +39 -18
- package/helpers/fieldsHelper.d.ts +3 -2
- package/helpers/fieldsHelper.js +5 -1
- package/helpers/inertiaAddHelper.d.ts +4 -5
- package/helpers/inertiaAddHelper.js +25 -7
- package/helpers/inertiaFromHelper.js +1 -1
- package/helpers/inertiaMenuHelper.d.ts +1 -1
- package/helpers/inertiaMenuHelper.js +1 -1
- package/helpers/menuHelper.d.ts +8 -3
- package/helpers/menuHelper.js +26 -17
- package/index.d.ts +2 -6
- package/index.js +5 -6
- package/interfaces/adminpanelConfig.d.ts +35 -30
- package/interfaces/global.d.ts +5 -2
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +9 -3
- package/lib/Adminizer.js +32 -16
- package/lib/media-manager/Items.js +0 -3
- package/lib/requestProcessor.js +10 -3
- package/lib/v4/DataAccessor.d.ts +3 -1
- package/lib/v4/DataAccessor.js +43 -18
- package/lib/v4/I18n.js +2 -0
- package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +89 -60
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -54
- package/lib/v4/catalog/Navigation.d.ts +43 -0
- package/lib/v4/catalog/Navigation.js +457 -0
- package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
- package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
- package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
- package/lib/{datatable → v4/datatable}/NodeTable.js +8 -5
- package/lib/v4/model/AbstractModel.d.ts +5 -1
- package/lib/v4/model/AbstractModel.js +2 -1
- package/lib/v4/model/ModelHandler.js +1 -3
- package/lib/v4/model/adapter/sequelize.d.ts +8 -0
- package/lib/v4/model/adapter/sequelize.js +274 -133
- package/lib/v4/model/adapter/waterline.js +5 -2
- package/lib/{widgets → v4/widgets}/abstractLink.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +11 -4
- package/lib/{widgets → v4/widgets}/widgetHandler.js +1 -1
- package/models/NavigationAP.d.ts +2 -3
- package/models/NavigationAP.js +5 -6
- package/models/UserAP.d.ts +2 -3
- package/package.json +17 -6
- package/system/Router.js +8 -11
- package/system/bindAccessRights.js +0 -4
- package/system/bindControls.js +6 -6
- package/system/bindDev.js +1 -0
- package/system/bindInertia.js +9 -4
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +9 -6
- package/system/bindNavigation.d.ts +2 -0
- package/system/bindNavigation.js +42 -42
- package/system/bindReqFunctions.js +0 -1
- package/system/defaults.js +13 -6
- package/translations/ar.json +70 -1
- package/translations/cn.json +70 -1
- package/translations/de.json +71 -3
- package/translations/en.json +70 -102
- package/translations/es.json +70 -1
- package/translations/fr.json +70 -1
- package/translations/hi.json +70 -1
- package/translations/jp.json +70 -1
- package/translations/ko.json +70 -1
- package/translations/pt.json +70 -1
- package/translations/ru.json +71 -103
- package/translations/ua.json +70 -1
- package/translations/uz.json +72 -0
- package/translations/vi.json +70 -1
- package/assets/add-BP_u3Tjl.js +0 -1
- package/assets/add-form-nffmiYTh.js +0 -1
- package/assets/add-group-D4vcHlm-.js +0 -1
- package/assets/add-group-form-gNJW11-q.js +0 -1
- package/assets/add-user-DWh3Nas0.js +0 -1
- package/assets/add-user-form-BJ0FsZYJ.js +0 -1
- package/assets/app-layout-DYsRFUuP.js +0 -1
- package/assets/app-shell-Dd9Eknik.js +0 -1
- package/assets/app-sidebar-BOmu6-Sl.js +0 -1
- package/assets/app-sidebar-header-CoXSzWxk.js +0 -11
- package/assets/breadcrumbs-BmAq4fHT.js +0 -1
- package/assets/button-C9B_5Jf_.js +0 -1
- package/assets/checkbox-Fg27sL_1.js +0 -1
- package/assets/compiler-runtime-hB6dAw2d.js +0 -9
- package/assets/dashboard-BACj996r.js +0 -3
- package/assets/dropdown-menu-Bhj17ENm.js +0 -1
- package/assets/form-BgWdwvz1.js +0 -1
- package/assets/form-DgtErfln.js +0 -1
- package/assets/home-CHntBHJa.js +0 -2
- package/assets/icon-Dt0vBgDO.js +0 -1
- package/assets/index-B8BS9wMC.js +0 -1
- package/assets/index-BC0yfOHo.js +0 -1
- package/assets/index-BKCgnGj_.js +0 -1
- package/assets/index-BbXEMx9n.js +0 -1
- package/assets/index-BykbU6Ee.js +0 -41
- package/assets/index-CaJgc5EZ.js +0 -1
- package/assets/index-DrWfGwtf.js +0 -1
- package/assets/init-user-JfCKJ5Ce.js +0 -1
- package/assets/input-CvRbIbk4.js +0 -1
- package/assets/input-error-DMK7cAt7.js +0 -1
- package/assets/label-CSLFe9Bz.js +0 -1
- package/assets/list-B2Oa5O_Q.js +0 -1
- package/assets/list-table-DA9MhywL.js +0 -62
- package/assets/login-DQwGtdis.js +0 -6
- package/assets/material-icon-BJg8o_fs.js +0 -1
- package/assets/module-DWXp59Vg.js +0 -1
- package/assets/nav-footer-Bs4dmN1d.js +0 -1
- package/assets/nav-main-Bq3IMk4C.js +0 -1
- package/assets/nav-user-CbB22J5O.js +0 -1
- package/assets/pagination-render-DuXDDbC_.js +0 -1
- package/assets/popover-DtoGI2b1.js +0 -1
- package/assets/register-BSogVF0h.js +0 -1
- package/assets/skeleton-COOcAA8f.js +0 -1
- package/assets/sonner-BI0IFOQN.js +0 -1
- package/assets/tooltip-DHwpLKOI.js +0 -1
- package/assets/use-appearance-DRfIqTgw.js +0 -1
- package/assets/use-window-size-h0Sh_NvX.js +0 -1
- package/assets/user-menu-content-DPXQdERj.js +0 -6
- package/assets/utils-DjqsqOe8.js +0 -1
- package/assets/welcome-B4WCIXKf.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -0
- package/controllers/processInstallStep.js +0 -122
- package/lib/catalog/Navigation.d.ts +0 -0
- package/lib/catalog/Navigation.js +0 -532
- package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
- package/lib/installStepper/InstallStepAbstract.js +0 -69
- package/lib/installStepper/finalizeStep.d.ts +0 -21
- package/lib/installStepper/finalizeStep.js +0 -48
- package/lib/installStepper/installStepper.d.ts +0 -40
- package/lib/installStepper/installStepper.js +0 -195
- package/models/MediaManagerAP.d.ts +0 -62
- package/models/MediaManagerAP.js +0 -45
- package/models/MediaManagerAssociationsAP.d.ts +0 -38
- package/models/MediaManagerAssociationsAP.js +0 -27
- package/models/MediaManagerMetaAP.d.ts +0 -30
- package/models/MediaManagerMetaAP.js +0 -21
- package/system/bindInstallStepper.d.ts +0 -2
- package/system/bindInstallStepper.js +0 -23
- /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
- /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
- /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
- /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
- /package/lib/{inertia → v4/inertia}/flash.js +0 -0
- /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractCustom.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractCustom.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractInfo.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { AbstractCatalog, AbstractGroup, AbstractItem } from "./AbstractCatalog";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
import { Adminizer } from "../../Adminizer";
|
|
4
|
+
class StorageService {
|
|
5
|
+
storageMap = new Map();
|
|
6
|
+
id;
|
|
7
|
+
model;
|
|
8
|
+
adminizer;
|
|
9
|
+
constructor(adminizer, id, model) {
|
|
10
|
+
this.adminizer = adminizer;
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.model = model.toLowerCase();
|
|
13
|
+
this.initModel();
|
|
14
|
+
}
|
|
15
|
+
async initModel() {
|
|
16
|
+
// Direct call by model adapter
|
|
17
|
+
const navigation = await this.adminizer.modelHandler.model.get(this.model)["_findOne"]({ label: this.id });
|
|
18
|
+
if (navigation) {
|
|
19
|
+
Adminizer.log.info(`Found existing navigation: ${this.id}`);
|
|
20
|
+
await this.populateFromTree(navigation.tree);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const newNavigation = { label: this.id, tree: [] };
|
|
24
|
+
// Direct call by model adapter
|
|
25
|
+
await this.adminizer.modelHandler.model.get(this.model)["_create"](newNavigation);
|
|
26
|
+
Adminizer.log.info(`Created a new navigation: ${this.id}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getId() {
|
|
30
|
+
return this.id;
|
|
31
|
+
}
|
|
32
|
+
async buildTree() {
|
|
33
|
+
const rootElements = await this.findElementsByParentId(0, null);
|
|
34
|
+
const buildSubTree = async (elements) => {
|
|
35
|
+
const tree = [];
|
|
36
|
+
for (const element of elements) {
|
|
37
|
+
const children = await this.findElementsByParentId(element.id, null);
|
|
38
|
+
tree.push({
|
|
39
|
+
...element,
|
|
40
|
+
children: await buildSubTree(children)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return tree;
|
|
44
|
+
};
|
|
45
|
+
let tree = await buildSubTree(rootElements);
|
|
46
|
+
function sortTree(items) {
|
|
47
|
+
items.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
48
|
+
for (let i = 0; i < items.length; i++) {
|
|
49
|
+
const item = items[i];
|
|
50
|
+
if (item.children) {
|
|
51
|
+
sortTree(item.children);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
sortTree(tree);
|
|
56
|
+
return tree;
|
|
57
|
+
}
|
|
58
|
+
async populateFromTree(tree) {
|
|
59
|
+
const traverseTree = async (node, parentId = 0) => {
|
|
60
|
+
const { children, ...itemData } = node;
|
|
61
|
+
const item = { ...itemData, parentId };
|
|
62
|
+
await this.setElement(item.id, item, true);
|
|
63
|
+
if (children && children.length > 0) {
|
|
64
|
+
for (const child of children) {
|
|
65
|
+
await traverseTree(child, item.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
for (const node of tree) {
|
|
70
|
+
await traverseTree(node);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async setElement(id, item, init = false) {
|
|
74
|
+
this.storageMap.set(item.id, item);
|
|
75
|
+
if (!init)
|
|
76
|
+
await this.saveToDB();
|
|
77
|
+
// This like fetch in DB
|
|
78
|
+
return this.findElementById(item.id);
|
|
79
|
+
}
|
|
80
|
+
async removeElementById(id) {
|
|
81
|
+
this.storageMap.delete(id);
|
|
82
|
+
setTimeout(async () => {
|
|
83
|
+
await this.saveToDB();
|
|
84
|
+
}, 500);
|
|
85
|
+
}
|
|
86
|
+
async findElementById(id) {
|
|
87
|
+
return this.storageMap.get(id);
|
|
88
|
+
}
|
|
89
|
+
async findElementByModelId(modelId) {
|
|
90
|
+
const elements = [];
|
|
91
|
+
for (const item of this.storageMap.values()) {
|
|
92
|
+
if (item.modelId === modelId) {
|
|
93
|
+
elements.push(item);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return elements;
|
|
97
|
+
}
|
|
98
|
+
async saveToDB() {
|
|
99
|
+
let tree = await this.buildTree();
|
|
100
|
+
try {
|
|
101
|
+
// Direct call by model adapter
|
|
102
|
+
await this.adminizer.modelHandler.model.get(this.model)["_update"]({ label: this.id }, { tree: tree });
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
console.log(e);
|
|
106
|
+
throw 'navigation model update error';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async findElementsByParentId(parentId, type) {
|
|
110
|
+
const elements = [];
|
|
111
|
+
for (const item of this.storageMap.values()) {
|
|
112
|
+
if (type === null && item.parentId === parentId) {
|
|
113
|
+
elements.push(item);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (item.parentId === parentId && item.type === type) {
|
|
117
|
+
elements.push(item);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return elements;
|
|
121
|
+
}
|
|
122
|
+
async getAllElements() {
|
|
123
|
+
return Array.from(this.storageMap.values());
|
|
124
|
+
}
|
|
125
|
+
async search(s, type) {
|
|
126
|
+
const lowerCaseQuery = s.toLowerCase(); // Convert query to lowercase for case-insensitive search
|
|
127
|
+
const matchedElements = [];
|
|
128
|
+
for (const item of this.storageMap.values()) {
|
|
129
|
+
// Check if item type matches the specified type
|
|
130
|
+
if (item.type === type) {
|
|
131
|
+
// Search by name
|
|
132
|
+
if (item.name.toLowerCase().includes(lowerCaseQuery)) {
|
|
133
|
+
matchedElements.push(item);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return matchedElements;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class StorageServices {
|
|
141
|
+
static storages = [];
|
|
142
|
+
static add(storage) {
|
|
143
|
+
this.storages.push(storage);
|
|
144
|
+
}
|
|
145
|
+
static get(id) {
|
|
146
|
+
return this.storages.find(storage => storage.getId() === id);
|
|
147
|
+
}
|
|
148
|
+
static getAll() {
|
|
149
|
+
return this.storages;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export class Navigation extends AbstractCatalog {
|
|
153
|
+
name = 'Navigation';
|
|
154
|
+
slug = 'navigation';
|
|
155
|
+
icon = "box";
|
|
156
|
+
actionHandlers = [];
|
|
157
|
+
idList = [];
|
|
158
|
+
constructor(adminizer, config) {
|
|
159
|
+
let items = [];
|
|
160
|
+
for (const configElement of config.items) {
|
|
161
|
+
items.push(new NavigationItem(adminizer, configElement.title, configElement.model, config.model, configElement.urlPath));
|
|
162
|
+
}
|
|
163
|
+
items.push(new NavigationGroup(adminizer, config.groupField));
|
|
164
|
+
items.push(new LinkItem(adminizer));
|
|
165
|
+
for (const section of config.sections) {
|
|
166
|
+
StorageServices.add(new StorageService(adminizer, section, config.model));
|
|
167
|
+
}
|
|
168
|
+
super(adminizer, items);
|
|
169
|
+
this.movingGroupsRootOnly = config.movingGroupsRootOnly;
|
|
170
|
+
this.idList = config.sections ?? [];
|
|
171
|
+
}
|
|
172
|
+
async getIdList() {
|
|
173
|
+
return this.idList;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class NavigationItem extends AbstractItem {
|
|
177
|
+
allowedRoot = true;
|
|
178
|
+
icon;
|
|
179
|
+
name;
|
|
180
|
+
type;
|
|
181
|
+
model;
|
|
182
|
+
navigationModel;
|
|
183
|
+
actionHandlers = [];
|
|
184
|
+
urlPath;
|
|
185
|
+
adminizer;
|
|
186
|
+
constructor(adminizer, name, model, navigationModel, urlPath) {
|
|
187
|
+
super();
|
|
188
|
+
this.name = name;
|
|
189
|
+
this.navigationModel = navigationModel;
|
|
190
|
+
this.model = model;
|
|
191
|
+
this.type = model.toLowerCase();
|
|
192
|
+
this.urlPath = urlPath;
|
|
193
|
+
let configModel = adminizer.config.models[this.model];
|
|
194
|
+
this.icon = configModel?.icon ?? 'file_present';
|
|
195
|
+
this.adminizer = adminizer;
|
|
196
|
+
}
|
|
197
|
+
async create(data, catalogId) {
|
|
198
|
+
let storage = StorageServices.get(catalogId);
|
|
199
|
+
let storageData = null;
|
|
200
|
+
if (data._method === 'select') {
|
|
201
|
+
// Direct call by model adapter
|
|
202
|
+
let record = await this.adminizer.modelHandler.model.get(this.model)["_findOne"]({ id: data.record });
|
|
203
|
+
storageData = await this.dataPreparation({
|
|
204
|
+
record: record,
|
|
205
|
+
parentId: data.parentId,
|
|
206
|
+
targetBlank: data.targetBlank
|
|
207
|
+
}, catalogId);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
storageData = await this.dataPreparation(data, catalogId);
|
|
211
|
+
}
|
|
212
|
+
return await storage.setElement(data.id, storageData);
|
|
213
|
+
}
|
|
214
|
+
async dataPreparation(data, catalogId, sortOrder) {
|
|
215
|
+
let storage = StorageServices.get(catalogId);
|
|
216
|
+
let urlPath = eval('`' + this.urlPath + '`');
|
|
217
|
+
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
218
|
+
return {
|
|
219
|
+
id: uuid(),
|
|
220
|
+
modelId: data.record.id,
|
|
221
|
+
targetBlank: data.targetBlank ?? data.record.targetBlank,
|
|
222
|
+
name: data.record.name ?? data.record.title ?? data.record.id,
|
|
223
|
+
parentId: parentId,
|
|
224
|
+
sortOrder: sortOrder ?? (await storage.findElementsByParentId(parentId, null)).length,
|
|
225
|
+
icon: this.icon,
|
|
226
|
+
type: this.type,
|
|
227
|
+
urlPath: urlPath
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async updateModelItems(modelId, data, catalogId) {
|
|
231
|
+
let storage = StorageServices.get(catalogId);
|
|
232
|
+
let items = await storage.findElementByModelId(modelId);
|
|
233
|
+
let urlPath = eval('`' + this.urlPath + '`');
|
|
234
|
+
let response = [];
|
|
235
|
+
for (const item of items) {
|
|
236
|
+
item.name = data.record.name ?? data.record.title ?? data.record.id;
|
|
237
|
+
item.urlPath = urlPath;
|
|
238
|
+
if (item.id === data.record.treeId) {
|
|
239
|
+
item.targetBlank = data.record.targetBlank;
|
|
240
|
+
}
|
|
241
|
+
response.push(await storage.setElement(item.id, item));
|
|
242
|
+
}
|
|
243
|
+
return response[0];
|
|
244
|
+
}
|
|
245
|
+
async update(itemId, data, catalogId) {
|
|
246
|
+
let storage = StorageServices.get(catalogId);
|
|
247
|
+
return await storage.setElement(itemId, data);
|
|
248
|
+
}
|
|
249
|
+
async deleteItem(itemId, catalogId) {
|
|
250
|
+
let storage = StorageServices.get(catalogId);
|
|
251
|
+
return await storage.removeElementById(itemId);
|
|
252
|
+
}
|
|
253
|
+
async find(itemId, catalogId) {
|
|
254
|
+
let storage = StorageServices.get(catalogId);
|
|
255
|
+
return await storage.findElementById(itemId);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated reason: migration for intertia
|
|
259
|
+
* // TODO: need passing custom React module
|
|
260
|
+
*/
|
|
261
|
+
async getAddTemplate(req) {
|
|
262
|
+
let type = 'model';
|
|
263
|
+
// Direct call by model adapter
|
|
264
|
+
let itemsDB = await this.adminizer.modelHandler.model.get(this.model)["_find"]({});
|
|
265
|
+
let items = itemsDB.map((item) => {
|
|
266
|
+
return {
|
|
267
|
+
id: item.id,
|
|
268
|
+
name: item.name ?? item.title ?? item.id
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
type: type,
|
|
273
|
+
data: {
|
|
274
|
+
items: items,
|
|
275
|
+
model: this.model,
|
|
276
|
+
labels: {
|
|
277
|
+
selectTitle: `${req.i18n.__('Select')} ${req.i18n.__(this.name + 's')}`,
|
|
278
|
+
createTitle: `${req.i18n.__('create new')} ${req.i18n.__(this.name + 's')}`,
|
|
279
|
+
OR: req.i18n.__('OR'),
|
|
280
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async getChilds(parentId, catalogId) {
|
|
286
|
+
let storage = StorageServices.get(catalogId);
|
|
287
|
+
return await storage.findElementsByParentId(parentId, this.type);
|
|
288
|
+
}
|
|
289
|
+
async getEditTemplate(id, catalogId, req, modelId) {
|
|
290
|
+
return Promise.resolve({
|
|
291
|
+
type: 'model',
|
|
292
|
+
data: {
|
|
293
|
+
item: await this.find(id, catalogId)
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
async search(s, catalogId) {
|
|
298
|
+
let storage = StorageServices.get(catalogId);
|
|
299
|
+
return await storage.search(s, this.type);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
class NavigationGroup extends AbstractGroup {
|
|
303
|
+
allowedRoot = true;
|
|
304
|
+
name = "Group";
|
|
305
|
+
groupField;
|
|
306
|
+
adminizer;
|
|
307
|
+
constructor(adminizer, groupField) {
|
|
308
|
+
super();
|
|
309
|
+
this.groupField = groupField;
|
|
310
|
+
this.adminizer = adminizer;
|
|
311
|
+
}
|
|
312
|
+
async create(data, catalogId) {
|
|
313
|
+
let storage = StorageServices.get(catalogId);
|
|
314
|
+
let storageData = await this.dataPreparation(data, catalogId);
|
|
315
|
+
delete data.name;
|
|
316
|
+
delete data.parentId;
|
|
317
|
+
storageData = { ...storageData, ...data };
|
|
318
|
+
return await storage.setElement(storageData.id, storageData);
|
|
319
|
+
}
|
|
320
|
+
async dataPreparation(data, catalogId, sortOrder) {
|
|
321
|
+
let storage = StorageServices.get(catalogId);
|
|
322
|
+
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
323
|
+
return {
|
|
324
|
+
id: uuid(),
|
|
325
|
+
name: data.name,
|
|
326
|
+
targetBlank: data.targetBlank,
|
|
327
|
+
parentId: parentId,
|
|
328
|
+
sortOrder: sortOrder ?? (await storage.findElementsByParentId(parentId, null)).length,
|
|
329
|
+
icon: this.icon,
|
|
330
|
+
type: this.type
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
async deleteItem(itemId, catalogId) {
|
|
334
|
+
let storage = StorageServices.get(catalogId);
|
|
335
|
+
return await storage.removeElementById(itemId);
|
|
336
|
+
}
|
|
337
|
+
async find(itemId, catalogId) {
|
|
338
|
+
let storage = StorageServices.get(catalogId);
|
|
339
|
+
return await storage.findElementById(itemId);
|
|
340
|
+
}
|
|
341
|
+
async update(itemId, data, catalogId) {
|
|
342
|
+
let storage = StorageServices.get(catalogId);
|
|
343
|
+
return await storage.setElement(itemId, data);
|
|
344
|
+
}
|
|
345
|
+
async updateModelItems(modelId, data, catalogId) {
|
|
346
|
+
let storage = StorageServices.get(catalogId);
|
|
347
|
+
return await storage.setElement(modelId, data);
|
|
348
|
+
}
|
|
349
|
+
getAddTemplate(req) {
|
|
350
|
+
let type = 'navigation.group';
|
|
351
|
+
let resItems = [];
|
|
352
|
+
if (this.groupField.length) {
|
|
353
|
+
resItems = this.groupField.map((field) => {
|
|
354
|
+
return {
|
|
355
|
+
name: field.name,
|
|
356
|
+
required: field.required
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return Promise.resolve({
|
|
361
|
+
type: type,
|
|
362
|
+
data: {
|
|
363
|
+
items: resItems,
|
|
364
|
+
labels: {
|
|
365
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
366
|
+
title: req.i18n.__('Title'),
|
|
367
|
+
save: req.i18n.__('Save')
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async getEditTemplate(id, catalogId, req, modelId) {
|
|
373
|
+
let item = await this.find(id, catalogId);
|
|
374
|
+
let type = 'navigation.group';
|
|
375
|
+
let resItems = [];
|
|
376
|
+
if (this.groupField.length) {
|
|
377
|
+
resItems = this.groupField.map((field) => {
|
|
378
|
+
return {
|
|
379
|
+
name: field.name,
|
|
380
|
+
required: field.required
|
|
381
|
+
};
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return Promise.resolve({
|
|
385
|
+
type: type,
|
|
386
|
+
data: {
|
|
387
|
+
items: resItems,
|
|
388
|
+
item: item,
|
|
389
|
+
labels: {
|
|
390
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
391
|
+
title: req.i18n.__('Title'),
|
|
392
|
+
save: req.i18n.__('Save')
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async getChilds(parentId, catalogId) {
|
|
398
|
+
let storage = StorageServices.get(catalogId);
|
|
399
|
+
return await storage.findElementsByParentId(parentId, this.type);
|
|
400
|
+
}
|
|
401
|
+
async search(s, catalogId) {
|
|
402
|
+
let storage = StorageServices.get(catalogId);
|
|
403
|
+
return await storage.search(s, this.type);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
class LinkItem extends NavigationGroup {
|
|
407
|
+
allowedRoot = true;
|
|
408
|
+
icon = 'insert_link';
|
|
409
|
+
name = 'Link';
|
|
410
|
+
type = 'link';
|
|
411
|
+
isGroup = false;
|
|
412
|
+
constructor(adminizer) {
|
|
413
|
+
super(adminizer, []);
|
|
414
|
+
}
|
|
415
|
+
getAddTemplate(req) {
|
|
416
|
+
let type = 'navigation.link';
|
|
417
|
+
let resItems = [
|
|
418
|
+
{
|
|
419
|
+
name: req.i18n.__('Link'),
|
|
420
|
+
required: true
|
|
421
|
+
}
|
|
422
|
+
];
|
|
423
|
+
return Promise.resolve({
|
|
424
|
+
type: type,
|
|
425
|
+
data: {
|
|
426
|
+
items: resItems,
|
|
427
|
+
labels: {
|
|
428
|
+
title: req.i18n.__('Title'),
|
|
429
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
430
|
+
save: req.i18n.__('Save')
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
async getEditTemplate(id, catalogId, req) {
|
|
436
|
+
let item = await this.find(id, catalogId);
|
|
437
|
+
let type = 'navigation.group';
|
|
438
|
+
let resItems = [
|
|
439
|
+
{
|
|
440
|
+
name: req.i18n.__('Link'),
|
|
441
|
+
required: true
|
|
442
|
+
}
|
|
443
|
+
];
|
|
444
|
+
return Promise.resolve({
|
|
445
|
+
type: type,
|
|
446
|
+
data: {
|
|
447
|
+
items: resItems,
|
|
448
|
+
item: item,
|
|
449
|
+
labels: {
|
|
450
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
451
|
+
title: req.i18n.__('Title'),
|
|
452
|
+
save: req.i18n.__('Save')
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class MonacoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class GeoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../../Adminizer";
|
|
4
4
|
export declare class JsonEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../../Adminizer";
|
|
4
4
|
export declare class ToastUiEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class Handsontable extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class CKeditor extends AbstractControls {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly type: ControlType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fields } from '
|
|
2
|
-
import { AbstractModel } from '../
|
|
3
|
-
import { DataAccessor } from "../
|
|
1
|
+
import { Fields } from '../../../helpers/fieldsHelper';
|
|
2
|
+
import { AbstractModel } from '../model/AbstractModel';
|
|
3
|
+
import { DataAccessor } from "../DataAccessor";
|
|
4
4
|
interface Request {
|
|
5
5
|
start: string;
|
|
6
6
|
length: string;
|
|
@@ -131,8 +131,8 @@ export class NodeTable {
|
|
|
131
131
|
async output(callback, dataAccessor) {
|
|
132
132
|
try {
|
|
133
133
|
const queryOptions = await this.buildQuery();
|
|
134
|
-
const totalRecords = await this.model.count({});
|
|
135
|
-
const filteredRecords = await this.model.count(queryOptions.where);
|
|
134
|
+
const totalRecords = await this.model.count({}, dataAccessor);
|
|
135
|
+
const filteredRecords = await this.model.count(queryOptions.where, dataAccessor);
|
|
136
136
|
const data = await this.model.find(queryOptions, dataAccessor);
|
|
137
137
|
const output = {
|
|
138
138
|
draw: this.request.draw !== "" ? this.request.draw : 0,
|
|
@@ -160,6 +160,9 @@ export class NodeTable {
|
|
|
160
160
|
Object.keys(this.fields).forEach((key) => {
|
|
161
161
|
let fieldConfigConfig = this.fields[key].config;
|
|
162
162
|
let fieldName = key;
|
|
163
|
+
let displayField = this.fields[key].modelConfig?.titleField ?? typeof row["title"] !== "undefined" ? 'title'
|
|
164
|
+
: typeof row["name"] !== "undefined" ? 'name'
|
|
165
|
+
: typeof row[this.fields[key].modelConfig?.identifierField] !== "undefined" ? this.fields[key].modelConfig?.identifierField : this.fields[key].modelConfig?.identifierField;
|
|
163
166
|
if (fieldConfigConfig.displayModifier) {
|
|
164
167
|
row[fieldName] = fieldConfigConfig.displayModifier(elem[key]);
|
|
165
168
|
}
|
|
@@ -169,7 +172,7 @@ export class NodeTable {
|
|
|
169
172
|
row[fieldName] = null;
|
|
170
173
|
}
|
|
171
174
|
else {
|
|
172
|
-
row[fieldName] = elem[key][
|
|
175
|
+
row[fieldName] = elem[key][displayField];
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
else if (this.fields[key].model.type === "association-many" || this.fields[key].model.type === "association") {
|
|
@@ -179,8 +182,8 @@ export class NodeTable {
|
|
|
179
182
|
else {
|
|
180
183
|
let displayValues = [];
|
|
181
184
|
elem[key].forEach((item) => {
|
|
182
|
-
if (item[
|
|
183
|
-
displayValues.push(item[
|
|
185
|
+
if (item[displayField]) {
|
|
186
|
+
displayValues.push(item[displayField]);
|
|
184
187
|
}
|
|
185
188
|
else {
|
|
186
189
|
displayValues.push(item[fieldConfigConfig.identifierField]);
|
|
@@ -10,6 +10,10 @@ export interface Attribute {
|
|
|
10
10
|
collection?: string;
|
|
11
11
|
via?: string;
|
|
12
12
|
allowNull?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* This is a field that indicates that it refers to keep the bond key 1: 1
|
|
15
|
+
*/
|
|
16
|
+
primaryKeyForAssociation?: boolean;
|
|
13
17
|
}
|
|
14
18
|
export interface ModelAttributes {
|
|
15
19
|
[key: string]: Attribute;
|
|
@@ -49,7 +53,7 @@ export declare abstract class AbstractModel<T> {
|
|
|
49
53
|
update(criteria: Partial<T>, data: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T>[]>;
|
|
50
54
|
destroyOne(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T> | null>;
|
|
51
55
|
destroy(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T>[]>;
|
|
52
|
-
count(criteria: Partial<T> | undefined): Promise<number>;
|
|
56
|
+
count(criteria: Partial<T> | undefined, dataAccessor: DataAccessor): Promise<number>;
|
|
53
57
|
}
|
|
54
58
|
export declare abstract class AbstractAdapter {
|
|
55
59
|
abstract Model: any;
|
|
@@ -46,7 +46,8 @@ export class AbstractModel {
|
|
|
46
46
|
let records = await this._destroy(criteria);
|
|
47
47
|
return records.map(record => dataAccessor.process(record));
|
|
48
48
|
}
|
|
49
|
-
async count(criteria) {
|
|
49
|
+
async count(criteria, dataAccessor) {
|
|
50
|
+
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
50
51
|
return this._count(criteria);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -3,12 +3,10 @@ export class ModelHandler {
|
|
|
3
3
|
models = new Map();
|
|
4
4
|
add(modelName, modelInstance) {
|
|
5
5
|
const modelname = modelName.toLowerCase();
|
|
6
|
-
if (this.models.has(modelname)) {
|
|
7
|
-
throw new Error(`Model "${modelname}" is already registered.`);
|
|
8
|
-
}
|
|
9
6
|
this.models.set(modelname, modelInstance);
|
|
10
7
|
Adminizer.log.debug(`Model with name [${modelname}] was registered`);
|
|
11
8
|
}
|
|
9
|
+
// TODO: 'hot reload' need add method for delete model
|
|
12
10
|
/** Improved model getter, so you can write both model.get("UserAP") and model.get("userap") */
|
|
13
11
|
get model() {
|
|
14
12
|
return {
|
|
@@ -4,6 +4,14 @@ export declare function mapSequelizeToWaterline(model: ModelStatic<any>): Record
|
|
|
4
4
|
export declare class SequelizeModel<T> extends AbstractModel<T> {
|
|
5
5
|
private model;
|
|
6
6
|
constructor(modelName: string, model: ModelStatic<any>);
|
|
7
|
+
_convertCriteriaToSequelize(criteria: any): any;
|
|
8
|
+
_convertWaterlineCriteriaToSequelizeOptions(criteria: any): {
|
|
9
|
+
where?: any;
|
|
10
|
+
limit?: number;
|
|
11
|
+
offset?: number;
|
|
12
|
+
order?: any[];
|
|
13
|
+
};
|
|
14
|
+
_assignAssociations(instance: any, assocData: Record<string, any>): Promise<void>;
|
|
7
15
|
protected _create(data: Record<string, any>): Promise<T>;
|
|
8
16
|
protected _findOne(criteria: Partial<T>): Promise<T | null>;
|
|
9
17
|
protected _find(criteria?: Partial<T>, options?: FindOptions): Promise<T[]>;
|