clickgo 3.1.4-dev13 → 3.1.6-dev15
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 +7 -7
- package/dist/app/demo/app.js +29 -3
- package/dist/app/demo/config.json +22 -3
- package/dist/app/demo/form/control/box/box.js +66 -0
- package/dist/app/demo/form/control/box/box.xml +18 -0
- package/dist/app/demo/form/control/button/button.js +24 -1
- package/dist/app/demo/form/control/check/check.js +24 -1
- package/dist/app/demo/form/control/dialog/dialog.js +24 -1
- package/dist/app/demo/form/control/file/file.js +24 -1
- package/dist/app/demo/form/control/flow/flow.js +24 -1
- package/dist/app/demo/form/control/form/form.js +24 -1
- package/dist/app/demo/form/control/layout/layout.js +57 -0
- package/dist/app/demo/form/control/layout/layout.xml +16 -0
- package/dist/app/demo/form/control/list/list.js +24 -1
- package/dist/app/demo/form/control/list/list.xml +8 -2
- package/dist/app/demo/form/control/marquee/marquee.js +24 -2
- package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
- package/dist/app/demo/form/control/menu/menu.js +24 -1
- package/dist/app/demo/form/control/monaco/monaco.js +24 -1
- package/dist/app/demo/form/control/nav/nav.js +52 -0
- package/dist/app/demo/form/control/nav/nav.xml +43 -0
- package/dist/app/demo/form/control/panel/panel.js +67 -0
- package/dist/app/demo/form/control/panel/panel.xml +11 -0
- package/dist/app/demo/form/control/panel/test1.js +58 -0
- package/dist/app/demo/form/control/panel/test1.xml +16 -0
- package/dist/app/demo/form/control/panel/test2.xml +3 -0
- package/dist/app/demo/form/control/property/property.js +24 -1
- package/dist/app/demo/form/control/radio/radio.js +24 -1
- package/dist/app/demo/form/control/scroll/scroll.js +25 -1
- package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
- package/dist/app/demo/form/control/select/select.js +24 -1
- package/dist/app/demo/form/control/tab/tab.js +24 -1
- package/dist/app/demo/form/control/table/table.js +164 -0
- package/dist/app/demo/form/control/table/table.xml +35 -0
- package/dist/app/demo/form/control/text/text.js +25 -1
- package/dist/app/demo/form/control/text/text.xml +1 -1
- package/dist/app/demo/form/control/vflow/vflow.js +24 -1
- package/dist/app/demo/form/event/form/form.js +24 -1
- package/dist/app/demo/form/event/other/other.js +24 -1
- package/dist/app/demo/form/event/screen/screen.js +24 -1
- package/dist/app/demo/form/event/task/task.js +24 -1
- package/dist/app/demo/form/main.js +130 -84
- package/dist/app/demo/form/main.xml +5 -0
- package/dist/app/demo/form/method/aform/aform.js +29 -15
- package/dist/app/demo/form/method/aform/aform.xml +0 -1
- package/dist/app/demo/form/method/aform/sd.js +25 -5
- package/dist/app/demo/form/method/core/core.js +24 -1
- package/dist/app/demo/form/method/dom/dom.js +48 -2
- package/dist/app/demo/form/method/dom/dom.xml +11 -0
- package/dist/app/demo/form/method/form/form.js +40 -7
- package/dist/app/demo/form/method/form/form.xml +3 -0
- package/dist/app/demo/form/method/{aform → form}/test.xml +0 -0
- package/dist/app/demo/form/method/fs/fs.js +139 -8
- package/dist/app/demo/form/method/fs/fs.xml +11 -1
- package/dist/app/demo/form/method/fs/text.js +24 -1
- package/dist/app/demo/form/method/native/native.js +24 -1
- package/dist/app/demo/form/method/system/system.js +24 -1
- package/dist/app/demo/form/method/task/task.js +31 -4
- package/dist/app/demo/form/method/task/task.xml +6 -1
- package/dist/app/demo/form/method/theme/theme.js +24 -1
- package/dist/app/demo/form/method/tool/tool.js +38 -1
- package/dist/app/demo/form/method/tool/tool.xml +1 -0
- package/dist/app/demo/form/method/zip/zip.js +30 -7
- package/dist/app/task/app.js +29 -3
- package/dist/app/task/form/bar/bar.js +24 -1
- package/dist/clickgo.js +33 -10
- package/dist/control/box.cgc +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/nav.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/table.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/lib/control.js +53 -12
- package/dist/lib/control.ts +25 -5
- package/dist/lib/core.js +44 -50
- package/dist/lib/core.ts +18 -48
- package/dist/lib/dom.js +322 -108
- package/dist/lib/dom.ts +394 -127
- package/dist/lib/form.js +590 -226
- package/dist/lib/form.ts +706 -267
- package/dist/lib/fs.js +485 -224
- package/dist/lib/fs.ts +493 -287
- package/dist/lib/native.js +24 -1
- package/dist/lib/task.js +159 -139
- package/dist/lib/task.ts +148 -130
- package/dist/lib/theme.js +27 -4
- package/dist/lib/tool.js +57 -2
- package/dist/lib/tool.ts +68 -1
- package/dist/lib/zip.js +29 -3
- package/dist/lib/zip.ts +1 -1
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +5 -7
- package/types/index.d.ts +51 -70
package/dist/lib/form.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,18 +32,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.hideLauncher = exports.showLauncher = exports.flash = exports.confirm = exports.dialog = exports.create = exports.remove = exports.doFocusAndPopEvent = exports.hidePop = exports.showPop = exports.removeFromPop = exports.appendToPop = exports.hideNotify = exports.notifyProgress = exports.notify = exports.hideDrag = exports.moveDrag = exports.showDrag = exports.hideRectangle = exports.showRectangle = exports.moveRectangle = exports.showCircular = exports.getRectByBorder = exports.getMaxZIndexID = exports.changeFocus = exports.getFocus = exports.getList = exports.send = exports.get = exports.getTaskId = exports.refreshMaxPosition = exports.bindDrag = exports.bindResize = exports.close = exports.max = exports.min = exports.superConfirm = exports.elements = exports.launcherRoot = exports.simpleSystemTaskRoot = exports.AbstractForm = void 0;
|
|
13
|
-
const clickgo = require("../clickgo");
|
|
14
|
-
const core = require("./core");
|
|
15
|
-
const task = require("./task");
|
|
16
|
-
const tool = require("./tool");
|
|
17
|
-
const dom = require("./dom");
|
|
18
|
-
const control = require("./control");
|
|
19
|
-
const fs = require("./fs");
|
|
20
|
-
const native = require("./native");
|
|
35
|
+
exports.hideLauncher = exports.showLauncher = exports.flash = exports.confirm = exports.dialog = exports.create = exports.createPanel = exports.removePanel = exports.remove = exports.doFocusAndPopEvent = exports.hidePop = exports.showPop = exports.removeFromPop = exports.appendToPop = exports.hideNotify = exports.notifyProgress = exports.notify = exports.hideDrag = exports.moveDrag = exports.showDrag = exports.hideRectangle = exports.showRectangle = exports.moveRectangle = exports.showCircular = exports.getRectByBorder = exports.getMaxZIndexID = exports.changeFocus = exports.setActivePanel = exports.removeActivePanel = exports.getActivePanel = exports.activePanels = exports.getFocus = exports.getList = exports.send = exports.get = exports.getTaskId = exports.refreshMaxPosition = exports.bindDrag = exports.bindResize = exports.close = exports.max = exports.min = exports.superConfirm = exports.elements = exports.launcherRoot = exports.simpleSystemTaskRoot = exports.AbstractForm = exports.AbstractPanel = void 0;
|
|
36
|
+
const clickgo = __importStar(require("../clickgo"));
|
|
37
|
+
const core = __importStar(require("./core"));
|
|
38
|
+
const task = __importStar(require("./task"));
|
|
39
|
+
const tool = __importStar(require("./tool"));
|
|
40
|
+
const dom = __importStar(require("./dom"));
|
|
41
|
+
const control = __importStar(require("./control"));
|
|
42
|
+
const fs = __importStar(require("./fs"));
|
|
43
|
+
const native = __importStar(require("./native"));
|
|
21
44
|
let focusId = null;
|
|
22
45
|
const info = {
|
|
23
46
|
'lastId': 0,
|
|
47
|
+
'lastPanelId': 0,
|
|
24
48
|
'lastZIndex': 999,
|
|
25
49
|
'topLastZIndex': 9999999,
|
|
26
50
|
'locale': {
|
|
@@ -54,86 +78,7 @@ const info = {
|
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
};
|
|
57
|
-
class
|
|
58
|
-
constructor() {
|
|
59
|
-
this.isNativeSync = false;
|
|
60
|
-
this._firstShow = true;
|
|
61
|
-
this.dialogResult = '';
|
|
62
|
-
}
|
|
63
|
-
static create(data, layout) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const frm = new this();
|
|
66
|
-
const code = {
|
|
67
|
-
'data': {},
|
|
68
|
-
'methods': {},
|
|
69
|
-
'computed': {},
|
|
70
|
-
beforeCreate: frm.onBeforeCreate,
|
|
71
|
-
created: function () {
|
|
72
|
-
this.onCreated();
|
|
73
|
-
},
|
|
74
|
-
beforeMount: function () {
|
|
75
|
-
this.onBeforeMount();
|
|
76
|
-
},
|
|
77
|
-
mounted: function (data) {
|
|
78
|
-
this.onMounted(data);
|
|
79
|
-
},
|
|
80
|
-
beforeUpdate: function () {
|
|
81
|
-
this.onBeforeUpdate();
|
|
82
|
-
},
|
|
83
|
-
updated: function () {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
yield this.$nextTick();
|
|
86
|
-
this.onUpdated();
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
beforeUnmount: function () {
|
|
90
|
-
this.onBeforeUnmount();
|
|
91
|
-
},
|
|
92
|
-
unmounted: function () {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
yield this.$nextTick();
|
|
95
|
-
this.onUnmounted();
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const cdata = Object.entries(frm);
|
|
100
|
-
for (const item of cdata) {
|
|
101
|
-
if (item[0] === 'access') {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
code.data[item[0]] = item[1];
|
|
105
|
-
}
|
|
106
|
-
if (!layout) {
|
|
107
|
-
const l = task.list[frm.taskId].app.files[frm.filename.slice(0, -2) + 'xml'];
|
|
108
|
-
if (typeof l !== 'string') {
|
|
109
|
-
return 0;
|
|
110
|
-
}
|
|
111
|
-
layout = l;
|
|
112
|
-
}
|
|
113
|
-
const prot = tool.getClassPrototype(frm);
|
|
114
|
-
code.methods = prot.method;
|
|
115
|
-
code.computed = prot.access;
|
|
116
|
-
let style = undefined;
|
|
117
|
-
const fstyle = task.list[frm.taskId].app.files[frm.filename.slice(0, -2) + 'css'];
|
|
118
|
-
if (typeof fstyle === 'string') {
|
|
119
|
-
style = fstyle;
|
|
120
|
-
}
|
|
121
|
-
const fid = yield create({
|
|
122
|
-
'code': code,
|
|
123
|
-
'layout': layout,
|
|
124
|
-
'style': style,
|
|
125
|
-
'path': frm.filename.slice(0, frm.filename.lastIndexOf('/')),
|
|
126
|
-
'data': data,
|
|
127
|
-
'taskId': frm.taskId
|
|
128
|
-
});
|
|
129
|
-
if (fid > 0) {
|
|
130
|
-
return task.list[frm.taskId].forms[fid].vroot;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return fid;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
81
|
+
class AbstractCommon {
|
|
137
82
|
get filename() {
|
|
138
83
|
return '';
|
|
139
84
|
}
|
|
@@ -174,9 +119,20 @@ class AbstractForm {
|
|
|
174
119
|
return task.list[this.taskId].locale.lang || core.config.locale;
|
|
175
120
|
}
|
|
176
121
|
get l() {
|
|
177
|
-
return (key) => {
|
|
122
|
+
return (key, data) => {
|
|
178
123
|
var _a, _b, _c, _d;
|
|
179
|
-
|
|
124
|
+
const loc = (_d = (_b = (_a = task.list[this.taskId].locale.data[this.locale]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = task.list[this.taskId].locale.data['en']) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : 'LocaleError';
|
|
125
|
+
if (!data) {
|
|
126
|
+
return loc;
|
|
127
|
+
}
|
|
128
|
+
let i = -1;
|
|
129
|
+
return loc.replace(/\?/g, function () {
|
|
130
|
+
++i;
|
|
131
|
+
if (!data[i]) {
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
return data[i];
|
|
135
|
+
});
|
|
180
136
|
};
|
|
181
137
|
}
|
|
182
138
|
get classPrepend() {
|
|
@@ -205,31 +161,63 @@ class AbstractForm {
|
|
|
205
161
|
}
|
|
206
162
|
core.trigger(name, this.taskId, this.formId, param1, param2);
|
|
207
163
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
164
|
+
send(fid, obj) {
|
|
165
|
+
obj.taskId = this.taskId;
|
|
166
|
+
obj.formId = this.formId;
|
|
167
|
+
send(fid, obj);
|
|
168
|
+
}
|
|
169
|
+
onBeforeCreate() {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
onCreated() {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
onBeforeMount() {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
onBeforeUpdate() {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
onUpdated() {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
onBeforeUnmount() {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
onUnmounted() {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
class AbstractPanel extends AbstractCommon {
|
|
192
|
+
get panelId() {
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
onShow() {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
onHide() {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
onMounted() {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
onReceive() {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.AbstractPanel = AbstractPanel;
|
|
209
|
+
class AbstractForm extends AbstractCommon {
|
|
210
|
+
constructor() {
|
|
211
|
+
super(...arguments);
|
|
212
|
+
this.isNativeSync = false;
|
|
213
|
+
this._firstShow = true;
|
|
214
|
+
this.dialogResult = '';
|
|
222
215
|
}
|
|
223
216
|
get topMost() {
|
|
224
217
|
return false;
|
|
225
218
|
}
|
|
226
219
|
set topMost(v) {
|
|
227
220
|
}
|
|
228
|
-
send(fid, obj) {
|
|
229
|
-
obj.taskId = this.taskId;
|
|
230
|
-
obj.formId = this.formId;
|
|
231
|
-
send(fid, obj);
|
|
232
|
-
}
|
|
233
221
|
get isMask() {
|
|
234
222
|
return !task.list[this.taskId].runtime.dialogFormIds.length ||
|
|
235
223
|
task.list[this.taskId].runtime.dialogFormIds[task.list[this.taskId].runtime.dialogFormIds.length - 1]
|
|
@@ -237,7 +225,6 @@ class AbstractForm {
|
|
|
237
225
|
}
|
|
238
226
|
show() {
|
|
239
227
|
const v = this;
|
|
240
|
-
v.$refs.form.$data.isShow = true;
|
|
241
228
|
if (this._firstShow) {
|
|
242
229
|
this._firstShow = false;
|
|
243
230
|
const area = core.getAvailArea();
|
|
@@ -252,6 +239,9 @@ class AbstractForm {
|
|
|
252
239
|
v.$refs.form.$data.isShow = true;
|
|
253
240
|
changeFocus(this.formId);
|
|
254
241
|
}
|
|
242
|
+
else {
|
|
243
|
+
v.$refs.form.$data.isShow = true;
|
|
244
|
+
}
|
|
255
245
|
}
|
|
256
246
|
showDialog() {
|
|
257
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -272,30 +262,9 @@ class AbstractForm {
|
|
|
272
262
|
close() {
|
|
273
263
|
close(this.formId);
|
|
274
264
|
}
|
|
275
|
-
onBeforeCreate() {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
onCreated() {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
onBeforeMount() {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
265
|
onMounted() {
|
|
285
266
|
return;
|
|
286
267
|
}
|
|
287
|
-
onBeforeUpdate() {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
onUpdated() {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
onBeforeUnmount() {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
onUnmounted() {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
268
|
onReceive() {
|
|
300
269
|
return;
|
|
301
270
|
}
|
|
@@ -817,6 +786,57 @@ function getFocus() {
|
|
|
817
786
|
return focusId;
|
|
818
787
|
}
|
|
819
788
|
exports.getFocus = getFocus;
|
|
789
|
+
exports.activePanels = {};
|
|
790
|
+
function getActivePanel(formId) {
|
|
791
|
+
var _a;
|
|
792
|
+
return (_a = exports.activePanels[formId]) !== null && _a !== void 0 ? _a : [];
|
|
793
|
+
}
|
|
794
|
+
exports.getActivePanel = getActivePanel;
|
|
795
|
+
function removeActivePanel(panelId, formId, taskId) {
|
|
796
|
+
if (!taskId) {
|
|
797
|
+
return false;
|
|
798
|
+
}
|
|
799
|
+
if (!task.list[taskId]) {
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
if (!task.list[taskId].forms[formId]) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
if (!exports.activePanels[formId]) {
|
|
806
|
+
return true;
|
|
807
|
+
}
|
|
808
|
+
const io = exports.activePanels[formId].indexOf(panelId);
|
|
809
|
+
if (io === -1) {
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
812
|
+
exports.activePanels[formId].splice(io, 1);
|
|
813
|
+
if (!exports.activePanels[formId].length) {
|
|
814
|
+
delete exports.activePanels[formId];
|
|
815
|
+
}
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
exports.removeActivePanel = removeActivePanel;
|
|
819
|
+
function setActivePanel(panelId, formId, taskId) {
|
|
820
|
+
if (!taskId) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
if (!task.list[taskId]) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
if (!task.list[taskId].forms[formId]) {
|
|
827
|
+
return false;
|
|
828
|
+
}
|
|
829
|
+
if (!exports.activePanels[formId]) {
|
|
830
|
+
exports.activePanels[formId] = [];
|
|
831
|
+
}
|
|
832
|
+
const io = exports.activePanels[formId].indexOf(panelId);
|
|
833
|
+
if (io !== -1) {
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
exports.activePanels[formId].push(panelId);
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
exports.setActivePanel = setActivePanel;
|
|
820
840
|
function changeFocus(formId = 0) {
|
|
821
841
|
var _a;
|
|
822
842
|
if (typeof formId !== 'number') {
|
|
@@ -1454,6 +1474,7 @@ function remove(formId) {
|
|
|
1454
1474
|
dom.clearWatchStyle(formId);
|
|
1455
1475
|
dom.clearWatchProperty(formId);
|
|
1456
1476
|
native.clear(formId, taskId);
|
|
1477
|
+
delete exports.activePanels[formId];
|
|
1457
1478
|
if (Object.keys(task.list[taskId].forms).length === 0) {
|
|
1458
1479
|
task.end(taskId);
|
|
1459
1480
|
}
|
|
@@ -1465,6 +1486,39 @@ function remove(formId) {
|
|
|
1465
1486
|
}
|
|
1466
1487
|
}
|
|
1467
1488
|
exports.remove = remove;
|
|
1489
|
+
function removePanel(id, vapp, el) {
|
|
1490
|
+
var _a;
|
|
1491
|
+
const formWrap = dom.findParentByClass(el, 'cg-form-wrap');
|
|
1492
|
+
if (!formWrap) {
|
|
1493
|
+
return false;
|
|
1494
|
+
}
|
|
1495
|
+
const formId = formWrap.dataset.formId;
|
|
1496
|
+
if (!formId) {
|
|
1497
|
+
return false;
|
|
1498
|
+
}
|
|
1499
|
+
const taskId = formWrap.dataset.taskId;
|
|
1500
|
+
if (!taskId) {
|
|
1501
|
+
return false;
|
|
1502
|
+
}
|
|
1503
|
+
const tid = parseInt(taskId);
|
|
1504
|
+
vapp.unmount();
|
|
1505
|
+
vapp._container.remove();
|
|
1506
|
+
(_a = el.querySelector('[data-panel-id="' + id.toString() + '"]')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1507
|
+
dom.removeStyle(tid, 'form', formId, id);
|
|
1508
|
+
dom.clearWatchStyle(formId, id);
|
|
1509
|
+
dom.clearWatchProperty(formId, id);
|
|
1510
|
+
if (exports.activePanels[formId]) {
|
|
1511
|
+
const io = exports.activePanels[formId].indexOf(id);
|
|
1512
|
+
if (io >= 0) {
|
|
1513
|
+
exports.activePanels[formId].splice(io, 1);
|
|
1514
|
+
}
|
|
1515
|
+
if (!exports.activePanels[formId].length) {
|
|
1516
|
+
delete exports.activePanels[formId];
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return true;
|
|
1520
|
+
}
|
|
1521
|
+
exports.removePanel = removePanel;
|
|
1468
1522
|
function getForm(taskId, formId) {
|
|
1469
1523
|
const t = task.list[taskId];
|
|
1470
1524
|
if (!t) {
|
|
@@ -1476,60 +1530,334 @@ function getForm(taskId, formId) {
|
|
|
1476
1530
|
}
|
|
1477
1531
|
return form;
|
|
1478
1532
|
}
|
|
1479
|
-
function
|
|
1480
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1533
|
+
function createPanel(cls, el, formId, taskId) {
|
|
1481
1534
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1482
|
-
if (!
|
|
1483
|
-
|
|
1535
|
+
if (!taskId) {
|
|
1536
|
+
const err = new Error('form.createPanel: -1');
|
|
1537
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1538
|
+
throw err;
|
|
1539
|
+
}
|
|
1540
|
+
if (el.dataset.cgControl !== 'panel') {
|
|
1541
|
+
const err = new Error('form.createPanel: -2');
|
|
1542
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1543
|
+
throw err;
|
|
1484
1544
|
}
|
|
1485
|
-
const t = task.list[
|
|
1545
|
+
const t = task.list[taskId];
|
|
1486
1546
|
if (!t) {
|
|
1487
|
-
|
|
1547
|
+
const err = new Error('form.createPanel: -3');
|
|
1548
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1549
|
+
throw err;
|
|
1550
|
+
}
|
|
1551
|
+
let filename = '';
|
|
1552
|
+
if (typeof cls === 'string') {
|
|
1553
|
+
filename = cls + '.js';
|
|
1554
|
+
cls = class extends AbstractPanel {
|
|
1555
|
+
get filename() {
|
|
1556
|
+
return filename;
|
|
1557
|
+
}
|
|
1558
|
+
get taskId() {
|
|
1559
|
+
return t.id;
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1488
1562
|
}
|
|
1489
|
-
const
|
|
1490
|
-
const
|
|
1563
|
+
const panelId = ++info.lastPanelId;
|
|
1564
|
+
const panel = new cls();
|
|
1565
|
+
if (!filename) {
|
|
1566
|
+
filename = panel.filename;
|
|
1567
|
+
}
|
|
1568
|
+
const lio = filename.lastIndexOf('/');
|
|
1569
|
+
const path = filename.slice(0, lio);
|
|
1570
|
+
const l = t.app.files[filename.slice(0, -2) + 'xml'];
|
|
1571
|
+
if (typeof l !== 'string') {
|
|
1572
|
+
const err = new Error('form.createPanel: -4');
|
|
1573
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1574
|
+
throw err;
|
|
1575
|
+
}
|
|
1576
|
+
let layout = l;
|
|
1577
|
+
let style = '';
|
|
1578
|
+
let prep = '';
|
|
1579
|
+
const s = t.app.files[filename.slice(0, -2) + 'css'];
|
|
1580
|
+
if (typeof s === 'string') {
|
|
1581
|
+
style = s;
|
|
1582
|
+
const r = tool.stylePrepend(style);
|
|
1583
|
+
prep = r.prep;
|
|
1584
|
+
style = yield tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
|
|
1585
|
+
}
|
|
1586
|
+
layout = tool.purify(layout);
|
|
1587
|
+
layout = tool.layoutAddTagClassAndReTagName(layout, true);
|
|
1588
|
+
layout = tool.layoutInsertAttr(layout, ':form-focus=\'formFocus\'', {
|
|
1589
|
+
'include': [/^cg-.+/]
|
|
1590
|
+
});
|
|
1591
|
+
const prepList = ['cg-task' + t.id.toString() + '_'];
|
|
1592
|
+
if (prep !== '') {
|
|
1593
|
+
prepList.push(prep);
|
|
1594
|
+
}
|
|
1595
|
+
layout = tool.layoutClassPrepend(layout, prepList);
|
|
1596
|
+
layout = tool.eventsAttrWrap(layout);
|
|
1597
|
+
if (layout.includes('<teleport')) {
|
|
1598
|
+
layout = tool.teleportGlue(layout, formId);
|
|
1599
|
+
}
|
|
1600
|
+
const components = control.buildComponents(t.id, formId, path);
|
|
1491
1601
|
if (!components) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1602
|
+
const err = new Error('form.createPanel: -5');
|
|
1603
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1604
|
+
throw err;
|
|
1605
|
+
}
|
|
1606
|
+
const idata = {};
|
|
1607
|
+
const cdata = Object.entries(panel);
|
|
1608
|
+
for (const item of cdata) {
|
|
1609
|
+
if (item[0] === 'access') {
|
|
1610
|
+
continue;
|
|
1611
|
+
}
|
|
1612
|
+
idata[item[0]] = item[1];
|
|
1613
|
+
}
|
|
1614
|
+
idata._formFocus = false;
|
|
1615
|
+
const prot = tool.getClassPrototype(panel);
|
|
1616
|
+
const methods = prot.method;
|
|
1617
|
+
const computed = prot.access;
|
|
1618
|
+
computed.formId = {
|
|
1619
|
+
get: function () {
|
|
1620
|
+
return formId;
|
|
1621
|
+
},
|
|
1622
|
+
set: function () {
|
|
1623
|
+
notify({
|
|
1624
|
+
'title': 'Error',
|
|
1625
|
+
'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
|
|
1626
|
+
'type': 'danger'
|
|
1627
|
+
});
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
computed.panelId = {
|
|
1632
|
+
get: function () {
|
|
1633
|
+
return panelId;
|
|
1634
|
+
},
|
|
1635
|
+
set: function () {
|
|
1636
|
+
notify({
|
|
1637
|
+
'title': 'Error',
|
|
1638
|
+
'content': `The software tries to modify the system variable "panelId".\nPath: ${this.filename}`,
|
|
1639
|
+
'type': 'danger'
|
|
1640
|
+
});
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
computed.path = {
|
|
1645
|
+
get: function () {
|
|
1646
|
+
return path;
|
|
1647
|
+
},
|
|
1648
|
+
set: function () {
|
|
1649
|
+
notify({
|
|
1650
|
+
'title': 'Error',
|
|
1651
|
+
'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
|
|
1652
|
+
'type': 'danger'
|
|
1653
|
+
});
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
computed.prep = {
|
|
1658
|
+
get: function () {
|
|
1659
|
+
return prep;
|
|
1660
|
+
},
|
|
1661
|
+
set: function () {
|
|
1662
|
+
notify({
|
|
1663
|
+
'title': 'Error',
|
|
1664
|
+
'content': `The software tries to modify the system variable "cgPrep".\nPath: ${this.filename}`,
|
|
1665
|
+
'type': 'danger'
|
|
1666
|
+
});
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
el.insertAdjacentHTML('beforeend', `<div data-panel-id="${panelId.toString()}"></div>`);
|
|
1671
|
+
if (style) {
|
|
1672
|
+
dom.pushStyle(t.id, style, 'form', formId, panelId);
|
|
1673
|
+
}
|
|
1674
|
+
const mel = el.children.item(el.children.length - 1);
|
|
1675
|
+
mel.style.flex = '1';
|
|
1676
|
+
const rtn = yield new Promise(function (resolve) {
|
|
1677
|
+
const vapp = clickgo.vue.createApp({
|
|
1678
|
+
'template': layout.replace(/^<cg-panel([\s\S]+)-panel>$/, '<cg-layout$1-layout>'),
|
|
1679
|
+
'data': function () {
|
|
1680
|
+
return tool.clone(idata);
|
|
1681
|
+
},
|
|
1682
|
+
'methods': methods,
|
|
1683
|
+
'computed': computed,
|
|
1684
|
+
'beforeCreate': panel.onBeforeCreate,
|
|
1685
|
+
'created': function () {
|
|
1686
|
+
if (panel.access) {
|
|
1687
|
+
this.access = tool.clone(panel.access);
|
|
1688
|
+
}
|
|
1689
|
+
this.onCreated();
|
|
1690
|
+
},
|
|
1691
|
+
'beforeMount': function () {
|
|
1692
|
+
this.onBeforeMount();
|
|
1693
|
+
},
|
|
1694
|
+
'mounted': function () {
|
|
1695
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1696
|
+
yield this.$nextTick();
|
|
1697
|
+
mel.children.item(0).style.flex = '1';
|
|
1698
|
+
resolve({
|
|
1699
|
+
'vapp': vapp,
|
|
1700
|
+
'vroot': this
|
|
1701
|
+
});
|
|
1702
|
+
});
|
|
1703
|
+
},
|
|
1704
|
+
'beforeUpdate': function () {
|
|
1705
|
+
this.onBeforeUpdate();
|
|
1706
|
+
},
|
|
1707
|
+
'updated': function () {
|
|
1708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1709
|
+
yield this.$nextTick();
|
|
1710
|
+
this.onUpdated();
|
|
1711
|
+
});
|
|
1712
|
+
},
|
|
1713
|
+
'beforeUnmount': function () {
|
|
1714
|
+
this.onBeforeUnmount();
|
|
1715
|
+
},
|
|
1716
|
+
'unmounted': function () {
|
|
1717
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1718
|
+
yield this.$nextTick();
|
|
1719
|
+
this.onUnmounted();
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
});
|
|
1723
|
+
vapp.config.errorHandler = function (err, vm, info) {
|
|
1724
|
+
notify({
|
|
1725
|
+
'title': 'Runtime Error',
|
|
1726
|
+
'content': `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`,
|
|
1727
|
+
'type': 'danger'
|
|
1728
|
+
});
|
|
1729
|
+
core.trigger('error', vm.taskId, vm.formId, err, info + '(-3,' + vm.taskId + ',' + vm.formId + ')');
|
|
1730
|
+
};
|
|
1731
|
+
for (const key in components) {
|
|
1732
|
+
vapp.component(key, components[key]);
|
|
1733
|
+
}
|
|
1734
|
+
try {
|
|
1735
|
+
vapp.mount(mel);
|
|
1736
|
+
}
|
|
1737
|
+
catch (err) {
|
|
1738
|
+
notify({
|
|
1739
|
+
'title': 'Runtime Error',
|
|
1740
|
+
'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
|
|
1741
|
+
'type': 'danger'
|
|
1742
|
+
});
|
|
1743
|
+
core.trigger('error', t.id, formId, err, err.message);
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
yield tool.sleep(34);
|
|
1747
|
+
try {
|
|
1748
|
+
yield panel.onMounted.call(rtn.vroot);
|
|
1749
|
+
}
|
|
1750
|
+
catch (err) {
|
|
1751
|
+
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create panel mounted error: -6.');
|
|
1752
|
+
try {
|
|
1753
|
+
rtn.vapp.unmount();
|
|
1754
|
+
}
|
|
1755
|
+
catch (err) {
|
|
1756
|
+
const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.createPanel, unmount.`;
|
|
1757
|
+
notify({
|
|
1758
|
+
'title': 'Panel Unmount Error',
|
|
1759
|
+
'content': msg,
|
|
1760
|
+
'type': 'danger'
|
|
1761
|
+
});
|
|
1762
|
+
console.log('Panel Unmount Error', msg, err);
|
|
1763
|
+
}
|
|
1764
|
+
rtn.vapp._container.remove();
|
|
1765
|
+
dom.clearWatchStyle(rtn.vroot.formId, panelId);
|
|
1766
|
+
dom.clearWatchProperty(rtn.vroot.formId, panelId);
|
|
1767
|
+
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId, panelId);
|
|
1768
|
+
throw err;
|
|
1769
|
+
}
|
|
1770
|
+
return {
|
|
1771
|
+
'id': panelId,
|
|
1772
|
+
'vapp': rtn.vapp,
|
|
1773
|
+
'vroot': rtn.vroot
|
|
1774
|
+
};
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
exports.createPanel = createPanel;
|
|
1778
|
+
function create(cls, data, opt = {}, taskId) {
|
|
1779
|
+
var _a, _b;
|
|
1780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1781
|
+
if (!taskId) {
|
|
1782
|
+
const err = new Error('form.create: -1');
|
|
1783
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1784
|
+
throw err;
|
|
1785
|
+
}
|
|
1786
|
+
const t = task.list[taskId];
|
|
1787
|
+
if (!t) {
|
|
1788
|
+
const err = new Error('form.create: -2');
|
|
1789
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1790
|
+
throw err;
|
|
1791
|
+
}
|
|
1792
|
+
let layout = '';
|
|
1793
|
+
if (opt.layout) {
|
|
1794
|
+
layout = opt.layout;
|
|
1519
1795
|
}
|
|
1520
1796
|
let style = '';
|
|
1521
1797
|
let prep = '';
|
|
1522
1798
|
if (opt.style) {
|
|
1523
|
-
|
|
1799
|
+
style = opt.style;
|
|
1800
|
+
}
|
|
1801
|
+
let filename = '';
|
|
1802
|
+
if (typeof cls === 'string') {
|
|
1803
|
+
filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', cls);
|
|
1804
|
+
if (!layout) {
|
|
1805
|
+
const l = t.app.files[filename + '.xml'];
|
|
1806
|
+
if (typeof l !== 'string') {
|
|
1807
|
+
const err = new Error('form.create: -3');
|
|
1808
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1809
|
+
throw err;
|
|
1810
|
+
}
|
|
1811
|
+
layout = l;
|
|
1812
|
+
}
|
|
1813
|
+
if (!style) {
|
|
1814
|
+
const s = t.app.files[filename + '.css'];
|
|
1815
|
+
if (typeof s === 'string') {
|
|
1816
|
+
style = s;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
cls = class extends AbstractForm {
|
|
1820
|
+
get filename() {
|
|
1821
|
+
return filename + '.js';
|
|
1822
|
+
}
|
|
1823
|
+
get taskId() {
|
|
1824
|
+
return t.id;
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
const formId = ++info.lastId;
|
|
1829
|
+
const frm = new cls();
|
|
1830
|
+
if (!filename) {
|
|
1831
|
+
filename = frm.filename;
|
|
1832
|
+
}
|
|
1833
|
+
const lio = filename.lastIndexOf('/');
|
|
1834
|
+
const path = filename.slice(0, lio);
|
|
1835
|
+
if (!layout) {
|
|
1836
|
+
const l = t.app.files[filename.slice(0, -2) + 'xml'];
|
|
1837
|
+
if (typeof l !== 'string') {
|
|
1838
|
+
const err = new Error('form.create: -4');
|
|
1839
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1840
|
+
throw err;
|
|
1841
|
+
}
|
|
1842
|
+
layout = l;
|
|
1843
|
+
}
|
|
1844
|
+
if (!style) {
|
|
1845
|
+
const s = t.app.files[filename.slice(0, -2) + 'css'];
|
|
1846
|
+
if (typeof s === 'string') {
|
|
1847
|
+
style = s;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
if (style) {
|
|
1851
|
+
const r = tool.stylePrepend(style);
|
|
1524
1852
|
prep = r.prep;
|
|
1525
|
-
style = yield tool.styleUrl2DataUrl(
|
|
1853
|
+
style = yield tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
|
|
1526
1854
|
}
|
|
1527
|
-
|
|
1855
|
+
layout = tool.purify(layout);
|
|
1528
1856
|
layout = tool.layoutAddTagClassAndReTagName(layout, true);
|
|
1529
1857
|
layout = tool.layoutInsertAttr(layout, ':form-focus=\'formFocus\'', {
|
|
1530
1858
|
'include': [/^cg-.+/]
|
|
1531
1859
|
});
|
|
1532
|
-
const prepList = ['cg-task' +
|
|
1860
|
+
const prepList = ['cg-task' + t.id.toString() + '_'];
|
|
1533
1861
|
if (prep !== '') {
|
|
1534
1862
|
prepList.push(prep);
|
|
1535
1863
|
}
|
|
@@ -1538,9 +1866,27 @@ function create(opt) {
|
|
|
1538
1866
|
if (layout.includes('<teleport')) {
|
|
1539
1867
|
layout = tool.teleportGlue(layout, formId);
|
|
1540
1868
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1869
|
+
const components = control.buildComponents(t.id, formId, path);
|
|
1870
|
+
if (!components) {
|
|
1871
|
+
const err = new Error('form.create: -5');
|
|
1872
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1873
|
+
throw err;
|
|
1874
|
+
}
|
|
1875
|
+
const idata = {};
|
|
1876
|
+
const cdata = Object.entries(frm);
|
|
1877
|
+
for (const item of cdata) {
|
|
1878
|
+
if (item[0] === 'access') {
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1881
|
+
idata[item[0]] = item[1];
|
|
1882
|
+
}
|
|
1883
|
+
idata._formFocus = false;
|
|
1884
|
+
if (clickgo.isNative() && (formId === 1) && !clickgo.isImmersion() && !clickgo.hasFrame()) {
|
|
1885
|
+
idata.isNativeSync = true;
|
|
1886
|
+
}
|
|
1887
|
+
const prot = tool.getClassPrototype(frm);
|
|
1888
|
+
const methods = prot.method;
|
|
1889
|
+
const computed = prot.access;
|
|
1544
1890
|
computed.formId = {
|
|
1545
1891
|
get: function () {
|
|
1546
1892
|
return formId;
|
|
@@ -1554,11 +1900,9 @@ function create(opt) {
|
|
|
1554
1900
|
return;
|
|
1555
1901
|
}
|
|
1556
1902
|
};
|
|
1557
|
-
data._formFocus = false;
|
|
1558
1903
|
computed.path = {
|
|
1559
1904
|
get: function () {
|
|
1560
|
-
|
|
1561
|
-
return (_a = opt.path) !== null && _a !== void 0 ? _a : '';
|
|
1905
|
+
return path;
|
|
1562
1906
|
},
|
|
1563
1907
|
set: function () {
|
|
1564
1908
|
notify({
|
|
@@ -1582,7 +1926,7 @@ function create(opt) {
|
|
|
1582
1926
|
return;
|
|
1583
1927
|
}
|
|
1584
1928
|
};
|
|
1585
|
-
|
|
1929
|
+
idata._topMost = false;
|
|
1586
1930
|
computed.topMost = {
|
|
1587
1931
|
get: function () {
|
|
1588
1932
|
return this._topMost;
|
|
@@ -1608,34 +1952,35 @@ function create(opt) {
|
|
|
1608
1952
|
return;
|
|
1609
1953
|
}
|
|
1610
1954
|
};
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
}
|
|
1955
|
+
exports.elements.list.insertAdjacentHTML('beforeend', `<div class="cg-form-wrap" data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
|
|
1956
|
+
exports.elements.popList.insertAdjacentHTML('beforeend', `<div data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
|
|
1614
1957
|
if (style) {
|
|
1615
|
-
dom.pushStyle(
|
|
1958
|
+
dom.pushStyle(t.id, style, 'form', formId);
|
|
1616
1959
|
}
|
|
1960
|
+
const el = exports.elements.list.children.item(exports.elements.list.children.length - 1);
|
|
1617
1961
|
const rtn = yield new Promise(function (resolve) {
|
|
1618
1962
|
const vapp = clickgo.vue.createApp({
|
|
1619
1963
|
'template': layout.replace(/^<cg-form/, '<cg-form ref="form"'),
|
|
1620
1964
|
'data': function () {
|
|
1621
|
-
return tool.clone(
|
|
1965
|
+
return tool.clone(idata);
|
|
1622
1966
|
},
|
|
1623
1967
|
'methods': methods,
|
|
1624
1968
|
'computed': computed,
|
|
1625
|
-
'beforeCreate':
|
|
1969
|
+
'beforeCreate': frm.onBeforeCreate,
|
|
1626
1970
|
'created': function () {
|
|
1627
|
-
|
|
1628
|
-
|
|
1971
|
+
if (frm.access) {
|
|
1972
|
+
this.access = tool.clone(frm.access);
|
|
1973
|
+
}
|
|
1974
|
+
this.onCreated();
|
|
1975
|
+
},
|
|
1976
|
+
'beforeMount': function () {
|
|
1977
|
+
this.onBeforeMount();
|
|
1629
1978
|
},
|
|
1630
|
-
'beforeMount': beforeMount,
|
|
1631
1979
|
'mounted': function () {
|
|
1632
1980
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1633
1981
|
yield this.$nextTick();
|
|
1634
1982
|
if (this.$refs.form.icon) {
|
|
1635
|
-
const icon = yield fs.getContent(this.$refs.form.icon,
|
|
1636
|
-
'current': t.current,
|
|
1637
|
-
'files': t.app.files
|
|
1638
|
-
});
|
|
1983
|
+
const icon = yield fs.getContent(this.$refs.form.icon, undefined, taskId);
|
|
1639
1984
|
this.$refs.form.iconDataUrl = (icon instanceof Blob) ? yield tool.blob2DataUrl(icon) : '';
|
|
1640
1985
|
}
|
|
1641
1986
|
resolve({
|
|
@@ -1644,10 +1989,24 @@ function create(opt) {
|
|
|
1644
1989
|
});
|
|
1645
1990
|
});
|
|
1646
1991
|
},
|
|
1647
|
-
'beforeUpdate':
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
'
|
|
1992
|
+
'beforeUpdate': function () {
|
|
1993
|
+
this.onBeforeUpdate();
|
|
1994
|
+
},
|
|
1995
|
+
'updated': function () {
|
|
1996
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1997
|
+
yield this.$nextTick();
|
|
1998
|
+
this.onUpdated();
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
2001
|
+
'beforeUnmount': function () {
|
|
2002
|
+
this.onBeforeUnmount();
|
|
2003
|
+
},
|
|
2004
|
+
'unmounted': function () {
|
|
2005
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2006
|
+
yield this.$nextTick();
|
|
2007
|
+
this.onUnmounted();
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
1651
2010
|
});
|
|
1652
2011
|
vapp.config.errorHandler = function (err, vm, info) {
|
|
1653
2012
|
notify({
|
|
@@ -1666,10 +2025,10 @@ function create(opt) {
|
|
|
1666
2025
|
catch (err) {
|
|
1667
2026
|
notify({
|
|
1668
2027
|
'title': 'Runtime Error',
|
|
1669
|
-
'content': `Message: ${err.message}\nTask id: ${
|
|
2028
|
+
'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
|
|
1670
2029
|
'type': 'danger'
|
|
1671
2030
|
});
|
|
1672
|
-
core.trigger('error',
|
|
2031
|
+
core.trigger('error', t.id, formId, err, err.message);
|
|
1673
2032
|
}
|
|
1674
2033
|
});
|
|
1675
2034
|
const nform = {
|
|
@@ -1679,35 +2038,33 @@ function create(opt) {
|
|
|
1679
2038
|
};
|
|
1680
2039
|
t.forms[formId] = nform;
|
|
1681
2040
|
yield tool.sleep(34);
|
|
1682
|
-
|
|
2041
|
+
try {
|
|
2042
|
+
yield frm.onMounted.call(rtn.vroot, data !== null && data !== void 0 ? data : {});
|
|
2043
|
+
}
|
|
2044
|
+
catch (err) {
|
|
2045
|
+
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -6.');
|
|
2046
|
+
delete t.forms[formId];
|
|
1683
2047
|
try {
|
|
1684
|
-
|
|
2048
|
+
rtn.vapp.unmount();
|
|
1685
2049
|
}
|
|
1686
2050
|
catch (err) {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
notify({
|
|
1695
|
-
'title': 'Form Unmount Error',
|
|
1696
|
-
'content': msg,
|
|
1697
|
-
'type': 'danger'
|
|
1698
|
-
});
|
|
1699
|
-
console.log('Form Unmount Error', msg, err);
|
|
1700
|
-
}
|
|
1701
|
-
rtn.vapp._container.remove();
|
|
1702
|
-
(_f = exports.elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')) === null || _f === void 0 ? void 0 : _f.remove();
|
|
1703
|
-
dom.clearWatchStyle(rtn.vroot.formId);
|
|
1704
|
-
dom.clearWatchProperty(rtn.vroot.formId);
|
|
1705
|
-
native.clear(formId, t.id);
|
|
1706
|
-
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
|
|
1707
|
-
return -8;
|
|
2051
|
+
const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.create, unmount.`;
|
|
2052
|
+
notify({
|
|
2053
|
+
'title': 'Form Unmount Error',
|
|
2054
|
+
'content': msg,
|
|
2055
|
+
'type': 'danger'
|
|
2056
|
+
});
|
|
2057
|
+
console.log('Form Unmount Error', msg, err);
|
|
1708
2058
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
2059
|
+
rtn.vapp._container.remove();
|
|
2060
|
+
(_b = exports.elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
2061
|
+
dom.clearWatchStyle(rtn.vroot.formId);
|
|
2062
|
+
dom.clearWatchProperty(rtn.vroot.formId);
|
|
2063
|
+
native.clear(formId, t.id);
|
|
2064
|
+
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
|
|
2065
|
+
throw err;
|
|
2066
|
+
}
|
|
2067
|
+
core.trigger('formCreated', t.id, formId, rtn.vroot.$refs.form.title, rtn.vroot.$refs.form.iconDataUrl);
|
|
1711
2068
|
if (rtn.vroot.isNativeSync) {
|
|
1712
2069
|
yield native.invoke('cg-set-size', native.getToken(), rtn.vroot.$refs.form.$el.offsetWidth, rtn.vroot.$refs.form.$el.offsetHeight);
|
|
1713
2070
|
window.addEventListener('resize', function () {
|
|
@@ -1715,18 +2072,19 @@ function create(opt) {
|
|
|
1715
2072
|
rtn.vroot.$refs.form.setPropData('height', window.innerHeight);
|
|
1716
2073
|
});
|
|
1717
2074
|
}
|
|
1718
|
-
return
|
|
2075
|
+
return rtn.vroot;
|
|
1719
2076
|
});
|
|
1720
2077
|
}
|
|
1721
2078
|
exports.create = create;
|
|
1722
2079
|
function dialog(opt) {
|
|
1723
2080
|
return new Promise(function (resolve) {
|
|
1724
|
-
var _a, _b, _c;
|
|
2081
|
+
var _a, _b, _c, _d;
|
|
1725
2082
|
if (typeof opt === 'string') {
|
|
1726
2083
|
opt = {
|
|
1727
2084
|
'content': opt
|
|
1728
2085
|
};
|
|
1729
2086
|
}
|
|
2087
|
+
const filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', './tmp' + (Math.random() * 100000000000000).toFixed() + '.js');
|
|
1730
2088
|
const nopt = opt;
|
|
1731
2089
|
const taskId = nopt.taskId;
|
|
1732
2090
|
if (!taskId) {
|
|
@@ -1740,13 +2098,16 @@ function dialog(opt) {
|
|
|
1740
2098
|
}
|
|
1741
2099
|
const locale = t.locale.lang || core.config.locale;
|
|
1742
2100
|
if (nopt.buttons === undefined) {
|
|
1743
|
-
nopt.buttons = [(
|
|
2101
|
+
nopt.buttons = [(_c = (_b = info.locale[locale]) === null || _b === void 0 ? void 0 : _b.ok) !== null && _c !== void 0 ? _c : info.locale['en'].ok];
|
|
1744
2102
|
}
|
|
1745
2103
|
const cls = class extends AbstractForm {
|
|
1746
2104
|
constructor() {
|
|
1747
2105
|
super(...arguments);
|
|
1748
2106
|
this.buttons = nopt.buttons;
|
|
1749
2107
|
}
|
|
2108
|
+
get filename() {
|
|
2109
|
+
return filename;
|
|
2110
|
+
}
|
|
1750
2111
|
get taskId() {
|
|
1751
2112
|
return taskId;
|
|
1752
2113
|
}
|
|
@@ -1765,7 +2126,10 @@ function dialog(opt) {
|
|
|
1765
2126
|
}
|
|
1766
2127
|
}
|
|
1767
2128
|
};
|
|
1768
|
-
|
|
2129
|
+
create(cls, undefined, {
|
|
2130
|
+
'layout': `<form title="${(_d = nopt.title) !== null && _d !== void 0 ? _d : 'dialog'}" min="false" max="false" resize="false" height="0" width="0" border="${nopt.title ? 'normal' : 'plain'}" direction="v"><dialog :buttons="buttons" @select="select"${nopt.direction ? ` direction="${nopt.direction}"` : ''}>${nopt.content}</dialog></form>`,
|
|
2131
|
+
'style': nopt.style
|
|
2132
|
+
}, t.id).then((frm) => {
|
|
1769
2133
|
if (typeof frm === 'number') {
|
|
1770
2134
|
resolve('');
|
|
1771
2135
|
return;
|