@solidev/data 0.0.1-dev.0 → 0.0.1-dev.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/esm2020/lib/data/data-query.mjs +7 -3
- package/esm2020/lib/data/fields/datetime.mjs +21 -6
- package/esm2020/lib/dispedit/sdelete/sdelete.component.mjs +6 -3
- package/esm2020/lib/messages/message-zone/message-zone.component.mjs +1 -1
- package/esm2020/lib/modellist/model-list-paginator/model-list-paginator/model-list-paginator.component.mjs +1 -1
- package/esm2020/lib/modellist/model-list.service.mjs +33 -13
- package/fesm2015/solidev-data.mjs +62 -20
- package/fesm2015/solidev-data.mjs.map +1 -1
- package/fesm2020/solidev-data.mjs +62 -20
- package/fesm2020/solidev-data.mjs.map +1 -1
- package/lib/data/data-query.d.ts +1 -0
- package/lib/data/fields/datetime.d.ts +1 -1
- package/lib/dispedit/sdelete/sdelete.component.d.ts +2 -1
- package/lib/modellist/model-list.service.d.ts +4 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, Component, I
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import * as i3$1 from '@angular/forms';
|
|
5
5
|
import { FormControl, Validators, FormGroup, UntypedFormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR, UntypedFormGroup } from '@angular/forms';
|
|
6
|
-
import { throwError, ReplaySubject, combineLatest, of, takeUntil, debounceTime, Subject, distinctUntilChanged, timer, firstValueFrom, Observable, BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { throwError, ReplaySubject, combineLatest, share, of, takeUntil, NEVER, debounceTime, Subject, distinctUntilChanged, timer, firstValueFrom, Observable, BehaviorSubject } from 'rxjs';
|
|
7
7
|
import { tap, switchMap, map, mergeMap, finalize, catchError, filter, take } from 'rxjs/operators';
|
|
8
8
|
import * as i2 from '@angular/platform-browser';
|
|
9
9
|
import { makeStateKey } from '@angular/platform-browser';
|
|
@@ -520,7 +520,10 @@ class Queryset {
|
|
|
520
520
|
}
|
|
521
521
|
/** Full results observable (results, loading, meta) */
|
|
522
522
|
get full() {
|
|
523
|
-
|
|
523
|
+
if (!this._full) {
|
|
524
|
+
this._full = combineLatest([this.results, this.loading, this.meta]);
|
|
525
|
+
}
|
|
526
|
+
return this._full.pipe(share());
|
|
524
527
|
}
|
|
525
528
|
/**
|
|
526
529
|
* Update current filter data. Null or undefined values are removed from filter data.
|
|
@@ -597,6 +600,7 @@ class Queryset {
|
|
|
597
600
|
return f;
|
|
598
601
|
}
|
|
599
602
|
get(refresh = true) {
|
|
603
|
+
console.log('queryset:get', this, refresh);
|
|
600
604
|
if (!refresh && !this._pristine) {
|
|
601
605
|
return this.results;
|
|
602
606
|
}
|
|
@@ -1298,16 +1302,36 @@ class ModelList {
|
|
|
1298
1302
|
this.name = name;
|
|
1299
1303
|
}
|
|
1300
1304
|
get results() {
|
|
1301
|
-
|
|
1305
|
+
if (!this._results) {
|
|
1306
|
+
this._results = this.queryset.results.pipe(
|
|
1307
|
+
// tap(() => console.log('RESULTS')),
|
|
1308
|
+
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1309
|
+
}
|
|
1310
|
+
return this._results;
|
|
1302
1311
|
}
|
|
1303
1312
|
get meta() {
|
|
1304
|
-
|
|
1313
|
+
if (!this._meta) {
|
|
1314
|
+
this._meta = this.queryset.meta.pipe(
|
|
1315
|
+
// tap(() => console.log('META')),
|
|
1316
|
+
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1317
|
+
}
|
|
1318
|
+
return this._meta;
|
|
1305
1319
|
}
|
|
1306
1320
|
get loading() {
|
|
1307
|
-
|
|
1321
|
+
if (!this._loading) {
|
|
1322
|
+
this._loading = this.queryset.loading.pipe(
|
|
1323
|
+
// tap(() => console.log('LOADING')),
|
|
1324
|
+
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1325
|
+
}
|
|
1326
|
+
return this._loading;
|
|
1308
1327
|
}
|
|
1309
1328
|
get full() {
|
|
1310
|
-
|
|
1329
|
+
if (!this._full) {
|
|
1330
|
+
this._full = this.queryset.full.pipe(
|
|
1331
|
+
// tap(() => console.log('FULL')),
|
|
1332
|
+
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1333
|
+
}
|
|
1334
|
+
return this._full;
|
|
1311
1335
|
}
|
|
1312
1336
|
start(params) {
|
|
1313
1337
|
let filter$;
|
|
@@ -1328,7 +1352,7 @@ class ModelList {
|
|
|
1328
1352
|
this.sorter.output,
|
|
1329
1353
|
this.fields.output,
|
|
1330
1354
|
])
|
|
1331
|
-
.pipe(
|
|
1355
|
+
.pipe(debounceTime(200), switchMap(([reload, filter, manualFilter, paginator, sorter, fields]) => {
|
|
1332
1356
|
this.queryset
|
|
1333
1357
|
.filter(filter)
|
|
1334
1358
|
.filter(manualFilter || {}, true)
|
|
@@ -1337,14 +1361,14 @@ class ModelList {
|
|
|
1337
1361
|
.sort(...sorter)
|
|
1338
1362
|
.setFields(fields);
|
|
1339
1363
|
return this.queryset.get(true);
|
|
1340
|
-
}))
|
|
1364
|
+
}), takeUntil(this.unsubscribe || NEVER))
|
|
1341
1365
|
.subscribe({
|
|
1342
1366
|
next: (results) => { },
|
|
1343
1367
|
error: (error) => {
|
|
1344
1368
|
console.error('Error while getting model list results : ', error);
|
|
1345
1369
|
},
|
|
1346
1370
|
complete: () => {
|
|
1347
|
-
console.log('modellist:completed', this.name);
|
|
1371
|
+
// console.log('modellist:completed', this.name);
|
|
1348
1372
|
this.started = false;
|
|
1349
1373
|
},
|
|
1350
1374
|
});
|
|
@@ -1354,11 +1378,11 @@ class ModelList {
|
|
|
1354
1378
|
}
|
|
1355
1379
|
class ModelListService {
|
|
1356
1380
|
constructor() {
|
|
1357
|
-
this._instances =
|
|
1381
|
+
this._instances = new Map();
|
|
1358
1382
|
}
|
|
1359
1383
|
get(name, collection, defaults) {
|
|
1360
1384
|
let ml;
|
|
1361
|
-
if (!name || !this._instances
|
|
1385
|
+
if (!name || !this._instances.has(name) || !defaults.keep) {
|
|
1362
1386
|
ml = new ModelList(name);
|
|
1363
1387
|
ml.queryset = collection.queryset();
|
|
1364
1388
|
ml.fields = new ModelListFields(collection, defaults.fields);
|
|
@@ -1366,11 +1390,11 @@ class ModelListService {
|
|
|
1366
1390
|
ml.paginator = new ModelListPaginator(defaults.paginator);
|
|
1367
1391
|
ml.filters = new ModelListFilters(defaults.filters);
|
|
1368
1392
|
if (defaults.keep) {
|
|
1369
|
-
this._instances
|
|
1393
|
+
this._instances.set(name, ml);
|
|
1370
1394
|
}
|
|
1371
1395
|
}
|
|
1372
1396
|
else {
|
|
1373
|
-
ml = this._instances
|
|
1397
|
+
ml = this._instances.get(name);
|
|
1374
1398
|
}
|
|
1375
1399
|
if (!ml.started) {
|
|
1376
1400
|
if (defaults.reload) {
|
|
@@ -3342,6 +3366,7 @@ class SafeDeleteComponent {
|
|
|
3342
3366
|
this._ofc = _ofc;
|
|
3343
3367
|
this.checks = {};
|
|
3344
3368
|
this.deleted = new EventEmitter();
|
|
3369
|
+
this.display = 'button';
|
|
3345
3370
|
}
|
|
3346
3371
|
checkDelete(model) {
|
|
3347
3372
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3361,10 +3386,10 @@ class SafeDeleteComponent {
|
|
|
3361
3386
|
}
|
|
3362
3387
|
}
|
|
3363
3388
|
SafeDeleteComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: SafeDeleteComponent, deps: [{ token: i2$1.NgbOffcanvas }], target: i0.ɵɵFactoryTarget.Component });
|
|
3364
|
-
SafeDeleteComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: SafeDeleteComponent, isStandalone: true, selector: "data-safe-delete", inputs: { model: "model", service: "service", checks: "checks" }, outputs: { deleted: "deleted" }, viewQueries: [{ propertyName: "_dialogRef", first: true, predicate: ["dialog"], descendants: true, static: true }], ngImport: i0, template: "\n<ng-template #dialog let-offcanvas>\n <div class=\"offcanvas-header\">\n <h2 class=\"offcanvas-title text-danger text-center\"><i class=\"bi bi-trash me-2\"></i>Supprimer r\u00E9ellement ??</h2>\n </div>\n <div class=\"offcanvas-body text-danger\" *ngIf=\"result\">\n <div class=\"text-center my-4 fs-1\"><i class=\"bi bi-exclamation-diamond my-5\"></i></div>\n <div class=\"fs-4\">\n <p>La suppression de cet \u00E9l\u00E9ment supprimera {{result.count}} \u00E9l\u00E9ments dans la base de donn\u00E9es..</p>\n </div>\n <table class=\"table table-sm table-striped table-danger\">\n <thead>\n <tr>\n <th>Type d'\u00E9l\u00E9ment</th>\n <th>Nombre</th>\n </tr>\n </thead>\n <tbody>\n <ng-container *ngFor=\"let rl of result.details\">\n <tr>\n <td>{{checks[rl[0]] ? checks[rl[0]] : rl[0]}}</td>\n <td>{{rl[1]}}</td>\n </tr>\n </ng-container>\n </tbody>\n </table>\n <button class=\"w-100 btn btn-lg btn-danger\" (click)=\"reallyDelete()\"><i class=\"bi bi-trash me-2\"></i>Je confirme la suppression</button>\n <button class=\"w-100 btn btn-outline-secondary my-3\" (click)=\"offcanvas.close()\"><i class=\"bi bi-door-open me-2\"></i>Je renonce \u00E0 la suppression</button>\n </div>\n</ng-template>\n<button class=\"btn btn-sm btn-outline-danger float-end\" (click)=\"checkDelete(model)\"><i class=\"bi bi-trash mx-2\"></i></button>", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: NgbOffcanvasModule }] });
|
|
3389
|
+
SafeDeleteComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: SafeDeleteComponent, isStandalone: true, selector: "data-safe-delete", inputs: { model: "model", service: "service", checks: "checks", display: "display" }, outputs: { deleted: "deleted" }, viewQueries: [{ propertyName: "_dialogRef", first: true, predicate: ["dialog"], descendants: true, static: true }], ngImport: i0, template: "\n<ng-template #dialog let-offcanvas>\n <div class=\"offcanvas-header\">\n <h2 class=\"offcanvas-title text-danger text-center\"><i class=\"bi bi-trash me-2\"></i>Supprimer r\u00E9ellement ??</h2>\n </div>\n <div class=\"offcanvas-body text-danger\" *ngIf=\"result\">\n <div class=\"text-center my-4 fs-1\"><i class=\"bi bi-exclamation-diamond my-5\"></i></div>\n <div class=\"fs-4\">\n <p>La suppression de cet \u00E9l\u00E9ment supprimera {{result.count}} \u00E9l\u00E9ments dans la base de donn\u00E9es..</p>\n </div>\n <table class=\"table table-sm table-striped table-danger\">\n <thead>\n <tr>\n <th>Type d'\u00E9l\u00E9ment</th>\n <th>Nombre</th>\n </tr>\n </thead>\n <tbody>\n <ng-container *ngFor=\"let rl of result.details\">\n <tr>\n <td>{{checks[rl[0]] ? checks[rl[0]] : rl[0]}}</td>\n <td>{{rl[1]}}</td>\n </tr>\n </ng-container>\n </tbody>\n </table>\n <button class=\"w-100 btn btn-lg btn-danger\" (click)=\"reallyDelete()\"><i class=\"bi bi-trash me-2\"></i>Je confirme la suppression</button>\n <button class=\"w-100 btn btn-outline-secondary my-3\" (click)=\"offcanvas.close()\"><i class=\"bi bi-door-open me-2\"></i>Je renonce \u00E0 la suppression</button>\n </div>\n</ng-template>\n<button class=\"btn btn-sm btn-outline-danger float-end\" (click)=\"checkDelete(model)\" *ngIf=\"display==='button'\"><i class=\"bi bi-trash mx-2\"></i></button><i class=\"bi bi-trash mx-2\" (click)=\"checkDelete(model)\" *ngIf=\"display==='icon'\" role=\"button\"></i>\n<div (click)=\"checkDelete(model)\" *ngIf=\"display==='custom'\" role=\"button\">\n <ng-content></ng-content>\n</div>", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: NgbOffcanvasModule }] });
|
|
3365
3390
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: SafeDeleteComponent, decorators: [{
|
|
3366
3391
|
type: Component,
|
|
3367
|
-
args: [{ selector: 'data-safe-delete', standalone: true, imports: [CommonModule, NgbOffcanvasModule], template: "\n<ng-template #dialog let-offcanvas>\n <div class=\"offcanvas-header\">\n <h2 class=\"offcanvas-title text-danger text-center\"><i class=\"bi bi-trash me-2\"></i>Supprimer r\u00E9ellement ??</h2>\n </div>\n <div class=\"offcanvas-body text-danger\" *ngIf=\"result\">\n <div class=\"text-center my-4 fs-1\"><i class=\"bi bi-exclamation-diamond my-5\"></i></div>\n <div class=\"fs-4\">\n <p>La suppression de cet \u00E9l\u00E9ment supprimera {{result.count}} \u00E9l\u00E9ments dans la base de donn\u00E9es..</p>\n </div>\n <table class=\"table table-sm table-striped table-danger\">\n <thead>\n <tr>\n <th>Type d'\u00E9l\u00E9ment</th>\n <th>Nombre</th>\n </tr>\n </thead>\n <tbody>\n <ng-container *ngFor=\"let rl of result.details\">\n <tr>\n <td>{{checks[rl[0]] ? checks[rl[0]] : rl[0]}}</td>\n <td>{{rl[1]}}</td>\n </tr>\n </ng-container>\n </tbody>\n </table>\n <button class=\"w-100 btn btn-lg btn-danger\" (click)=\"reallyDelete()\"><i class=\"bi bi-trash me-2\"></i>Je confirme la suppression</button>\n <button class=\"w-100 btn btn-outline-secondary my-3\" (click)=\"offcanvas.close()\"><i class=\"bi bi-door-open me-2\"></i>Je renonce \u00E0 la suppression</button>\n </div>\n</ng-template>\n<button class=\"btn btn-sm btn-outline-danger float-end\" (click)=\"checkDelete(model)\"><i class=\"bi bi-trash mx-2\"></i></button>" }]
|
|
3392
|
+
args: [{ selector: 'data-safe-delete', standalone: true, imports: [CommonModule, NgbOffcanvasModule], template: "\n<ng-template #dialog let-offcanvas>\n <div class=\"offcanvas-header\">\n <h2 class=\"offcanvas-title text-danger text-center\"><i class=\"bi bi-trash me-2\"></i>Supprimer r\u00E9ellement ??</h2>\n </div>\n <div class=\"offcanvas-body text-danger\" *ngIf=\"result\">\n <div class=\"text-center my-4 fs-1\"><i class=\"bi bi-exclamation-diamond my-5\"></i></div>\n <div class=\"fs-4\">\n <p>La suppression de cet \u00E9l\u00E9ment supprimera {{result.count}} \u00E9l\u00E9ments dans la base de donn\u00E9es..</p>\n </div>\n <table class=\"table table-sm table-striped table-danger\">\n <thead>\n <tr>\n <th>Type d'\u00E9l\u00E9ment</th>\n <th>Nombre</th>\n </tr>\n </thead>\n <tbody>\n <ng-container *ngFor=\"let rl of result.details\">\n <tr>\n <td>{{checks[rl[0]] ? checks[rl[0]] : rl[0]}}</td>\n <td>{{rl[1]}}</td>\n </tr>\n </ng-container>\n </tbody>\n </table>\n <button class=\"w-100 btn btn-lg btn-danger\" (click)=\"reallyDelete()\"><i class=\"bi bi-trash me-2\"></i>Je confirme la suppression</button>\n <button class=\"w-100 btn btn-outline-secondary my-3\" (click)=\"offcanvas.close()\"><i class=\"bi bi-door-open me-2\"></i>Je renonce \u00E0 la suppression</button>\n </div>\n</ng-template>\n<button class=\"btn btn-sm btn-outline-danger float-end\" (click)=\"checkDelete(model)\" *ngIf=\"display==='button'\"><i class=\"bi bi-trash mx-2\"></i></button><i class=\"bi bi-trash mx-2\" (click)=\"checkDelete(model)\" *ngIf=\"display==='icon'\" role=\"button\"></i>\n<div (click)=\"checkDelete(model)\" *ngIf=\"display==='custom'\" role=\"button\">\n <ng-content></ng-content>\n</div>" }]
|
|
3368
3393
|
}], ctorParameters: function () { return [{ type: i2$1.NgbOffcanvas }]; }, propDecorators: { model: [{
|
|
3369
3394
|
type: Input
|
|
3370
3395
|
}], service: [{
|
|
@@ -3373,6 +3398,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImpor
|
|
|
3373
3398
|
type: Input
|
|
3374
3399
|
}], deleted: [{
|
|
3375
3400
|
type: Output
|
|
3401
|
+
}], display: [{
|
|
3402
|
+
type: Input
|
|
3376
3403
|
}], _dialogRef: [{
|
|
3377
3404
|
type: ViewChild,
|
|
3378
3405
|
args: ['dialog', { static: true }]
|
|
@@ -3552,18 +3579,26 @@ class DateFieldManager extends BaseFieldManager {
|
|
|
3552
3579
|
return v;
|
|
3553
3580
|
}
|
|
3554
3581
|
fromJson(data) {
|
|
3555
|
-
if (data === null) {
|
|
3582
|
+
if (data === null || data === undefined) {
|
|
3556
3583
|
return null;
|
|
3557
3584
|
}
|
|
3558
|
-
|
|
3585
|
+
const date = new Date(data);
|
|
3586
|
+
if (date instanceof Date && !isNaN(date)) {
|
|
3587
|
+
return date;
|
|
3588
|
+
}
|
|
3589
|
+
return null;
|
|
3559
3590
|
}
|
|
3560
3591
|
toJson(data) {
|
|
3561
3592
|
if (data === null || data === undefined) {
|
|
3562
3593
|
return null;
|
|
3563
3594
|
}
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3595
|
+
if (typeof data === 'string') {
|
|
3596
|
+
const d = this.fromJson(data);
|
|
3597
|
+
if (d === null) {
|
|
3598
|
+
return null;
|
|
3599
|
+
}
|
|
3600
|
+
data = d;
|
|
3601
|
+
}
|
|
3567
3602
|
return `${data.getUTCFullYear()}-${data.getUTCMonth() + 1}-${data.getUTCDate()}`;
|
|
3568
3603
|
}
|
|
3569
3604
|
/**
|
|
@@ -3595,6 +3630,13 @@ class DatetimeFieldManager extends DateFieldManager {
|
|
|
3595
3630
|
if (data === null || data === undefined) {
|
|
3596
3631
|
return null;
|
|
3597
3632
|
}
|
|
3633
|
+
if (typeof data === 'string') {
|
|
3634
|
+
const d = this.fromJson(data);
|
|
3635
|
+
if (d === null) {
|
|
3636
|
+
return null;
|
|
3637
|
+
}
|
|
3638
|
+
data = d;
|
|
3639
|
+
}
|
|
3598
3640
|
try {
|
|
3599
3641
|
return data.toISOString();
|
|
3600
3642
|
}
|