@azrico/webobject 1.4.88 → 1.4.90

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.
@@ -42,7 +42,7 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
42
42
  _defineProperty(_assertThisInitialized(_this), "__last_web_path", "");
43
43
  _defineProperty(_assertThisInitialized(_this), "__last_web_type", "");
44
44
  if (_this.constructor["__save_message"]) {
45
- _this.event_add("on_save", "onsave_sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
45
+ _this.event_add("on_save", "on_save-sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
46
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
47
  while (1) switch (_context.prev = _context.next) {
48
48
  case 0:
@@ -79,6 +79,64 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
79
79
  }
80
80
  }, _callee);
81
81
  })));
82
+ _this.event_add("on_archive", "on_archive-sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
83
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
84
+ while (1) switch (_context2.prev = _context2.next) {
85
+ case 0:
86
+ _context2.t0 = _this.getSaveResultType();
87
+ _context2.next = _context2.t0 === "normal" ? 3 : 6;
88
+ break;
89
+ case 3:
90
+ _context2.next = 5;
91
+ return _global.gfunc.run_action("show_message", {
92
+ message: "Archived",
93
+ type: "success"
94
+ });
95
+ case 5:
96
+ return _context2.abrupt("return", _context2.sent);
97
+ case 6:
98
+ _context2.next = 8;
99
+ return _global.gfunc.run_action("show_message", {
100
+ message: "Not archived",
101
+ type: "error"
102
+ });
103
+ case 8:
104
+ return _context2.abrupt("return", _context2.sent);
105
+ case 9:
106
+ case "end":
107
+ return _context2.stop();
108
+ }
109
+ }, _callee2);
110
+ })));
111
+ _this.event_add("on_delete", "on_delete-sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
112
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
113
+ while (1) switch (_context3.prev = _context3.next) {
114
+ case 0:
115
+ _context3.t0 = _this.getSaveResultType();
116
+ _context3.next = _context3.t0 === "normal" ? 3 : 6;
117
+ break;
118
+ case 3:
119
+ _context3.next = 5;
120
+ return _global.gfunc.run_action("show_message", {
121
+ message: "Deleted",
122
+ type: "success"
123
+ });
124
+ case 5:
125
+ return _context3.abrupt("return", _context3.sent);
126
+ case 6:
127
+ _context3.next = 8;
128
+ return _global.gfunc.run_action("show_message", {
129
+ message: "Not deleted",
130
+ type: "error"
131
+ });
132
+ case 8:
133
+ return _context3.abrupt("return", _context3.sent);
134
+ case 9:
135
+ case "end":
136
+ return _context3.stop();
137
+ }
138
+ }, _callee3);
139
+ })));
82
140
  }
83
141
  return _this;
84
142
  }
@@ -107,23 +165,23 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
107
165
  }, {
108
166
  key: "setMetaValue",
109
167
  value: function setMetaValue(_x, _x2) {
110
- return (_setMetaValue = _setMetaValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
168
+ return (_setMetaValue = _setMetaValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
111
169
  var _this$obj;
112
170
  var sendChange,
113
- _args2 = arguments;
114
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
115
- while (1) switch (_context2.prev = _context2.next) {
171
+ _args4 = arguments;
172
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
173
+ while (1) switch (_context4.prev = _context4.next) {
116
174
  case 0:
117
- sendChange = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : "auto";
118
- _context2.next = 3;
175
+ sendChange = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "auto";
176
+ _context4.next = 3;
119
177
  return (_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.setMetaValue(key, value, sendChange);
120
178
  case 3:
121
- return _context2.abrupt("return", _context2.sent);
179
+ return _context4.abrupt("return", _context4.sent);
122
180
  case 4:
123
181
  case "end":
124
- return _context2.stop();
182
+ return _context4.stop();
125
183
  }
126
- }, _callee2, this);
184
+ }, _callee4, this);
127
185
  }))).apply(this, arguments);
128
186
  }
129
187
  }, {
@@ -136,68 +194,68 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
136
194
  }, {
137
195
  key: "get_deltaObject",
138
196
  value: function get_deltaObject() {
139
- return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
197
+ return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
140
198
  var _this$obj3;
141
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
142
- while (1) switch (_context3.prev = _context3.next) {
199
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
200
+ while (1) switch (_context5.prev = _context5.next) {
143
201
  case 0:
144
- _context3.next = 2;
202
+ _context5.next = 2;
145
203
  return (_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.get_deltaObject();
146
204
  case 2:
147
- _context3.t0 = _context3.sent;
148
- if (_context3.t0) {
149
- _context3.next = 5;
205
+ _context5.t0 = _context5.sent;
206
+ if (_context5.t0) {
207
+ _context5.next = 5;
150
208
  break;
151
209
  }
152
- _context3.t0 = {};
210
+ _context5.t0 = {};
153
211
  case 5:
154
- return _context3.abrupt("return", _context3.t0);
212
+ return _context5.abrupt("return", _context5.t0);
155
213
  case 6:
156
214
  case "end":
157
- return _context3.stop();
215
+ return _context5.stop();
158
216
  }
159
- }, _callee3, this);
217
+ }, _callee5, this);
160
218
  }))).apply(this, arguments);
161
219
  } /* ------------------------------ save and load ----------------------------- */
162
220
  }, {
163
221
  key: "Save",
164
222
  value: function Save() {
165
- return (_Save = _Save || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
223
+ return (_Save = _Save || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
166
224
  var _this$obj4;
167
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
168
- while (1) switch (_context4.prev = _context4.next) {
225
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
226
+ while (1) switch (_context6.prev = _context6.next) {
169
227
  case 0:
170
- _context4.next = 2;
228
+ _context6.next = 2;
171
229
  return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.Save();
172
230
  case 2:
173
- _context4.t0 = _context4.sent;
174
- if (_context4.t0) {
175
- _context4.next = 5;
231
+ _context6.t0 = _context6.sent;
232
+ if (_context6.t0) {
233
+ _context6.next = 5;
176
234
  break;
177
235
  }
178
- _context4.t0 = false;
236
+ _context6.t0 = false;
179
237
  case 5:
180
- return _context4.abrupt("return", _context4.t0);
238
+ return _context6.abrupt("return", _context6.t0);
181
239
  case 6:
182
240
  case "end":
183
- return _context4.stop();
241
+ return _context6.stop();
184
242
  }
185
- }, _callee4, this);
243
+ }, _callee6, this);
186
244
  }))).apply(this, arguments);
187
245
  }
188
246
  }, {
189
247
  key: "Load",
190
248
  value: function Load(_x3) {
191
- return (_Load = _Load || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(search) {
192
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
193
- while (1) switch (_context5.prev = _context5.next) {
249
+ return (_Load = _Load || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(search) {
250
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
251
+ while (1) switch (_context7.prev = _context7.next) {
194
252
  case 0:
195
253
  throw Error("load not implented");
196
254
  case 1:
197
255
  case "end":
198
- return _context5.stop();
256
+ return _context7.stop();
199
257
  }
200
- }, _callee5);
258
+ }, _callee7);
201
259
  }))).apply(this, arguments);
202
260
  }
203
261
  /* -------------------------------------------------------------------------- */
@@ -233,32 +291,32 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
233
291
  }, {
234
292
  key: "onNew",
235
293
  value: function onNew() {
236
- return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
294
+ return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
237
295
  var _this$obj9;
238
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
239
- while (1) switch (_context6.prev = _context6.next) {
296
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
297
+ while (1) switch (_context8.prev = _context8.next) {
240
298
  case 0:
241
299
  if (this.canModify) {
242
300
  (_this$obj9 = this.obj) === null || _this$obj9 === void 0 || _this$obj9.setOriginal();
243
301
  }
244
- _context6.next = 3;
302
+ _context8.next = 3;
245
303
  return this.event_run("on_new");
246
304
  case 3:
247
- _context6.next = 5;
305
+ _context8.next = 5;
248
306
  return this.event_run("on_change", true);
249
307
  case 5:
250
- _context6.next = 7;
308
+ _context8.next = 7;
251
309
  return this.event_run("on_after_new");
252
310
  case 7:
253
- _context6.next = 9;
311
+ _context8.next = 9;
254
312
  return Promise.resolve(true);
255
313
  case 9:
256
- return _context6.abrupt("return", _context6.sent);
314
+ return _context8.abrupt("return", _context8.sent);
257
315
  case 10:
258
316
  case "end":
259
- return _context6.stop();
317
+ return _context8.stop();
260
318
  }
261
- }, _callee6, this);
319
+ }, _callee8, this);
262
320
  }))).apply(this, arguments);
263
321
  }
264
322
  /**
@@ -269,49 +327,49 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
269
327
  }, {
270
328
  key: "onDelete",
271
329
  value: function onDelete() {
272
- return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
273
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
274
- while (1) switch (_context7.prev = _context7.next) {
330
+ return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
331
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
332
+ while (1) switch (_context9.prev = _context9.next) {
275
333
  case 0:
276
334
  if (this.obj) {
277
335
  this.obj.isDeleted = true;
278
336
  }
279
- _context7.next = 3;
337
+ _context9.next = 3;
280
338
  return this.event_run("on_delete");
281
339
  case 3:
282
- _context7.next = 5;
340
+ _context9.next = 5;
283
341
  return this.event_run("on_after_delete");
284
342
  case 5:
285
- return _context7.abrupt("return", true);
343
+ return _context9.abrupt("return", true);
286
344
  case 6:
287
345
  case "end":
288
- return _context7.stop();
346
+ return _context9.stop();
289
347
  }
290
- }, _callee7, this);
348
+ }, _callee9, this);
291
349
  }))).apply(this, arguments);
292
350
  }
293
351
  }, {
294
352
  key: "onArchive",
295
353
  value: function onArchive() {
296
- return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
297
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
298
- while (1) switch (_context8.prev = _context8.next) {
354
+ return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
355
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
356
+ while (1) switch (_context10.prev = _context10.next) {
299
357
  case 0:
300
358
  if (this.obj) {
301
359
  this.obj.isDeleted = true;
302
360
  }
303
- _context8.next = 3;
361
+ _context10.next = 3;
304
362
  return this.event_run("on_archive");
305
363
  case 3:
306
- _context8.next = 5;
364
+ _context10.next = 5;
307
365
  return this.event_run("on_after_archive");
308
366
  case 5:
309
- return _context8.abrupt("return", true);
367
+ return _context10.abrupt("return", true);
310
368
  case 6:
311
369
  case "end":
312
- return _context8.stop();
370
+ return _context10.stop();
313
371
  }
314
- }, _callee8, this);
372
+ }, _callee10, this);
315
373
  }))).apply(this, arguments);
316
374
  }
317
375
  /**
@@ -322,32 +380,32 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
322
380
  }, {
323
381
  key: "onLoad",
324
382
  value: function onLoad() {
325
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
326
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
327
- while (1) switch (_context9.prev = _context9.next) {
383
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
384
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
385
+ while (1) switch (_context11.prev = _context11.next) {
328
386
  case 0:
329
387
  if (this.canModify && this.obj) {
330
388
  this.obj.isDeleted = false;
331
389
  this.obj.setOriginal();
332
390
  }
333
- _context9.next = 3;
391
+ _context11.next = 3;
334
392
  return this.event_run("on_load");
335
393
  case 3:
336
- _context9.next = 5;
394
+ _context11.next = 5;
337
395
  return this.event_run("on_change", true);
338
396
  case 5:
339
- _context9.next = 7;
397
+ _context11.next = 7;
340
398
  return this.event_run("on_after_load");
341
399
  case 7:
342
- _context9.next = 9;
400
+ _context11.next = 9;
343
401
  return this.event_run("on_load_finished");
344
402
  case 9:
345
- return _context9.abrupt("return", true);
403
+ return _context11.abrupt("return", true);
346
404
  case 10:
347
405
  case "end":
348
- return _context9.stop();
406
+ return _context11.stop();
349
407
  }
350
- }, _callee9, this);
408
+ }, _callee11, this);
351
409
  }))).apply(this, arguments);
352
410
  }
353
411
  /**
@@ -358,49 +416,49 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
358
416
  }, {
359
417
  key: "onSave",
360
418
  value: function onSave() {
361
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
362
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
363
- while (1) switch (_context10.prev = _context10.next) {
419
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
420
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
421
+ while (1) switch (_context12.prev = _context12.next) {
364
422
  case 0:
365
- _context10.next = 2;
423
+ _context12.next = 2;
366
424
  return this.event_run("on_save");
367
425
  case 2:
368
- _context10.next = 4;
426
+ _context12.next = 4;
369
427
  return this.event_run("on_change", true);
370
428
  case 4:
371
- _context10.next = 6;
429
+ _context12.next = 6;
372
430
  return Promise.resolve(true);
373
431
  case 6:
374
- return _context10.abrupt("return", _context10.sent);
432
+ return _context12.abrupt("return", _context12.sent);
375
433
  case 7:
376
434
  case "end":
377
- return _context10.stop();
435
+ return _context12.stop();
378
436
  }
379
- }, _callee10, this);
437
+ }, _callee12, this);
380
438
  }))).apply(this, arguments);
381
439
  }
382
440
  }, {
383
441
  key: "onAfterSave",
384
442
  value: function onAfterSave() {
385
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
386
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
387
- while (1) switch (_context11.prev = _context11.next) {
443
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
444
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
445
+ while (1) switch (_context13.prev = _context13.next) {
388
446
  case 0:
389
- _context11.next = 2;
447
+ _context13.next = 2;
390
448
  return this.event_run("on_after_save");
391
449
  case 2:
392
- _context11.next = 4;
450
+ _context13.next = 4;
393
451
  return this.event_run("on_save_finished");
394
452
  case 4:
395
- _context11.next = 6;
453
+ _context13.next = 6;
396
454
  return Promise.resolve(true);
397
455
  case 6:
398
- return _context11.abrupt("return", _context11.sent);
456
+ return _context13.abrupt("return", _context13.sent);
399
457
  case 7:
400
458
  case "end":
401
- return _context11.stop();
459
+ return _context13.stop();
402
460
  }
403
- }, _callee11, this);
461
+ }, _callee13, this);
404
462
  }))).apply(this, arguments);
405
463
  }
406
464
  }]);
@@ -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"): void;
194
+ setSaveResult(toObj: any, type?: saveResultType | "auto", registerErrors?: boolean): void;
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>;
@@ -865,12 +865,17 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
865
865
  */
866
866
  function setSaveResult(toObj) {
867
867
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "auto";
868
+ var registerErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
868
869
  _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
869
870
  //check if the given object is a valid save result
870
871
  if (type === "error") this.__saveResultIsSuccess = false;else this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
871
872
  if (type === "auto") {
872
873
  type = this.__saveResultIsSuccess ? "normal" : "error";
873
874
  }
875
+ if (registerErrors && !this.__saveResultIsSuccess) {
876
+ console.error("bad save result : ", this.__saveResultObject);
877
+ SimpleObject.addError(this, "save result is not valid", "the response from server was not valid", true);
878
+ }
874
879
  this.__saveResultType = type;
875
880
  }
876
881
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.88",
3
+ "version": "1.4.90",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",