clickgo 3.1.5-dev14 → 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 +28 -2
- package/dist/app/demo/config.json +17 -1
- 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 +24 -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 +84 -33
- package/dist/app/demo/form/main.xml +5 -0
- package/dist/app/demo/form/method/aform/aform.js +28 -2
- package/dist/app/demo/form/method/aform/sd.js +24 -1
- 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 +35 -1
- package/dist/app/demo/form/method/form/form.xml +2 -0
- package/dist/app/demo/form/method/fs/fs.js +138 -4
- 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 +35 -1
- package/dist/app/demo/form/method/zip/zip.js +29 -3
- package/dist/app/task/app.js +28 -2
- 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 -45
- package/dist/lib/core.ts +17 -41
- package/dist/lib/dom.js +322 -108
- package/dist/lib/dom.ts +394 -127
- package/dist/lib/form.js +441 -58
- package/dist/lib/form.ts +525 -74
- 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 +143 -136
- package/dist/lib/task.ts +124 -127
- package/dist/lib/theme.js +27 -4
- package/dist/lib/tool.js +19 -2
- package/dist/lib/tool.ts +23 -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 +4 -6
- package/types/index.d.ts +42 -34
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,12 +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
|
-
}
|
|
81
|
+
class AbstractCommon {
|
|
63
82
|
get filename() {
|
|
64
83
|
return '';
|
|
65
84
|
}
|
|
@@ -100,9 +119,20 @@ class AbstractForm {
|
|
|
100
119
|
return task.list[this.taskId].locale.lang || core.config.locale;
|
|
101
120
|
}
|
|
102
121
|
get l() {
|
|
103
|
-
return (key) => {
|
|
122
|
+
return (key, data) => {
|
|
104
123
|
var _a, _b, _c, _d;
|
|
105
|
-
|
|
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
|
+
});
|
|
106
136
|
};
|
|
107
137
|
}
|
|
108
138
|
get classPrepend() {
|
|
@@ -131,16 +161,63 @@ class AbstractForm {
|
|
|
131
161
|
}
|
|
132
162
|
core.trigger(name, this.taskId, this.formId, param1, param2);
|
|
133
163
|
}
|
|
134
|
-
get topMost() {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
set topMost(v) {
|
|
138
|
-
}
|
|
139
164
|
send(fid, obj) {
|
|
140
165
|
obj.taskId = this.taskId;
|
|
141
166
|
obj.formId = this.formId;
|
|
142
167
|
send(fid, obj);
|
|
143
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 = '';
|
|
215
|
+
}
|
|
216
|
+
get topMost() {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
set topMost(v) {
|
|
220
|
+
}
|
|
144
221
|
get isMask() {
|
|
145
222
|
return !task.list[this.taskId].runtime.dialogFormIds.length ||
|
|
146
223
|
task.list[this.taskId].runtime.dialogFormIds[task.list[this.taskId].runtime.dialogFormIds.length - 1]
|
|
@@ -185,30 +262,9 @@ class AbstractForm {
|
|
|
185
262
|
close() {
|
|
186
263
|
close(this.formId);
|
|
187
264
|
}
|
|
188
|
-
onBeforeCreate() {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
onCreated() {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
onBeforeMount() {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
265
|
onMounted() {
|
|
198
266
|
return;
|
|
199
267
|
}
|
|
200
|
-
onBeforeUpdate() {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
onUpdated() {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
onBeforeUnmount() {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
onUnmounted() {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
268
|
onReceive() {
|
|
213
269
|
return;
|
|
214
270
|
}
|
|
@@ -730,6 +786,57 @@ function getFocus() {
|
|
|
730
786
|
return focusId;
|
|
731
787
|
}
|
|
732
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;
|
|
733
840
|
function changeFocus(formId = 0) {
|
|
734
841
|
var _a;
|
|
735
842
|
if (typeof formId !== 'number') {
|
|
@@ -1367,6 +1474,7 @@ function remove(formId) {
|
|
|
1367
1474
|
dom.clearWatchStyle(formId);
|
|
1368
1475
|
dom.clearWatchProperty(formId);
|
|
1369
1476
|
native.clear(formId, taskId);
|
|
1477
|
+
delete exports.activePanels[formId];
|
|
1370
1478
|
if (Object.keys(task.list[taskId].forms).length === 0) {
|
|
1371
1479
|
task.end(taskId);
|
|
1372
1480
|
}
|
|
@@ -1378,6 +1486,39 @@ function remove(formId) {
|
|
|
1378
1486
|
}
|
|
1379
1487
|
}
|
|
1380
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;
|
|
1381
1522
|
function getForm(taskId, formId) {
|
|
1382
1523
|
const t = task.list[taskId];
|
|
1383
1524
|
if (!t) {
|
|
@@ -1389,6 +1530,251 @@ function getForm(taskId, formId) {
|
|
|
1389
1530
|
}
|
|
1390
1531
|
return form;
|
|
1391
1532
|
}
|
|
1533
|
+
function createPanel(cls, el, formId, taskId) {
|
|
1534
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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;
|
|
1544
|
+
}
|
|
1545
|
+
const t = task.list[taskId];
|
|
1546
|
+
if (!t) {
|
|
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
|
+
};
|
|
1562
|
+
}
|
|
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);
|
|
1601
|
+
if (!components) {
|
|
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;
|
|
1392
1778
|
function create(cls, data, opt = {}, taskId) {
|
|
1393
1779
|
var _a, _b;
|
|
1394
1780
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1408,10 +1794,10 @@ function create(cls, data, opt = {}, taskId) {
|
|
|
1408
1794
|
layout = opt.layout;
|
|
1409
1795
|
}
|
|
1410
1796
|
let style = '';
|
|
1797
|
+
let prep = '';
|
|
1411
1798
|
if (opt.style) {
|
|
1412
1799
|
style = opt.style;
|
|
1413
1800
|
}
|
|
1414
|
-
let prep = '';
|
|
1415
1801
|
let filename = '';
|
|
1416
1802
|
if (typeof cls === 'string') {
|
|
1417
1803
|
filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', cls);
|
|
@@ -1446,6 +1832,15 @@ function create(cls, data, opt = {}, taskId) {
|
|
|
1446
1832
|
}
|
|
1447
1833
|
const lio = filename.lastIndexOf('/');
|
|
1448
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
|
+
}
|
|
1449
1844
|
if (!style) {
|
|
1450
1845
|
const s = t.app.files[filename.slice(0, -2) + 'css'];
|
|
1451
1846
|
if (typeof s === 'string') {
|
|
@@ -1457,15 +1852,6 @@ function create(cls, data, opt = {}, taskId) {
|
|
|
1457
1852
|
prep = r.prep;
|
|
1458
1853
|
style = yield tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
|
|
1459
1854
|
}
|
|
1460
|
-
if (!layout) {
|
|
1461
|
-
const l = t.app.files[frm.filename.slice(0, -2) + 'xml'];
|
|
1462
|
-
if (typeof l !== 'string') {
|
|
1463
|
-
const err = new Error('form.create: -4');
|
|
1464
|
-
core.trigger('error', 0, 0, err, err.message);
|
|
1465
|
-
throw err;
|
|
1466
|
-
}
|
|
1467
|
-
layout = l;
|
|
1468
|
-
}
|
|
1469
1855
|
layout = tool.purify(layout);
|
|
1470
1856
|
layout = tool.layoutAddTagClassAndReTagName(layout, true);
|
|
1471
1857
|
layout = tool.layoutInsertAttr(layout, ':form-focus=\'formFocus\'', {
|
|
@@ -1594,10 +1980,7 @@ function create(cls, data, opt = {}, taskId) {
|
|
|
1594
1980
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1595
1981
|
yield this.$nextTick();
|
|
1596
1982
|
if (this.$refs.form.icon) {
|
|
1597
|
-
const icon = yield fs.getContent(this.$refs.form.icon,
|
|
1598
|
-
'current': t.current,
|
|
1599
|
-
'files': t.app.files
|
|
1600
|
-
});
|
|
1983
|
+
const icon = yield fs.getContent(this.$refs.form.icon, undefined, taskId);
|
|
1601
1984
|
this.$refs.form.iconDataUrl = (icon instanceof Blob) ? yield tool.blob2DataUrl(icon) : '';
|
|
1602
1985
|
}
|
|
1603
1986
|
resolve({
|
|
@@ -1659,7 +2042,7 @@ function create(cls, data, opt = {}, taskId) {
|
|
|
1659
2042
|
yield frm.onMounted.call(rtn.vroot, data !== null && data !== void 0 ? data : {});
|
|
1660
2043
|
}
|
|
1661
2044
|
catch (err) {
|
|
1662
|
-
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -
|
|
2045
|
+
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -6.');
|
|
1663
2046
|
delete t.forms[formId];
|
|
1664
2047
|
try {
|
|
1665
2048
|
rtn.vapp.unmount();
|