@azrico/webobject 1.5.66 → 1.5.68
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/dist/index.js +1 -16
- package/dist/src/WebObjects/ParentWebObject.js +71 -115
- package/dist/src/WebObjects/WebObject.js +584 -1554
- package/dist/src/WebObjects/WebObjectHelper.js +15 -35
- package/dist/src/WebObjects/WebObjectHelper.test.js +45 -67
- package/dist/src/WebObjects/WebObjectManager.js +265 -864
- package/dist/src/WebObjects/WebObjectPathHelper.js +71 -142
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +31 -122
- package/dist/src/index.js +10 -115
- package/dist/src/structs/DummyObject.js +8 -32
- package/dist/src/structs/MapableObject.js +75 -121
- package/dist/src/structs/MetaObject.js +35 -121
- package/dist/src/structs/ObjectArray.js +43 -68
- package/dist/src/structs/ObjectManager.d.ts +6 -7
- package/dist/src/structs/ObjectManager.js +285 -744
- package/dist/src/structs/ObjectWithTemp.d.ts +3 -2
- package/dist/src/structs/ObjectWithTemp.js +28 -71
- package/dist/src/structs/SimpleObject.d.ts +2 -2
- package/dist/src/structs/SimpleObject.js +1044 -1702
- package/package.json +2 -2
|
@@ -1,469 +1,270 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
34
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
35
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
36
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
37
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
38
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
39
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
40
|
-
var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
41
|
-
function WebObject() {
|
|
42
|
-
var _this;
|
|
43
|
-
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
44
|
-
_classCallCheck(this, WebObject);
|
|
45
|
-
_this = _callSuper(this, WebObject, [is_readonly]);
|
|
46
|
-
_defineProperty(_this, "meta_data", void 0);
|
|
47
|
-
//created date
|
|
48
|
-
_defineProperty(_this, "_created_date", void 0);
|
|
49
|
-
//the owner of the object
|
|
50
|
-
_defineProperty(_this, "_creator", void 0);
|
|
51
|
-
//multiple users can work on one object
|
|
52
|
-
_defineProperty(_this, "_users", void 0);
|
|
53
|
-
_this.meta_data = {};
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* get a list of all user ids that work on the given object
|
|
58
|
-
* _creator + _users + attentions(old)
|
|
59
|
-
* removes duplicates
|
|
60
|
-
* @returns array of ids
|
|
61
|
-
*/
|
|
62
|
-
_inherits(WebObject, _SimpleObject);
|
|
63
|
-
return _createClass(WebObject, [{
|
|
64
|
-
key: "getAllUsers",
|
|
65
|
-
value: function getAllUsers() {
|
|
66
|
-
return WebObject.getAllUsers(this);
|
|
67
|
-
}
|
|
1
|
+
import { SimpleObject } from "../index";
|
|
2
|
+
import { array_chunks, array_first, array_intersection, array_merge, array_remove_duplicates, fn_eval_this, object_clean, object_equals, object_getStatic, object_isEmpty, wrap_array, } from "@azrico/object";
|
|
3
|
+
import { string_compress, string_decompress } from "@azrico/string";
|
|
4
|
+
import { gcache, gfunc } from "@azrico/global";
|
|
5
|
+
import FormatHelper from "@azrico/convert";
|
|
6
|
+
import WebObjectPathHelper from "./WebObjectPathHelper";
|
|
7
|
+
import WebObjectHelper from "./WebObjectHelper";
|
|
8
|
+
export class WebObject extends SimpleObject {
|
|
9
|
+
static __web_path = "";
|
|
10
|
+
static __protectedProperties = ["_users"];
|
|
11
|
+
//you cant create a new weboject without these properties
|
|
12
|
+
static __requiredProperties = [];
|
|
13
|
+
meta_data;
|
|
14
|
+
//created date
|
|
15
|
+
_created_date;
|
|
16
|
+
//the owner of the object
|
|
17
|
+
_creator;
|
|
18
|
+
//multiple users can work on one object
|
|
19
|
+
_users;
|
|
20
|
+
constructor(is_readonly = false) {
|
|
21
|
+
super(is_readonly);
|
|
22
|
+
this.meta_data = {};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* get a list of all user ids that work on the given object
|
|
26
|
+
* _creator + _users + attentions(old)
|
|
27
|
+
* removes duplicates
|
|
28
|
+
* @returns array of ids
|
|
29
|
+
*/
|
|
30
|
+
getAllUsers() {
|
|
31
|
+
return WebObject.getAllUsers(this);
|
|
32
|
+
}
|
|
68
33
|
/**
|
|
69
34
|
* get a unique list of all user ids that work on the given object
|
|
70
35
|
* `_creator + _users + attentions`
|
|
71
36
|
* @returns array of ids
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
37
|
+
*/
|
|
38
|
+
static getAllUsers(obj) {
|
|
39
|
+
if (typeof obj != "object")
|
|
40
|
+
return [];
|
|
41
|
+
return array_remove_duplicates(array_merge(obj._creator, wrap_array(obj._users), wrap_array(obj.attentions))
|
|
42
|
+
.map((r) => String(typeof r === "object" ? WebObject.getID(r) : r))
|
|
43
|
+
.filter((s) => s));
|
|
44
|
+
}
|
|
45
|
+
/* -------------------------------------------------------------------------- */
|
|
46
|
+
/* Meta data */
|
|
47
|
+
/* -------------------------------------------------------------------------- */
|
|
79
48
|
/**
|
|
80
49
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
81
50
|
* @param key
|
|
82
51
|
* @param value
|
|
83
52
|
* @param sendChange
|
|
84
53
|
* @returns
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
_context.next = 13;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
if (!(this.__throw_errors !== false)) {
|
|
113
|
-
_context.next = 12;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
throw Error("Bad key at setMetaValue");
|
|
117
|
-
case 12:
|
|
118
|
-
return _context.abrupt("return", false);
|
|
119
|
-
case 13:
|
|
120
|
-
old_value = WebObject.getMetaValue(this, key);
|
|
121
|
-
if (!(0, _object.object_equals)(old_value, value)) {
|
|
122
|
-
_context.next = 16;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
return _context.abrupt("return", false);
|
|
126
|
-
case 16:
|
|
127
|
-
//same value, no changes
|
|
128
|
-
new_metalist = _objectSpread({}, this.get("meta_data"));
|
|
129
|
-
new_metalist[key] = value;
|
|
130
|
-
_context.next = 20;
|
|
131
|
-
return this.set("meta_data", new_metalist);
|
|
132
|
-
case 20:
|
|
133
|
-
if (!(sendChange !== false)) {
|
|
134
|
-
_context.next = 23;
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
_context.next = 23;
|
|
138
|
-
return this.notifyChanged("meta", key, value);
|
|
139
|
-
case 23:
|
|
140
|
-
return _context.abrupt("return", true);
|
|
141
|
-
case 24:
|
|
142
|
-
case "end":
|
|
143
|
-
return _context.stop();
|
|
144
|
-
}
|
|
145
|
-
}, _callee, this);
|
|
146
|
-
}));
|
|
147
|
-
function setMetaValue(_x, _x2) {
|
|
148
|
-
return _setMetaValue.apply(this, arguments);
|
|
149
|
-
}
|
|
150
|
-
return setMetaValue;
|
|
151
|
-
}()
|
|
54
|
+
*/
|
|
55
|
+
async setMetaValue(key, value, sendChange = "auto") {
|
|
56
|
+
if (!this.canModify) {
|
|
57
|
+
if (this.__throw_errors !== false)
|
|
58
|
+
throw Error(`Cant use setMetaValue on ${key} when on readonly mode`);
|
|
59
|
+
else
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (!key || typeof key != "string") {
|
|
63
|
+
if (this.__throw_errors !== false)
|
|
64
|
+
throw Error(`Bad key at setMetaValue`);
|
|
65
|
+
else
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const old_value = WebObject.getMetaValue(this, key);
|
|
69
|
+
if (object_equals(old_value, value))
|
|
70
|
+
return false; //same value, no changes
|
|
71
|
+
const new_metalist = { ...this.get("meta_data") };
|
|
72
|
+
new_metalist[key] = value;
|
|
73
|
+
await this.set("meta_data", new_metalist);
|
|
74
|
+
if (sendChange !== false)
|
|
75
|
+
await this.notifyChanged("meta", key, value);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
152
78
|
/**
|
|
153
79
|
* Get meta value by key
|
|
154
80
|
* @param key
|
|
155
81
|
* @returns value or undefined
|
|
156
|
-
*/
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
value: function getMetaValue(key) {
|
|
161
|
-
return WebObject.getMetaValue(this, key);
|
|
162
|
-
}
|
|
82
|
+
*/
|
|
83
|
+
getMetaValue(key) {
|
|
84
|
+
return WebObject.getMetaValue(this, key);
|
|
85
|
+
}
|
|
163
86
|
/**
|
|
164
87
|
* Get meta value by key
|
|
165
88
|
* @param o
|
|
166
89
|
* @param key
|
|
167
90
|
* @returns value or undefined
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
case 4:
|
|
346
|
-
usepath = _context5.sent;
|
|
347
|
-
_context5.next = 7;
|
|
348
|
-
return _global.gfunc.run_action("post", usepath);
|
|
349
|
-
case 7:
|
|
350
|
-
resultObject = _context5.sent;
|
|
351
|
-
this.setSaveResult(resultObject, "auto", true);
|
|
352
|
-
_context5.next = 11;
|
|
353
|
-
return this.onUnLock();
|
|
354
|
-
case 11:
|
|
355
|
-
return _context5.abrupt("return", resultObject);
|
|
356
|
-
case 12:
|
|
357
|
-
case "end":
|
|
358
|
-
return _context5.stop();
|
|
359
|
-
}
|
|
360
|
-
}, _callee5, this);
|
|
361
|
-
}));
|
|
362
|
-
function UnLock() {
|
|
363
|
-
return _UnLock.apply(this, arguments);
|
|
364
|
-
}
|
|
365
|
-
return UnLock;
|
|
366
|
-
}()
|
|
367
|
-
}, {
|
|
368
|
-
key: "Archive",
|
|
369
|
-
value: function () {
|
|
370
|
-
var _Archive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
371
|
-
var usepath, resultObject;
|
|
372
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
373
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
374
|
-
case 0:
|
|
375
|
-
if (!(this.isNew || this.isArchived)) {
|
|
376
|
-
_context6.next = 2;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
return _context6.abrupt("return");
|
|
380
|
-
case 2:
|
|
381
|
-
_context6.next = 4;
|
|
382
|
-
return _WebObjectPathHelper["default"].get_path(this, "archive");
|
|
383
|
-
case 4:
|
|
384
|
-
usepath = _context6.sent;
|
|
385
|
-
_context6.next = 7;
|
|
386
|
-
return _global.gfunc.run_action("post", usepath);
|
|
387
|
-
case 7:
|
|
388
|
-
resultObject = _context6.sent;
|
|
389
|
-
this.setSaveResult(resultObject, "auto", true);
|
|
390
|
-
_context6.next = 11;
|
|
391
|
-
return this.onArchive();
|
|
392
|
-
case 11:
|
|
393
|
-
return _context6.abrupt("return", resultObject);
|
|
394
|
-
case 12:
|
|
395
|
-
case "end":
|
|
396
|
-
return _context6.stop();
|
|
397
|
-
}
|
|
398
|
-
}, _callee6, this);
|
|
399
|
-
}));
|
|
400
|
-
function Archive() {
|
|
401
|
-
return _Archive.apply(this, arguments);
|
|
402
|
-
}
|
|
403
|
-
return Archive;
|
|
404
|
-
}()
|
|
405
|
-
}, {
|
|
406
|
-
key: "UnArchive",
|
|
407
|
-
value: function () {
|
|
408
|
-
var _UnArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
409
|
-
var usepath, resultObject;
|
|
410
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
411
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
412
|
-
case 0:
|
|
413
|
-
if (!(this.isNew || !this.isArchived)) {
|
|
414
|
-
_context7.next = 2;
|
|
415
|
-
break;
|
|
416
|
-
}
|
|
417
|
-
return _context7.abrupt("return");
|
|
418
|
-
case 2:
|
|
419
|
-
_context7.next = 4;
|
|
420
|
-
return _WebObjectPathHelper["default"].get_path(this, "unarchive");
|
|
421
|
-
case 4:
|
|
422
|
-
usepath = _context7.sent;
|
|
423
|
-
_context7.next = 7;
|
|
424
|
-
return _global.gfunc.run_action("post", usepath);
|
|
425
|
-
case 7:
|
|
426
|
-
resultObject = _context7.sent;
|
|
427
|
-
_context7.next = 10;
|
|
428
|
-
return this.onUnArchive();
|
|
429
|
-
case 10:
|
|
430
|
-
return _context7.abrupt("return", resultObject);
|
|
431
|
-
case 11:
|
|
432
|
-
case "end":
|
|
433
|
-
return _context7.stop();
|
|
434
|
-
}
|
|
435
|
-
}, _callee7, this);
|
|
436
|
-
}));
|
|
437
|
-
function UnArchive() {
|
|
438
|
-
return _UnArchive.apply(this, arguments);
|
|
439
|
-
}
|
|
440
|
-
return UnArchive;
|
|
441
|
-
}() /* -------------------------------------------------------------------------- */
|
|
442
|
-
}, {
|
|
443
|
-
key: "canSave",
|
|
444
|
-
value: function canSave(deltaObj) {
|
|
445
|
-
var deltaRes = this.deltaIsValid(deltaObj);
|
|
446
|
-
if (deltaRes !== true) return deltaRes;
|
|
447
|
-
return true;
|
|
448
|
-
}
|
|
449
|
-
}, {
|
|
450
|
-
key: "canDelete",
|
|
451
|
-
value: function canDelete() {
|
|
452
|
-
return true;
|
|
453
|
-
}
|
|
454
|
-
}, {
|
|
455
|
-
key: "canArchive",
|
|
456
|
-
value: function canArchive() {
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
}, {
|
|
460
|
-
key: "deltaIsValid",
|
|
461
|
-
value: function deltaIsValid(d) {
|
|
462
|
-
return true;
|
|
463
|
-
}
|
|
464
|
-
/* -------------------------------------------------------------------------- */
|
|
465
|
-
/* get delta */
|
|
466
|
-
/* -------------------------------------------------------------------------- */
|
|
91
|
+
*/
|
|
92
|
+
static getMetaValue(o, key) {
|
|
93
|
+
if (o == null)
|
|
94
|
+
return null;
|
|
95
|
+
if (!key || typeof key != "string")
|
|
96
|
+
return undefined;
|
|
97
|
+
let metalist = {};
|
|
98
|
+
if (typeof o === "object") {
|
|
99
|
+
metalist =
|
|
100
|
+
typeof o.get === "function" ? o.get("meta_data") : o.meta_data;
|
|
101
|
+
}
|
|
102
|
+
return metalist[key];
|
|
103
|
+
}
|
|
104
|
+
/* -------------------------------------------------------------------------- */
|
|
105
|
+
/* Save */
|
|
106
|
+
/* -------------------------------------------------------------------------- */
|
|
107
|
+
static zipSaveList(svlist) {
|
|
108
|
+
if (typeof svlist === "object")
|
|
109
|
+
svlist = JSON.stringify(svlist);
|
|
110
|
+
return string_compress(svlist);
|
|
111
|
+
}
|
|
112
|
+
static unzipSaveList(svlist) {
|
|
113
|
+
try {
|
|
114
|
+
if (typeof svlist === "object") {
|
|
115
|
+
if (Array.isArray(svlist))
|
|
116
|
+
return svlist;
|
|
117
|
+
if (svlist.__save_list)
|
|
118
|
+
return this.unzipSaveList(svlist.__save_list);
|
|
119
|
+
}
|
|
120
|
+
else if (typeof svlist === "string")
|
|
121
|
+
return wrap_array(JSON.parse(string_decompress(svlist)));
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
return wrap_array(svlist);
|
|
125
|
+
}
|
|
126
|
+
static async saveList(itemList, extraOptions = {}) {
|
|
127
|
+
if (!extraOptions)
|
|
128
|
+
extraOptions = {};
|
|
129
|
+
const chunks = array_chunks(itemList, extraOptions.chunksize ?? 50);
|
|
130
|
+
delete extraOptions.chunksize;
|
|
131
|
+
const putAddress = this.get_webpath();
|
|
132
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
133
|
+
const items_to_save = chunks[index];
|
|
134
|
+
const save_array = [];
|
|
135
|
+
for (let k = 0; k < items_to_save.length; k++) {
|
|
136
|
+
const item = items_to_save[k];
|
|
137
|
+
const dlt = await item.get_deltaObject();
|
|
138
|
+
save_array.push(item.isNew
|
|
139
|
+
? {
|
|
140
|
+
...dlt,
|
|
141
|
+
}
|
|
142
|
+
: {
|
|
143
|
+
_id: item.getID(),
|
|
144
|
+
...dlt,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const resultObject = await gfunc.run_action("post", putAddress, {
|
|
148
|
+
__save_list: WebObject.zipSaveList(save_array),
|
|
149
|
+
...extraOptions,
|
|
150
|
+
});
|
|
151
|
+
if (Array.isArray(resultObject)) {
|
|
152
|
+
for (let index = 0; index < Math.min(resultObject.length, items_to_save.length); index++) {
|
|
153
|
+
const res = resultObject[index];
|
|
154
|
+
const item = items_to_save[index];
|
|
155
|
+
item.setSaveResult(res);
|
|
156
|
+
await item.onSave();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (let index = 0; index < itemList.length; index++) {
|
|
161
|
+
const item = itemList[index];
|
|
162
|
+
if (!item.isSaved)
|
|
163
|
+
return false;
|
|
164
|
+
if (item.getSaveResultType() != "normal")
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
async Save() {
|
|
170
|
+
try {
|
|
171
|
+
if (this.manager) {
|
|
172
|
+
await this.manager.setOption("saving", true);
|
|
173
|
+
await this.manager.setOption("loading", true);
|
|
174
|
+
}
|
|
175
|
+
const deltaObject = await this.get_deltaObject();
|
|
176
|
+
const putAction = "post";
|
|
177
|
+
const usepath = await WebObjectPathHelper.get_path(this, this.isNew ? "new" : "save");
|
|
178
|
+
/* ---------------------------------- save ---------------------------------- */
|
|
179
|
+
if (!object_isEmpty(deltaObject)) {
|
|
180
|
+
const canSaveResult = this.canSave(deltaObject);
|
|
181
|
+
if (canSaveResult !== true) {
|
|
182
|
+
WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
|
|
183
|
+
this.setSaveResult(false, "canceled");
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const resultObject = await gfunc.run_action(putAction, usepath, deltaObject);
|
|
187
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
/* nothing to save */
|
|
191
|
+
this.setSaveResult(null, "nothing");
|
|
192
|
+
}
|
|
193
|
+
if (this.isSaved) {
|
|
194
|
+
await this.onSave();
|
|
195
|
+
return this.getSaveResult();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
if (this.manager) {
|
|
200
|
+
await this.manager.setOption("saving", false);
|
|
201
|
+
await this.manager.setOption("loading", false);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async Delete() {
|
|
206
|
+
if (this.isNew)
|
|
207
|
+
return;
|
|
208
|
+
const usepath = await WebObjectPathHelper.get_path(this, "delete");
|
|
209
|
+
const resultObject = await gfunc.run_action("delete", usepath);
|
|
210
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
211
|
+
await this.onDelete();
|
|
212
|
+
return resultObject;
|
|
213
|
+
}
|
|
214
|
+
async Lock() {
|
|
215
|
+
if (this.isNew || this.isArchived)
|
|
216
|
+
return;
|
|
217
|
+
const usepath = await WebObjectPathHelper.get_path(this, "lock");
|
|
218
|
+
const resultObject = await gfunc.run_action("post", usepath);
|
|
219
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
220
|
+
await this.onLock();
|
|
221
|
+
return resultObject;
|
|
222
|
+
}
|
|
223
|
+
async UnLock() {
|
|
224
|
+
if (this.isNew || this.isArchived)
|
|
225
|
+
return;
|
|
226
|
+
const usepath = await WebObjectPathHelper.get_path(this, "unlock");
|
|
227
|
+
const resultObject = await gfunc.run_action("post", usepath);
|
|
228
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
229
|
+
await this.onUnLock();
|
|
230
|
+
return resultObject;
|
|
231
|
+
}
|
|
232
|
+
async Archive() {
|
|
233
|
+
if (this.isNew || this.isArchived)
|
|
234
|
+
return;
|
|
235
|
+
const usepath = await WebObjectPathHelper.get_path(this, "archive");
|
|
236
|
+
const resultObject = await gfunc.run_action("post", usepath);
|
|
237
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
238
|
+
await this.onArchive();
|
|
239
|
+
return resultObject;
|
|
240
|
+
}
|
|
241
|
+
async UnArchive() {
|
|
242
|
+
if (this.isNew || !this.isArchived)
|
|
243
|
+
return;
|
|
244
|
+
const usepath = await WebObjectPathHelper.get_path(this, "unarchive");
|
|
245
|
+
const resultObject = await gfunc.run_action("post", usepath);
|
|
246
|
+
await this.onUnArchive();
|
|
247
|
+
return resultObject;
|
|
248
|
+
}
|
|
249
|
+
/* -------------------------------------------------------------------------- */
|
|
250
|
+
canSave(deltaObj) {
|
|
251
|
+
const deltaRes = this.deltaIsValid(deltaObj);
|
|
252
|
+
if (deltaRes !== true)
|
|
253
|
+
return deltaRes;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
canDelete() {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
canArchive() {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
deltaIsValid(d) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
/* -------------------------------------------------------------------------- */
|
|
266
|
+
/* get delta */
|
|
267
|
+
/* -------------------------------------------------------------------------- */
|
|
467
268
|
/**
|
|
468
269
|
* converts this object to an basic object
|
|
469
270
|
* that can be passed into client components from server components
|
|
@@ -471,1154 +272,383 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
471
272
|
* uses `get_fullDeltaObject`
|
|
472
273
|
* @param p
|
|
473
274
|
* @returns
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
fullobject[key] = String(element);
|
|
493
|
-
} else {
|
|
494
|
-
fullobject[key] = JSON.parse(JSON.stringify(element));
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
return _context8.abrupt("return", fullobject);
|
|
499
|
-
case 5:
|
|
500
|
-
case "end":
|
|
501
|
-
return _context8.stop();
|
|
502
|
-
}
|
|
503
|
-
}, _callee8, this);
|
|
504
|
-
}));
|
|
505
|
-
function get_basicObject() {
|
|
506
|
-
return _get_basicObject.apply(this, arguments);
|
|
507
|
-
}
|
|
508
|
-
return get_basicObject;
|
|
509
|
-
}()
|
|
275
|
+
*/
|
|
276
|
+
async get_basicObject() {
|
|
277
|
+
const fullobject = await this.get_fullObject();
|
|
278
|
+
for (const key in fullobject) {
|
|
279
|
+
const element = fullobject[key];
|
|
280
|
+
/* --------------------------- check for id fields -------------------------- */
|
|
281
|
+
if (element != null && typeof element === "object") {
|
|
282
|
+
if ((key === "id" || key.endsWith("_id")) &&
|
|
283
|
+
typeof element.toString === "function") {
|
|
284
|
+
fullobject[key] = String(element);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
fullobject[key] = JSON.parse(JSON.stringify(element));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return fullobject;
|
|
292
|
+
}
|
|
510
293
|
/**
|
|
511
294
|
* calls the `get_deltaObject` with
|
|
512
295
|
* `allProperties` `extraProperties`
|
|
513
296
|
* set to true
|
|
514
297
|
*
|
|
515
298
|
* @returns
|
|
516
|
-
*/
|
|
517
|
-
)
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
case 0:
|
|
525
|
-
_context9.next = 2;
|
|
526
|
-
return this.get_deltaObject(_objectSpread({
|
|
527
|
-
allProperties: true,
|
|
528
|
-
extraProperties: true
|
|
529
|
-
}, p));
|
|
530
|
-
case 2:
|
|
531
|
-
return _context9.abrupt("return", _context9.sent);
|
|
532
|
-
case 3:
|
|
533
|
-
case "end":
|
|
534
|
-
return _context9.stop();
|
|
535
|
-
}
|
|
536
|
-
}, _callee9, this);
|
|
537
|
-
}));
|
|
538
|
-
function get_fullDeltaObject(_x3) {
|
|
539
|
-
return _get_fullDeltaObject.apply(this, arguments);
|
|
540
|
-
}
|
|
541
|
-
return get_fullDeltaObject;
|
|
542
|
-
}()
|
|
299
|
+
*/
|
|
300
|
+
async get_fullDeltaObject(p) {
|
|
301
|
+
return await this.get_deltaObject({
|
|
302
|
+
allProperties: true,
|
|
303
|
+
extraProperties: true,
|
|
304
|
+
...p,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
543
307
|
/**
|
|
544
308
|
* calls the `get_deltaObject` with
|
|
545
309
|
* `allProperties` `extraProperties` `tempProperties`
|
|
546
310
|
* set to true
|
|
547
311
|
*
|
|
548
312
|
* @returns
|
|
549
|
-
*/
|
|
550
|
-
)
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
_context0.next = 2;
|
|
559
|
-
return this.get_deltaObject(_objectSpread({
|
|
560
|
-
allProperties: true,
|
|
561
|
-
extraProperties: true,
|
|
562
|
-
tempProperties: true
|
|
563
|
-
}, p));
|
|
564
|
-
case 2:
|
|
565
|
-
return _context0.abrupt("return", _context0.sent);
|
|
566
|
-
case 3:
|
|
567
|
-
case "end":
|
|
568
|
-
return _context0.stop();
|
|
569
|
-
}
|
|
570
|
-
}, _callee0, this);
|
|
571
|
-
}));
|
|
572
|
-
function get_fullObject(_x4) {
|
|
573
|
-
return _get_fullObject.apply(this, arguments);
|
|
574
|
-
}
|
|
575
|
-
return get_fullObject;
|
|
576
|
-
}()
|
|
313
|
+
*/
|
|
314
|
+
async get_fullObject(p) {
|
|
315
|
+
return await this.get_deltaObject({
|
|
316
|
+
allProperties: true,
|
|
317
|
+
extraProperties: true,
|
|
318
|
+
tempProperties: true,
|
|
319
|
+
...p,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
577
322
|
/**
|
|
578
323
|
* You will post this to the server for saving
|
|
579
324
|
* automatically removes unchangeable fields
|
|
580
325
|
* @returns
|
|
581
|
-
*/
|
|
582
|
-
)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
return _context10.abrupt("return", undefined);
|
|
602
|
-
case 2:
|
|
603
|
-
if (!Array.isArray(obj)) {
|
|
604
|
-
_context10.next = 6;
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
|
-
_context10.next = 5;
|
|
608
|
-
return Promise.all(obj.map(/*#__PURE__*/function () {
|
|
609
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(r, i) {
|
|
610
|
-
return _regeneratorRuntime().wrap(function _callee1$(_context1) {
|
|
611
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
612
|
-
case 0:
|
|
613
|
-
_context1.next = 2;
|
|
614
|
-
return parseObj(key, r);
|
|
615
|
-
case 2:
|
|
616
|
-
return _context1.abrupt("return", _context1.sent);
|
|
617
|
-
case 3:
|
|
618
|
-
case "end":
|
|
619
|
-
return _context1.stop();
|
|
620
|
-
}
|
|
621
|
-
}, _callee1);
|
|
622
|
-
}));
|
|
623
|
-
return function (_x8, _x9) {
|
|
624
|
-
return _ref.apply(this, arguments);
|
|
625
|
-
};
|
|
626
|
-
}()));
|
|
627
|
-
case 5:
|
|
628
|
-
return _context10.abrupt("return", _context10.sent);
|
|
629
|
-
case 6:
|
|
630
|
-
if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
|
|
631
|
-
_context10.next = 18;
|
|
632
|
-
break;
|
|
633
|
-
}
|
|
634
|
-
/* -------------------- parse changeableKeys for children -------------------- */
|
|
635
|
-
keydot = "".concat(key, ".");
|
|
636
|
-
child_changeableKeys = (_p = p) === null || _p === void 0 || (_p = _p.changeableKeys) === null || _p === void 0 ? void 0 : _p.filter(function (s) {
|
|
637
|
-
return s.startsWith(keydot);
|
|
638
|
-
}).map(function (r) {
|
|
639
|
-
return r.substring(keydot.length);
|
|
640
|
-
});
|
|
641
|
-
/**
|
|
642
|
-
* if no key is set for children consider it as undefined
|
|
643
|
-
* if we send the empty array to get_delta we get no keys
|
|
644
|
-
*/
|
|
645
|
-
if (child_changeableKeys == null || ((_child_changeableKeys = child_changeableKeys) === null || _child_changeableKeys === void 0 ? void 0 : _child_changeableKeys.length) === 0) {
|
|
646
|
-
child_changeableKeys = undefined;
|
|
647
|
-
}
|
|
648
|
-
/* -------------------------------------------------------------------------- */
|
|
649
|
-
//child elements have different kind of delta
|
|
650
|
-
_context10.next = 12;
|
|
651
|
-
return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
|
|
652
|
-
isChild: true,
|
|
653
|
-
changeableKeys: child_changeableKeys
|
|
654
|
-
}));
|
|
655
|
-
case 12:
|
|
656
|
-
newobj_dlt = _context10.sent;
|
|
657
|
-
if ((0, _object.object_isEmpty)(newobj_dlt)) {
|
|
658
|
-
_context10.next = 17;
|
|
659
|
-
break;
|
|
660
|
-
}
|
|
661
|
-
return _context10.abrupt("return", newobj_dlt);
|
|
662
|
-
case 17:
|
|
663
|
-
return _context10.abrupt("return", obj);
|
|
664
|
-
case 18:
|
|
665
|
-
return _context10.abrupt("return", obj);
|
|
666
|
-
case 19:
|
|
667
|
-
case "end":
|
|
668
|
-
return _context10.stop();
|
|
669
|
-
}
|
|
670
|
-
}, _callee10);
|
|
671
|
-
}));
|
|
672
|
-
return _parseObj.apply(this, arguments);
|
|
673
|
-
};
|
|
674
|
-
parseObj = function _parseObj2(_x6, _x7) {
|
|
675
|
-
return _parseObj.apply(this, arguments);
|
|
676
|
-
};
|
|
677
|
-
if (!p) p = {};
|
|
678
|
-
final_object = {};
|
|
679
|
-
useDelta = Boolean(this.__use_delta || p.useDelta);
|
|
680
|
-
/**
|
|
681
|
-
* child objects usually dont update their __delta
|
|
682
|
-
* so we read info from all of its properties
|
|
683
|
-
*/
|
|
684
|
-
changedFields = Boolean(p.allProperties || p.isChild || !useDelta) ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
|
|
685
|
-
/* ------------- parse children that have WebObject as delta ------------- */
|
|
686
|
-
_context11.t0 = _regeneratorRuntime().keys(this);
|
|
687
|
-
case 7:
|
|
688
|
-
if ((_context11.t1 = _context11.t0()).done) {
|
|
689
|
-
_context11.next = 14;
|
|
690
|
-
break;
|
|
691
|
-
}
|
|
692
|
-
key = _context11.t1.value;
|
|
693
|
-
if (!(key.startsWith("__") || key in changedFields)) {
|
|
694
|
-
_context11.next = 11;
|
|
695
|
-
break;
|
|
696
|
-
}
|
|
697
|
-
return _context11.abrupt("continue", 7);
|
|
698
|
-
case 11:
|
|
699
|
-
if (_WebObjectHelper["default"].isChangedWebObjectField(this[key])) {
|
|
326
|
+
*/
|
|
327
|
+
async get_deltaObject(p) {
|
|
328
|
+
if (!p)
|
|
329
|
+
p = {};
|
|
330
|
+
const final_object = {};
|
|
331
|
+
const useDelta = Boolean(this.__use_delta || p.useDelta);
|
|
332
|
+
/**
|
|
333
|
+
* child objects usually dont update their __delta
|
|
334
|
+
* so we read info from all of its properties
|
|
335
|
+
*/
|
|
336
|
+
const changedFields = Boolean(p.allProperties || p.isChild || !useDelta)
|
|
337
|
+
? { ...this.allproperties }
|
|
338
|
+
: { ...this.__delta };
|
|
339
|
+
/* ------------- parse children that have WebObject as delta ------------- */
|
|
340
|
+
for (const key in this) {
|
|
341
|
+
if (key.startsWith("__") || key in changedFields)
|
|
342
|
+
continue;
|
|
343
|
+
if (WebObjectHelper.isChangedWebObjectField(this[key])) {
|
|
700
344
|
/**
|
|
701
345
|
* if a child has any change we must add it into our delta
|
|
702
346
|
* notice that the changes may not be saved to database depending on __changeables
|
|
703
347
|
* but they are changes nevertheless
|
|
704
|
-
*/
|
|
705
|
-
changedFields[key] = this[key];
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
fp =
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
_args14 = arguments;
|
|
900
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
901
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
902
|
-
case 0:
|
|
903
|
-
if (this.isSaved) this.isArchived = false;
|
|
904
|
-
for (_len3 = _args14.length, p = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
|
|
905
|
-
p[_key4] = _args14[_key4];
|
|
906
|
-
}
|
|
907
|
-
_context14.next = 4;
|
|
908
|
-
return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onUnArchive.apply(_this$manager3, p);
|
|
909
|
-
case 4:
|
|
910
|
-
return _context14.abrupt("return", _context14.sent);
|
|
911
|
-
case 5:
|
|
912
|
-
case "end":
|
|
913
|
-
return _context14.stop();
|
|
914
|
-
}
|
|
915
|
-
}, _callee14, this);
|
|
916
|
-
}));
|
|
917
|
-
function onUnArchive() {
|
|
918
|
-
return _onUnArchive.apply(this, arguments);
|
|
919
|
-
}
|
|
920
|
-
return onUnArchive;
|
|
921
|
-
}()
|
|
922
|
-
}, {
|
|
923
|
-
key: "onLock",
|
|
924
|
-
value: function () {
|
|
925
|
-
var _onLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
926
|
-
var _this$manager4;
|
|
927
|
-
var _len4,
|
|
928
|
-
p,
|
|
929
|
-
_key5,
|
|
930
|
-
_args15 = arguments;
|
|
931
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
932
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
933
|
-
case 0:
|
|
934
|
-
if (this.isSaved) this.isLocked = true;
|
|
935
|
-
for (_len4 = _args15.length, p = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
|
|
936
|
-
p[_key5] = _args15[_key5];
|
|
937
|
-
}
|
|
938
|
-
_context15.next = 4;
|
|
939
|
-
return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onLock.apply(_this$manager4, p);
|
|
940
|
-
case 4:
|
|
941
|
-
return _context15.abrupt("return", _context15.sent);
|
|
942
|
-
case 5:
|
|
943
|
-
case "end":
|
|
944
|
-
return _context15.stop();
|
|
945
|
-
}
|
|
946
|
-
}, _callee15, this);
|
|
947
|
-
}));
|
|
948
|
-
function onLock() {
|
|
949
|
-
return _onLock.apply(this, arguments);
|
|
950
|
-
}
|
|
951
|
-
return onLock;
|
|
952
|
-
}()
|
|
953
|
-
}, {
|
|
954
|
-
key: "onUnLock",
|
|
955
|
-
value: function () {
|
|
956
|
-
var _onUnLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
957
|
-
var _this$manager5;
|
|
958
|
-
var _len5,
|
|
959
|
-
p,
|
|
960
|
-
_key6,
|
|
961
|
-
_args16 = arguments;
|
|
962
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
963
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
964
|
-
case 0:
|
|
965
|
-
if (this.isSaved) this.isLocked = false;
|
|
966
|
-
for (_len5 = _args16.length, p = new Array(_len5), _key6 = 0; _key6 < _len5; _key6++) {
|
|
967
|
-
p[_key6] = _args16[_key6];
|
|
968
|
-
}
|
|
969
|
-
_context16.next = 4;
|
|
970
|
-
return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onUnLock.apply(_this$manager5, p);
|
|
971
|
-
case 4:
|
|
972
|
-
return _context16.abrupt("return", _context16.sent);
|
|
973
|
-
case 5:
|
|
974
|
-
case "end":
|
|
975
|
-
return _context16.stop();
|
|
976
|
-
}
|
|
977
|
-
}, _callee16, this);
|
|
978
|
-
}));
|
|
979
|
-
function onUnLock() {
|
|
980
|
-
return _onUnLock.apply(this, arguments);
|
|
981
|
-
}
|
|
982
|
-
return onUnLock;
|
|
983
|
-
}()
|
|
984
|
-
}, {
|
|
985
|
-
key: "onLoad",
|
|
986
|
-
value: function () {
|
|
987
|
-
var _onLoad = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
988
|
-
var _this$manager6;
|
|
989
|
-
var _len6,
|
|
990
|
-
p,
|
|
991
|
-
_key7,
|
|
992
|
-
_args17 = arguments;
|
|
993
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
994
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
995
|
-
case 0:
|
|
996
|
-
this.isDeleted = false;
|
|
997
|
-
for (_len6 = _args17.length, p = new Array(_len6), _key7 = 0; _key7 < _len6; _key7++) {
|
|
998
|
-
p[_key7] = _args17[_key7];
|
|
999
|
-
}
|
|
1000
|
-
_context17.next = 4;
|
|
1001
|
-
return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onLoad.apply(_this$manager6, p);
|
|
1002
|
-
case 4:
|
|
1003
|
-
return _context17.abrupt("return", _context17.sent);
|
|
1004
|
-
case 5:
|
|
1005
|
-
case "end":
|
|
1006
|
-
return _context17.stop();
|
|
1007
|
-
}
|
|
1008
|
-
}, _callee17, this);
|
|
1009
|
-
}));
|
|
1010
|
-
function onLoad() {
|
|
1011
|
-
return _onLoad.apply(this, arguments);
|
|
1012
|
-
}
|
|
1013
|
-
return onLoad;
|
|
1014
|
-
}()
|
|
1015
|
-
}, {
|
|
1016
|
-
key: "onSave",
|
|
1017
|
-
value: function () {
|
|
1018
|
-
var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1019
|
-
var _this$manager8;
|
|
1020
|
-
var srObject,
|
|
1021
|
-
_this$manager7,
|
|
1022
|
-
_len7,
|
|
1023
|
-
p,
|
|
1024
|
-
_key8,
|
|
1025
|
-
_args18 = arguments;
|
|
1026
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1027
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1028
|
-
case 0:
|
|
1029
|
-
if (!this.isSaved) {
|
|
1030
|
-
_context18.next = 7;
|
|
1031
|
-
break;
|
|
1032
|
-
}
|
|
1033
|
-
this.apply_changes();
|
|
1034
|
-
srObject = this.getSaveResult(true);
|
|
1035
|
-
if (!this.saveResultHasID(srObject)) {
|
|
1036
|
-
_context18.next = 7;
|
|
1037
|
-
break;
|
|
1038
|
-
}
|
|
1039
|
-
/* -------------------------------------------------------------------------- */
|
|
1040
|
-
WebObject.LoadIdsFromSaveResult(this, srObject);
|
|
1041
|
-
_context18.next = 7;
|
|
1042
|
-
return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.event_run("on_id_change");
|
|
1043
|
-
case 7:
|
|
1044
|
-
for (_len7 = _args18.length, p = new Array(_len7), _key8 = 0; _key8 < _len7; _key8++) {
|
|
1045
|
-
p[_key8] = _args18[_key8];
|
|
1046
|
-
}
|
|
1047
|
-
_context18.next = 10;
|
|
1048
|
-
return (_this$manager8 = this.manager) === null || _this$manager8 === void 0 ? void 0 : _this$manager8.onSave.apply(_this$manager8, p);
|
|
1049
|
-
case 10:
|
|
1050
|
-
_context18.next = 12;
|
|
1051
|
-
return this.onAfterSave();
|
|
1052
|
-
case 12:
|
|
1053
|
-
return _context18.abrupt("return", true);
|
|
1054
|
-
case 13:
|
|
1055
|
-
case "end":
|
|
1056
|
-
return _context18.stop();
|
|
1057
|
-
}
|
|
1058
|
-
}, _callee18, this);
|
|
1059
|
-
}));
|
|
1060
|
-
function onSave() {
|
|
1061
|
-
return _onSave.apply(this, arguments);
|
|
1062
|
-
}
|
|
1063
|
-
return onSave;
|
|
1064
|
-
}()
|
|
1065
|
-
}, {
|
|
1066
|
-
key: "onAfterSave",
|
|
1067
|
-
value: function () {
|
|
1068
|
-
var _onAfterSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1069
|
-
var _this$manager9;
|
|
1070
|
-
var _len8,
|
|
1071
|
-
p,
|
|
1072
|
-
_key9,
|
|
1073
|
-
_args19 = arguments;
|
|
1074
|
-
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1075
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1076
|
-
case 0:
|
|
1077
|
-
for (_len8 = _args19.length, p = new Array(_len8), _key9 = 0; _key9 < _len8; _key9++) {
|
|
1078
|
-
p[_key9] = _args19[_key9];
|
|
1079
|
-
}
|
|
1080
|
-
_context19.next = 3;
|
|
1081
|
-
return (_this$manager9 = this.manager) === null || _this$manager9 === void 0 ? void 0 : _this$manager9.onAfterSave.apply(_this$manager9, p);
|
|
1082
|
-
case 3:
|
|
1083
|
-
return _context19.abrupt("return", true);
|
|
1084
|
-
case 4:
|
|
1085
|
-
case "end":
|
|
1086
|
-
return _context19.stop();
|
|
1087
|
-
}
|
|
1088
|
-
}, _callee19, this);
|
|
1089
|
-
}));
|
|
1090
|
-
function onAfterSave() {
|
|
1091
|
-
return _onAfterSave.apply(this, arguments);
|
|
1092
|
-
}
|
|
1093
|
-
return onAfterSave;
|
|
1094
|
-
}()
|
|
1095
|
-
}, {
|
|
1096
|
-
key: "getSaveResult",
|
|
1097
|
-
value: function getSaveResult() {
|
|
1098
|
-
var _this2 = this;
|
|
1099
|
-
var original = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1100
|
-
var srObject = _superPropGet(WebObject, "getSaveResult", this, 3)([original]);
|
|
1101
|
-
if (!srObject) return false;
|
|
1102
|
-
if (Array.isArray(srObject)) {
|
|
1103
|
-
var actual_sr = srObject.find(function (s) {
|
|
1104
|
-
return _this2.saveResultHasID(s);
|
|
1105
|
-
});
|
|
1106
|
-
if (actual_sr) srObject = actual_sr;
|
|
1107
|
-
}
|
|
1108
|
-
return srObject;
|
|
1109
|
-
}
|
|
1110
|
-
}, {
|
|
1111
|
-
key: "onNew",
|
|
1112
|
-
value: function () {
|
|
1113
|
-
var _onNew = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1114
|
-
var _this$manager0;
|
|
1115
|
-
var _len9,
|
|
1116
|
-
p,
|
|
1117
|
-
_key0,
|
|
1118
|
-
_args20 = arguments;
|
|
1119
|
-
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1120
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
1121
|
-
case 0:
|
|
1122
|
-
for (_len9 = _args20.length, p = new Array(_len9), _key0 = 0; _key0 < _len9; _key0++) {
|
|
1123
|
-
p[_key0] = _args20[_key0];
|
|
1124
|
-
}
|
|
1125
|
-
_context20.next = 3;
|
|
1126
|
-
return (_this$manager0 = this.manager) === null || _this$manager0 === void 0 ? void 0 : _this$manager0.onNew.apply(_this$manager0, p);
|
|
1127
|
-
case 3:
|
|
1128
|
-
return _context20.abrupt("return", _context20.sent);
|
|
1129
|
-
case 4:
|
|
1130
|
-
case "end":
|
|
1131
|
-
return _context20.stop();
|
|
1132
|
-
}
|
|
1133
|
-
}, _callee20, this);
|
|
1134
|
-
}));
|
|
1135
|
-
function onNew() {
|
|
1136
|
-
return _onNew.apply(this, arguments);
|
|
1137
|
-
}
|
|
1138
|
-
return onNew;
|
|
1139
|
-
}() /* -------------------------------------------------------------------------- */
|
|
1140
|
-
}, {
|
|
1141
|
-
key: "saveResultHasID",
|
|
1142
|
-
value: function saveResultHasID(s) {
|
|
1143
|
-
return WebObject.saveResultHasID(s);
|
|
1144
|
-
}
|
|
1145
|
-
}], [{
|
|
1146
|
-
key: "getAllUsers",
|
|
1147
|
-
value: function getAllUsers(obj) {
|
|
1148
|
-
if (_typeof(obj) != "object") return [];
|
|
1149
|
-
return (0, _object.array_remove_duplicates)((0, _object.array_merge)(obj._creator, (0, _object.wrap_array)(obj._users), (0, _object.wrap_array)(obj.attentions)).map(function (r) {
|
|
1150
|
-
return String(_typeof(r) === "object" ? WebObject.getID(r) : r);
|
|
1151
|
-
}).filter(function (s) {
|
|
1152
|
-
return s;
|
|
1153
|
-
}));
|
|
1154
|
-
}
|
|
1155
|
-
}, {
|
|
1156
|
-
key: "getMetaValue",
|
|
1157
|
-
value: function getMetaValue(o, key) {
|
|
1158
|
-
if (o == null) return null;
|
|
1159
|
-
if (!key || typeof key != "string") return undefined;
|
|
1160
|
-
var metalist = {};
|
|
1161
|
-
if (_typeof(o) === "object") {
|
|
1162
|
-
metalist = typeof o.get === "function" ? o.get("meta_data") : o.meta_data;
|
|
1163
|
-
}
|
|
1164
|
-
return metalist[key];
|
|
1165
|
-
}
|
|
1166
|
-
/* -------------------------------------------------------------------------- */
|
|
1167
|
-
/* Save */
|
|
1168
|
-
/* -------------------------------------------------------------------------- */
|
|
1169
|
-
}, {
|
|
1170
|
-
key: "zipSaveList",
|
|
1171
|
-
value: function zipSaveList(svlist) {
|
|
1172
|
-
if (_typeof(svlist) === "object") svlist = JSON.stringify(svlist);
|
|
1173
|
-
return (0, _string.string_compress)(svlist);
|
|
1174
|
-
}
|
|
1175
|
-
}, {
|
|
1176
|
-
key: "unzipSaveList",
|
|
1177
|
-
value: function unzipSaveList(svlist) {
|
|
1178
|
-
try {
|
|
1179
|
-
if (_typeof(svlist) === "object") {
|
|
1180
|
-
if (Array.isArray(svlist)) return svlist;
|
|
1181
|
-
if (svlist.__save_list) return this.unzipSaveList(svlist.__save_list);
|
|
1182
|
-
} else if (typeof svlist === "string") return (0, _object.wrap_array)(JSON.parse((0, _string.string_decompress)(svlist)));
|
|
1183
|
-
} catch (_unused) {}
|
|
1184
|
-
return (0, _object.wrap_array)(svlist);
|
|
1185
|
-
}
|
|
1186
|
-
}, {
|
|
1187
|
-
key: "saveList",
|
|
1188
|
-
value: function () {
|
|
1189
|
-
var _saveList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(itemList) {
|
|
1190
|
-
var _extraOptions$chunksi;
|
|
1191
|
-
var extraOptions,
|
|
1192
|
-
chunks,
|
|
1193
|
-
putAddress,
|
|
1194
|
-
index,
|
|
1195
|
-
items_to_save,
|
|
1196
|
-
save_array,
|
|
1197
|
-
k,
|
|
1198
|
-
item,
|
|
1199
|
-
dlt,
|
|
1200
|
-
resultObject,
|
|
1201
|
-
_index,
|
|
1202
|
-
res,
|
|
1203
|
-
_item,
|
|
1204
|
-
_index2,
|
|
1205
|
-
_item2,
|
|
1206
|
-
_args21 = arguments;
|
|
1207
|
-
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1208
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1209
|
-
case 0:
|
|
1210
|
-
extraOptions = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
|
|
1211
|
-
if (!extraOptions) extraOptions = {};
|
|
1212
|
-
chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
|
|
1213
|
-
delete extraOptions.chunksize;
|
|
1214
|
-
putAddress = this.get_webpath();
|
|
1215
|
-
index = 0;
|
|
1216
|
-
case 6:
|
|
1217
|
-
if (!(index < chunks.length)) {
|
|
1218
|
-
_context21.next = 36;
|
|
1219
|
-
break;
|
|
1220
|
-
}
|
|
1221
|
-
items_to_save = chunks[index];
|
|
1222
|
-
save_array = [];
|
|
1223
|
-
k = 0;
|
|
1224
|
-
case 10:
|
|
1225
|
-
if (!(k < items_to_save.length)) {
|
|
1226
|
-
_context21.next = 19;
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
item = items_to_save[k];
|
|
1230
|
-
_context21.next = 14;
|
|
1231
|
-
return item.get_deltaObject();
|
|
1232
|
-
case 14:
|
|
1233
|
-
dlt = _context21.sent;
|
|
1234
|
-
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
1235
|
-
_id: item.getID()
|
|
1236
|
-
}, dlt));
|
|
1237
|
-
case 16:
|
|
1238
|
-
k++;
|
|
1239
|
-
_context21.next = 10;
|
|
1240
|
-
break;
|
|
1241
|
-
case 19:
|
|
1242
|
-
_context21.next = 21;
|
|
1243
|
-
return _global.gfunc.run_action("post", putAddress, _objectSpread({
|
|
1244
|
-
__save_list: WebObject.zipSaveList(save_array)
|
|
1245
|
-
}, extraOptions));
|
|
1246
|
-
case 21:
|
|
1247
|
-
resultObject = _context21.sent;
|
|
1248
|
-
if (!Array.isArray(resultObject)) {
|
|
1249
|
-
_context21.next = 33;
|
|
1250
|
-
break;
|
|
1251
|
-
}
|
|
1252
|
-
_index = 0;
|
|
1253
|
-
case 24:
|
|
1254
|
-
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
1255
|
-
_context21.next = 33;
|
|
1256
|
-
break;
|
|
1257
|
-
}
|
|
1258
|
-
res = resultObject[_index];
|
|
1259
|
-
_item = items_to_save[_index];
|
|
1260
|
-
_item.setSaveResult(res);
|
|
1261
|
-
_context21.next = 30;
|
|
1262
|
-
return _item.onSave();
|
|
1263
|
-
case 30:
|
|
1264
|
-
_index++;
|
|
1265
|
-
_context21.next = 24;
|
|
1266
|
-
break;
|
|
1267
|
-
case 33:
|
|
1268
|
-
index++;
|
|
1269
|
-
_context21.next = 6;
|
|
1270
|
-
break;
|
|
1271
|
-
case 36:
|
|
1272
|
-
_index2 = 0;
|
|
1273
|
-
case 37:
|
|
1274
|
-
if (!(_index2 < itemList.length)) {
|
|
1275
|
-
_context21.next = 46;
|
|
1276
|
-
break;
|
|
1277
|
-
}
|
|
1278
|
-
_item2 = itemList[_index2];
|
|
1279
|
-
if (_item2.isSaved) {
|
|
1280
|
-
_context21.next = 41;
|
|
1281
|
-
break;
|
|
1282
|
-
}
|
|
1283
|
-
return _context21.abrupt("return", false);
|
|
1284
|
-
case 41:
|
|
1285
|
-
if (!(_item2.getSaveResultType() != "normal")) {
|
|
1286
|
-
_context21.next = 43;
|
|
1287
|
-
break;
|
|
1288
|
-
}
|
|
1289
|
-
return _context21.abrupt("return", false);
|
|
1290
|
-
case 43:
|
|
1291
|
-
_index2++;
|
|
1292
|
-
_context21.next = 37;
|
|
1293
|
-
break;
|
|
1294
|
-
case 46:
|
|
1295
|
-
return _context21.abrupt("return", true);
|
|
1296
|
-
case 47:
|
|
1297
|
-
case "end":
|
|
1298
|
-
return _context21.stop();
|
|
1299
|
-
}
|
|
1300
|
-
}, _callee21, this);
|
|
1301
|
-
}));
|
|
1302
|
-
function saveList(_x0) {
|
|
1303
|
-
return _saveList.apply(this, arguments);
|
|
1304
|
-
}
|
|
1305
|
-
return saveList;
|
|
1306
|
-
}()
|
|
1307
|
-
}, {
|
|
1308
|
-
key: "get_webpath",
|
|
1309
|
-
value: function get_webpath() {
|
|
1310
|
-
return this.__web_path || this.__db_name || "";
|
|
1311
|
-
}
|
|
1312
|
-
}, {
|
|
1313
|
-
key: "get_dbname",
|
|
1314
|
-
value: function get_dbname() {
|
|
1315
|
-
return this.__db_name || this.__web_path || "";
|
|
1316
|
-
}
|
|
1317
|
-
}, {
|
|
1318
|
-
key: "saveResultHasID",
|
|
1319
|
-
value: function saveResultHasID(s) {
|
|
1320
|
-
if (_typeof(s) !== "object" || s == null || !s) return false;
|
|
1321
|
-
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
1322
|
-
}
|
|
348
|
+
*/
|
|
349
|
+
changedFields[key] = this[key];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* get keys that can be changed.
|
|
354
|
+
* intersection of keys in delta and keys that are defined as changeable
|
|
355
|
+
*/
|
|
356
|
+
let changeableKeys = array_intersection(Object.keys(changedFields), WebObject.getChangeableKeys(this, p));
|
|
357
|
+
/**
|
|
358
|
+
* if parameter of changeableKeys is given, limit our keys with that param
|
|
359
|
+
*/
|
|
360
|
+
if (p.changeableKeys) {
|
|
361
|
+
changeableKeys = array_intersection(changeableKeys, p.changeableKeys);
|
|
362
|
+
}
|
|
363
|
+
/* -------------------------------------------------------------------------- */
|
|
364
|
+
FormatHelper.format({
|
|
365
|
+
original: this,
|
|
366
|
+
inputobject: changedFields,
|
|
367
|
+
formats: object_getStatic(this, "__formatList"),
|
|
368
|
+
isNew: this.isNew,
|
|
369
|
+
changeableKeys: changeableKeys,
|
|
370
|
+
applyDefaults: true,
|
|
371
|
+
});
|
|
372
|
+
/* -------------------------------------------------------------------------- */
|
|
373
|
+
/* __functionProperties */
|
|
374
|
+
/* -------------------------------------------------------------------------- */
|
|
375
|
+
const functionProps = object_getStatic(this, "__functionProperties");
|
|
376
|
+
for (let index = 0; index < functionProps.length; index++) {
|
|
377
|
+
const fp = functionProps[index];
|
|
378
|
+
if (changedFields[fp])
|
|
379
|
+
changedFields[fp] = fn_eval_this(this, changedFields[fp]);
|
|
380
|
+
}
|
|
381
|
+
/* -------------------------------------------------------------------------- */
|
|
382
|
+
/* parse all changeableKeys */
|
|
383
|
+
/* -------------------------------------------------------------------------- */
|
|
384
|
+
async function parseObj(key, obj) {
|
|
385
|
+
if (obj == null)
|
|
386
|
+
return undefined;
|
|
387
|
+
if (Array.isArray(obj))
|
|
388
|
+
return await Promise.all(obj.map(async (r, i) => await parseObj(key, r)));
|
|
389
|
+
if (obj instanceof WebObject &&
|
|
390
|
+
typeof obj.get_deltaObject === "function") {
|
|
391
|
+
/* -------------------- parse changeableKeys for children -------------------- */
|
|
392
|
+
const keydot = `${key}.`;
|
|
393
|
+
let child_changeableKeys = p?.changeableKeys
|
|
394
|
+
?.filter((s) => s.startsWith(keydot))
|
|
395
|
+
.map((r) => r.substring(keydot.length));
|
|
396
|
+
/**
|
|
397
|
+
* if no key is set for children consider it as undefined
|
|
398
|
+
* if we send the empty array to get_delta we get no keys
|
|
399
|
+
*/
|
|
400
|
+
if (child_changeableKeys == null ||
|
|
401
|
+
child_changeableKeys?.length === 0) {
|
|
402
|
+
child_changeableKeys = undefined;
|
|
403
|
+
}
|
|
404
|
+
/* -------------------------------------------------------------------------- */
|
|
405
|
+
//child elements have different kind of delta
|
|
406
|
+
const newobj_dlt = await obj.get_deltaObject({
|
|
407
|
+
...p,
|
|
408
|
+
isChild: true,
|
|
409
|
+
changeableKeys: child_changeableKeys,
|
|
410
|
+
});
|
|
411
|
+
if (!object_isEmpty(newobj_dlt))
|
|
412
|
+
return newobj_dlt;
|
|
413
|
+
else
|
|
414
|
+
return obj;
|
|
415
|
+
}
|
|
416
|
+
return obj;
|
|
417
|
+
}
|
|
418
|
+
for (const key of changeableKeys) {
|
|
419
|
+
final_object[key] = await parseObj(key, changedFields[key]);
|
|
420
|
+
}
|
|
421
|
+
/* -------------------- add acrhived and date properties -------------------- */
|
|
422
|
+
if (p.allProperties) {
|
|
423
|
+
final_object["_created_date"] = this["_created_date"];
|
|
424
|
+
final_object["_archived"] = this.isArchived;
|
|
425
|
+
final_object["_deleted"] = this.isDeleted;
|
|
426
|
+
}
|
|
427
|
+
if (p.tempProperties) {
|
|
428
|
+
final_object["__temp"] = this.__temp;
|
|
429
|
+
}
|
|
430
|
+
/* ---------------------------- add id properties --------------------------- */
|
|
431
|
+
if (p.allProperties || p.needId || p.isChild) {
|
|
432
|
+
if (this["_index_key"])
|
|
433
|
+
final_object["_index_key"] = this["_index_key"];
|
|
434
|
+
const gotIndex = this.getIndex();
|
|
435
|
+
const gotId = this.getID();
|
|
436
|
+
if (gotIndex && gotIndex >= 0)
|
|
437
|
+
final_object["_index_value"] = gotIndex;
|
|
438
|
+
if (gotId)
|
|
439
|
+
final_object["_id"] = gotId;
|
|
440
|
+
}
|
|
441
|
+
/* -------------------------------------------------------------------------- */
|
|
442
|
+
/* fix _user property */
|
|
443
|
+
/* -------------------------------------------------------------------------- */
|
|
444
|
+
if (final_object["_users"]) {
|
|
445
|
+
let tempusers = final_object["_users"];
|
|
446
|
+
if (typeof tempusers === "string")
|
|
447
|
+
tempusers = tempusers.split(",").filter((s) => s);
|
|
448
|
+
final_object["_users"] = wrap_array(tempusers);
|
|
449
|
+
}
|
|
450
|
+
if (p.clean)
|
|
451
|
+
return object_clean(final_object, false, true);
|
|
452
|
+
return final_object;
|
|
453
|
+
}
|
|
454
|
+
/* --------------------------------- Getters -------------------------------- */
|
|
455
|
+
get manager() {
|
|
456
|
+
return this.get_managerClass() || undefined;
|
|
457
|
+
}
|
|
458
|
+
get __web_path() {
|
|
459
|
+
return this.constructor["__web_path"] || this.__db_name;
|
|
460
|
+
}
|
|
461
|
+
get_webpath() {
|
|
462
|
+
return this.__web_path || this.__db_name || "";
|
|
463
|
+
}
|
|
464
|
+
static get_webpath() {
|
|
465
|
+
return this.__web_path || this.__db_name || "";
|
|
466
|
+
}
|
|
467
|
+
static get_dbname() {
|
|
468
|
+
return this.__db_name || this.__web_path || "";
|
|
469
|
+
}
|
|
470
|
+
/* -------------------------------------------------------------------------- */
|
|
471
|
+
async onDelete(...p) {
|
|
472
|
+
if (this.isSaved)
|
|
473
|
+
this.isDeleted = true;
|
|
474
|
+
return await this.manager?.onDelete(...p); //events are handled by the manager
|
|
475
|
+
}
|
|
476
|
+
async onArchive(...p) {
|
|
477
|
+
if (this.isSaved)
|
|
478
|
+
this.isArchived = true;
|
|
479
|
+
return await this.manager?.onArchive(...p); //events are handled by the manager
|
|
480
|
+
}
|
|
481
|
+
async onUnArchive(...p) {
|
|
482
|
+
if (this.isSaved)
|
|
483
|
+
this.isArchived = false;
|
|
484
|
+
return await this.manager?.onUnArchive(...p); //events are handled by the manager
|
|
485
|
+
}
|
|
486
|
+
async onLock(...p) {
|
|
487
|
+
if (this.isSaved)
|
|
488
|
+
this.isLocked = true;
|
|
489
|
+
return await this.manager?.onLock(...p); //events are handled by the manager
|
|
490
|
+
}
|
|
491
|
+
async onUnLock(...p) {
|
|
492
|
+
if (this.isSaved)
|
|
493
|
+
this.isLocked = false;
|
|
494
|
+
return await this.manager?.onUnLock(...p); //events are handled by the manager
|
|
495
|
+
}
|
|
496
|
+
async onLoad(...p) {
|
|
497
|
+
this.isDeleted = false;
|
|
498
|
+
return await this.manager?.onLoad(...p); //events are handled by the manager
|
|
499
|
+
}
|
|
500
|
+
async onSave(...p) {
|
|
501
|
+
if (this.isSaved) {
|
|
502
|
+
this.apply_changes();
|
|
503
|
+
var srObject = this.getSaveResult(true);
|
|
504
|
+
if (this.saveResultHasID(srObject)) {
|
|
505
|
+
/* -------------------------------------------------------------------------- */
|
|
506
|
+
WebObject.LoadIdsFromSaveResult(this, srObject);
|
|
507
|
+
await this.manager?.event_run("on_id_change");
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
await this.manager?.onSave(...p); //events are handled by the manager
|
|
511
|
+
await this.onAfterSave();
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
async onAfterSave(...p) {
|
|
515
|
+
await this.manager?.onAfterSave(...p); //events are handled by the manager
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
getSaveResult(original = false) {
|
|
519
|
+
let srObject = super.getSaveResult(original);
|
|
520
|
+
if (!srObject)
|
|
521
|
+
return false;
|
|
522
|
+
if (Array.isArray(srObject)) {
|
|
523
|
+
const actual_sr = srObject.find((s) => this.saveResultHasID(s));
|
|
524
|
+
if (actual_sr)
|
|
525
|
+
srObject = actual_sr;
|
|
526
|
+
}
|
|
527
|
+
return srObject;
|
|
528
|
+
}
|
|
529
|
+
async onNew(...p) {
|
|
530
|
+
return await this.manager?.onNew(...p); //events are handled by the manager
|
|
531
|
+
}
|
|
532
|
+
/* -------------------------------------------------------------------------- */
|
|
533
|
+
saveResultHasID(s) {
|
|
534
|
+
return WebObject.saveResultHasID(s);
|
|
535
|
+
}
|
|
536
|
+
static saveResultHasID(s) {
|
|
537
|
+
if (typeof s !== "object" || s == null || !s)
|
|
538
|
+
return false;
|
|
539
|
+
return (s.insertedId ||
|
|
540
|
+
s._id ||
|
|
541
|
+
(s._index_value && !Number.isNaN(s._index_value)));
|
|
542
|
+
}
|
|
1323
543
|
/**
|
|
1324
544
|
* Load Id and _index_value from the given save result into our object
|
|
1325
545
|
* @param o
|
|
1326
546
|
* @param srObject
|
|
1327
547
|
* @returns
|
|
1328
|
-
*/
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
/* -------------------------------------------------------------------------- */
|
|
548
|
+
*/
|
|
549
|
+
static LoadIdsFromSaveResult(o, srObject) {
|
|
550
|
+
if (typeof o !== "object" || typeof srObject !== "object")
|
|
551
|
+
return;
|
|
552
|
+
/* -------------------------------------------------------------------------- */
|
|
553
|
+
const srID = srObject.insertedId || srObject._id || WebObject.getID(srObject);
|
|
554
|
+
if (srID) {
|
|
555
|
+
o._id = srID;
|
|
556
|
+
}
|
|
557
|
+
/* -------------------------------------------------------------------------- */
|
|
558
|
+
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
559
|
+
o._index_value = Number(srObject._index_value);
|
|
560
|
+
}
|
|
561
|
+
/* -------------------------------------------------------------------------- */
|
|
562
|
+
if (srObject._index_key) {
|
|
563
|
+
o._index_key = srObject._index_key;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
/* -------------------------------------------------------------------------- */
|
|
1348
567
|
/**
|
|
1349
568
|
* get a single web object
|
|
1350
569
|
* default order of parameters : search,readonly,fetchID
|
|
1351
|
-
*/
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
break;
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
search = String(search);
|
|
1388
|
-
// const usepath =
|
|
1389
|
-
// (await WebObjectPathHelper.get_path(this, "get")) +
|
|
1390
|
-
// "/" +
|
|
1391
|
-
// search;
|
|
1392
|
-
// res = await gfunc.run_action("get", usepath, params, {
|
|
1393
|
-
// fetchID: fetchID,
|
|
1394
|
-
// });
|
|
1395
|
-
_context22.next = 14;
|
|
1396
|
-
return this.get_list({
|
|
1397
|
-
__searchid: search
|
|
1398
|
-
}, readonly, fetchID);
|
|
1399
|
-
case 14:
|
|
1400
|
-
result = _context22.sent;
|
|
1401
|
-
return _context22.abrupt("break", 20);
|
|
1402
|
-
case 16:
|
|
1403
|
-
_context22.next = 18;
|
|
1404
|
-
return this.get_list(search, readonly, fetchID);
|
|
1405
|
-
case 18:
|
|
1406
|
-
result = _context22.sent;
|
|
1407
|
-
return _context22.abrupt("break", 20);
|
|
1408
|
-
case 20:
|
|
1409
|
-
if (result) result = (0, _object.array_first)(result);
|
|
1410
|
-
if (!(0, _object.object_isEmpty)(result)) {
|
|
1411
|
-
result = this.ensure(this, result);
|
|
1412
|
-
WebObject.setReadonly(result, readonly);
|
|
1413
|
-
}
|
|
1414
|
-
return _context22.abrupt("return", result);
|
|
1415
|
-
case 23:
|
|
1416
|
-
case "end":
|
|
1417
|
-
return _context22.stop();
|
|
1418
|
-
}
|
|
1419
|
-
}, _callee22, this);
|
|
1420
|
-
}));
|
|
1421
|
-
function get_single() {
|
|
1422
|
-
return _get_single.apply(this, arguments);
|
|
1423
|
-
}
|
|
1424
|
-
return get_single;
|
|
1425
|
-
}()
|
|
570
|
+
*/
|
|
571
|
+
static async get_single(...p) {
|
|
572
|
+
let search = p.shift();
|
|
573
|
+
let readonly = p.shift() ?? false;
|
|
574
|
+
let fetchID = p.shift();
|
|
575
|
+
if (object_isEmpty(search))
|
|
576
|
+
return undefined;
|
|
577
|
+
let result;
|
|
578
|
+
const params = {};
|
|
579
|
+
params.__context = readonly ? "view" : "edit";
|
|
580
|
+
switch (typeof search) {
|
|
581
|
+
case "string":
|
|
582
|
+
case "number":
|
|
583
|
+
search = String(search);
|
|
584
|
+
// const usepath =
|
|
585
|
+
// (await WebObjectPathHelper.get_path(this, "get")) +
|
|
586
|
+
// "/" +
|
|
587
|
+
// search;
|
|
588
|
+
// res = await gfunc.run_action("get", usepath, params, {
|
|
589
|
+
// fetchID: fetchID,
|
|
590
|
+
// });
|
|
591
|
+
result = await this.get_list({ __searchid: search }, readonly, fetchID);
|
|
592
|
+
break;
|
|
593
|
+
case "object":
|
|
594
|
+
default:
|
|
595
|
+
result = await this.get_list(search, readonly, fetchID);
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
if (result)
|
|
599
|
+
result = array_first(result);
|
|
600
|
+
if (!object_isEmpty(result)) {
|
|
601
|
+
result = this.ensure(this, result);
|
|
602
|
+
WebObject.setReadonly(result, readonly);
|
|
603
|
+
}
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
1426
606
|
/**
|
|
1427
607
|
* Get a list of web objects
|
|
1428
608
|
* default order of parameters : search,readonly,fetchID
|
|
1429
|
-
*/
|
|
1430
|
-
)
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
res,
|
|
1445
|
-
_args23 = arguments;
|
|
1446
|
-
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1447
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
1448
|
-
case 0:
|
|
1449
|
-
for (_len1 = _args23.length, p = new Array(_len1), _key10 = 0; _key10 < _len1; _key10++) {
|
|
1450
|
-
p[_key10] = _args23[_key10];
|
|
1451
|
-
}
|
|
1452
|
-
search = p.shift();
|
|
1453
|
-
readonly = (_p$shift2 = p.shift()) !== null && _p$shift2 !== void 0 ? _p$shift2 : false;
|
|
1454
|
-
fetchID = p.shift();
|
|
1455
|
-
if (!search) search = {};
|
|
1456
|
-
_context23.next = 7;
|
|
1457
|
-
return _WebObjectPathHelper["default"].get_path(this, "get");
|
|
1458
|
-
case 7:
|
|
1459
|
-
usepath = _context23.sent;
|
|
1460
|
-
_context23.next = 10;
|
|
1461
|
-
return _global.gfunc.run_action("get", usepath, search, {
|
|
1462
|
-
fetchID: fetchID
|
|
1463
|
-
});
|
|
1464
|
-
case 10:
|
|
1465
|
-
result_items = _context23.sent;
|
|
1466
|
-
// const selftype = (this.constructor ||
|
|
1467
|
-
// Object.getPrototypeOf(this)) as any;
|
|
1468
|
-
res = WebObject.map_rowindex(WebObject.mapto(this, result_items, readonly));
|
|
1469
|
-
WebObject.setReadonly(res, readonly);
|
|
1470
|
-
return _context23.abrupt("return", res);
|
|
1471
|
-
case 14:
|
|
1472
|
-
case "end":
|
|
1473
|
-
return _context23.stop();
|
|
1474
|
-
}
|
|
1475
|
-
}, _callee23, this);
|
|
1476
|
-
}));
|
|
1477
|
-
function get_list() {
|
|
1478
|
-
return _get_list.apply(this, arguments);
|
|
1479
|
-
}
|
|
1480
|
-
return get_list;
|
|
1481
|
-
}()
|
|
609
|
+
*/
|
|
610
|
+
static async get_list(...p) {
|
|
611
|
+
let search = p.shift();
|
|
612
|
+
let readonly = p.shift() ?? false;
|
|
613
|
+
let fetchID = p.shift();
|
|
614
|
+
if (!search)
|
|
615
|
+
search = {};
|
|
616
|
+
const usepath = await WebObjectPathHelper.get_path(this, "get");
|
|
617
|
+
let result_items = await gfunc.run_action("get", usepath, search, { fetchID: fetchID });
|
|
618
|
+
// const selftype = (this.constructor ||
|
|
619
|
+
// Object.getPrototypeOf(this)) as any;
|
|
620
|
+
const res = WebObject.map_rowindex(WebObject.mapto(this, result_items, readonly));
|
|
621
|
+
WebObject.setReadonly(res, readonly);
|
|
622
|
+
return res;
|
|
623
|
+
}
|
|
1482
624
|
/**
|
|
1483
625
|
* uses `get_list` and then saves the result to `gcache`
|
|
1484
626
|
* then uses the `equals` function to return matched results
|
|
1485
627
|
* @param search
|
|
1486
628
|
* @returns
|
|
1487
|
-
*/
|
|
1488
|
-
)
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
var all_data;
|
|
1495
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1496
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
1497
|
-
case 0:
|
|
1498
|
-
_context25.next = 2;
|
|
1499
|
-
return _global.gcache.get_temp_cache(this.get_webpath(), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1500
|
-
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1501
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
1502
|
-
case 0:
|
|
1503
|
-
_context24.next = 2;
|
|
1504
|
-
return _this3.get_list();
|
|
1505
|
-
case 2:
|
|
1506
|
-
return _context24.abrupt("return", _context24.sent);
|
|
1507
|
-
case 3:
|
|
1508
|
-
case "end":
|
|
1509
|
-
return _context24.stop();
|
|
1510
|
-
}
|
|
1511
|
-
}, _callee24);
|
|
1512
|
-
})));
|
|
1513
|
-
case 2:
|
|
1514
|
-
all_data = _context25.sent;
|
|
1515
|
-
if (search) {
|
|
1516
|
-
_context25.next = 5;
|
|
1517
|
-
break;
|
|
1518
|
-
}
|
|
1519
|
-
return _context25.abrupt("return", all_data);
|
|
1520
|
-
case 5:
|
|
1521
|
-
return _context25.abrupt("return", all_data.filter(function (s) {
|
|
1522
|
-
return _this3.equals(s, search);
|
|
1523
|
-
}));
|
|
1524
|
-
case 6:
|
|
1525
|
-
case "end":
|
|
1526
|
-
return _context25.stop();
|
|
1527
|
-
}
|
|
1528
|
-
}, _callee25, this);
|
|
1529
|
-
}));
|
|
1530
|
-
function get_list_cache(_x1) {
|
|
1531
|
-
return _get_list_cache.apply(this, arguments);
|
|
1532
|
-
}
|
|
1533
|
-
return get_list_cache;
|
|
1534
|
-
}()
|
|
629
|
+
*/
|
|
630
|
+
static async get_list_cache(search) {
|
|
631
|
+
const all_data = await gcache.get_temp_cache(this.get_webpath(), async () => await this.get_list());
|
|
632
|
+
if (!search)
|
|
633
|
+
return all_data;
|
|
634
|
+
return all_data.filter((s) => this.equals(s, search));
|
|
635
|
+
}
|
|
1535
636
|
/**
|
|
1536
637
|
* uses `get_list_cache` then the `equals` function to return matched result
|
|
1537
638
|
* @param search
|
|
1538
639
|
* @returns
|
|
1539
|
-
*/
|
|
1540
|
-
)
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
value: (function () {
|
|
1544
|
-
var _get_single_cache = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(search) {
|
|
1545
|
-
var _this4 = this;
|
|
1546
|
-
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1547
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
1548
|
-
case 0:
|
|
1549
|
-
_context26.next = 2;
|
|
1550
|
-
return this.get_list_cache();
|
|
1551
|
-
case 2:
|
|
1552
|
-
return _context26.abrupt("return", _context26.sent.find(function (s) {
|
|
1553
|
-
return _this4.equals(s, search);
|
|
1554
|
-
}));
|
|
1555
|
-
case 3:
|
|
1556
|
-
case "end":
|
|
1557
|
-
return _context26.stop();
|
|
1558
|
-
}
|
|
1559
|
-
}, _callee26, this);
|
|
1560
|
-
}));
|
|
1561
|
-
function get_single_cache(_x10) {
|
|
1562
|
-
return _get_single_cache.apply(this, arguments);
|
|
1563
|
-
}
|
|
1564
|
-
return get_single_cache;
|
|
1565
|
-
}()
|
|
640
|
+
*/
|
|
641
|
+
static async get_single_cache(search) {
|
|
642
|
+
return (await this.get_list_cache()).find((s) => this.equals(s, search));
|
|
643
|
+
}
|
|
1566
644
|
/**
|
|
1567
645
|
* Get a list of web objects and convert them to basic objects
|
|
1568
646
|
* can be passed to client components
|
|
1569
647
|
* default order of parameters : search,readonly,fetchID
|
|
1570
|
-
*/
|
|
1571
|
-
)
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
_args28 = arguments;
|
|
1578
|
-
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1579
|
-
while (1) switch (_context28.prev = _context28.next) {
|
|
1580
|
-
case 0:
|
|
1581
|
-
_context28.next = 2;
|
|
1582
|
-
return this.get_list.apply(this, _args28);
|
|
1583
|
-
case 2:
|
|
1584
|
-
itemlist = _context28.sent;
|
|
1585
|
-
_context28.next = 5;
|
|
1586
|
-
return Promise.all(itemlist.map(/*#__PURE__*/function () {
|
|
1587
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(r) {
|
|
1588
|
-
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1589
|
-
while (1) switch (_context27.prev = _context27.next) {
|
|
1590
|
-
case 0:
|
|
1591
|
-
_context27.next = 2;
|
|
1592
|
-
return r.get_basicObject();
|
|
1593
|
-
case 2:
|
|
1594
|
-
return _context27.abrupt("return", _context27.sent);
|
|
1595
|
-
case 3:
|
|
1596
|
-
case "end":
|
|
1597
|
-
return _context27.stop();
|
|
1598
|
-
}
|
|
1599
|
-
}, _callee27);
|
|
1600
|
-
}));
|
|
1601
|
-
return function (_x11) {
|
|
1602
|
-
return _ref3.apply(this, arguments);
|
|
1603
|
-
};
|
|
1604
|
-
}()));
|
|
1605
|
-
case 5:
|
|
1606
|
-
return _context28.abrupt("return", _context28.sent);
|
|
1607
|
-
case 6:
|
|
1608
|
-
case "end":
|
|
1609
|
-
return _context28.stop();
|
|
1610
|
-
}
|
|
1611
|
-
}, _callee28, this);
|
|
1612
|
-
}));
|
|
1613
|
-
function get_basicList() {
|
|
1614
|
-
return _get_basicList.apply(this, arguments);
|
|
1615
|
-
}
|
|
1616
|
-
return get_basicList;
|
|
1617
|
-
}())
|
|
1618
|
-
}]);
|
|
1619
|
-
}(_index3.SimpleObject);
|
|
1620
|
-
_defineProperty(WebObject, "__web_path", "");
|
|
1621
|
-
_defineProperty(WebObject, "__protectedProperties", ["_users"]);
|
|
1622
|
-
//you cant create a new weboject without these properties
|
|
1623
|
-
_defineProperty(WebObject, "__requiredProperties", []);
|
|
1624
|
-
var _default = exports["default"] = WebObject;
|
|
648
|
+
*/
|
|
649
|
+
static async get_basicList(...p) {
|
|
650
|
+
const itemlist = await this.get_list(...p);
|
|
651
|
+
return await Promise.all(itemlist.map(async (r) => await r.get_basicObject()));
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
export default WebObject;
|