@azrico/webobject 1.4.0 → 1.4.2
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.
|
@@ -9,12 +9,6 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
|
|
|
9
9
|
static readonly __web_type: string;
|
|
10
10
|
static readonly __save_message: boolean;
|
|
11
11
|
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* use an option and detect its changes in real time. similar to recat state
|
|
14
|
-
* @param key name of the option
|
|
15
|
-
* @returns value of the option
|
|
16
|
-
*/
|
|
17
|
-
useOption(key: string): Promise<any>;
|
|
18
12
|
/**
|
|
19
13
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
20
14
|
* @param key
|
|
@@ -78,47 +78,17 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
78
78
|
return _this;
|
|
79
79
|
}
|
|
80
80
|
/* -------------------------------------------------------------------------- */
|
|
81
|
-
/*
|
|
81
|
+
/* Meta data */
|
|
82
82
|
/* -------------------------------------------------------------------------- */
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @param key
|
|
86
|
-
* @
|
|
84
|
+
* Update meta value of this object , meta data is stored in meta_data variable
|
|
85
|
+
* @param key
|
|
86
|
+
* @param value
|
|
87
|
+
* @param createIfNotExists should we create a new meta if key does not exist
|
|
88
|
+
* @param sendChange
|
|
89
|
+
* @returns
|
|
87
90
|
*/
|
|
88
91
|
_createClass(WebObjectManager, [{
|
|
89
|
-
key: "useOption",
|
|
90
|
-
value: function () {
|
|
91
|
-
var _useOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
|
|
92
|
-
var _this2 = this;
|
|
93
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
94
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
-
case 0:
|
|
96
|
-
return _context2.abrupt("return", this.event_use("on_option_change", function () {
|
|
97
|
-
return Boolean(_this2.getOption(key));
|
|
98
|
-
}, [key], false));
|
|
99
|
-
case 1:
|
|
100
|
-
case "end":
|
|
101
|
-
return _context2.stop();
|
|
102
|
-
}
|
|
103
|
-
}, _callee2, this);
|
|
104
|
-
}));
|
|
105
|
-
function useOption(_x) {
|
|
106
|
-
return _useOption.apply(this, arguments);
|
|
107
|
-
}
|
|
108
|
-
return useOption;
|
|
109
|
-
}()
|
|
110
|
-
/* -------------------------------------------------------------------------- */
|
|
111
|
-
/* Meta data */
|
|
112
|
-
/* -------------------------------------------------------------------------- */
|
|
113
|
-
/**
|
|
114
|
-
* Update meta value of this object , meta data is stored in meta_data variable
|
|
115
|
-
* @param key
|
|
116
|
-
* @param value
|
|
117
|
-
* @param createIfNotExists should we create a new meta if key does not exist
|
|
118
|
-
* @param sendChange
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
}, {
|
|
122
92
|
key: "setMetaValue",
|
|
123
93
|
value: function setMetaValue(key, value) {
|
|
124
94
|
var _this$obj;
|
|
@@ -142,27 +112,27 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
142
112
|
}, {
|
|
143
113
|
key: "get_deltaObject",
|
|
144
114
|
value: function () {
|
|
145
|
-
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
115
|
+
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
146
116
|
var _this$obj4;
|
|
147
|
-
return _regeneratorRuntime().wrap(function
|
|
148
|
-
while (1) switch (
|
|
117
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
118
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
149
119
|
case 0:
|
|
150
|
-
|
|
120
|
+
_context2.next = 2;
|
|
151
121
|
return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.get_deltaObject();
|
|
152
122
|
case 2:
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
123
|
+
_context2.t0 = _context2.sent;
|
|
124
|
+
if (_context2.t0) {
|
|
125
|
+
_context2.next = 5;
|
|
156
126
|
break;
|
|
157
127
|
}
|
|
158
|
-
|
|
128
|
+
_context2.t0 = {};
|
|
159
129
|
case 5:
|
|
160
|
-
return
|
|
130
|
+
return _context2.abrupt("return", _context2.t0);
|
|
161
131
|
case 6:
|
|
162
132
|
case "end":
|
|
163
|
-
return
|
|
133
|
+
return _context2.stop();
|
|
164
134
|
}
|
|
165
|
-
},
|
|
135
|
+
}, _callee2, this);
|
|
166
136
|
}));
|
|
167
137
|
function get_deltaObject() {
|
|
168
138
|
return _get_deltaObject.apply(this, arguments);
|
|
@@ -172,27 +142,27 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
172
142
|
}, {
|
|
173
143
|
key: "Save",
|
|
174
144
|
value: function () {
|
|
175
|
-
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
145
|
+
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
176
146
|
var _this$obj5;
|
|
177
|
-
return _regeneratorRuntime().wrap(function
|
|
178
|
-
while (1) switch (
|
|
147
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
148
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
179
149
|
case 0:
|
|
180
|
-
|
|
150
|
+
_context3.next = 2;
|
|
181
151
|
return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.Save();
|
|
182
152
|
case 2:
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
153
|
+
_context3.t0 = _context3.sent;
|
|
154
|
+
if (_context3.t0) {
|
|
155
|
+
_context3.next = 5;
|
|
186
156
|
break;
|
|
187
157
|
}
|
|
188
|
-
|
|
158
|
+
_context3.t0 = false;
|
|
189
159
|
case 5:
|
|
190
|
-
return
|
|
160
|
+
return _context3.abrupt("return", _context3.t0);
|
|
191
161
|
case 6:
|
|
192
162
|
case "end":
|
|
193
|
-
return
|
|
163
|
+
return _context3.stop();
|
|
194
164
|
}
|
|
195
|
-
},
|
|
165
|
+
}, _callee3, this);
|
|
196
166
|
}));
|
|
197
167
|
function Save() {
|
|
198
168
|
return _Save.apply(this, arguments);
|
|
@@ -202,18 +172,18 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
202
172
|
}, {
|
|
203
173
|
key: "Load",
|
|
204
174
|
value: function () {
|
|
205
|
-
var _Load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
206
|
-
return _regeneratorRuntime().wrap(function
|
|
207
|
-
while (1) switch (
|
|
175
|
+
var _Load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(search) {
|
|
176
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
177
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
208
178
|
case 0:
|
|
209
179
|
throw Error("load not implented");
|
|
210
180
|
case 1:
|
|
211
181
|
case "end":
|
|
212
|
-
return
|
|
182
|
+
return _context4.stop();
|
|
213
183
|
}
|
|
214
|
-
},
|
|
184
|
+
}, _callee4);
|
|
215
185
|
}));
|
|
216
|
-
function Load(
|
|
186
|
+
function Load(_x) {
|
|
217
187
|
return _Load.apply(this, arguments);
|
|
218
188
|
}
|
|
219
189
|
return Load;
|
|
@@ -249,32 +219,32 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
249
219
|
}, {
|
|
250
220
|
key: "onNew",
|
|
251
221
|
value: function () {
|
|
252
|
-
var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
222
|
+
var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
253
223
|
var _this$obj8;
|
|
254
|
-
return _regeneratorRuntime().wrap(function
|
|
255
|
-
while (1) switch (
|
|
224
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
225
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
256
226
|
case 0:
|
|
257
227
|
if (this.canModify) {
|
|
258
228
|
(_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setOriginal();
|
|
259
229
|
}
|
|
260
|
-
|
|
230
|
+
_context5.next = 3;
|
|
261
231
|
return this.event_run("on_new");
|
|
262
232
|
case 3:
|
|
263
|
-
|
|
233
|
+
_context5.next = 5;
|
|
264
234
|
return this.event_run("on_change", true);
|
|
265
235
|
case 5:
|
|
266
|
-
|
|
236
|
+
_context5.next = 7;
|
|
267
237
|
return this.event_run("on_after_new");
|
|
268
238
|
case 7:
|
|
269
|
-
|
|
239
|
+
_context5.next = 9;
|
|
270
240
|
return Promise.resolve(true);
|
|
271
241
|
case 9:
|
|
272
|
-
return
|
|
242
|
+
return _context5.abrupt("return", _context5.sent);
|
|
273
243
|
case 10:
|
|
274
244
|
case "end":
|
|
275
|
-
return
|
|
245
|
+
return _context5.stop();
|
|
276
246
|
}
|
|
277
|
-
},
|
|
247
|
+
}, _callee5, this);
|
|
278
248
|
}));
|
|
279
249
|
function onNew() {
|
|
280
250
|
return _onNew.apply(this, arguments);
|
|
@@ -289,28 +259,28 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
289
259
|
}, {
|
|
290
260
|
key: "onDelete",
|
|
291
261
|
value: function () {
|
|
292
|
-
var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
293
|
-
return _regeneratorRuntime().wrap(function
|
|
294
|
-
while (1) switch (
|
|
262
|
+
var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
263
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
264
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
295
265
|
case 0:
|
|
296
266
|
if (this.obj) {
|
|
297
267
|
this.obj.isDeleted = true;
|
|
298
268
|
}
|
|
299
|
-
|
|
269
|
+
_context6.next = 3;
|
|
300
270
|
return this.event_run("on_delete");
|
|
301
271
|
case 3:
|
|
302
|
-
|
|
272
|
+
_context6.next = 5;
|
|
303
273
|
return this.event_run("on_after_delete");
|
|
304
274
|
case 5:
|
|
305
|
-
|
|
275
|
+
_context6.next = 7;
|
|
306
276
|
return Promise.resolve(true);
|
|
307
277
|
case 7:
|
|
308
|
-
return
|
|
278
|
+
return _context6.abrupt("return", _context6.sent);
|
|
309
279
|
case 8:
|
|
310
280
|
case "end":
|
|
311
|
-
return
|
|
281
|
+
return _context6.stop();
|
|
312
282
|
}
|
|
313
|
-
},
|
|
283
|
+
}, _callee6, this);
|
|
314
284
|
}));
|
|
315
285
|
function onDelete() {
|
|
316
286
|
return _onDelete.apply(this, arguments);
|
|
@@ -325,35 +295,35 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
325
295
|
}, {
|
|
326
296
|
key: "onLoad",
|
|
327
297
|
value: function () {
|
|
328
|
-
var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
329
|
-
return _regeneratorRuntime().wrap(function
|
|
330
|
-
while (1) switch (
|
|
298
|
+
var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
299
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
300
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
331
301
|
case 0:
|
|
332
302
|
if (this.canModify && this.obj) {
|
|
333
303
|
this.obj.isDeleted = false;
|
|
334
304
|
this.obj.setOriginal();
|
|
335
305
|
}
|
|
336
|
-
|
|
306
|
+
_context7.next = 3;
|
|
337
307
|
return this.event_run("on_load");
|
|
338
308
|
case 3:
|
|
339
|
-
|
|
309
|
+
_context7.next = 5;
|
|
340
310
|
return this.event_run("on_change", true);
|
|
341
311
|
case 5:
|
|
342
|
-
|
|
312
|
+
_context7.next = 7;
|
|
343
313
|
return this.event_run("on_after_load");
|
|
344
314
|
case 7:
|
|
345
|
-
|
|
315
|
+
_context7.next = 9;
|
|
346
316
|
return this.event_run("on_load_finished");
|
|
347
317
|
case 9:
|
|
348
|
-
|
|
318
|
+
_context7.next = 11;
|
|
349
319
|
return Promise.resolve(true);
|
|
350
320
|
case 11:
|
|
351
|
-
return
|
|
321
|
+
return _context7.abrupt("return", _context7.sent);
|
|
352
322
|
case 12:
|
|
353
323
|
case "end":
|
|
354
|
-
return
|
|
324
|
+
return _context7.stop();
|
|
355
325
|
}
|
|
356
|
-
},
|
|
326
|
+
}, _callee7, this);
|
|
357
327
|
}));
|
|
358
328
|
function onLoad() {
|
|
359
329
|
return _onLoad.apply(this, arguments);
|
|
@@ -368,31 +338,31 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
368
338
|
}, {
|
|
369
339
|
key: "onSave",
|
|
370
340
|
value: function () {
|
|
371
|
-
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
372
|
-
return _regeneratorRuntime().wrap(function
|
|
373
|
-
while (1) switch (
|
|
341
|
+
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
342
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
343
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
374
344
|
case 0:
|
|
375
|
-
|
|
345
|
+
_context8.next = 2;
|
|
376
346
|
return this.event_run("on_save");
|
|
377
347
|
case 2:
|
|
378
|
-
|
|
348
|
+
_context8.next = 4;
|
|
379
349
|
return this.event_run("on_change", true);
|
|
380
350
|
case 4:
|
|
381
|
-
|
|
351
|
+
_context8.next = 6;
|
|
382
352
|
return this.event_run("on_after_save");
|
|
383
353
|
case 6:
|
|
384
|
-
|
|
354
|
+
_context8.next = 8;
|
|
385
355
|
return this.event_run("on_save_finished");
|
|
386
356
|
case 8:
|
|
387
|
-
|
|
357
|
+
_context8.next = 10;
|
|
388
358
|
return Promise.resolve(true);
|
|
389
359
|
case 10:
|
|
390
|
-
return
|
|
360
|
+
return _context8.abrupt("return", _context8.sent);
|
|
391
361
|
case 11:
|
|
392
362
|
case "end":
|
|
393
|
-
return
|
|
363
|
+
return _context8.stop();
|
|
394
364
|
}
|
|
395
|
-
},
|
|
365
|
+
}, _callee8, this);
|
|
396
366
|
}));
|
|
397
367
|
function onSave() {
|
|
398
368
|
return _onSave.apply(this, arguments);
|
|
@@ -70,6 +70,12 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
70
70
|
*/
|
|
71
71
|
toggleOption(key: string, value: any): Promise<void>;
|
|
72
72
|
setOption(key: string, value: any): Promise<any[] | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* use an option and detect its changes in real time. similar to recat state
|
|
75
|
+
* @param key name of the option
|
|
76
|
+
* @returns value of the option
|
|
77
|
+
*/
|
|
78
|
+
useOption(key: string): any;
|
|
73
79
|
/**
|
|
74
80
|
* Sets an option then does an action,
|
|
75
81
|
* after the action is run, updates the option again
|
|
@@ -459,6 +459,19 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
459
459
|
}
|
|
460
460
|
return setOption;
|
|
461
461
|
}()
|
|
462
|
+
/**
|
|
463
|
+
* use an option and detect its changes in real time. similar to recat state
|
|
464
|
+
* @param key name of the option
|
|
465
|
+
* @returns value of the option
|
|
466
|
+
*/
|
|
467
|
+
}, {
|
|
468
|
+
key: "useOption",
|
|
469
|
+
value: function useOption(key) {
|
|
470
|
+
var _this = this;
|
|
471
|
+
return this.event_use("on_option_change", function () {
|
|
472
|
+
return Boolean(_this.getOption(key));
|
|
473
|
+
}, [key], true);
|
|
474
|
+
}
|
|
462
475
|
/**
|
|
463
476
|
* Sets an option then does an action,
|
|
464
477
|
* after the action is run, updates the option again
|
|
@@ -651,9 +651,6 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
651
651
|
/* -------------------------------------------------------------------------- */
|
|
652
652
|
/* Events */
|
|
653
653
|
/* -------------------------------------------------------------------------- */
|
|
654
|
-
/* -------------------------------------------------------------------------- */
|
|
655
|
-
/* Events */
|
|
656
|
-
/* -------------------------------------------------------------------------- */
|
|
657
654
|
function () {
|
|
658
655
|
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
|
|
659
656
|
var _this$manager;
|