complexqa_frontend_core 1.15.1 → 1.16.1
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/package.json +1 -1
- package/publish/api/api_abstract_class.js +326 -0
- package/publish/api/api_abstract_element_class.js +5 -298
- package/publish/api/api_abstract_reference_class.js +56 -0
- package/publish/api/context/context_browser_api.js +17 -0
- package/publish/api/context/context_deployment_target_api.js +17 -0
- package/publish/api/context/context_devices_api.js +17 -0
- package/publish/api/context/context_execution_general_api.js +17 -0
- package/publish/api/context/context_locale_api.js +17 -0
- package/publish/api/context/context_os_api.js +17 -0
- package/publish/api/context/context_screen_resolution_api.js +17 -0
- package/publish/api/index.js +43 -15
- package/publish/index.js +9 -0
- package/publish/types/core/0_familyGeneralElement.js +632 -0
- package/publish/types/core/1_familyContext.js +144 -0
- package/publish/types/core/1_familyTestAutomation.js +20 -0
- package/publish/types/core/1_familyTestDocumentation.js +21 -0
- package/publish/types/family_context/0_familyContext.js +144 -0
- package/publish/types/family_context/typeBrowserContext.js +59 -0
- package/publish/types/family_context/typeDeploymentTargetContext.js +98 -0
- package/publish/types/family_context/typeDeviceContext.js +86 -0
- package/publish/types/family_context/typeExecutionContext.js +148 -0
- package/publish/types/family_context/typeLocaleContext.js +75 -0
- package/publish/types/family_context/typeOsContext.js +86 -0
- package/publish/types/family_context/typeScreenResolutionContext.js +99 -0
- package/publish/types/family_elements/typeAutomationTestEnvironment.js +1 -1
- package/publish/types/family_elements/typeAutomationTestPlan.js +1 -1
- package/publish/types/family_elements/typeAutomationTestStep.js +1 -1
- package/publish/types/family_elements/typeAutomationTestStepTarget.js +1 -1
- package/publish/types/family_elements/typeBug.js +4 -4
- package/publish/types/family_elements/typeFunctional.js +2 -2
- package/publish/types/family_elements/typeFunctionalGroup.js +2 -2
- package/publish/types/family_elements/typeMilestone.js +1 -1
- package/publish/types/family_elements/typePrice.js +1 -1
- package/publish/types/family_elements/typeProject.js +1 -1
- package/publish/types/family_elements/typeProjectDocument.js +1 -1
- package/publish/types/family_elements/typeProjectTestData.js +1 -1
- package/publish/types/family_elements/typeProjectUserRole.js +1 -1
- package/publish/types/family_elements/typeTask.js +1 -1
- package/publish/types/family_elements/typeTeam.js +1 -1
- package/publish/types/family_elements/typeTeamMember.js +1 -1
- package/publish/types/family_elements/typeTeamUserRole.js +1 -1
- package/publish/types/family_elements/typeTestAccount.js +1 -1
- package/publish/types/family_elements/typeTestCase.js +1 -1
- package/publish/types/family_elements/typeTestCaseStep.js +1 -1
- package/publish/types/family_elements/typeTestPlan.js +2 -2
- package/publish/types/family_elements/typeTestRun.js +1 -1
- package/publish/types/family_elements/typeTestRunResult.js +1 -1
- package/publish/types/family_elements/typeTestSuite.js +1 -1
- package/publish/types/family_elements/typeUser.js +1 -1
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { clone_object, echo, in_array, is_array } from "../../utils/utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Базовый абстрактный класс для всех типов
|
|
5
|
+
*
|
|
6
|
+
* @version v.0.2 (12/06/2025)
|
|
7
|
+
*/
|
|
8
|
+
export class familyGeneralElement
|
|
9
|
+
{
|
|
10
|
+
primary_key = false;
|
|
11
|
+
create_scheme = false;
|
|
12
|
+
structure_scheme = false;
|
|
13
|
+
available_enum_values = false;
|
|
14
|
+
api_key = false;
|
|
15
|
+
attribute_name_translate_matrix = {
|
|
16
|
+
en: {},
|
|
17
|
+
ru: {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum_value_translate_matrix = false;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/***********************************************/
|
|
24
|
+
/***********************************************/
|
|
25
|
+
|
|
26
|
+
/***********************************************/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @version v.0.1 (26/05/2024)
|
|
31
|
+
* @return {string|false}
|
|
32
|
+
*/
|
|
33
|
+
get_primary_key()
|
|
34
|
+
{
|
|
35
|
+
if (this.primary_key)
|
|
36
|
+
{
|
|
37
|
+
return this.primary_key;
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
{
|
|
41
|
+
throw new Error('familyGeneralElement has no primary_key. Error #01-01');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @version v.0.1 (14/03/2026)
|
|
49
|
+
* @return {string|false}
|
|
50
|
+
*/
|
|
51
|
+
get_primary_key_value()
|
|
52
|
+
{
|
|
53
|
+
if (this.get_primary_key())
|
|
54
|
+
{
|
|
55
|
+
return this[ this.get_primary_key() ];
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @version v.0.1 (27/06/2024)
|
|
67
|
+
* @returns {array<familyGeneralElement>}
|
|
68
|
+
* @param {number} count
|
|
69
|
+
*/
|
|
70
|
+
get_random_demo_data(count)
|
|
71
|
+
{
|
|
72
|
+
// @todo validations
|
|
73
|
+
let response = [];
|
|
74
|
+
for (let i = 0; i < count; i++)
|
|
75
|
+
{
|
|
76
|
+
response.push(this.get_demo_row());
|
|
77
|
+
}
|
|
78
|
+
// получаем массив сгенерированных элементов,
|
|
79
|
+
// в том числе - с незаполненными данными (корректная обработка)
|
|
80
|
+
|
|
81
|
+
// контроль пересечения primary key
|
|
82
|
+
// прототип идеи
|
|
83
|
+
// @todo - дописать
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @returns {familyGeneralElement}
|
|
90
|
+
*/
|
|
91
|
+
get_demo_row()
|
|
92
|
+
{
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @version v.0.2 (15/06/2024)
|
|
99
|
+
* @param {string} attribute
|
|
100
|
+
*/
|
|
101
|
+
get_available_enum_values(attribute)
|
|
102
|
+
{
|
|
103
|
+
let response = false;
|
|
104
|
+
if (!this.structure_scheme?.[ attribute ])
|
|
105
|
+
{
|
|
106
|
+
// выбрасывать исключения?
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let rules = this.get_attribute_structure_scheme(attribute);
|
|
111
|
+
if (!rules)
|
|
112
|
+
{
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (!in_array('enum', rules))
|
|
116
|
+
{
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (this.available_enum_values?.[ attribute ])
|
|
121
|
+
{
|
|
122
|
+
response = this.available_enum_values?.[ attribute ];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param attribute
|
|
132
|
+
* @returns {array|false}
|
|
133
|
+
*/
|
|
134
|
+
get_attribute_structure_scheme(attribute)
|
|
135
|
+
{
|
|
136
|
+
let response = false;
|
|
137
|
+
if (this.structure_scheme[ attribute ])
|
|
138
|
+
{
|
|
139
|
+
let scheme = clone_object(this.structure_scheme[ attribute ]);
|
|
140
|
+
|
|
141
|
+
if (scheme)
|
|
142
|
+
{
|
|
143
|
+
scheme = scheme.split('|');
|
|
144
|
+
if (is_array(scheme))
|
|
145
|
+
{
|
|
146
|
+
response = [];
|
|
147
|
+
scheme.map((row) =>
|
|
148
|
+
{
|
|
149
|
+
response.push(row.trim());
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @version v.0.1 (26/05/2024)
|
|
162
|
+
*/
|
|
163
|
+
get_data()
|
|
164
|
+
{
|
|
165
|
+
return this.get_pure_data();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @version v.0.1 (26/05/2024)
|
|
172
|
+
*/
|
|
173
|
+
get_pure_data()
|
|
174
|
+
{
|
|
175
|
+
let response = false;
|
|
176
|
+
if (this.structure_scheme)
|
|
177
|
+
{
|
|
178
|
+
response = {};
|
|
179
|
+
_.mapObject(this.structure_scheme, (value, attribute) =>
|
|
180
|
+
{
|
|
181
|
+
if (this[ attribute ] !== undefined)
|
|
182
|
+
{
|
|
183
|
+
response [ attribute ] = this[ attribute ];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return response;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @todo - сделать нормализация по create scheme с валидацией
|
|
194
|
+
*
|
|
195
|
+
* @version v.0.1 (26/01/2025)
|
|
196
|
+
*
|
|
197
|
+
* @param payload
|
|
198
|
+
* @returns {*}
|
|
199
|
+
*/
|
|
200
|
+
normalize_payload(payload)
|
|
201
|
+
{
|
|
202
|
+
|
|
203
|
+
return payload;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
get_editable_attributes() {}
|
|
208
|
+
|
|
209
|
+
is_editable_attribute(attribute) {}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
* @version v.1.0 (14/03/2026)
|
|
215
|
+
*
|
|
216
|
+
* @param {string} attribute_name
|
|
217
|
+
* @param {string} lang
|
|
218
|
+
*
|
|
219
|
+
* @return {string}
|
|
220
|
+
*/
|
|
221
|
+
get_attribute_name_translate(attribute_name, lang)
|
|
222
|
+
{
|
|
223
|
+
let response = attribute_name;
|
|
224
|
+
|
|
225
|
+
if (!lang)
|
|
226
|
+
{
|
|
227
|
+
lang = 'en';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this.attribute_name_translate_matrix?.[ lang ]?.[ attribute_name ])
|
|
231
|
+
{
|
|
232
|
+
response = this.attribute_name_translate_matrix?.[ lang ]?.[ attribute_name ];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return response;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
* @version v.1.0 (05/04/2026)
|
|
242
|
+
* @returns {*}
|
|
243
|
+
*/
|
|
244
|
+
get_enum_value_translate(attribute, value, lang)
|
|
245
|
+
{
|
|
246
|
+
let response = value;
|
|
247
|
+
|
|
248
|
+
if (!lang)
|
|
249
|
+
{
|
|
250
|
+
lang = 'en';
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (this.enum_value_translate_matrix?.[ attribute ]?.[ lang ]?.[ value ])
|
|
254
|
+
{
|
|
255
|
+
response = this.enum_value_translate_matrix?.[ attribute ]?.[ lang ]?.[ value ];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return response;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/***********************************************/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Возвращаем "имя", то есть значение атрибута, который является именем
|
|
265
|
+
*
|
|
266
|
+
* @version v.0.1 (05/06/2025)
|
|
267
|
+
*/
|
|
268
|
+
get_element_name()
|
|
269
|
+
{
|
|
270
|
+
alert('Error #205-001 Not implemented method');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/***********************************************/
|
|
274
|
+
/***********************************************/
|
|
275
|
+
|
|
276
|
+
/***********************************************/
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
* @version v.0.1 (26/05/2024)
|
|
281
|
+
* @param id
|
|
282
|
+
*/
|
|
283
|
+
async find(id = false)
|
|
284
|
+
{
|
|
285
|
+
// или передаем ID, или используем вложенный
|
|
286
|
+
// возвращаем инстанс себя же
|
|
287
|
+
alert('Error #267-001 Not implemented method');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
*
|
|
293
|
+
* @param {familyGeneralElement|object} payload
|
|
294
|
+
*
|
|
295
|
+
* @param {typeFunctionCallback|object|false} callback
|
|
296
|
+
*
|
|
297
|
+
* @param {?function} callback.before
|
|
298
|
+
* @param {?function} callback.success
|
|
299
|
+
* @param {?function} callback.error
|
|
300
|
+
* @param {?function} callback.final
|
|
301
|
+
*
|
|
302
|
+
* @version v.2.0 (12/06/2025)
|
|
303
|
+
*/
|
|
304
|
+
async create(payload, callback)
|
|
305
|
+
{
|
|
306
|
+
if (!this.api_key)
|
|
307
|
+
{
|
|
308
|
+
throw new Error('Error #249-2215 - element has no api_key');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (typeof callback?.before === 'function')
|
|
312
|
+
{
|
|
313
|
+
callback?.before({ payload });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
payload = this.normalize_payload(payload);
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* {Api} ApiService
|
|
321
|
+
*/
|
|
322
|
+
return ApiService[ this.api_key ].create(payload).then((response) =>
|
|
323
|
+
{
|
|
324
|
+
if (typeof callback?.success === 'function')
|
|
325
|
+
{
|
|
326
|
+
callback?.success({ response, payload })
|
|
327
|
+
}
|
|
328
|
+
}).catch((error) =>
|
|
329
|
+
{
|
|
330
|
+
echo({ error });
|
|
331
|
+
if (typeof callback?.error === 'function')
|
|
332
|
+
{
|
|
333
|
+
callback?.error({ error, payload })
|
|
334
|
+
}
|
|
335
|
+
}).finally((response) =>
|
|
336
|
+
{
|
|
337
|
+
if (typeof callback?.final === 'function')
|
|
338
|
+
{
|
|
339
|
+
callback?.final({ response, payload })
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Обновление целой модели элемента
|
|
347
|
+
*
|
|
348
|
+
* @version v.2.0 (12/06/2025)
|
|
349
|
+
*/
|
|
350
|
+
async update(payload, callback)
|
|
351
|
+
{
|
|
352
|
+
if (!this.api_key)
|
|
353
|
+
{
|
|
354
|
+
throw new Error('Error #259-2215 - element has no api_key');
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (typeof callback?.before === 'function')
|
|
358
|
+
{
|
|
359
|
+
callback?.before({ payload });
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
payload = this.normalize_payload(payload);
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* {Api} ApiService
|
|
367
|
+
*/
|
|
368
|
+
return ApiService[ this.api_key ].update(payload).then((response) =>
|
|
369
|
+
{
|
|
370
|
+
if (typeof callback?.success === 'function')
|
|
371
|
+
{
|
|
372
|
+
callback?.success({ response, payload })
|
|
373
|
+
}
|
|
374
|
+
}).catch((error) =>
|
|
375
|
+
{
|
|
376
|
+
echo({ error });
|
|
377
|
+
if (typeof callback?.error === 'function')
|
|
378
|
+
{
|
|
379
|
+
callback?.error({ error, payload })
|
|
380
|
+
}
|
|
381
|
+
}).finally((response) =>
|
|
382
|
+
{
|
|
383
|
+
if (typeof callback?.final === 'function')
|
|
384
|
+
{
|
|
385
|
+
callback?.final({ response, payload })
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Обновление 1 атрибута у 1 элемента
|
|
393
|
+
*
|
|
394
|
+
* @version v.2.0 (12/06/2025)
|
|
395
|
+
* @param key
|
|
396
|
+
* @param value
|
|
397
|
+
* @param callback
|
|
398
|
+
* @returns {Promise<>}
|
|
399
|
+
*/
|
|
400
|
+
async update_property(key, value, callback)
|
|
401
|
+
{
|
|
402
|
+
if (!this.api_key)
|
|
403
|
+
{
|
|
404
|
+
throw new Error('Error #345-2215 - element has no api_key');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
let payload = {
|
|
408
|
+
key : key,
|
|
409
|
+
value: value,
|
|
410
|
+
};
|
|
411
|
+
payload[ this.get_primary_key() ] = this[ this.get_primary_key() ];
|
|
412
|
+
|
|
413
|
+
if (typeof callback?.before === 'function')
|
|
414
|
+
{
|
|
415
|
+
callback?.before({ payload });
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* {Api} ApiService
|
|
420
|
+
*/
|
|
421
|
+
return ApiService[ this.api_key ].update_property(payload).then((response) =>
|
|
422
|
+
{
|
|
423
|
+
if (typeof callback?.success === 'function')
|
|
424
|
+
{
|
|
425
|
+
callback?.success({ response, payload })
|
|
426
|
+
}
|
|
427
|
+
}).catch((error) =>
|
|
428
|
+
{
|
|
429
|
+
echo({ error });
|
|
430
|
+
if (typeof callback?.error === 'function')
|
|
431
|
+
{
|
|
432
|
+
callback?.error({ error, payload })
|
|
433
|
+
}
|
|
434
|
+
}).finally((response) =>
|
|
435
|
+
{
|
|
436
|
+
if (typeof callback?.final === 'function')
|
|
437
|
+
{
|
|
438
|
+
callback?.final({ response, payload })
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Массив свойств у 1 элемента
|
|
446
|
+
*
|
|
447
|
+
* @version v.0.1 (26/05/2024)
|
|
448
|
+
* @param {number} element_id
|
|
449
|
+
* @param {array} payload array<key->value>
|
|
450
|
+
* @returns {Promise<void>}
|
|
451
|
+
*/
|
|
452
|
+
async update_properties(element_id, payload, callback)
|
|
453
|
+
{
|
|
454
|
+
alert('Error #272-001 Not implemented method');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* 1 свойство и массива элементов
|
|
460
|
+
*
|
|
461
|
+
* @version v.0.1 (07/07/2026)
|
|
462
|
+
*
|
|
463
|
+
* @param {array<number>} element_ids
|
|
464
|
+
* @param {string} key
|
|
465
|
+
* @param {any} value в зависимости от типа
|
|
466
|
+
* @param {object|typeFunctionCallback} callback
|
|
467
|
+
*
|
|
468
|
+
* @returns {Promise<void>}
|
|
469
|
+
*/
|
|
470
|
+
async update_property_mass(element_ids, key, value, callback)
|
|
471
|
+
{
|
|
472
|
+
if (!this.api_key)
|
|
473
|
+
{
|
|
474
|
+
throw new Error('Error #471-2598 - element has no api_key');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
let payload = {
|
|
478
|
+
element_ids: element_ids,
|
|
479
|
+
key : key,
|
|
480
|
+
value : value,
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
if (typeof callback?.before === 'function')
|
|
484
|
+
{
|
|
485
|
+
callback?.before({ payload });
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* {Api} ApiService
|
|
490
|
+
*/
|
|
491
|
+
return ApiService[ this.api_key ].update_property_mass(payload).then((response) =>
|
|
492
|
+
{
|
|
493
|
+
if (typeof callback?.success === 'function')
|
|
494
|
+
{
|
|
495
|
+
callback?.success({ response, payload })
|
|
496
|
+
}
|
|
497
|
+
}).catch((error) =>
|
|
498
|
+
{
|
|
499
|
+
echo({ error });
|
|
500
|
+
if (typeof callback?.error === 'function')
|
|
501
|
+
{
|
|
502
|
+
callback?.error({ error, payload })
|
|
503
|
+
}
|
|
504
|
+
}).finally((response) =>
|
|
505
|
+
{
|
|
506
|
+
if (typeof callback?.final === 'function')
|
|
507
|
+
{
|
|
508
|
+
callback?.final({ response, payload })
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
*
|
|
516
|
+
* @version v.2.0 (12/06/2025)
|
|
517
|
+
*/
|
|
518
|
+
async delete(element = false, callback = {})
|
|
519
|
+
{
|
|
520
|
+
if (!this.api_key)
|
|
521
|
+
{
|
|
522
|
+
throw new Error('Error #404-2215 - element has no api_key');
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (!element)
|
|
526
|
+
{
|
|
527
|
+
element = this;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (!window.confirm("Submit delete"))
|
|
531
|
+
{
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
let payload = {};
|
|
536
|
+
|
|
537
|
+
payload[ this.get_primary_key() ] = element[ this.get_primary_key() ];
|
|
538
|
+
|
|
539
|
+
if (typeof callback?.before === 'function')
|
|
540
|
+
{
|
|
541
|
+
callback?.before({ payload });
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return ApiService[ this.api_key ].delete(payload).then((response) =>
|
|
545
|
+
{
|
|
546
|
+
if (typeof callback?.success === 'function')
|
|
547
|
+
{
|
|
548
|
+
callback?.success({ response, payload })
|
|
549
|
+
}
|
|
550
|
+
}).catch((error) =>
|
|
551
|
+
{
|
|
552
|
+
echo({ error });
|
|
553
|
+
if (typeof callback?.error === 'function')
|
|
554
|
+
{
|
|
555
|
+
callback?.error({ error, payload })
|
|
556
|
+
}
|
|
557
|
+
}).finally((response) =>
|
|
558
|
+
{
|
|
559
|
+
if (typeof callback?.final === 'function')
|
|
560
|
+
{
|
|
561
|
+
callback?.final({ response, payload })
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
*
|
|
569
|
+
* @version v.1.0 (07/03/2026)
|
|
570
|
+
*/
|
|
571
|
+
async delete_mass(element_ids, callback = {})
|
|
572
|
+
{
|
|
573
|
+
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
*
|
|
579
|
+
* @version v.1.0 (07/03/2026)
|
|
580
|
+
*/
|
|
581
|
+
async clone_element(element = false, callback = {})
|
|
582
|
+
{
|
|
583
|
+
if (!this.api_key)
|
|
584
|
+
{
|
|
585
|
+
throw new Error('Error #463-2215 - element has no api_key');
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (!element)
|
|
589
|
+
{
|
|
590
|
+
element = this;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
let payload = {};
|
|
594
|
+
|
|
595
|
+
payload[ this.get_primary_key() ] = element[ this.get_primary_key() ];
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* {Api} ApiService
|
|
600
|
+
*/
|
|
601
|
+
return ApiService[ this.api_key ].clone_element(payload).then((response) =>
|
|
602
|
+
{
|
|
603
|
+
if (typeof callback?.success === 'function')
|
|
604
|
+
{
|
|
605
|
+
callback?.success({ response, payload })
|
|
606
|
+
}
|
|
607
|
+
}).catch((error) =>
|
|
608
|
+
{
|
|
609
|
+
echo({ error });
|
|
610
|
+
if (typeof callback?.error === 'function')
|
|
611
|
+
{
|
|
612
|
+
callback?.error({ error, payload })
|
|
613
|
+
}
|
|
614
|
+
}).finally((response) =>
|
|
615
|
+
{
|
|
616
|
+
if (typeof callback?.final === 'function')
|
|
617
|
+
{
|
|
618
|
+
callback?.final({ response, payload })
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
*
|
|
626
|
+
* @version v.1.0 (07/03/2026)
|
|
627
|
+
*/
|
|
628
|
+
async clone_element_mass(element_ids, callback = {})
|
|
629
|
+
{
|
|
630
|
+
|
|
631
|
+
}
|
|
632
|
+
}
|