@solidev/data 0.0.1-alpha.0 → 0.0.1-alpha.2
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 +23 -23
- package/esm2020/lib/dispedit/choice.pipe.mjs +40 -1
- package/esm2020/lib/dispedit/factor.pipe.mjs +33 -1
- package/esm2020/lib/dispedit/factorc.pipe.mjs +48 -1
- package/esm2020/lib/modellist/model-list.service.mjs +13 -11
- package/fesm2015/solidev-data.mjs +156 -32
- package/fesm2015/solidev-data.mjs.map +1 -1
- package/fesm2020/solidev-data.mjs +152 -32
- package/fesm2020/solidev-data.mjs.map +1 -1
- package/lib/data/data-query.d.ts +9 -9
- package/lib/dispedit/choice.pipe.d.ts +5 -0
- package/lib/dispedit/factor.pipe.d.ts +7 -0
- package/lib/dispedit/factorc.pipe.d.ts +8 -0
- package/lib/modellist/model-list.service.d.ts +4 -4
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, Component, I
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import * as i2$2 from '@angular/forms';
|
|
5
5
|
import { FormControl, Validators, FormGroup, UntypedFormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR, UntypedFormGroup } from '@angular/forms';
|
|
6
|
-
import { throwError, ReplaySubject,
|
|
7
|
-
import { tap, switchMap, map, filter, mergeMap, finalize, catchError, take } from 'rxjs/operators';
|
|
6
|
+
import { throwError, ReplaySubject, share, combineLatest, of, takeUntil, NEVER, Subject, debounceTime, distinctUntilChanged, isObservable, firstValueFrom, timer, Observable, BehaviorSubject } from 'rxjs';
|
|
7
|
+
import { tap, switchMap, map, throttleTime, filter, mergeMap, finalize, catchError, take } from 'rxjs/operators';
|
|
8
8
|
import * as i2 from '@angular/platform-browser';
|
|
9
9
|
import { makeStateKey } from '@angular/platform-browser';
|
|
10
10
|
import * as i1$1 from '@angular/common';
|
|
@@ -495,11 +495,25 @@ class Queryset {
|
|
|
495
495
|
this.pageSize = 500;
|
|
496
496
|
/** Current page number */
|
|
497
497
|
this.page = 1;
|
|
498
|
-
this._pristine = true;
|
|
499
498
|
this._loading = new ReplaySubject(1);
|
|
499
|
+
/** Loading status (true if currently fetching data) */
|
|
500
|
+
this.loading = this._loading.asObservable().pipe(share());
|
|
500
501
|
this._meta = new ReplaySubject(1);
|
|
502
|
+
/** Results meta part observable */
|
|
503
|
+
this.meta = this._meta.asObservable().pipe(share());
|
|
501
504
|
this._results = new ReplaySubject(1);
|
|
505
|
+
/** Results data part observable */
|
|
506
|
+
this.results = this._results.asObservable().pipe(share());
|
|
507
|
+
this._full = combineLatest([
|
|
508
|
+
this.results,
|
|
509
|
+
this.loading,
|
|
510
|
+
this.meta,
|
|
511
|
+
]);
|
|
512
|
+
/** Full results observable (results, loading, meta) */
|
|
513
|
+
this.full = this._full.pipe(share());
|
|
514
|
+
this._pristine = true;
|
|
502
515
|
/** Default options */
|
|
516
|
+
// console.log('@solidev/data: Creating collection', _coll);
|
|
503
517
|
this.options = { emitFields: true };
|
|
504
518
|
Object.assign(this.options, options);
|
|
505
519
|
}
|
|
@@ -507,25 +521,6 @@ class Queryset {
|
|
|
507
521
|
get pristine() {
|
|
508
522
|
return this._pristine;
|
|
509
523
|
}
|
|
510
|
-
/** Loading status (true if currently fetching data) */
|
|
511
|
-
get loading() {
|
|
512
|
-
return this._loading.asObservable();
|
|
513
|
-
}
|
|
514
|
-
/** Results meta part observable */
|
|
515
|
-
get meta() {
|
|
516
|
-
return this._meta.asObservable();
|
|
517
|
-
}
|
|
518
|
-
/** Results data part observable */
|
|
519
|
-
get results() {
|
|
520
|
-
return this._results.asObservable();
|
|
521
|
-
}
|
|
522
|
-
/** Full results observable (results, loading, meta) */
|
|
523
|
-
get full() {
|
|
524
|
-
if (!this._full) {
|
|
525
|
-
this._full = combineLatest([this.results, this.loading, this.meta]);
|
|
526
|
-
}
|
|
527
|
-
return this._full.pipe(share());
|
|
528
|
-
}
|
|
529
524
|
/**
|
|
530
525
|
* Update current filter data. Null or undefined values are removed from filter data.
|
|
531
526
|
* @param params filter data
|
|
@@ -601,10 +596,11 @@ class Queryset {
|
|
|
601
596
|
return f;
|
|
602
597
|
}
|
|
603
598
|
get(refresh = true) {
|
|
604
|
-
console.log('queryset:get', this, refresh);
|
|
605
599
|
if (!refresh && !this._pristine) {
|
|
600
|
+
// console.log('@solidev/data: Get not refreshing, return current result observable');
|
|
606
601
|
return this.results;
|
|
607
602
|
}
|
|
603
|
+
// console.log('@solidev/data: start get (query)');
|
|
608
604
|
this._loading.next(true);
|
|
609
605
|
return this._coll
|
|
610
606
|
.raw({
|
|
@@ -613,6 +609,7 @@ class Queryset {
|
|
|
613
609
|
})
|
|
614
610
|
.pipe(switchMap((result) => {
|
|
615
611
|
// Process results
|
|
612
|
+
// console.log('@solidev/data: have meta');
|
|
616
613
|
this._meta.next({ nav: result.nav, parameters: result.parameters });
|
|
617
614
|
const out = [];
|
|
618
615
|
for (const r of result.results) {
|
|
@@ -620,8 +617,11 @@ class Queryset {
|
|
|
620
617
|
out.push(m);
|
|
621
618
|
}
|
|
622
619
|
this._pristine = false;
|
|
620
|
+
// console.log('@solidev/data: have loading');
|
|
623
621
|
this._loading.next(false);
|
|
622
|
+
// console.log('@solidev/data: have result');
|
|
624
623
|
this._results.next(out);
|
|
624
|
+
// console.log('@solidev/data: done get');
|
|
625
625
|
return this.results;
|
|
626
626
|
}));
|
|
627
627
|
}
|
|
@@ -1303,7 +1303,7 @@ class ModelList {
|
|
|
1303
1303
|
get results() {
|
|
1304
1304
|
if (!this._results) {
|
|
1305
1305
|
this._results = this.queryset.results.pipe(
|
|
1306
|
-
// tap(() => console.log('
|
|
1306
|
+
// tap(() => console.log('@solidev/data: modellist result')),
|
|
1307
1307
|
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1308
1308
|
}
|
|
1309
1309
|
return this._results;
|
|
@@ -1311,7 +1311,7 @@ class ModelList {
|
|
|
1311
1311
|
get meta() {
|
|
1312
1312
|
if (!this._meta) {
|
|
1313
1313
|
this._meta = this.queryset.meta.pipe(
|
|
1314
|
-
// tap(() => console.log('
|
|
1314
|
+
// tap(() => console.log('@solidev/data: modellist meta')),
|
|
1315
1315
|
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1316
1316
|
}
|
|
1317
1317
|
return this._meta;
|
|
@@ -1319,7 +1319,7 @@ class ModelList {
|
|
|
1319
1319
|
get loading() {
|
|
1320
1320
|
if (!this._loading) {
|
|
1321
1321
|
this._loading = this.queryset.loading.pipe(
|
|
1322
|
-
// tap(() => console.log('
|
|
1322
|
+
// tap(() => console.log('@solidev/data: modellist loading')),
|
|
1323
1323
|
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1324
1324
|
}
|
|
1325
1325
|
return this._loading;
|
|
@@ -1327,7 +1327,7 @@ class ModelList {
|
|
|
1327
1327
|
get full() {
|
|
1328
1328
|
if (!this._full) {
|
|
1329
1329
|
this._full = this.queryset.full.pipe(
|
|
1330
|
-
// tap(() => console.log('
|
|
1330
|
+
// tap(() => console.log('@solidev/data: modellist full')),
|
|
1331
1331
|
share(), takeUntil(this.unsubscribe || NEVER));
|
|
1332
1332
|
}
|
|
1333
1333
|
return this._full;
|
|
@@ -1351,7 +1351,7 @@ class ModelList {
|
|
|
1351
1351
|
this.sorter.output,
|
|
1352
1352
|
this.fields.output,
|
|
1353
1353
|
])
|
|
1354
|
-
.pipe(
|
|
1354
|
+
.pipe(throttleTime(200), switchMap(([reload, filter, manualFilter, paginator, sorter, fields]) => {
|
|
1355
1355
|
this.queryset
|
|
1356
1356
|
.filter(filter)
|
|
1357
1357
|
.filter(manualFilter || {}, true)
|
|
@@ -1362,12 +1362,14 @@ class ModelList {
|
|
|
1362
1362
|
return this.queryset.get(true);
|
|
1363
1363
|
}), takeUntil(this.unsubscribe || NEVER))
|
|
1364
1364
|
.subscribe({
|
|
1365
|
-
next: (results) => {
|
|
1365
|
+
next: (results) => {
|
|
1366
|
+
// console.log('@solidev/data: modellist:get results');
|
|
1367
|
+
},
|
|
1366
1368
|
error: (error) => {
|
|
1367
|
-
console.error('
|
|
1369
|
+
console.error('@solidev/data: error while getting model list results : ', error);
|
|
1368
1370
|
},
|
|
1369
1371
|
complete: () => {
|
|
1370
|
-
// console.log('modellist:completed', this.name);
|
|
1372
|
+
// console.log('@solidev/data: modellist:completed', this.name);
|
|
1371
1373
|
this.started = false;
|
|
1372
1374
|
},
|
|
1373
1375
|
});
|
|
@@ -2542,6 +2544,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
|
|
|
2542
2544
|
standalone: true,
|
|
2543
2545
|
}]
|
|
2544
2546
|
}] });
|
|
2547
|
+
class PChoicePipe {
|
|
2548
|
+
transform(value, model, field, mode = 'desc') {
|
|
2549
|
+
if (!model) {
|
|
2550
|
+
return '-';
|
|
2551
|
+
}
|
|
2552
|
+
if (!value) {
|
|
2553
|
+
return '-';
|
|
2554
|
+
}
|
|
2555
|
+
const fvalue = model[field];
|
|
2556
|
+
if (mode === 'code') {
|
|
2557
|
+
return `${fvalue}`;
|
|
2558
|
+
}
|
|
2559
|
+
const manager = model.FM(field);
|
|
2560
|
+
const choices = manager.choices;
|
|
2561
|
+
if (!choices) {
|
|
2562
|
+
return `${fvalue}`;
|
|
2563
|
+
}
|
|
2564
|
+
for (const ch of choices) {
|
|
2565
|
+
if (ch.value === fvalue) {
|
|
2566
|
+
if (mode === 'desc') {
|
|
2567
|
+
return ch.desc;
|
|
2568
|
+
}
|
|
2569
|
+
else {
|
|
2570
|
+
return `[${fvalue}] ${ch.desc}`;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
return `[${fvalue}] ??`;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
PChoicePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PChoicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2578
|
+
PChoicePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: PChoicePipe, isStandalone: true, name: "pchoice" });
|
|
2579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PChoicePipe, decorators: [{
|
|
2580
|
+
type: Pipe,
|
|
2581
|
+
args: [{
|
|
2582
|
+
name: 'pchoice',
|
|
2583
|
+
standalone: true,
|
|
2584
|
+
}]
|
|
2585
|
+
}] });
|
|
2545
2586
|
|
|
2546
2587
|
function isValue(value) {
|
|
2547
2588
|
return !(value == null || value === '' || value !== value);
|
|
@@ -2587,6 +2628,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
|
|
|
2587
2628
|
type: Inject,
|
|
2588
2629
|
args: [LOCALE_ID]
|
|
2589
2630
|
}] }]; } });
|
|
2631
|
+
class PFactorPipe {
|
|
2632
|
+
constructor(_locale) {
|
|
2633
|
+
this._locale = _locale;
|
|
2634
|
+
}
|
|
2635
|
+
transform(value, model, field, digitsInfo, locale) {
|
|
2636
|
+
if (!model)
|
|
2637
|
+
return null;
|
|
2638
|
+
if (!value)
|
|
2639
|
+
return null;
|
|
2640
|
+
locale = locale || this._locale;
|
|
2641
|
+
const fvalue = model[field];
|
|
2642
|
+
if (!isValue(fvalue))
|
|
2643
|
+
return null;
|
|
2644
|
+
const manager = model.FM(field);
|
|
2645
|
+
let factor = manager.factor;
|
|
2646
|
+
factor = factor || 1;
|
|
2647
|
+
const num = strToNumber(fvalue);
|
|
2648
|
+
return formatNumber(num / factor, locale, digitsInfo);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
PFactorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PFactorPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2652
|
+
PFactorPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: PFactorPipe, isStandalone: true, name: "pfactor" });
|
|
2653
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PFactorPipe, decorators: [{
|
|
2654
|
+
type: Pipe,
|
|
2655
|
+
args: [{
|
|
2656
|
+
name: 'pfactor',
|
|
2657
|
+
standalone: true,
|
|
2658
|
+
}]
|
|
2659
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2660
|
+
type: Inject,
|
|
2661
|
+
args: [LOCALE_ID]
|
|
2662
|
+
}] }]; } });
|
|
2590
2663
|
|
|
2591
2664
|
class FactorcPipe {
|
|
2592
2665
|
constructor(_locale, _defaultCurrencyCode = 'EUR') {
|
|
@@ -2633,6 +2706,53 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
|
|
|
2633
2706
|
type: Inject,
|
|
2634
2707
|
args: [DEFAULT_CURRENCY_CODE]
|
|
2635
2708
|
}] }]; } });
|
|
2709
|
+
class PFactorcPipe {
|
|
2710
|
+
constructor(_locale, _defaultCurrencyCode = 'EUR') {
|
|
2711
|
+
this._locale = _locale;
|
|
2712
|
+
this._defaultCurrencyCode = _defaultCurrencyCode;
|
|
2713
|
+
}
|
|
2714
|
+
transform(value, model, field, currencyCode, display, digitsInfo, locale) {
|
|
2715
|
+
if (!model)
|
|
2716
|
+
return null;
|
|
2717
|
+
if (!value)
|
|
2718
|
+
return null;
|
|
2719
|
+
const fvalue = model[field];
|
|
2720
|
+
if (!isValue(fvalue))
|
|
2721
|
+
return null;
|
|
2722
|
+
locale = locale || this._locale;
|
|
2723
|
+
let currency = currencyCode || this._defaultCurrencyCode;
|
|
2724
|
+
if (!display) {
|
|
2725
|
+
display = 'symbol';
|
|
2726
|
+
}
|
|
2727
|
+
if (display !== 'code') {
|
|
2728
|
+
if (display === 'symbol' || display === 'symbol-narrow') {
|
|
2729
|
+
currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
|
|
2730
|
+
}
|
|
2731
|
+
else {
|
|
2732
|
+
currency = display;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
const manager = model.FM(field);
|
|
2736
|
+
const factor = manager.factor || 1;
|
|
2737
|
+
const num = strToNumber(fvalue);
|
|
2738
|
+
return formatCurrency(num / factor, locale, currency, currencyCode, digitsInfo);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
PFactorcPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PFactorcPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2742
|
+
PFactorcPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: PFactorcPipe, isStandalone: true, name: "pfactorc" });
|
|
2743
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: PFactorcPipe, decorators: [{
|
|
2744
|
+
type: Pipe,
|
|
2745
|
+
args: [{
|
|
2746
|
+
name: 'pfactorc',
|
|
2747
|
+
standalone: true,
|
|
2748
|
+
}]
|
|
2749
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2750
|
+
type: Inject,
|
|
2751
|
+
args: [LOCALE_ID]
|
|
2752
|
+
}] }, { type: undefined, decorators: [{
|
|
2753
|
+
type: Inject,
|
|
2754
|
+
args: [DEFAULT_CURRENCY_CODE]
|
|
2755
|
+
}] }]; } });
|
|
2636
2756
|
|
|
2637
2757
|
class FkselectComponent {
|
|
2638
2758
|
constructor() {
|
|
@@ -5354,5 +5474,5 @@ const slugify = (str) => {
|
|
|
5354
5474
|
* Generated bundle index. Do not edit.
|
|
5355
5475
|
*/
|
|
5356
5476
|
|
|
5357
|
-
export { AuthInterceptor, AuthServiceBase, BanAdapter, BootstrapDataDisplayConfig, BreadcrumbComponent, ChoicePipe, Collection, CollectionMock, DATA_API_URL, DATA_AUTH_PARAMS, DATA_AUTH_SERVICE, DATA_AUTH_USER_SERVICE, DATA_DISPLAY_CONFIG, DATA_MAX_TRANSFERSTATE_TIME, DATA_MESSAGE_SOUNDS, DEFAULT_TIMEOUTS, DataBackend, DataMessageService, DataModel, DataUploaderService, DispeditComponent, FactorPipe, FactorcPipe, FkselectComponent, FlagsComponent, Jwt, Link, M2mselectComponent, Message, MessageZoneComponent, ModelList, ModelListAutocompleteFilter, ModelListAutocompleteMultiFilter, ModelListDateFilter, ModelListDatetimeFilter, ModelListDatetimerangeFilter, ModelListFieldHeaderComponent, ModelListFieldsSelectorComponent, ModelListFilters, ModelListFiltersComponent, ModelListFiltersSelectComponent, ModelListFlagsFilter, ModelListGeodistanceFilter, ModelListNumberFilter, ModelListNumberOperations, ModelListPaginatorComponent, ModelListSelectFilter, ModelListSelectMultiFilter, ModelListService, ModelListSorterComponent, ModelListTextFilter, ModelListTreeFilter, NavDriver, NgFileDropDirective, NgFileSelectDirective, NgxUploaderModule, Queryset, RData, RicheditComponent, STATUS, SafeDeleteComponent, TabMemoryService, UploadStatus, booleanField, charField, dateField, datetimeField, decimalField, detailsField, emailField, floatField, foreignKeyField, humanizeBytes, integerField, isValue, manyToManyField, passwordField, primaryField, reverseForeignKeyField, slugify, strToNumber, textField };
|
|
5477
|
+
export { AuthInterceptor, AuthServiceBase, BanAdapter, BootstrapDataDisplayConfig, BreadcrumbComponent, ChoicePipe, Collection, CollectionMock, DATA_API_URL, DATA_AUTH_PARAMS, DATA_AUTH_SERVICE, DATA_AUTH_USER_SERVICE, DATA_DISPLAY_CONFIG, DATA_MAX_TRANSFERSTATE_TIME, DATA_MESSAGE_SOUNDS, DEFAULT_TIMEOUTS, DataBackend, DataMessageService, DataModel, DataUploaderService, DispeditComponent, FactorPipe, FactorcPipe, FkselectComponent, FlagsComponent, Jwt, Link, M2mselectComponent, Message, MessageZoneComponent, ModelList, ModelListAutocompleteFilter, ModelListAutocompleteMultiFilter, ModelListDateFilter, ModelListDatetimeFilter, ModelListDatetimerangeFilter, ModelListFieldHeaderComponent, ModelListFieldsSelectorComponent, ModelListFilters, ModelListFiltersComponent, ModelListFiltersSelectComponent, ModelListFlagsFilter, ModelListGeodistanceFilter, ModelListNumberFilter, ModelListNumberOperations, ModelListPaginatorComponent, ModelListSelectFilter, ModelListSelectMultiFilter, ModelListService, ModelListSorterComponent, ModelListTextFilter, ModelListTreeFilter, NavDriver, NgFileDropDirective, NgFileSelectDirective, NgxUploaderModule, PChoicePipe, PFactorPipe, PFactorcPipe, Queryset, RData, RicheditComponent, STATUS, SafeDeleteComponent, TabMemoryService, UploadStatus, booleanField, charField, dateField, datetimeField, decimalField, detailsField, emailField, floatField, foreignKeyField, humanizeBytes, integerField, isValue, manyToManyField, passwordField, primaryField, reverseForeignKeyField, slugify, strToNumber, textField };
|
|
5358
5478
|
//# sourceMappingURL=solidev-data.mjs.map
|