flamerest 1.0.44 → 1.0.47
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/REST.d.ts +1 -1
- package/REST.js +29 -19
- package/package.json +1 -1
package/REST.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function get<T>(table: string, where?: object | string | null, expand?: o
|
|
|
29
29
|
* @param {object} params
|
|
30
30
|
* @returns
|
|
31
31
|
*/
|
|
32
|
-
export function all<T>(table: string, params?: { where?: object, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number }): Promise<Rows<T>>;
|
|
32
|
+
export function all<T>(table: string, params?: { where?: object, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number, tree?: number }): Promise<Rows<T>>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Стандартный ответ от Request с несколькими строками
|
package/REST.js
CHANGED
|
@@ -295,9 +295,10 @@ class FLAMEREST {
|
|
|
295
295
|
* @param RemoveDuplicates
|
|
296
296
|
* @param format
|
|
297
297
|
* @param titles Это чтобы мы могли контроллить какие названия полей мы будет загружать при экспорте, чтобы они были как в таблице
|
|
298
|
+
* @param tree дерево
|
|
298
299
|
* @return Promise<>
|
|
299
300
|
*/
|
|
300
|
-
get(table, where, expand, fields, sortfields, page, perPage, RemoveDuplicates, format, titles) {
|
|
301
|
+
get(table, where, expand, fields, sortfields, page, perPage, RemoveDuplicates, format, titles, tree) {
|
|
301
302
|
|
|
302
303
|
// Нормализуем имена таблиц
|
|
303
304
|
table = table.replace(/_/g, "");
|
|
@@ -313,6 +314,10 @@ class FLAMEREST {
|
|
|
313
314
|
if (where !== undefined && where !== null)
|
|
314
315
|
json.where = where;
|
|
315
316
|
|
|
317
|
+
// Генерим условия
|
|
318
|
+
if (tree !== undefined && tree !== null)
|
|
319
|
+
json.tree = tree;
|
|
320
|
+
|
|
316
321
|
if (fields !== undefined && fields !== null)
|
|
317
322
|
json.fields = fields;
|
|
318
323
|
|
|
@@ -484,31 +489,36 @@ class FLAMEREST {
|
|
|
484
489
|
for (let val in values) {
|
|
485
490
|
|
|
486
491
|
// Преобразуем
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
let value = values[val];
|
|
493
|
+
let isRef = false;
|
|
494
|
+
if (value instanceof Object
|
|
495
|
+
&& value.hasOwnProperty('_value')
|
|
489
496
|
&& (
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
497
|
+
value._value instanceof Event ||
|
|
498
|
+
value._value instanceof HTMLInputElement ||
|
|
499
|
+
value._value instanceof ClipboardEvent ||
|
|
500
|
+
value._value instanceof DataTransfer ||
|
|
501
|
+
value._value instanceof FileList
|
|
495
502
|
)
|
|
496
|
-
)
|
|
503
|
+
) {value = value.value; isRef = true}
|
|
497
504
|
|
|
498
|
-
if (
|
|
499
|
-
if (
|
|
500
|
-
if (
|
|
501
|
-
if (
|
|
502
|
-
if (
|
|
505
|
+
if (value instanceof Event && value.target instanceof HTMLInputElement && value.target.type === 'file') value = value.target.files;
|
|
506
|
+
if (value instanceof HTMLInputElement && value.type === 'file') value = value.files;
|
|
507
|
+
if (value instanceof ClipboardEvent) value = value.clipboardData.files;
|
|
508
|
+
if (value instanceof DataTransfer) value = value.files;
|
|
509
|
+
if (value instanceof FileList) {
|
|
503
510
|
let newValues = [];
|
|
504
|
-
|
|
505
|
-
for (let file in
|
|
511
|
+
value = Array.from(value);
|
|
512
|
+
for (let file in value) {
|
|
506
513
|
newValues.push({
|
|
507
|
-
'name':
|
|
508
|
-
'data': await this.readFileAsync(
|
|
514
|
+
'name': value[file].name,
|
|
515
|
+
'data': await this.readFileAsync(value[file])
|
|
509
516
|
});
|
|
510
517
|
}
|
|
511
|
-
|
|
518
|
+
if (isRef)
|
|
519
|
+
values[val].value = newValues;
|
|
520
|
+
else
|
|
521
|
+
values[val] = newValues;
|
|
512
522
|
}
|
|
513
523
|
}
|
|
514
524
|
|