not-node 5.1.12 → 5.1.15
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
package/src/bootstrap/route.js
CHANGED
|
@@ -79,12 +79,20 @@ module.exports = ({
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const getForm = (actionName) => {
|
|
83
|
+
const form = getApp().getForm(
|
|
84
|
+
[MODULE_NAME, `${MODEL_NAME}.${actionName}`].join("//")
|
|
85
|
+
);
|
|
86
|
+
if (form) {
|
|
87
|
+
return form;
|
|
88
|
+
}
|
|
89
|
+
return getApp().getForm([MODULE_NAME, actionName].join("//"));
|
|
90
|
+
};
|
|
91
|
+
|
|
82
92
|
const beforeDecorator = async (req, res, next) => {
|
|
83
93
|
const actionName = req.notRouteData.actionName;
|
|
84
94
|
const trimmedActionName = actionName.replace("_", "");
|
|
85
|
-
const FormValidator =
|
|
86
|
-
[MODULE_NAME, trimmedActionName].join("//")
|
|
87
|
-
);
|
|
95
|
+
const FormValidator = getForm(trimmedActionName);
|
|
88
96
|
if (FormValidator) {
|
|
89
97
|
const prepared = await FormValidator.run(req, res, next);
|
|
90
98
|
checkAccessRules(trimmedActionName, prepared);
|
package/src/core/locales/en.json
CHANGED
|
@@ -63,5 +63,6 @@
|
|
|
63
63
|
"crud_update_action_waiting": "Updating record...",
|
|
64
64
|
"crud_delete_action_waiting": "Deleting record...",
|
|
65
65
|
"add_label": "Add",
|
|
66
|
-
"select_from_list_label": "Select from list..."
|
|
66
|
+
"select_from_list_label": "Select from list...",
|
|
67
|
+
"field_actions_label": "Actions"
|
|
67
68
|
}
|
package/src/core/locales/ru.json
CHANGED
|
@@ -62,6 +62,8 @@
|
|
|
62
62
|
"crud_update_action_waiting": "Обновление записи...",
|
|
63
63
|
"crud_delete_action_waiting": "Удаление записи...",
|
|
64
64
|
"add_label": "Добавить",
|
|
65
|
-
"select_from_list_label": "Выберите из списка..."
|
|
65
|
+
"select_from_list_label": "Выберите из списка...",
|
|
66
|
+
"field_actions_label": "Действия"
|
|
67
|
+
|
|
66
68
|
|
|
67
69
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const Form = require("../form/form");
|
|
2
|
+
const { firstLetterToUpper } = require("../common");
|
|
3
|
+
const { getIP } = require("../auth");
|
|
4
|
+
const notFilter = require("not-filter");
|
|
5
|
+
const getApp = require("../getApp");
|
|
6
|
+
|
|
7
|
+
const FIELDS = [
|
|
8
|
+
["query", `not-filter//_filterQuery`],
|
|
9
|
+
["activeUserId", { required: true }, "not-node//objectId"],
|
|
10
|
+
["activeUser", "not-node//requiredObject"],
|
|
11
|
+
["ip", "not-node//ip"],
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
module.exports = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
|
|
15
|
+
const FORM_NAME = `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
|
|
16
|
+
actionName
|
|
17
|
+
)}Form`;
|
|
18
|
+
return class extends Form {
|
|
19
|
+
constructor({ app }) {
|
|
20
|
+
super({ FIELDS, FORM_NAME, app });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
extract(req) {
|
|
24
|
+
const thisSchema = getApp().getModelSchema(
|
|
25
|
+
`${MODULE_NAME}//${MODEL_NAME}`
|
|
26
|
+
);
|
|
27
|
+
const { skip, size } = notFilter.pager.process(req), //skip,size
|
|
28
|
+
sorter = notFilter.sorter.process(req, thisSchema),
|
|
29
|
+
search = notFilter.search.process(req, thisSchema);
|
|
30
|
+
let filter = notFilter.filter.process(req, thisSchema);
|
|
31
|
+
|
|
32
|
+
if (!req.user.isRoot() && !req.user.isAdmin()) {
|
|
33
|
+
filter = notFilter.filter.modifyRules(filter, {
|
|
34
|
+
owner: req.user._id,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
query: {
|
|
40
|
+
skip,
|
|
41
|
+
size,
|
|
42
|
+
sorter,
|
|
43
|
+
filter,
|
|
44
|
+
search,
|
|
45
|
+
},
|
|
46
|
+
activeUser: req.user,
|
|
47
|
+
activeUserId: req.user._id,
|
|
48
|
+
ip: getIP(req),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
package/src/generic/index.js
CHANGED