@magda/org-tree 2.3.3 → 3.0.0-alpha.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/dist/getNodeIdFromNameOrId.js +21 -0
- package/dist/getUserIdFromNameOrId.js +24 -0
- package/dist/index.js +4466 -0
- package/dist/org-tree-assign.js +13563 -0
- package/dist/org-tree-create.js +13524 -0
- package/dist/org-tree-delete.js +13549 -0
- package/dist/org-tree-insert.js +13545 -0
- package/dist/org-tree-move.js +13543 -0
- package/dist/org-tree-unassign.js +4495 -0
- package/dist/org-tree-view.js +13511 -0
- package/package.json +23 -19
- package/bin/db/getDBConfig.js +0 -19
- package/bin/db/getDBPool.js +0 -13
- package/bin/org-tree/NestedSetModelQueryer.js +0 -19718
- package/bin/org-tree/getNodeIdFromNameOrId.js +0 -134
- package/bin/org-tree/getUserIdFromNameOrId.js +0 -137
- package/bin/org-tree/org-tree-assign.js +0 -220
- package/bin/org-tree/org-tree-create.js +0 -180
- package/bin/org-tree/org-tree-delete.js +0 -206
- package/bin/org-tree/org-tree-insert.js +0 -200
- package/bin/org-tree/org-tree-move.js +0 -202
- package/bin/org-tree/org-tree-unassign.js +0 -197
- package/bin/org-tree/org-tree-view.js +0 -168
- package/bin/org-tree/org-tree.js +0 -199
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
|
-
module.exports = factory();
|
|
5
|
-
else if(typeof define === 'function' && define.amd)
|
|
6
|
-
define([], factory);
|
|
7
|
-
else {
|
|
8
|
-
var a = factory();
|
|
9
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
10
|
-
}
|
|
11
|
-
})(global, function() {
|
|
12
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
13
|
-
/******/ // The module cache
|
|
14
|
-
/******/ var installedModules = {};
|
|
15
|
-
/******/
|
|
16
|
-
/******/ // The require function
|
|
17
|
-
/******/ function __webpack_require__(moduleId) {
|
|
18
|
-
/******/
|
|
19
|
-
/******/ // Check if module is in cache
|
|
20
|
-
/******/ if(installedModules[moduleId]) {
|
|
21
|
-
/******/ return installedModules[moduleId].exports;
|
|
22
|
-
/******/ }
|
|
23
|
-
/******/ // Create a new module (and put it into the cache)
|
|
24
|
-
/******/ var module = installedModules[moduleId] = {
|
|
25
|
-
/******/ i: moduleId,
|
|
26
|
-
/******/ l: false,
|
|
27
|
-
/******/ exports: {}
|
|
28
|
-
/******/ };
|
|
29
|
-
/******/
|
|
30
|
-
/******/ // Execute the module function
|
|
31
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
32
|
-
/******/
|
|
33
|
-
/******/ // Flag the module as loaded
|
|
34
|
-
/******/ module.l = true;
|
|
35
|
-
/******/
|
|
36
|
-
/******/ // Return the exports of the module
|
|
37
|
-
/******/ return module.exports;
|
|
38
|
-
/******/ }
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
42
|
-
/******/ __webpack_require__.m = modules;
|
|
43
|
-
/******/
|
|
44
|
-
/******/ // expose the module cache
|
|
45
|
-
/******/ __webpack_require__.c = installedModules;
|
|
46
|
-
/******/
|
|
47
|
-
/******/ // define getter function for harmony exports
|
|
48
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
49
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
50
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
51
|
-
/******/ }
|
|
52
|
-
/******/ };
|
|
53
|
-
/******/
|
|
54
|
-
/******/ // define __esModule on exports
|
|
55
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
56
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
57
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
58
|
-
/******/ }
|
|
59
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
60
|
-
/******/ };
|
|
61
|
-
/******/
|
|
62
|
-
/******/ // create a fake namespace object
|
|
63
|
-
/******/ // mode & 1: value is a module id, require it
|
|
64
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
65
|
-
/******/ // mode & 4: return value when already ns object
|
|
66
|
-
/******/ // mode & 8|1: behave like require
|
|
67
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
68
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
69
|
-
/******/ if(mode & 8) return value;
|
|
70
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
71
|
-
/******/ var ns = Object.create(null);
|
|
72
|
-
/******/ __webpack_require__.r(ns);
|
|
73
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
74
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
75
|
-
/******/ return ns;
|
|
76
|
-
/******/ };
|
|
77
|
-
/******/
|
|
78
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
79
|
-
/******/ __webpack_require__.n = function(module) {
|
|
80
|
-
/******/ var getter = module && module.__esModule ?
|
|
81
|
-
/******/ function getDefault() { return module['default']; } :
|
|
82
|
-
/******/ function getModuleExports() { return module; };
|
|
83
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
84
|
-
/******/ return getter;
|
|
85
|
-
/******/ };
|
|
86
|
-
/******/
|
|
87
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
88
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
89
|
-
/******/
|
|
90
|
-
/******/ // __webpack_public_path__
|
|
91
|
-
/******/ __webpack_require__.p = "";
|
|
92
|
-
/******/
|
|
93
|
-
/******/
|
|
94
|
-
/******/ // Load entry module and return exports
|
|
95
|
-
/******/ return __webpack_require__(__webpack_require__.s = 23);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ({
|
|
99
|
-
|
|
100
|
-
/***/ 0:
|
|
101
|
-
/***/ (function(module, exports) {
|
|
102
|
-
|
|
103
|
-
module.exports = require("../../package.json");
|
|
104
|
-
|
|
105
|
-
/***/ }),
|
|
106
|
-
|
|
107
|
-
/***/ 1:
|
|
108
|
-
/***/ (function(module, exports) {
|
|
109
|
-
|
|
110
|
-
module.exports = require("commander");
|
|
111
|
-
|
|
112
|
-
/***/ }),
|
|
113
|
-
|
|
114
|
-
/***/ 2:
|
|
115
|
-
/***/ (function(module, exports) {
|
|
116
|
-
|
|
117
|
-
module.exports = require("chalk");
|
|
118
|
-
|
|
119
|
-
/***/ }),
|
|
120
|
-
|
|
121
|
-
/***/ 23:
|
|
122
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const pkg = __webpack_require__(0);
|
|
126
|
-
const program = __webpack_require__(1);
|
|
127
|
-
const chalk = __webpack_require__(2);
|
|
128
|
-
const NestedSetModelQueryer = __webpack_require__(3)
|
|
129
|
-
.default;
|
|
130
|
-
const getDBPool = __webpack_require__(4);
|
|
131
|
-
const getNodeIdFromNameOrId = __webpack_require__(5);
|
|
132
|
-
|
|
133
|
-
program
|
|
134
|
-
.description(
|
|
135
|
-
"Delete the node specified and all its dependents from the tree." +
|
|
136
|
-
"\nIf the node name is given instead of the node Id, the first located node (and its dependents) will be removed." +
|
|
137
|
-
"\nIf -o or --only switch is on, only specified node will be removed and its children (if any) " +
|
|
138
|
-
"will become its parent's children."
|
|
139
|
-
)
|
|
140
|
-
.option("<nodeNameOrId>", "node name or id that to be removed")
|
|
141
|
-
.option(
|
|
142
|
-
"-o, --only",
|
|
143
|
-
"If only remove specified node and left its children (if any) to its parent"
|
|
144
|
-
)
|
|
145
|
-
.version(pkg.version)
|
|
146
|
-
.action(async (nodeNameOrId) => {
|
|
147
|
-
try {
|
|
148
|
-
if (!process.argv.slice(2).length) {
|
|
149
|
-
program.help();
|
|
150
|
-
}
|
|
151
|
-
const options = program.opts();
|
|
152
|
-
nodeNameOrId = nodeNameOrId ? nodeNameOrId.trim() : "";
|
|
153
|
-
if (nodeNameOrId === "")
|
|
154
|
-
throw new Error("Node Name or Id can't be empty!");
|
|
155
|
-
const pool = getDBPool();
|
|
156
|
-
const queryer = new NestedSetModelQueryer(pool, "org_units");
|
|
157
|
-
|
|
158
|
-
const nodeId = await getNodeIdFromNameOrId(nodeNameOrId, queryer);
|
|
159
|
-
if (options.only) {
|
|
160
|
-
await queryer.deleteNode(nodeId);
|
|
161
|
-
console.log(
|
|
162
|
-
chalk.green(
|
|
163
|
-
`A node with id: ${nodeId} has been deleted from the tree.`
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
} else {
|
|
167
|
-
await queryer.deleteSubTree(nodeId);
|
|
168
|
-
console.log(
|
|
169
|
-
chalk.green(
|
|
170
|
-
`A node with id: ${nodeId} and all its children have been deleted from the tree.`
|
|
171
|
-
)
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
} catch (e) {
|
|
175
|
-
console.error(chalk.red(`Error: ${e}`));
|
|
176
|
-
}
|
|
177
|
-
process.exit(0);
|
|
178
|
-
})
|
|
179
|
-
.parse(process.argv);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
/***/ }),
|
|
183
|
-
|
|
184
|
-
/***/ 3:
|
|
185
|
-
/***/ (function(module, exports) {
|
|
186
|
-
|
|
187
|
-
module.exports = require("./NestedSetModelQueryer");
|
|
188
|
-
|
|
189
|
-
/***/ }),
|
|
190
|
-
|
|
191
|
-
/***/ 4:
|
|
192
|
-
/***/ (function(module, exports) {
|
|
193
|
-
|
|
194
|
-
module.exports = require("../db/getDBPool");
|
|
195
|
-
|
|
196
|
-
/***/ }),
|
|
197
|
-
|
|
198
|
-
/***/ 5:
|
|
199
|
-
/***/ (function(module, exports) {
|
|
200
|
-
|
|
201
|
-
module.exports = require("./getNodeIdFromNameOrId");
|
|
202
|
-
|
|
203
|
-
/***/ })
|
|
204
|
-
|
|
205
|
-
/******/ });
|
|
206
|
-
});
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
|
-
module.exports = factory();
|
|
5
|
-
else if(typeof define === 'function' && define.amd)
|
|
6
|
-
define([], factory);
|
|
7
|
-
else {
|
|
8
|
-
var a = factory();
|
|
9
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
10
|
-
}
|
|
11
|
-
})(global, function() {
|
|
12
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
13
|
-
/******/ // The module cache
|
|
14
|
-
/******/ var installedModules = {};
|
|
15
|
-
/******/
|
|
16
|
-
/******/ // The require function
|
|
17
|
-
/******/ function __webpack_require__(moduleId) {
|
|
18
|
-
/******/
|
|
19
|
-
/******/ // Check if module is in cache
|
|
20
|
-
/******/ if(installedModules[moduleId]) {
|
|
21
|
-
/******/ return installedModules[moduleId].exports;
|
|
22
|
-
/******/ }
|
|
23
|
-
/******/ // Create a new module (and put it into the cache)
|
|
24
|
-
/******/ var module = installedModules[moduleId] = {
|
|
25
|
-
/******/ i: moduleId,
|
|
26
|
-
/******/ l: false,
|
|
27
|
-
/******/ exports: {}
|
|
28
|
-
/******/ };
|
|
29
|
-
/******/
|
|
30
|
-
/******/ // Execute the module function
|
|
31
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
32
|
-
/******/
|
|
33
|
-
/******/ // Flag the module as loaded
|
|
34
|
-
/******/ module.l = true;
|
|
35
|
-
/******/
|
|
36
|
-
/******/ // Return the exports of the module
|
|
37
|
-
/******/ return module.exports;
|
|
38
|
-
/******/ }
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
42
|
-
/******/ __webpack_require__.m = modules;
|
|
43
|
-
/******/
|
|
44
|
-
/******/ // expose the module cache
|
|
45
|
-
/******/ __webpack_require__.c = installedModules;
|
|
46
|
-
/******/
|
|
47
|
-
/******/ // define getter function for harmony exports
|
|
48
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
49
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
50
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
51
|
-
/******/ }
|
|
52
|
-
/******/ };
|
|
53
|
-
/******/
|
|
54
|
-
/******/ // define __esModule on exports
|
|
55
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
56
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
57
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
58
|
-
/******/ }
|
|
59
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
60
|
-
/******/ };
|
|
61
|
-
/******/
|
|
62
|
-
/******/ // create a fake namespace object
|
|
63
|
-
/******/ // mode & 1: value is a module id, require it
|
|
64
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
65
|
-
/******/ // mode & 4: return value when already ns object
|
|
66
|
-
/******/ // mode & 8|1: behave like require
|
|
67
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
68
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
69
|
-
/******/ if(mode & 8) return value;
|
|
70
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
71
|
-
/******/ var ns = Object.create(null);
|
|
72
|
-
/******/ __webpack_require__.r(ns);
|
|
73
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
74
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
75
|
-
/******/ return ns;
|
|
76
|
-
/******/ };
|
|
77
|
-
/******/
|
|
78
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
79
|
-
/******/ __webpack_require__.n = function(module) {
|
|
80
|
-
/******/ var getter = module && module.__esModule ?
|
|
81
|
-
/******/ function getDefault() { return module['default']; } :
|
|
82
|
-
/******/ function getModuleExports() { return module; };
|
|
83
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
84
|
-
/******/ return getter;
|
|
85
|
-
/******/ };
|
|
86
|
-
/******/
|
|
87
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
88
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
89
|
-
/******/
|
|
90
|
-
/******/ // __webpack_public_path__
|
|
91
|
-
/******/ __webpack_require__.p = "";
|
|
92
|
-
/******/
|
|
93
|
-
/******/
|
|
94
|
-
/******/ // Load entry module and return exports
|
|
95
|
-
/******/ return __webpack_require__(__webpack_require__.s = 24);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ({
|
|
99
|
-
|
|
100
|
-
/***/ 0:
|
|
101
|
-
/***/ (function(module, exports) {
|
|
102
|
-
|
|
103
|
-
module.exports = require("../../package.json");
|
|
104
|
-
|
|
105
|
-
/***/ }),
|
|
106
|
-
|
|
107
|
-
/***/ 1:
|
|
108
|
-
/***/ (function(module, exports) {
|
|
109
|
-
|
|
110
|
-
module.exports = require("commander");
|
|
111
|
-
|
|
112
|
-
/***/ }),
|
|
113
|
-
|
|
114
|
-
/***/ 2:
|
|
115
|
-
/***/ (function(module, exports) {
|
|
116
|
-
|
|
117
|
-
module.exports = require("chalk");
|
|
118
|
-
|
|
119
|
-
/***/ }),
|
|
120
|
-
|
|
121
|
-
/***/ 24:
|
|
122
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const pkg = __webpack_require__(0);
|
|
126
|
-
const program = __webpack_require__(1);
|
|
127
|
-
const chalk = __webpack_require__(2);
|
|
128
|
-
const NestedSetModelQueryer = __webpack_require__(3)
|
|
129
|
-
.default;
|
|
130
|
-
const getDBPool = __webpack_require__(4);
|
|
131
|
-
const getNodeIdFromNameOrId = __webpack_require__(5);
|
|
132
|
-
|
|
133
|
-
program
|
|
134
|
-
.description(
|
|
135
|
-
"Insert a node as a child node of the specified the parent node with specified name. " +
|
|
136
|
-
"\nIf the parent node name is given instead of the parent node Id, the newly created child node will be inserted to the first located parent node."
|
|
137
|
-
)
|
|
138
|
-
.option("<parentNodeNameOrId>", "parent node id or name")
|
|
139
|
-
.option("<nodeName>", "insert node name")
|
|
140
|
-
.version(pkg.version)
|
|
141
|
-
.action(async (parentNodeNameOrId, nodeName) => {
|
|
142
|
-
try {
|
|
143
|
-
if (process.argv.slice(2).length < 2) {
|
|
144
|
-
program.help();
|
|
145
|
-
}
|
|
146
|
-
nodeName = nodeName ? nodeName.trim() : "";
|
|
147
|
-
if (nodeName === "") throw new Error("Node Name can't be empty!");
|
|
148
|
-
parentNodeNameOrId = parentNodeNameOrId
|
|
149
|
-
? parentNodeNameOrId.trim()
|
|
150
|
-
: "";
|
|
151
|
-
if (parentNodeNameOrId === "")
|
|
152
|
-
throw new Error("Parent Node Name or Id can't be empty!");
|
|
153
|
-
const pool = getDBPool();
|
|
154
|
-
const queryer = new NestedSetModelQueryer(pool, "org_units");
|
|
155
|
-
|
|
156
|
-
const parentNodeId = await getNodeIdFromNameOrId(
|
|
157
|
-
parentNodeNameOrId,
|
|
158
|
-
queryer
|
|
159
|
-
);
|
|
160
|
-
const nodeId = await queryer.insertNode(parentNodeId, {
|
|
161
|
-
name: nodeName
|
|
162
|
-
});
|
|
163
|
-
console.log(
|
|
164
|
-
chalk.green(
|
|
165
|
-
`A node with name: ${nodeName} has been inserted to parent node. \n Id: ${nodeId}`
|
|
166
|
-
)
|
|
167
|
-
);
|
|
168
|
-
} catch (e) {
|
|
169
|
-
console.error(chalk.red(`Error: ${e}`));
|
|
170
|
-
}
|
|
171
|
-
process.exit(0);
|
|
172
|
-
})
|
|
173
|
-
.parse(process.argv);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
/***/ }),
|
|
177
|
-
|
|
178
|
-
/***/ 3:
|
|
179
|
-
/***/ (function(module, exports) {
|
|
180
|
-
|
|
181
|
-
module.exports = require("./NestedSetModelQueryer");
|
|
182
|
-
|
|
183
|
-
/***/ }),
|
|
184
|
-
|
|
185
|
-
/***/ 4:
|
|
186
|
-
/***/ (function(module, exports) {
|
|
187
|
-
|
|
188
|
-
module.exports = require("../db/getDBPool");
|
|
189
|
-
|
|
190
|
-
/***/ }),
|
|
191
|
-
|
|
192
|
-
/***/ 5:
|
|
193
|
-
/***/ (function(module, exports) {
|
|
194
|
-
|
|
195
|
-
module.exports = require("./getNodeIdFromNameOrId");
|
|
196
|
-
|
|
197
|
-
/***/ })
|
|
198
|
-
|
|
199
|
-
/******/ });
|
|
200
|
-
});
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
|
-
module.exports = factory();
|
|
5
|
-
else if(typeof define === 'function' && define.amd)
|
|
6
|
-
define([], factory);
|
|
7
|
-
else {
|
|
8
|
-
var a = factory();
|
|
9
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
10
|
-
}
|
|
11
|
-
})(global, function() {
|
|
12
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
13
|
-
/******/ // The module cache
|
|
14
|
-
/******/ var installedModules = {};
|
|
15
|
-
/******/
|
|
16
|
-
/******/ // The require function
|
|
17
|
-
/******/ function __webpack_require__(moduleId) {
|
|
18
|
-
/******/
|
|
19
|
-
/******/ // Check if module is in cache
|
|
20
|
-
/******/ if(installedModules[moduleId]) {
|
|
21
|
-
/******/ return installedModules[moduleId].exports;
|
|
22
|
-
/******/ }
|
|
23
|
-
/******/ // Create a new module (and put it into the cache)
|
|
24
|
-
/******/ var module = installedModules[moduleId] = {
|
|
25
|
-
/******/ i: moduleId,
|
|
26
|
-
/******/ l: false,
|
|
27
|
-
/******/ exports: {}
|
|
28
|
-
/******/ };
|
|
29
|
-
/******/
|
|
30
|
-
/******/ // Execute the module function
|
|
31
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
32
|
-
/******/
|
|
33
|
-
/******/ // Flag the module as loaded
|
|
34
|
-
/******/ module.l = true;
|
|
35
|
-
/******/
|
|
36
|
-
/******/ // Return the exports of the module
|
|
37
|
-
/******/ return module.exports;
|
|
38
|
-
/******/ }
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
42
|
-
/******/ __webpack_require__.m = modules;
|
|
43
|
-
/******/
|
|
44
|
-
/******/ // expose the module cache
|
|
45
|
-
/******/ __webpack_require__.c = installedModules;
|
|
46
|
-
/******/
|
|
47
|
-
/******/ // define getter function for harmony exports
|
|
48
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
49
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
50
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
51
|
-
/******/ }
|
|
52
|
-
/******/ };
|
|
53
|
-
/******/
|
|
54
|
-
/******/ // define __esModule on exports
|
|
55
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
56
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
57
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
58
|
-
/******/ }
|
|
59
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
60
|
-
/******/ };
|
|
61
|
-
/******/
|
|
62
|
-
/******/ // create a fake namespace object
|
|
63
|
-
/******/ // mode & 1: value is a module id, require it
|
|
64
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
65
|
-
/******/ // mode & 4: return value when already ns object
|
|
66
|
-
/******/ // mode & 8|1: behave like require
|
|
67
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
68
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
69
|
-
/******/ if(mode & 8) return value;
|
|
70
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
71
|
-
/******/ var ns = Object.create(null);
|
|
72
|
-
/******/ __webpack_require__.r(ns);
|
|
73
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
74
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
75
|
-
/******/ return ns;
|
|
76
|
-
/******/ };
|
|
77
|
-
/******/
|
|
78
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
79
|
-
/******/ __webpack_require__.n = function(module) {
|
|
80
|
-
/******/ var getter = module && module.__esModule ?
|
|
81
|
-
/******/ function getDefault() { return module['default']; } :
|
|
82
|
-
/******/ function getModuleExports() { return module; };
|
|
83
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
84
|
-
/******/ return getter;
|
|
85
|
-
/******/ };
|
|
86
|
-
/******/
|
|
87
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
88
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
89
|
-
/******/
|
|
90
|
-
/******/ // __webpack_public_path__
|
|
91
|
-
/******/ __webpack_require__.p = "";
|
|
92
|
-
/******/
|
|
93
|
-
/******/
|
|
94
|
-
/******/ // Load entry module and return exports
|
|
95
|
-
/******/ return __webpack_require__(__webpack_require__.s = 25);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ({
|
|
99
|
-
|
|
100
|
-
/***/ 0:
|
|
101
|
-
/***/ (function(module, exports) {
|
|
102
|
-
|
|
103
|
-
module.exports = require("../../package.json");
|
|
104
|
-
|
|
105
|
-
/***/ }),
|
|
106
|
-
|
|
107
|
-
/***/ 1:
|
|
108
|
-
/***/ (function(module, exports) {
|
|
109
|
-
|
|
110
|
-
module.exports = require("commander");
|
|
111
|
-
|
|
112
|
-
/***/ }),
|
|
113
|
-
|
|
114
|
-
/***/ 2:
|
|
115
|
-
/***/ (function(module, exports) {
|
|
116
|
-
|
|
117
|
-
module.exports = require("chalk");
|
|
118
|
-
|
|
119
|
-
/***/ }),
|
|
120
|
-
|
|
121
|
-
/***/ 25:
|
|
122
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const pkg = __webpack_require__(0);
|
|
126
|
-
const program = __webpack_require__(1);
|
|
127
|
-
const chalk = __webpack_require__(2);
|
|
128
|
-
const NestedSetModelQueryer = __webpack_require__(3)
|
|
129
|
-
.default;
|
|
130
|
-
const getDBPool = __webpack_require__(4);
|
|
131
|
-
const getNodeIdFromNameOrId = __webpack_require__(5);
|
|
132
|
-
|
|
133
|
-
program
|
|
134
|
-
.description(
|
|
135
|
-
"Move the node specified and all its dependents to the specified parent node." +
|
|
136
|
-
"\nIf the node name is given instead of the node Id, the first located node (and its dependents) will be moved." +
|
|
137
|
-
"\nIf the parent node name is given instead of the parent node Id, the specifed node will be moved to the first located parent node."
|
|
138
|
-
)
|
|
139
|
-
.option("<nodeNameOrId>", "The id or name of the node to be moved")
|
|
140
|
-
.option("<parentNodeNameOrId>", "The new parent node id or name")
|
|
141
|
-
.version(pkg.version)
|
|
142
|
-
.action(async (nodeNameOrId, parentNodeNameOrId) => {
|
|
143
|
-
try {
|
|
144
|
-
if (process.argv.slice(2).length < 2) {
|
|
145
|
-
program.help();
|
|
146
|
-
}
|
|
147
|
-
nodeNameOrId = nodeNameOrId ? nodeNameOrId.trim() : "";
|
|
148
|
-
if (nodeNameOrId === "")
|
|
149
|
-
throw new Error("Node Name or Id can't be empty!");
|
|
150
|
-
parentNodeNameOrId = parentNodeNameOrId
|
|
151
|
-
? parentNodeNameOrId.trim()
|
|
152
|
-
: "";
|
|
153
|
-
if (parentNodeNameOrId === "")
|
|
154
|
-
throw new Error("Parent Node Name or Id can't be empty!");
|
|
155
|
-
const pool = getDBPool();
|
|
156
|
-
const queryer = new NestedSetModelQueryer(pool, "org_units");
|
|
157
|
-
|
|
158
|
-
const nodeId = await getNodeIdFromNameOrId(nodeNameOrId, queryer);
|
|
159
|
-
const parentNodeId = await getNodeIdFromNameOrId(
|
|
160
|
-
parentNodeNameOrId,
|
|
161
|
-
queryer
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
await queryer.moveSubTreeTo(nodeId, parentNodeId);
|
|
165
|
-
console.log(
|
|
166
|
-
chalk.green(
|
|
167
|
-
`The sub tree with root node Id: ${nodeId} has been moved to the new parent node (id: ${parentNodeId}).`
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
} catch (e) {
|
|
171
|
-
console.error(chalk.red(`Error: ${e}`));
|
|
172
|
-
}
|
|
173
|
-
process.exit(0);
|
|
174
|
-
})
|
|
175
|
-
.parse(process.argv);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/***/ }),
|
|
179
|
-
|
|
180
|
-
/***/ 3:
|
|
181
|
-
/***/ (function(module, exports) {
|
|
182
|
-
|
|
183
|
-
module.exports = require("./NestedSetModelQueryer");
|
|
184
|
-
|
|
185
|
-
/***/ }),
|
|
186
|
-
|
|
187
|
-
/***/ 4:
|
|
188
|
-
/***/ (function(module, exports) {
|
|
189
|
-
|
|
190
|
-
module.exports = require("../db/getDBPool");
|
|
191
|
-
|
|
192
|
-
/***/ }),
|
|
193
|
-
|
|
194
|
-
/***/ 5:
|
|
195
|
-
/***/ (function(module, exports) {
|
|
196
|
-
|
|
197
|
-
module.exports = require("./getNodeIdFromNameOrId");
|
|
198
|
-
|
|
199
|
-
/***/ })
|
|
200
|
-
|
|
201
|
-
/******/ });
|
|
202
|
-
});
|