flameresttable 1.0.103 → 1.0.105
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 +20 -20
- package/src/App.vue +1 -1
- package/src/Table/FlameTable.ts +58 -9
- package/src/Table/TableRowParams.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flameresttable",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.105",
|
|
4
4
|
"main": "./src/plugin.ts",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,37 +12,37 @@
|
|
|
12
12
|
"dev": "vite"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@vuepic/vue-datepicker": "^7.
|
|
16
|
-
"flamerest": "^1.0.
|
|
15
|
+
"@vuepic/vue-datepicker": "^7.4.1",
|
|
16
|
+
"flamerest": "^1.0.109",
|
|
17
17
|
"lodash-es": "^4.17.21",
|
|
18
|
-
"pinia": "^2.
|
|
18
|
+
"pinia": "^2.2.6",
|
|
19
19
|
"pug": "github:FlameArt/pug-tailwind-only",
|
|
20
20
|
"pug-lexer": "github:FlameArt/pug-lexer-only",
|
|
21
|
-
"sass": "^1.
|
|
21
|
+
"sass": "^1.81.0",
|
|
22
22
|
"vue": "^3.3.7",
|
|
23
|
-
"vue-router": "^4.
|
|
23
|
+
"vue-router": "^4.4.5",
|
|
24
24
|
"vue-select": "^4.0.0-beta.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@heroicons/vue": "^2.
|
|
28
|
-
"@types/lodash-es": "^4.17.
|
|
29
|
-
"@types/lodash.merge": "^4.6.
|
|
27
|
+
"@heroicons/vue": "^2.1.5",
|
|
28
|
+
"@types/lodash-es": "^4.17.12",
|
|
29
|
+
"@types/lodash.merge": "^4.6.9",
|
|
30
30
|
"@types/node": "20.8.9",
|
|
31
|
-
"@types/vue-select": "^3.16.
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
33
|
-
"@typescript-eslint/parser": "^6.
|
|
34
|
-
"@vitejs/plugin-vue": "^4.
|
|
31
|
+
"@types/vue-select": "^3.16.8",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
33
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
34
|
+
"@vitejs/plugin-vue": "^4.6.2",
|
|
35
35
|
"@volar/vue-language-plugin-pug": "^1.6.5",
|
|
36
36
|
"@vue/compiler-sfc": "^3.3.7",
|
|
37
|
-
"autoprefixer": "^10.4.
|
|
38
|
-
"eslint": "^8.
|
|
37
|
+
"autoprefixer": "^10.4.20",
|
|
38
|
+
"eslint": "^8.57.1",
|
|
39
39
|
"eslint-plugin-vue": "^8.7.1",
|
|
40
|
-
"postcss": "^8.4.
|
|
40
|
+
"postcss": "^8.4.49",
|
|
41
41
|
"postcss-import": "^14.1.0",
|
|
42
|
-
"tailwindcss": "^3.
|
|
43
|
-
"typescript": "^5.
|
|
44
|
-
"vite": "^4.5.
|
|
45
|
-
"vue-tsc": "^1.8.
|
|
42
|
+
"tailwindcss": "^3.4.15",
|
|
43
|
+
"typescript": "^5.6.3",
|
|
44
|
+
"vite": "^4.5.5",
|
|
45
|
+
"vue-tsc": "^1.8.27",
|
|
46
46
|
"vue-universal-modal": "^1.1.4"
|
|
47
47
|
},
|
|
48
48
|
"rules": {}
|
package/src/App.vue
CHANGED
|
@@ -27,7 +27,7 @@ opts.set('name', { title: 'Название' });
|
|
|
27
27
|
opts.set('dt1', { title: 'Дата 1' });
|
|
28
28
|
opts.set('dt2', { title: 'Дата 2' });
|
|
29
29
|
opts.set('id', { title: 'ID', Selector: { model: Relatedtable }, Filter: { isShow: true, type: 'selector', selector: { multiselect: true, mode: 'vertical' } } });
|
|
30
|
-
opts.set('file', { title: 'файл', Filter: { isShow: false } });
|
|
30
|
+
opts.set('file', { title: 'файл', Popup: {popupType: 'image'}, Filter: { isShow: false } });
|
|
31
31
|
opts.set("name", {
|
|
32
32
|
title: 'Название', Table:
|
|
33
33
|
{
|
package/src/Table/FlameTable.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { reactive, UnwrapRef } from 'vue';
|
|
|
5
5
|
import merge from 'lodash-es/merge'
|
|
6
6
|
import ITableLoadParams from './TableLoadParams';
|
|
7
7
|
import TableRowParams from './TableRowParams';
|
|
8
|
+
import cloneDeep from 'lodash-es/cloneDeep';
|
|
8
9
|
|
|
9
10
|
// Подгрузчик типа класса
|
|
10
11
|
type Class<T> = new (...args: any[]) => T
|
|
@@ -162,6 +163,7 @@ export default class FlameTable<T> {
|
|
|
162
163
|
if (typeof this.RowsParams[row[pk]] === 'undefined') {
|
|
163
164
|
const newParam = new TableRowParams;
|
|
164
165
|
newParam.item = row;
|
|
166
|
+
newParam.previousAttributes = cloneDeep(row);
|
|
165
167
|
this.RowsParams[row[pk]] = newParam;
|
|
166
168
|
}
|
|
167
169
|
})
|
|
@@ -423,8 +425,15 @@ export default class FlameTable<T> {
|
|
|
423
425
|
// Сперва предобработка
|
|
424
426
|
if (await this.opts.Popup.beforeEdit(columns, this) === false) { return null; }
|
|
425
427
|
|
|
428
|
+
// Убираем поля, которые не требуют изменения
|
|
429
|
+
const cleanedCols = this.RemoveUnchagedFields(columns);
|
|
430
|
+
|
|
431
|
+
// Если изменений нет, то не посылаем
|
|
432
|
+
if (Object.keys(cleanedCols).length === 0) return null;
|
|
433
|
+
|
|
426
434
|
// Подготовка к загрузке
|
|
427
|
-
const preparedCols = await (window as any).REST.prepare(
|
|
435
|
+
const preparedCols = await (window as any).REST.prepare(cleanedCols, true);
|
|
436
|
+
|
|
428
437
|
|
|
429
438
|
// Сохраняем
|
|
430
439
|
const res: SavedObject<T> = await tClass.edit(columns[indexKey], preparedCols);
|
|
@@ -435,14 +444,51 @@ export default class FlameTable<T> {
|
|
|
435
444
|
|
|
436
445
|
if (res.data) {
|
|
437
446
|
const findedIdx = this.Rows.rows.findIndex((row: any) => row[indexKey] === (res.data as any)[indexKey])
|
|
438
|
-
if (findedIdx !== -1)
|
|
447
|
+
if (findedIdx !== -1) {
|
|
439
448
|
this.Rows.rows[findedIdx] = reactive(res.data as any);
|
|
449
|
+
this.RowsParams[columns[indexKey]].previousAttributes = res.data;
|
|
450
|
+
}
|
|
440
451
|
}
|
|
441
452
|
|
|
442
453
|
return res;
|
|
443
454
|
|
|
444
455
|
}
|
|
445
456
|
|
|
457
|
+
private RemoveUnchagedFields(row: { [key: string]: any }) {
|
|
458
|
+
|
|
459
|
+
// primarykey
|
|
460
|
+
const pk = (this.model as any).constructor.primaryKeys[0];
|
|
461
|
+
const isPlainObject = (obj: any) => typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
|
|
462
|
+
|
|
463
|
+
// Теперь не отправляем на обнову значения, что не обновились
|
|
464
|
+
const cleanRow: { [key: string]: any } = {};
|
|
465
|
+
for (const key in this.columns) {
|
|
466
|
+
|
|
467
|
+
const cParam = this.RowsParams[row[pk]];
|
|
468
|
+
switch (this.columns[key].Popup.popupType) {
|
|
469
|
+
|
|
470
|
+
case 'file':
|
|
471
|
+
case 'image':
|
|
472
|
+
// Неизменный объект будет как простой объект, а не событие, File итд
|
|
473
|
+
if (row[key] === null || typeof row[key]?.[0]?.['id'] === 'string' && typeof row[key]?.[0]?.['file'] === 'string' || isPlainObject(row[key])) continue;
|
|
474
|
+
break;
|
|
475
|
+
case 'text':
|
|
476
|
+
case 'string':
|
|
477
|
+
case 'date':
|
|
478
|
+
case 'selector':
|
|
479
|
+
if (cParam.previousAttributes[key] === row[key]) continue;
|
|
480
|
+
break;
|
|
481
|
+
default:
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
cleanRow[key] = row[key];
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return cleanRow;
|
|
488
|
+
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
|
|
446
492
|
|
|
447
493
|
public async remove(row: T): Promise<SavedObject<T>> {
|
|
448
494
|
|
|
@@ -462,15 +508,18 @@ export default class FlameTable<T> {
|
|
|
462
508
|
private getColumnsForUpdate(mode: "add" | "edit") {
|
|
463
509
|
const res: { [key: string]: string } = {};
|
|
464
510
|
for (const key in this.columns) {
|
|
511
|
+
|
|
465
512
|
if (mode === 'add' && !this.columns[key].Popup.isSendFromAdd) continue;
|
|
466
513
|
if (mode === 'edit' && !this.columns[key].Popup.isSendFromEdit) continue;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
514
|
+
|
|
515
|
+
// пропускаем виртуальные поля
|
|
516
|
+
if (this.columns[key].isVirtual) continue;
|
|
517
|
+
|
|
518
|
+
if (this.columns[key].Popup.fileModel !== null)
|
|
519
|
+
res[key] = this.columns[key].Popup.fileModel
|
|
520
|
+
else
|
|
521
|
+
res[key] = this.columns[key].Popup.model
|
|
522
|
+
|
|
474
523
|
}
|
|
475
524
|
return res;
|
|
476
525
|
}
|