@azrico/webobject 1.4.94 → 1.4.96

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.
@@ -80,29 +80,31 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
80
80
  }, _callee);
81
81
  })));
82
82
  _this.event_add("on_{archive,unarchive}", "on_archive-sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
83
+ var srType;
83
84
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
84
85
  while (1) switch (_context2.prev = _context2.next) {
85
86
  case 0:
86
- _context2.t0 = _this.getSaveResultType();
87
- _context2.next = _context2.t0 === "normal" ? 3 : 6;
87
+ srType = _this.getSaveResultType();
88
+ _context2.t0 = srType;
89
+ _context2.next = _context2.t0 === "normal" ? 4 : 7;
88
90
  break;
89
- case 3:
90
- _context2.next = 5;
91
+ case 4:
92
+ _context2.next = 6;
91
93
  return _global.gfunc.run_action("show_message", {
92
94
  message: _this.isArchived ? "Archived" : "Restored",
93
95
  type: "success"
94
96
  });
95
- case 5:
96
- return _context2.abrupt("return", _context2.sent);
97
97
  case 6:
98
- _context2.next = 8;
98
+ return _context2.abrupt("return", _context2.sent);
99
+ case 7:
100
+ _context2.next = 9;
99
101
  return _global.gfunc.run_action("show_message", {
100
- message: "Not archived",
102
+ message: "Not archived (".concat(srType, ")"),
101
103
  type: "error"
102
104
  });
103
- case 8:
104
- return _context2.abrupt("return", _context2.sent);
105
105
  case 9:
106
+ return _context2.abrupt("return", _context2.sent);
107
+ case 10:
106
108
  case "end":
107
109
  return _context2.stop();
108
110
  }
@@ -330,17 +332,19 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
330
332
  key: "onDelete",
331
333
  value: function onDelete() {
332
334
  return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
335
+ var srt;
333
336
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
334
337
  while (1) switch (_context9.prev = _context9.next) {
335
338
  case 0:
336
- _context9.next = 2;
337
- return this.event_run("on_delete");
338
- case 2:
339
- _context9.next = 4;
340
- return this.event_run("on_after_delete");
341
- case 4:
342
- return _context9.abrupt("return", true);
339
+ srt = this.getSaveResultType();
340
+ _context9.next = 3;
341
+ return this.event_run("on_delete", srt);
342
+ case 3:
343
+ _context9.next = 5;
344
+ return this.event_run("on_after_delete", srt);
343
345
  case 5:
346
+ return _context9.abrupt("return", true);
347
+ case 6:
344
348
  case "end":
345
349
  return _context9.stop();
346
350
  }
@@ -351,17 +355,19 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
351
355
  key: "onArchive",
352
356
  value: function onArchive() {
353
357
  return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
358
+ var srt;
354
359
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
355
360
  while (1) switch (_context10.prev = _context10.next) {
356
361
  case 0:
357
- _context10.next = 2;
358
- return this.event_run("on_archive");
359
- case 2:
360
- _context10.next = 4;
361
- return this.event_run("on_after_archive");
362
- case 4:
363
- return _context10.abrupt("return", true);
362
+ srt = this.getSaveResultType();
363
+ _context10.next = 3;
364
+ return this.event_run("on_archive", srt);
365
+ case 3:
366
+ _context10.next = 5;
367
+ return this.event_run("on_after_archive", srt);
364
368
  case 5:
369
+ return _context10.abrupt("return", true);
370
+ case 6:
365
371
  case "end":
366
372
  return _context10.stop();
367
373
  }
@@ -372,17 +378,19 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
372
378
  key: "onUnArchive",
373
379
  value: function onUnArchive() {
374
380
  return (_onUnArchive = _onUnArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
381
+ var srt;
375
382
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
376
383
  while (1) switch (_context11.prev = _context11.next) {
377
384
  case 0:
378
- _context11.next = 2;
379
- return this.event_run("on_unarchive");
380
- case 2:
381
- _context11.next = 4;
382
- return this.event_run("on_after_unarchive");
383
- case 4:
384
- return _context11.abrupt("return", true);
385
+ srt = this.getSaveResultType();
386
+ _context11.next = 3;
387
+ return this.event_run("on_unarchive", srt);
388
+ case 3:
389
+ _context11.next = 5;
390
+ return this.event_run("on_after_unarchive", srt);
385
391
  case 5:
392
+ return _context11.abrupt("return", true);
393
+ case 6:
386
394
  case "end":
387
395
  return _context11.stop();
388
396
  }
@@ -434,20 +442,22 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
434
442
  key: "onSave",
435
443
  value: function onSave() {
436
444
  return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
445
+ var srt;
437
446
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
438
447
  while (1) switch (_context13.prev = _context13.next) {
439
448
  case 0:
440
- _context13.next = 2;
441
- return this.event_run("on_save");
442
- case 2:
443
- _context13.next = 4;
449
+ srt = this.getSaveResultType();
450
+ _context13.next = 3;
451
+ return this.event_run("on_save", srt);
452
+ case 3:
453
+ _context13.next = 5;
444
454
  return this.event_run("on_change", true);
445
- case 4:
446
- _context13.next = 6;
455
+ case 5:
456
+ _context13.next = 7;
447
457
  return Promise.resolve(true);
448
- case 6:
449
- return _context13.abrupt("return", _context13.sent);
450
458
  case 7:
459
+ return _context13.abrupt("return", _context13.sent);
460
+ case 8:
451
461
  case "end":
452
462
  return _context13.stop();
453
463
  }
@@ -458,20 +468,22 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
458
468
  key: "onAfterSave",
459
469
  value: function onAfterSave() {
460
470
  return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
471
+ var srt;
461
472
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
462
473
  while (1) switch (_context14.prev = _context14.next) {
463
474
  case 0:
464
- _context14.next = 2;
465
- return this.event_run("on_after_save");
466
- case 2:
467
- _context14.next = 4;
468
- return this.event_run("on_save_finished");
469
- case 4:
470
- _context14.next = 6;
475
+ srt = this.getSaveResultType();
476
+ _context14.next = 3;
477
+ return this.event_run("on_after_save", srt);
478
+ case 3:
479
+ _context14.next = 5;
480
+ return this.event_run("on_save_finished", srt);
481
+ case 5:
482
+ _context14.next = 7;
471
483
  return Promise.resolve(true);
472
- case 6:
473
- return _context14.abrupt("return", _context14.sent);
474
484
  case 7:
485
+ return _context14.abrupt("return", _context14.sent);
486
+ case 8:
475
487
  case "end":
476
488
  return _context14.stop();
477
489
  }
@@ -14,6 +14,10 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
14
14
  protected __options?: object;
15
15
  __object_nullable: boolean;
16
16
  notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
17
+ /**
18
+ * Get the object this manager is managing
19
+ * @returns the object
20
+ */
17
21
  get obj(): ObjType | undefined;
18
22
  /**
19
23
  * Get the object this manager is managing
@@ -34,9 +38,9 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
34
38
  get isNew(): boolean;
35
39
  get isSaved(): boolean;
36
40
  get __cache_name(): string;
37
- getSaveResult(): any;
41
+ getSaveResult(): any | null;
38
42
  getSaveResultType(): saveResultType | null;
39
- setSaveResult(toObj: any, type: saveResultType): void | undefined;
43
+ setSaveResult(toObj: any, type: saveResultType): saveResultType | undefined;
40
44
  apply_changes(): boolean;
41
45
  getValue(key: PropOf<ObjType>, original?: boolean): import("./SimpleObject").PropType<ObjType, any> | null;
42
46
  get: (key: PropOf<ObjType>, original?: boolean) => import("./SimpleObject").PropType<ObjType, any> | null;
@@ -62,11 +62,17 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
62
62
  }
63
63
  }, _callee, this);
64
64
  }))).apply(this, arguments);
65
- } /* -------------------------------------------------------------------------- */
65
+ }
66
+ /* -------------------------------------------------------------------------- */
67
+ /**
68
+ * Get the object this manager is managing
69
+ * @returns the object
70
+ */
66
71
  }, {
67
72
  key: "obj",
68
73
  get: function get() {
69
- return this.getObject();
74
+ var _this$__currentObject;
75
+ return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
70
76
  }
71
77
  /**
72
78
  * Get the object this manager is managing
@@ -75,8 +81,8 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
75
81
  }, {
76
82
  key: "getObject",
77
83
  value: function getObject() {
78
- var _this$__currentObject;
79
- return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
84
+ var _this$__currentObject2;
85
+ return (_this$__currentObject2 = this.__currentObject) !== null && _this$__currentObject2 !== void 0 ? _this$__currentObject2 : undefined;
80
86
  }
81
87
  /**
82
88
  * Set the object this manager is managing
@@ -145,26 +151,26 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
145
151
  }, {
146
152
  key: "getSaveResult",
147
153
  value: function getSaveResult() {
148
- var _this$getObject;
149
- return ((_this$getObject = this.getObject()) === null || _this$getObject === void 0 ? void 0 : _this$getObject.getSaveResult()) || undefined;
154
+ var _this$obj5;
155
+ return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getSaveResult()) || null;
150
156
  }
151
157
  }, {
152
158
  key: "getSaveResultType",
153
159
  value: function getSaveResultType() {
154
- var _this$getObject2;
155
- return ((_this$getObject2 = this.getObject()) === null || _this$getObject2 === void 0 ? void 0 : _this$getObject2.getSaveResultType()) || null;
160
+ var _this$obj6;
161
+ return ((_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.getSaveResultType()) || null;
156
162
  }
157
163
  }, {
158
164
  key: "setSaveResult",
159
165
  value: function setSaveResult(toObj, type) {
160
- var _this$getObject3;
161
- return (_this$getObject3 = this.getObject()) === null || _this$getObject3 === void 0 ? void 0 : _this$getObject3.setSaveResult(toObj, type);
166
+ var _this$obj7;
167
+ return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.setSaveResult(toObj, type);
162
168
  }
163
169
  }, {
164
170
  key: "apply_changes",
165
171
  value: function apply_changes() {
166
- var _this$obj5;
167
- return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.apply_changes()) || false;
172
+ var _this$obj8;
173
+ return ((_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.apply_changes()) || false;
168
174
  }
169
175
  }, {
170
176
  key: "getValue",
@@ -229,12 +235,12 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
229
235
  key: "setSubValue",
230
236
  value: function setSubValue(_x7, _x8, _x9) {
231
237
  return (_setSubValue = _setSubValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
232
- var _yield$this$obj$setSu, _this$obj6;
238
+ var _yield$this$obj$setSu, _this$obj9;
233
239
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
234
240
  while (1) switch (_context3.prev = _context3.next) {
235
241
  case 0:
236
242
  _context3.next = 2;
237
- return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setSubValue(key, objKey, subvalue);
243
+ return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.setSubValue(key, objKey, subvalue);
238
244
  case 2:
239
245
  _context3.t1 = _yield$this$obj$setSu = _context3.sent;
240
246
  _context3.t0 = _context3.t1 !== null;
@@ -266,12 +272,12 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
266
272
  key: "pushValue",
267
273
  value: function pushValue(_x10, _x11) {
268
274
  return (_pushValue = _pushValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
269
- var _yield$this$obj$pushV, _this$obj7;
275
+ var _yield$this$obj$pushV, _this$obj10;
270
276
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
271
277
  while (1) switch (_context4.prev = _context4.next) {
272
278
  case 0:
273
279
  _context4.next = 2;
274
- return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.pushValue(key, value);
280
+ return (_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.pushValue(key, value);
275
281
  case 2:
276
282
  _context4.t1 = _yield$this$obj$pushV = _context4.sent;
277
283
  _context4.t0 = _context4.t1 !== null;
@@ -303,7 +309,7 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
303
309
  key: "setTemp",
304
310
  value: function setTemp(_x12, _x13) {
305
311
  return (_setTemp = _setTemp || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
306
- var _yield$this$obj$setTe, _this$obj8;
312
+ var _yield$this$obj$setTe, _this$obj11;
307
313
  var sendChanges,
308
314
  _args5 = arguments;
309
315
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -311,7 +317,7 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
311
317
  case 0:
312
318
  sendChanges = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : false;
313
319
  _context5.next = 3;
314
- return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setTemp(key, value, sendChanges);
320
+ return (_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.setTemp(key, value, sendChanges);
315
321
  case 3:
316
322
  _context5.t1 = _yield$this$obj$setTe = _context5.sent;
317
323
  _context5.t0 = _context5.t1 !== null;
@@ -342,27 +348,27 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
342
348
  }, {
343
349
  key: "getTemp",
344
350
  value: function getTemp(key) {
345
- var _this$obj$getTemp, _this$obj9;
346
- return (_this$obj$getTemp = (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.getTemp(key)) !== null && _this$obj$getTemp !== void 0 ? _this$obj$getTemp : undefined;
351
+ var _this$obj$getTemp, _this$obj12;
352
+ return (_this$obj$getTemp = (_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getTemp(key)) !== null && _this$obj$getTemp !== void 0 ? _this$obj$getTemp : undefined;
347
353
  }
348
354
  /* -------------------------------------------------------------------------- */
349
355
  }, {
350
356
  key: "getIndexOrID",
351
357
  value: function getIndexOrID() {
352
- var _this$obj10;
353
- return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndexOrID()) || -1;
358
+ var _this$obj13;
359
+ return ((_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.getIndexOrID()) || -1;
354
360
  }
355
361
  }, {
356
362
  key: "getIndex",
357
363
  value: function getIndex() {
358
- var _this$obj11;
359
- return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getIndex()) || -1;
364
+ var _this$obj14;
365
+ return ((_this$obj14 = this.obj) === null || _this$obj14 === void 0 ? void 0 : _this$obj14.getIndex()) || -1;
360
366
  }
361
367
  }, {
362
368
  key: "getID",
363
369
  value: function getID() {
364
- var _this$obj12;
365
- return ((_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getID()) || "";
370
+ var _this$obj15;
371
+ return ((_this$obj15 = this.obj) === null || _this$obj15 === void 0 ? void 0 : _this$obj15.getID()) || "";
366
372
  }
367
373
  /* -------------------------------------------------------------------------- */
368
374
  /* Events */
@@ -462,14 +468,14 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
462
468
  }, {
463
469
  key: "clear_changes",
464
470
  value: function clear_changes() {
465
- var _this$obj13;
466
- return (_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.clear_changes();
471
+ var _this$obj16;
472
+ return (_this$obj16 = this.obj) === null || _this$obj16 === void 0 ? void 0 : _this$obj16.clear_changes();
467
473
  }
468
474
  }, {
469
475
  key: "clear_cache",
470
476
  value: function clear_cache() {
471
- var _this$obj14;
472
- return (_this$obj14 = this.obj) === null || _this$obj14 === void 0 ? void 0 : _this$obj14.clear_cache();
477
+ var _this$obj17;
478
+ return (_this$obj17 = this.obj) === null || _this$obj17 === void 0 ? void 0 : _this$obj17.clear_cache();
473
479
  }
474
480
  }, {
475
481
  key: "toggleOption",
@@ -191,7 +191,7 @@ export declare class SimpleObject extends MapableObject {
191
191
  * and its type
192
192
  * @param toObj
193
193
  */
194
- setSaveResult(toObj: any, type?: saveResultType | "auto", registerErrors?: boolean): void;
194
+ setSaveResult(toObj: any, type?: saveResultType | "auto", registerErrors?: boolean): saveResultType;
195
195
  getSaveResult(original?: boolean): any;
196
196
  getSaveResultType(): saveResultType;
197
197
  static setTemp(obj: SimpleObject | any, key: string, value: any, sendChanges?: sendChangesType): Promise<void>;
@@ -877,6 +877,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
877
877
  SimpleObject.addError(this, "save result is not valid", "the response from server was not valid", true);
878
878
  }
879
879
  this.__saveResultType = type;
880
+ return type;
880
881
  }
881
882
  }, {
882
883
  key: "getSaveResult",
@@ -1261,6 +1262,7 @@ function _setTempProperty2(key, value) {
1261
1262
  function _setSaveResultObject2(toObj) {
1262
1263
  if (toObj == null) toObj = null; //null or undefined
1263
1264
  this.__saveResultObject = toObj;
1265
+ return true;
1264
1266
  }
1265
1267
  _defineProperty(SimpleObject, "__cache_name", void 0);
1266
1268
  //these properties should not be changed and are usually set by server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.94",
3
+ "version": "1.4.96",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",