not-options 0.1.38 → 0.2.0
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 +2 -2
- package/src/controllers/common/import.svelte +2 -1
- package/src/controllers/common/validators.js +1 -1
- package/src/controllers/root/index.js +1 -4
- package/src/controllers/root/ncOptions.js +6 -2
- package/src/models/options.js +9 -5
- package/src/routes/options.js +15 -1
- package/src/routes/options.manifest.js +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "not-options",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "not-* family options model in not- environment",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint": "*",
|
|
35
35
|
"ink-docstrap": "^1.3.2",
|
|
36
36
|
"istanbul": "*",
|
|
37
|
-
"jsdoc": "^3.6.
|
|
37
|
+
"jsdoc": "^3.6.7",
|
|
38
38
|
"mocha": "*"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import Validators from '../common/validators.js';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
Frame
|
|
4
4
|
} from 'not-bulma';
|
|
5
5
|
|
|
6
|
+
const notCRUD = Frame.notCRUD;
|
|
7
|
+
|
|
6
8
|
import UIImport from '../common/import.svelte';
|
|
7
9
|
|
|
8
10
|
const LABELS = {
|
|
@@ -12,7 +14,9 @@ const LABELS = {
|
|
|
12
14
|
|
|
13
15
|
const MODEL = 'options';
|
|
14
16
|
|
|
15
|
-
class ncOptions extends
|
|
17
|
+
class ncOptions extends notCRUD {
|
|
18
|
+
static MODEL_NAME = MODEL;
|
|
19
|
+
static MODULE_NAME = '';
|
|
16
20
|
constructor(app, params, schemes) {
|
|
17
21
|
super(app, MODEL);
|
|
18
22
|
this.setModuleName('');
|
package/src/models/options.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const log = require('not-log')(module, 'Options Model');
|
|
2
2
|
try {
|
|
3
3
|
const MODEL_NAME = 'Options';
|
|
4
|
-
const initFields = require('not-node').Fields.initFields;
|
|
5
4
|
const Increment = require('not-node').Increment;
|
|
6
5
|
const notError = require('not-error').notError;
|
|
7
6
|
|
|
@@ -13,12 +12,15 @@ try {
|
|
|
13
12
|
{
|
|
14
13
|
default: true
|
|
15
14
|
}
|
|
16
|
-
]
|
|
15
|
+
],
|
|
16
|
+
'createdAt',
|
|
17
|
+
'updatedAt'
|
|
17
18
|
];
|
|
18
19
|
|
|
20
|
+
exports.FIELDS = FIELDS;
|
|
21
|
+
|
|
19
22
|
exports.keepNotExtended = false;
|
|
20
23
|
exports.thisModelName = MODEL_NAME;
|
|
21
|
-
exports.thisSchema = initFields(FIELDS, 'model');
|
|
22
24
|
|
|
23
25
|
exports.enrich = {
|
|
24
26
|
versioning: true,
|
|
@@ -72,6 +74,7 @@ try {
|
|
|
72
74
|
__closed: false
|
|
73
75
|
}, {
|
|
74
76
|
value,
|
|
77
|
+
updatedAt: Date.now()
|
|
75
78
|
}).exec();
|
|
76
79
|
let item = await this.findOne({
|
|
77
80
|
id: name,
|
|
@@ -87,10 +90,11 @@ try {
|
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
} else {
|
|
90
|
-
this.add({
|
|
93
|
+
return this.add({
|
|
91
94
|
id: name,
|
|
92
95
|
value,
|
|
93
|
-
active: true
|
|
96
|
+
active: true,
|
|
97
|
+
updatedAt: Date.now()
|
|
94
98
|
});
|
|
95
99
|
}
|
|
96
100
|
},
|
package/src/routes/options.js
CHANGED
|
@@ -240,8 +240,22 @@ exports._updateForModule = async (req, res) => {
|
|
|
240
240
|
throw new Error('moduleName is now valid');
|
|
241
241
|
}
|
|
242
242
|
const notApp = notNode.Application;
|
|
243
|
-
await notApp.getModel(MODEL_NAME).writeModuleOptions(moduleName, options);
|
|
243
|
+
const result = await notApp.getModel(MODEL_NAME).writeModuleOptions(moduleName, options);
|
|
244
244
|
notNode.Application.emit(`module:${moduleName}:options:updated`);
|
|
245
|
+
const information = {
|
|
246
|
+
recipient:{
|
|
247
|
+
role: 'root'
|
|
248
|
+
},
|
|
249
|
+
tags: ['moduleOptionsUpdated'],
|
|
250
|
+
userId,
|
|
251
|
+
username: req.user.username,
|
|
252
|
+
userRole: req.user.role.toString(),
|
|
253
|
+
updatedAt: result.updatedAt,
|
|
254
|
+
moduleName
|
|
255
|
+
};
|
|
256
|
+
setTimeout(()=>{
|
|
257
|
+
notNode.Application.inform(information);
|
|
258
|
+
}, 1000);
|
|
245
259
|
res.status(200).json({
|
|
246
260
|
status: 'ok'
|
|
247
261
|
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const modelSchema = require('../models/options').thisSchema;
|
|
3
|
-
|
|
4
|
-
const FIELDS = initFromSchema(modelSchema, [
|
|
1
|
+
const FIELDS = [
|
|
5
2
|
'_id',
|
|
6
3
|
['optionsID', {}, 'ID'],
|
|
7
|
-
]
|
|
4
|
+
];
|
|
8
5
|
|
|
9
6
|
module.exports = {
|
|
10
7
|
model: 'options',
|