clickgo 3.0.7-dev8 → 3.1.1-dev10
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 +1 -1
- package/dist/app/demo/app.js +93 -0
- package/dist/app/demo/form/control/dialog/dialog.js +10 -6
- package/dist/app/demo/form/control/form/form.js +21 -20
- package/dist/app/demo/form/control/form/form.xml +3 -3
- package/dist/app/demo/form/main.js +34 -10
- package/dist/app/demo/form/main.xml +4 -4
- package/dist/app/demo/form/method/form/form.js +103 -101
- package/dist/app/demo/form/method/form/form.xml +9 -10
- package/dist/app/task/app.js +46 -0
- package/dist/app/task/form/bar/bar.js +84 -88
- package/dist/app/task/form/bar/bar.xml +4 -5
- package/dist/clickgo.js +1 -10
- package/dist/clickgo.ts +0 -8
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/index.js +105 -56
- package/dist/index.ts +164 -59
- package/dist/lib/control.js +363 -240
- package/dist/lib/control.ts +497 -284
- package/dist/lib/core.js +313 -228
- package/dist/lib/core.ts +400 -255
- package/dist/lib/dom.ts +1 -3
- package/dist/lib/form.js +447 -951
- package/dist/lib/form.ts +686 -1097
- package/dist/lib/fs.js +42 -39
- package/dist/lib/fs.ts +45 -41
- package/dist/lib/native.ts +3 -0
- package/dist/lib/task.js +708 -182
- package/dist/lib/task.ts +778 -200
- package/dist/lib/theme.ts +2 -2
- package/dist/lib/tool.js +58 -48
- package/dist/lib/tool.ts +80 -64
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +5 -7
- package/types/index.d.ts +284 -335
- package/dist/app/demo/config.json +0 -106
- package/dist/app/task/config.json +0 -32
package/dist/lib/control.js
CHANGED
|
@@ -9,13 +9,152 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.init = exports.read = void 0;
|
|
12
|
+
exports.buildComponents = exports.init = exports.read = exports.AbstractControl = void 0;
|
|
13
13
|
const core = require("./core");
|
|
14
14
|
const zip = require("./zip");
|
|
15
15
|
const tool = require("./tool");
|
|
16
16
|
const task = require("./task");
|
|
17
17
|
const dom = require("./dom");
|
|
18
18
|
const form = require("./form");
|
|
19
|
+
const fs = require("./fs");
|
|
20
|
+
class AbstractControl {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.props = {};
|
|
23
|
+
}
|
|
24
|
+
get filename() {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
get controlName() {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
get taskId() {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
get formId() {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
get formFocus() {
|
|
37
|
+
return this.props.formFocus;
|
|
38
|
+
}
|
|
39
|
+
get path() {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
get prep() {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
get locale() {
|
|
46
|
+
return task.list[this.taskId].locale.lang || core.config.locale;
|
|
47
|
+
}
|
|
48
|
+
get l() {
|
|
49
|
+
return (key, data) => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f;
|
|
51
|
+
if (data) {
|
|
52
|
+
return (_c = (_b = (_a = data[this.locale]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : data['en'][key]) !== null && _c !== void 0 ? _c : 'LocaleError';
|
|
53
|
+
}
|
|
54
|
+
else if (this.localeData) {
|
|
55
|
+
return (_f = (_e = (_d = this.localeData[this.locale]) === null || _d === void 0 ? void 0 : _d[key]) !== null && _e !== void 0 ? _e : this.localeData['en'][key]) !== null && _f !== void 0 ? _f : 'LocaleError';
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return 'LocaleError';
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
get classPrepend() {
|
|
63
|
+
return (cla) => {
|
|
64
|
+
if (typeof cla !== 'string') {
|
|
65
|
+
return cla;
|
|
66
|
+
}
|
|
67
|
+
return `cg-theme-task${this.taskId}-${this.controlName}_${cla}${this.prep ? (' ' + this.prep + cla) : ''}`;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
watch(name, cb, opt = {}) {
|
|
71
|
+
return this.$watch(name, cb, opt);
|
|
72
|
+
}
|
|
73
|
+
get refs() {
|
|
74
|
+
return this.$refs;
|
|
75
|
+
}
|
|
76
|
+
get nextTick() {
|
|
77
|
+
return this.$nextTick;
|
|
78
|
+
}
|
|
79
|
+
allowEvent(e) {
|
|
80
|
+
return dom.allowEvent(e);
|
|
81
|
+
}
|
|
82
|
+
trigger(name, param1 = '', param2 = '') {
|
|
83
|
+
if (!['formTitleChanged', 'formIconChanged', 'formStateMinChanged', 'formStateMaxChanged', 'formShowChanged'].includes(name)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
core.trigger(name, this.taskId, this.formId, param1, param2);
|
|
87
|
+
}
|
|
88
|
+
get element() {
|
|
89
|
+
return this.$el;
|
|
90
|
+
}
|
|
91
|
+
emit(name, ...v) {
|
|
92
|
+
this.$emit(name, ...v);
|
|
93
|
+
}
|
|
94
|
+
get slots() {
|
|
95
|
+
return (name = 'default') => {
|
|
96
|
+
const d = this.$slots[name];
|
|
97
|
+
if (!d) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const slots = [];
|
|
101
|
+
const list = d();
|
|
102
|
+
for (const item of list) {
|
|
103
|
+
if (typeof item.type === 'symbol') {
|
|
104
|
+
for (const item2 of item.children) {
|
|
105
|
+
slots.push(item2);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
slots.push(item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return slots;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
get parent() {
|
|
116
|
+
return this.$parent;
|
|
117
|
+
}
|
|
118
|
+
get parentByName() {
|
|
119
|
+
return (controlName) => {
|
|
120
|
+
let parent = this.$parent;
|
|
121
|
+
while (true) {
|
|
122
|
+
if (!parent) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
if (parent.controlName === controlName) {
|
|
126
|
+
return parent;
|
|
127
|
+
}
|
|
128
|
+
parent = parent.$parent;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
onBeforeCreate() {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
onCreated() {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
onBeforeMount() {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
onMounted() {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
onBeforeUpdate() {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
onUpdated() {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
onBeforeUnmount() {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
onUnmounted() {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.AbstractControl = AbstractControl;
|
|
19
158
|
function read(blob) {
|
|
20
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
160
|
const z = yield zip.get(blob);
|
|
@@ -102,264 +241,248 @@ function read(blob) {
|
|
|
102
241
|
});
|
|
103
242
|
}
|
|
104
243
|
exports.read = read;
|
|
105
|
-
function init(taskId
|
|
244
|
+
function init(taskId) {
|
|
106
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
246
|
const t = task.list[taskId];
|
|
108
247
|
if (!t) {
|
|
109
248
|
return false;
|
|
110
249
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
cpath += '.cgc';
|
|
115
|
-
}
|
|
116
|
-
const control = t.controls.loaded[cpath];
|
|
117
|
-
if (!control) {
|
|
118
|
-
return false;
|
|
250
|
+
for (let path of t.config.controls) {
|
|
251
|
+
if (!path.endsWith('.cgc')) {
|
|
252
|
+
path += '.cgc';
|
|
119
253
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const style = item.files[item.config.style + '.css'];
|
|
147
|
-
if (style) {
|
|
148
|
-
const r = tool.stylePrepend(style);
|
|
149
|
-
prep = r.prep;
|
|
150
|
-
dom.pushStyle(t.id, yield tool.styleUrl2DataUrl(item.config.style, r.style, item.files), 'control', name);
|
|
151
|
-
}
|
|
152
|
-
const prepList = [
|
|
153
|
-
'cg-theme-task' + t.id.toString() + '-' + name + '_'
|
|
154
|
-
];
|
|
155
|
-
if (prep !== '') {
|
|
156
|
-
prepList.push(prep);
|
|
157
|
-
}
|
|
158
|
-
layout = tool.layoutAddTagClassAndReTagName(layout, false);
|
|
159
|
-
layout = tool.layoutClassPrepend(layout, prepList);
|
|
160
|
-
if (layout.includes('<cg-')) {
|
|
161
|
-
layout = tool.layoutInsertAttr(layout, ':cg-focus=\'cgFocus\'', {
|
|
162
|
-
'include': [/^cg-.+/]
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
layout = tool.eventsAttrWrap(layout);
|
|
166
|
-
t.controls.layout[name] = layout;
|
|
167
|
-
t.controls.prep[name] = prep;
|
|
168
|
-
}
|
|
169
|
-
if (item.files[item.config.code + '.js']) {
|
|
170
|
-
item.files['/invoke/clickgo.js'] = `module.exports = invokeClickgo;`;
|
|
171
|
-
const expo = loader.require(item.config.code, item.files, {
|
|
172
|
-
'dir': '/',
|
|
173
|
-
'invoke': invoke,
|
|
174
|
-
'preprocess': preprocess,
|
|
175
|
-
'map': {
|
|
176
|
-
'clickgo': '/invoke/clickgo'
|
|
254
|
+
path = tool.urlResolve('/', path);
|
|
255
|
+
const file = yield fs.getContent(path, {
|
|
256
|
+
'files': t.app.files,
|
|
257
|
+
'current': t.current
|
|
258
|
+
});
|
|
259
|
+
if (file && typeof file !== 'string') {
|
|
260
|
+
const c = yield read(file);
|
|
261
|
+
if (c) {
|
|
262
|
+
for (const name in c) {
|
|
263
|
+
const item = c[name];
|
|
264
|
+
let prep = '';
|
|
265
|
+
t.controls[name] = {
|
|
266
|
+
'layout': '',
|
|
267
|
+
'props': {
|
|
268
|
+
'formFocus': {
|
|
269
|
+
'default': false
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
'data': {},
|
|
273
|
+
'access': {},
|
|
274
|
+
'methods': {},
|
|
275
|
+
'computed': {}
|
|
276
|
+
};
|
|
277
|
+
t.controls[name].layout = item.files[item.config.layout + '.html'];
|
|
278
|
+
if (t.controls[name].layout === undefined) {
|
|
279
|
+
return false;
|
|
177
280
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
watch = expo.watch || {};
|
|
185
|
-
beforeCreate = expo.beforeCreate;
|
|
186
|
-
created = expo.created;
|
|
187
|
-
beforeMount = expo.beforeMount;
|
|
188
|
-
mounted = expo.mounted;
|
|
189
|
-
beforeUpdate = expo.beforeUpdate;
|
|
190
|
-
updated = expo.updated;
|
|
191
|
-
beforeUnmount = expo.beforeUnmount;
|
|
192
|
-
unmounted = expo.unmounted;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
props.cgFocus = {
|
|
196
|
-
'default': false
|
|
197
|
-
};
|
|
198
|
-
computed.taskId = {
|
|
199
|
-
get: function () {
|
|
200
|
-
return taskId;
|
|
201
|
-
},
|
|
202
|
-
set: function () {
|
|
203
|
-
form.notify({
|
|
204
|
-
'title': 'Error',
|
|
205
|
-
'content': `The control tries to modify the system variable "taskId".\nPath: ${this.cgPath}\nControl: ${name}`,
|
|
206
|
-
'type': 'danger'
|
|
207
|
-
});
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
computed.controlName = {
|
|
212
|
-
get: function () {
|
|
213
|
-
return name;
|
|
214
|
-
},
|
|
215
|
-
set: function () {
|
|
216
|
-
form.notify({
|
|
217
|
-
'title': 'Error',
|
|
218
|
-
'content': `The control tries to modify the system variable "controlName".\nPath: ${this.cgPath}\nControl: ${name}`,
|
|
219
|
-
'type': 'danger'
|
|
220
|
-
});
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
computed.cgPrep = {
|
|
225
|
-
get: function () {
|
|
226
|
-
return prep;
|
|
227
|
-
},
|
|
228
|
-
set: function () {
|
|
229
|
-
form.notify({
|
|
230
|
-
'title': 'Error',
|
|
231
|
-
'content': `The control tries to modify the system variable "cgPrep".\nPath: ${this.cgPath}\nControl: ${name}`,
|
|
232
|
-
'type': 'danger'
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
computed.cgSlots = function () {
|
|
238
|
-
return (name = 'default') => {
|
|
239
|
-
const d = this.$slots[name];
|
|
240
|
-
if (!d) {
|
|
241
|
-
return [];
|
|
281
|
+
t.controls[name].layout = t.controls[name].layout.replace(/^(<[a-zA-Z0-9-]+)( |>)/, '$1 data-cg-control-' + name + '$2');
|
|
282
|
+
const style = item.files[item.config.style + '.css'];
|
|
283
|
+
if (style) {
|
|
284
|
+
const r = tool.stylePrepend(style);
|
|
285
|
+
prep = r.prep;
|
|
286
|
+
dom.pushStyle(t.id, yield tool.styleUrl2DataUrl(item.config.style, r.style, item.files), 'control', name);
|
|
242
287
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
slots.push(item2);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
slots.push(item);
|
|
253
|
-
}
|
|
288
|
+
const prepList = [
|
|
289
|
+
'cg-theme-task' + t.id.toString() + '-' + name + '_'
|
|
290
|
+
];
|
|
291
|
+
if (prep !== '') {
|
|
292
|
+
prepList.push(prep);
|
|
254
293
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
return task.list[this.taskId].locale.lang;
|
|
263
|
-
};
|
|
264
|
-
computed.l = function () {
|
|
265
|
-
return (key, data) => {
|
|
266
|
-
var _a, _b, _c, _d, _e, _f;
|
|
267
|
-
if (data) {
|
|
268
|
-
return (_c = (_b = (_a = data[this.cgLocale]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : data['en'][key]) !== null && _c !== void 0 ? _c : 'LocaleError';
|
|
294
|
+
t.controls[name].layout = tool.layoutAddTagClassAndReTagName(t.controls[name].layout, false);
|
|
295
|
+
t.controls[name].layout = tool.layoutClassPrepend(t.controls[name].layout, prepList);
|
|
296
|
+
if (t.controls[name].layout.includes('<cg-')) {
|
|
297
|
+
t.controls[name].layout = tool.layoutInsertAttr(t.controls[name].layout, ':form-focus=\'formFocus\'', {
|
|
298
|
+
'include': [/^cg-.+/]
|
|
299
|
+
});
|
|
269
300
|
}
|
|
270
|
-
|
|
271
|
-
|
|
301
|
+
t.controls[name].layout = tool.eventsAttrWrap(t.controls[name].layout);
|
|
302
|
+
let cls;
|
|
303
|
+
if (item.files[item.config.code + '.js']) {
|
|
304
|
+
item.files['/invoke/clickgo.js'] = `module.exports = invokeClickgo;`;
|
|
305
|
+
let expo = [];
|
|
306
|
+
try {
|
|
307
|
+
expo = loader.require(item.config.code, item.files, {
|
|
308
|
+
'dir': '/',
|
|
309
|
+
'invoke': t.invoke,
|
|
310
|
+
'preprocess': function (code, path) {
|
|
311
|
+
const exec = /eval\W/.exec(code);
|
|
312
|
+
if (exec) {
|
|
313
|
+
form.notify({
|
|
314
|
+
'title': 'Error',
|
|
315
|
+
'content': `The "eval" is prohibited.\nFile: "${path}".`,
|
|
316
|
+
'type': 'danger'
|
|
317
|
+
});
|
|
318
|
+
return '';
|
|
319
|
+
}
|
|
320
|
+
code = code.replace(/extends[\s\S]+?\.\s*AbstractControl\s*{/, (t) => {
|
|
321
|
+
return t + 'get filename() {return __filename;}';
|
|
322
|
+
});
|
|
323
|
+
return code;
|
|
324
|
+
},
|
|
325
|
+
'map': {
|
|
326
|
+
'clickgo': '/invoke/clickgo'
|
|
327
|
+
}
|
|
328
|
+
})[0];
|
|
329
|
+
}
|
|
330
|
+
catch (e) {
|
|
331
|
+
core.trigger('error', taskId, 0, e, e.message + '(-4)');
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
if (!(expo === null || expo === void 0 ? void 0 : expo.default)) {
|
|
335
|
+
const msg = '"default" not found on "' + item.config.code + '" of "' + name + '" control.';
|
|
336
|
+
core.trigger('error', taskId, 0, new Error(msg), msg);
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
cls = new expo.default();
|
|
272
340
|
}
|
|
273
341
|
else {
|
|
274
|
-
|
|
342
|
+
cls = new (class extends AbstractControl {
|
|
343
|
+
get taskId() {
|
|
344
|
+
return taskId;
|
|
345
|
+
}
|
|
346
|
+
})();
|
|
275
347
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
while (true) {
|
|
282
|
-
if (!parent) {
|
|
283
|
-
return null;
|
|
348
|
+
if (cls.props) {
|
|
349
|
+
for (const key in cls.props) {
|
|
350
|
+
t.controls[name].props[key] = {
|
|
351
|
+
'default': cls.props[key]
|
|
352
|
+
};
|
|
284
353
|
}
|
|
285
|
-
|
|
286
|
-
|
|
354
|
+
}
|
|
355
|
+
const cdata = Object.entries(cls);
|
|
356
|
+
for (const item of cdata) {
|
|
357
|
+
if (item[0] === 'access') {
|
|
358
|
+
t.controls[name].access = item[1];
|
|
359
|
+
continue;
|
|
287
360
|
}
|
|
288
|
-
|
|
361
|
+
t.controls[name].data[item[0]] = item[1];
|
|
289
362
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
return `cg-theme-task${this.taskId}-${this.controlName}_${cla}${this.cgPrep ? (' ' + this.cgPrep + cla) : ''}`;
|
|
321
|
-
};
|
|
322
|
-
methods.cgAllowEvent = function (e) {
|
|
323
|
-
return dom.allowEvent(e);
|
|
324
|
-
};
|
|
325
|
-
components['cg-' + name] = {
|
|
326
|
-
'template': layout,
|
|
327
|
-
'props': props,
|
|
328
|
-
'data': function () {
|
|
329
|
-
return tool.clone(data);
|
|
330
|
-
},
|
|
331
|
-
'methods': methods,
|
|
332
|
-
'computed': computed,
|
|
333
|
-
'watch': watch,
|
|
334
|
-
'beforeCreate': beforeCreate,
|
|
335
|
-
'created': created,
|
|
336
|
-
'beforeMount': beforeMount,
|
|
337
|
-
'mounted': function () {
|
|
338
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
-
yield this.$nextTick();
|
|
340
|
-
mounted === null || mounted === void 0 ? void 0 : mounted.call(this);
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
'beforeUpdate': beforeUpdate,
|
|
344
|
-
'updated': function () {
|
|
345
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
-
yield this.$nextTick();
|
|
347
|
-
updated === null || updated === void 0 ? void 0 : updated.call(this);
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
'beforeUnmount': function () {
|
|
351
|
-
beforeUnmount === null || beforeUnmount === void 0 ? void 0 : beforeUnmount.call(this);
|
|
352
|
-
},
|
|
353
|
-
'unmounted': function () {
|
|
354
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
355
|
-
yield this.$nextTick();
|
|
356
|
-
unmounted === null || unmounted === void 0 ? void 0 : unmounted.call(this);
|
|
357
|
-
});
|
|
363
|
+
const prot = tool.getClassPrototype(cls);
|
|
364
|
+
t.controls[name].methods = prot.method;
|
|
365
|
+
Object.assign(t.controls[name].computed, prot.access);
|
|
366
|
+
t.controls[name].computed.controlName = {
|
|
367
|
+
get: function () {
|
|
368
|
+
return name;
|
|
369
|
+
},
|
|
370
|
+
set: function () {
|
|
371
|
+
form.notify({
|
|
372
|
+
'title': 'Error',
|
|
373
|
+
'content': `The software tries to modify the system variable "controlName".\nControl: ${name}`,
|
|
374
|
+
'type': 'danger'
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
t.controls[name].computed.prep = {
|
|
380
|
+
get: function () {
|
|
381
|
+
return prep;
|
|
382
|
+
},
|
|
383
|
+
set: function () {
|
|
384
|
+
form.notify({
|
|
385
|
+
'title': 'Error',
|
|
386
|
+
'content': `The software tries to modify the system variable "prep".\nControl: ${name}`,
|
|
387
|
+
'type': 'danger'
|
|
388
|
+
});
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
358
392
|
}
|
|
359
|
-
}
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
form.notify({
|
|
396
|
+
'title': 'Error',
|
|
397
|
+
'content': 'Control failed to load.\nTask id: ' + t.id.toString() + '\nPath: ' + path,
|
|
398
|
+
'type': 'danger'
|
|
399
|
+
});
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
360
402
|
}
|
|
361
403
|
}
|
|
362
|
-
|
|
404
|
+
t.invoke = undefined;
|
|
405
|
+
delete t.invoke;
|
|
406
|
+
return true;
|
|
363
407
|
});
|
|
364
408
|
}
|
|
365
409
|
exports.init = init;
|
|
410
|
+
function buildComponents(taskId, formId, path) {
|
|
411
|
+
const t = task.list[taskId];
|
|
412
|
+
if (!t) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
const components = {};
|
|
416
|
+
for (const name in t.controls) {
|
|
417
|
+
const control = t.controls[name];
|
|
418
|
+
const computed = Object.assign({}, control.computed);
|
|
419
|
+
computed.formId = {
|
|
420
|
+
get: function () {
|
|
421
|
+
return formId;
|
|
422
|
+
},
|
|
423
|
+
set: function () {
|
|
424
|
+
form.notify({
|
|
425
|
+
'title': 'Error',
|
|
426
|
+
'content': `The control tries to modify the system variable "formId".\nControl: ${name}`,
|
|
427
|
+
'type': 'danger'
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
computed.path = {
|
|
432
|
+
get: function () {
|
|
433
|
+
return path;
|
|
434
|
+
},
|
|
435
|
+
set: function () {
|
|
436
|
+
form.notify({
|
|
437
|
+
'title': 'Error',
|
|
438
|
+
'content': `The control tries to modify the system variable "path".\nControl: ${name}`,
|
|
439
|
+
'type': 'danger'
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
components['cg-' + name] = {
|
|
444
|
+
'template': control.layout,
|
|
445
|
+
'props': control.props,
|
|
446
|
+
'data': function () {
|
|
447
|
+
return tool.clone(control.data);
|
|
448
|
+
},
|
|
449
|
+
'methods': control.methods,
|
|
450
|
+
'computed': computed,
|
|
451
|
+
beforeCreate: control.methods.onBeforeCreate,
|
|
452
|
+
created: function () {
|
|
453
|
+
this.props = this.$props;
|
|
454
|
+
this.access = tool.clone(control.access);
|
|
455
|
+
this.onCreated();
|
|
456
|
+
},
|
|
457
|
+
beforeMount: function () {
|
|
458
|
+
this.onBeforeMount();
|
|
459
|
+
},
|
|
460
|
+
mounted: function () {
|
|
461
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
462
|
+
yield this.$nextTick();
|
|
463
|
+
this.onMounted();
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
beforeUpdate: function () {
|
|
467
|
+
this.onBeforeUpdate();
|
|
468
|
+
},
|
|
469
|
+
updated: function () {
|
|
470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
471
|
+
yield this.$nextTick();
|
|
472
|
+
this.onUpdated();
|
|
473
|
+
});
|
|
474
|
+
},
|
|
475
|
+
beforeUnmount: function () {
|
|
476
|
+
this.onBeforeUnmount();
|
|
477
|
+
},
|
|
478
|
+
unmounted: function () {
|
|
479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
+
yield this.$nextTick();
|
|
481
|
+
this.onUnmounted();
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
return components;
|
|
487
|
+
}
|
|
488
|
+
exports.buildComponents = buildComponents;
|