@ecodev/natural 70.0.0 → 70.1.0

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.
@@ -6754,6 +6754,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
6754
6754
  ], template: "<form [formGroup]=\"form\">\n @if (configuration.operators) {\n <mat-form-field style=\"max-width: 7em; margin-right: 1em\" subscriptSizing=\"dynamic\">\n <mat-label i18n=\"Mathematical operator < > =\">Op\u00E9rateur</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"operatorCtrl\" [required]=\"true\">\n @for (item of operators; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n\n @if (requireValueCtrl) {\n <mat-selection-list [formControl]=\"valueCtrl\" [multiple]=\"configuration.multiple\">\n @for (item of items; track item) {\n <mat-list-option togglePosition=\"before\" [value]=\"getId(item)\">\n {{ getDisplay(item) }}\n </mat-list-option>\n }\n </mat-selection-list>\n }\n</form>\n" }]
6755
6755
  }], ctorParameters: () => [] });
6756
6756
 
6757
+ // If you use this to set it to false, then you **MUST** call the init method in your constructor
6758
+ const DO_INIT = new InjectionToken('Must be true', {
6759
+ factory: () => true,
6760
+ });
6757
6761
  class AbstractAssociationSelectComponent {
6758
6762
  configuration;
6759
6763
  renderedValue = new BehaviorSubject('');
@@ -6766,7 +6770,12 @@ class AbstractAssociationSelectComponent {
6766
6770
  value: this.valueCtrl,
6767
6771
  });
6768
6772
  constructor() {
6769
- const data = inject(NATURAL_DROPDOWN_DATA);
6773
+ if (inject(DO_INIT)) {
6774
+ const data = inject(NATURAL_DROPDOWN_DATA);
6775
+ this.init(data);
6776
+ }
6777
+ }
6778
+ init(data) {
6770
6779
  this.configuration = data.configuration;
6771
6780
  // Immediately initValidators and everytime the operator change later
6772
6781
  this.operatorCtrl.valueChanges.pipe(startWith$1(null)).subscribe(() => this.initValidators());
@@ -6823,16 +6832,16 @@ class AbstractAssociationSelectComponent {
6823
6832
  }
6824
6833
  return 'is';
6825
6834
  }
6826
- operatorKeyToCondition(key, values) {
6835
+ operatorKeyToCondition(key, values, extra = {}) {
6827
6836
  switch (key) {
6828
6837
  case 'is':
6829
- return { have: { values: values } };
6838
+ return { have: { values: values, ...extra } };
6830
6839
  case 'isnot':
6831
- return { have: { values: values, not: true } };
6840
+ return { have: { values: values, not: true, ...extra } };
6832
6841
  case 'any':
6833
- return { empty: { not: true } };
6842
+ return { empty: { not: true, ...extra } };
6834
6843
  case 'none':
6835
- return { empty: { not: false } };
6844
+ return { empty: { not: false, ...extra } };
6836
6845
  default:
6837
6846
  throw new Error('Unsupported operator key: ' + key);
6838
6847
  }
@@ -8521,6 +8530,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
8521
8530
  ], template: "<form [formGroup]=\"form\">\n <mat-form-field style=\"max-width: 7em; margin-right: 1em\" subscriptSizing=\"dynamic\">\n <mat-label i18n=\"Mathematical operator < > =\">Op\u00E9rateur</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"operatorCtrl\" [required]=\"true\">\n @for (item of operators; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n @if (requireValueCtrl) {\n <natural-hierarchic-selector\n style=\"margin-right: 20px\"\n [config]=\"configuration.config\"\n [filters]=\"configuration.filters\"\n [multiple]=\"true\"\n [selected]=\"valueCtrl.value || {}\"\n (selectionChange)=\"selectionChange($event)\"\n />\n }\n</form>\n" }]
8522
8531
  }] });
8523
8532
 
8533
+ const possibleWhere = [
8534
+ {
8535
+ key: 'DebitOrCredit',
8536
+ label: $localize `Débit ou crédit`,
8537
+ render: ``,
8538
+ },
8539
+ {
8540
+ key: 'Debit',
8541
+ label: $localize `Débit`,
8542
+ render: $localize `au débit`,
8543
+ },
8544
+ {
8545
+ key: 'Credit',
8546
+ label: $localize `Crédit`,
8547
+ render: $localize `au crédit`,
8548
+ },
8549
+ ];
8550
+ /**
8551
+ * This is a specialized facet for Account model with extra fields specific to the specialized operator on the server side.
8552
+ */
8553
+ class TypeAccountSelectorComponent extends TypeHierarchicSelectorComponent {
8554
+ whereCtrl = new FormControl('DebitOrCredit', {
8555
+ nonNullable: true,
8556
+ validators: Validators.required,
8557
+ });
8558
+ recursiveCtrl = new FormControl(false, {
8559
+ nonNullable: true,
8560
+ validators: Validators.required,
8561
+ });
8562
+ possibleWhere = possibleWhere;
8563
+ constructor() {
8564
+ super();
8565
+ // We can reload extra condition only after calling ou parent constructor
8566
+ const data = inject(NATURAL_DROPDOWN_DATA);
8567
+ this.init(data);
8568
+ this.form.addControl('where', this.whereCtrl);
8569
+ this.form.addControl('recursive', this.recursiveCtrl);
8570
+ this.operatorCtrl.valueChanges
8571
+ .pipe(takeUntilDestroyed(), startWith$1(this.operatorCtrl.value))
8572
+ .subscribe(operator => {
8573
+ if (['is', 'isnot'].includes(operator)) {
8574
+ this.recursiveCtrl.enable();
8575
+ }
8576
+ else {
8577
+ this.recursiveCtrl.setValue(false);
8578
+ this.recursiveCtrl.disable();
8579
+ }
8580
+ });
8581
+ }
8582
+ operatorKeyToCondition(key, values) {
8583
+ return super.operatorKeyToCondition(key, values, {
8584
+ where: this.whereCtrl.value,
8585
+ recursive: this.recursiveCtrl.getRawValue(),
8586
+ });
8587
+ }
8588
+ reloadCondition(condition) {
8589
+ if (condition) {
8590
+ const q = (condition.have ? condition.have : condition.empty);
8591
+ this.recursiveCtrl.setValue(q?.recursive ?? false);
8592
+ this.whereCtrl.setValue(q?.where ?? 'DebitOrCredit');
8593
+ }
8594
+ super.reloadCondition(condition);
8595
+ }
8596
+ getRenderedValue() {
8597
+ const operator = this.operators.find(v => v.key === this.operatorCtrl.value);
8598
+ const where = this.possibleWhere.find(v => v.key === this.whereCtrl.value);
8599
+ if (!operator || !where || !this.isValid()) {
8600
+ return '';
8601
+ }
8602
+ const selection = this.renderValueWithoutOperator();
8603
+ const recursive = this.recursiveCtrl.value ? $localize `(inclut sous-comptes)` : '';
8604
+ const parts = ['is', 'isnot'].includes(operator.key)
8605
+ ? [where.render, operator.label, selection, recursive]
8606
+ : [operator.label, where.render];
8607
+ return parts.filter(v => v).join(' ');
8608
+ }
8609
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: TypeAccountSelectorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
8610
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: TypeAccountSelectorComponent, isStandalone: true, selector: "ng-component", providers: [
8611
+ {
8612
+ provide: DO_INIT,
8613
+ useValue: false,
8614
+ },
8615
+ ], usesInheritance: true, ngImport: i0, template: "<form [formGroup]=\"form\">\n <mat-form-field style=\"max-width: 12em; margin-right: 1em\">\n <mat-label i18n>Compte</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"whereCtrl\">\n @for (item of possibleWhere; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field style=\"max-width: 7em; margin-right: 1em\">\n <mat-label i18n=\"Mathematical operator < > =\">Op\u00E9rateur</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"operatorCtrl\" [required]=\"true\">\n @for (item of operators; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-checkbox i18n [formControl]=\"recursiveCtrl\">inclure les sous-comptes</mat-checkbox>\n\n @if (requireValueCtrl) {\n <natural-hierarchic-selector\n style=\"margin-right: 20px\"\n [config]=\"configuration.config\"\n [filters]=\"configuration.filters\"\n [multiple]=\"true\"\n [selected]=\"valueCtrl.value || {}\"\n (selectionChange)=\"selectionChange($event)\"\n />\n }\n</form>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: NaturalHierarchicSelectorComponent, selector: "natural-hierarchic-selector", inputs: ["displayWith", "config", "multiple", "selected", "filters", "searchFacets", "searchSelections", "allowSelectAll"], outputs: ["searchSelectionChange", "selectionChange"] }, { kind: "component", type: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }] });
8616
+ }
8617
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: TypeAccountSelectorComponent, decorators: [{
8618
+ type: Component,
8619
+ args: [{ imports: [
8620
+ FormsModule,
8621
+ ReactiveFormsModule,
8622
+ MatFormField,
8623
+ MatLabel,
8624
+ MatSelect,
8625
+ MatOption,
8626
+ NaturalHierarchicSelectorComponent,
8627
+ MatCheckbox,
8628
+ ], providers: [
8629
+ {
8630
+ provide: DO_INIT,
8631
+ useValue: false,
8632
+ },
8633
+ ], template: "<form [formGroup]=\"form\">\n <mat-form-field style=\"max-width: 12em; margin-right: 1em\">\n <mat-label i18n>Compte</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"whereCtrl\">\n @for (item of possibleWhere; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field style=\"max-width: 7em; margin-right: 1em\">\n <mat-label i18n=\"Mathematical operator < > =\">Op\u00E9rateur</mat-label>\n <mat-select panelWidth=\"\" [formControl]=\"operatorCtrl\" [required]=\"true\">\n @for (item of operators; track item) {\n <mat-option [value]=\"item.key\">\n {{ item.label }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-checkbox i18n [formControl]=\"recursiveCtrl\">inclure les sous-comptes</mat-checkbox>\n\n @if (requireValueCtrl) {\n <natural-hierarchic-selector\n style=\"margin-right: 20px\"\n [config]=\"configuration.config\"\n [filters]=\"configuration.filters\"\n [multiple]=\"true\"\n [selected]=\"valueCtrl.value || {}\"\n (selectionChange)=\"selectionChange($event)\"\n />\n }\n</form>\n" }]
8634
+ }], ctorParameters: () => [] });
8635
+
8524
8636
  class InvalidWithValueStateMatcher {
8525
8637
  isErrorState(control, form) {
8526
8638
  return (form && form.invalid && (form.value.to || form.value.from)) || control?.invalid;
@@ -11579,5 +11691,5 @@ function graphqlQuerySigner(key) {
11579
11691
  * Generated bundle index. Do not edit.
11580
11692
  */
11581
11693
 
11582
- export { AvatarService, ColorScheme, InvalidWithValueStateMatcher$1 as InvalidWithValueStateMatcher, LOCAL_STORAGE, NATURAL_DROPDOWN_DATA, NATURAL_ICONS_CONFIG, NATURAL_PERSISTENCE_VALIDATOR, NATURAL_SEO_CONFIG, NaturalAbstractDetail, NaturalAbstractEditableList, NaturalAbstractList, NaturalAbstractModelService, NaturalAbstractNavigableList, NaturalAbstractPanel, NaturalAlertService, NaturalAvatarComponent, NaturalBackgroundDensityDirective, NaturalCapitalizePipe, NaturalColorSchemerComponent, NaturalColumnsPickerComponent, NaturalCompactColorSchemerComponent, NaturalConfirmComponent, NaturalDataSource, NaturalDebounceService, NaturalDetailHeaderComponent, NaturalDialogTriggerComponent, NaturalDropdownRef, NaturalEllipsisPipe, NaturalEnumPipe, NaturalEnumService, NaturalErrorHandler, NaturalErrorMessagePipe, NaturalFileComponent, NaturalFileDropDirective, NaturalFileSelectDirective, NaturalFileService, NaturalFixedButtonComponent, NaturalFixedButtonDetailComponent, NaturalHierarchicSelectorComponent, NaturalHierarchicSelectorDialogComponent, NaturalHierarchicSelectorDialogService, NaturalHierarchicSelectorService, NaturalHttpPrefixDirective, NaturalIconDirective, NaturalLinkMutationService, NaturalLinkableTabDirective, NaturalLoggerConfigExtra, NaturalLoggerConfigUrl, NaturalMatomoService, NaturalMemoryStorage, NaturalPanelsComponent, NaturalPanelsService, NaturalPersistenceService, NaturalQueryVariablesManager, NaturalRelationsComponent, NaturalSearchComponent, NaturalSelectComponent, NaturalSelectEnumComponent, NaturalSelectHierarchicComponent, NaturalSeoService, NaturalSidenavComponent, NaturalSidenavContainerComponent, NaturalSidenavContentComponent, NaturalSidenavService, NaturalSidenavStackService, NaturalSrcDensityDirective, NaturalStampComponent, NaturalSwissParsingDateAdapter, NaturalTableButtonComponent, NaturalThemeChangerComponent, NaturalThemeService, NaturalTimeAgoPipe, NetworkActivityService, PanelsHooksConfig, SESSION_STORAGE, SortingOrder, TypeBooleanComponent, TypeDateComponent, TypeDateRangeComponent, TypeHierarchicSelectorComponent, TypeNaturalSelectComponent, TypeNumberComponent, TypeOptionsComponent, TypeSelectComponent, TypeTextComponent, TypedMatCellDef, activityInterceptor, available, cancellableTimeout, cloneDeepButSkipFile, collectErrors, commonImageMimeTypes, copyToClipboard, createHttpLink, debug, decimal, deepFreeze, deliverableEmail, ensureHttpPrefix, fallbackIfNoOpenedPanels, formatIsoDate, formatIsoDateTime, fromUrl, getForegroundColor, getNumberRows, getVisibleSelections, graphqlQuerySigner, greaterThan, hasFilesAndProcessDate, ifValid, integer, isAllVisibleSelected, isFile, isPartiallyVisibleSelected, localStorageFactory, localStorageProvider, makePlural, masterToggleVisible, memoryLocalStorageProvider, memorySessionStorageProvider, mergeOverrideArray, money, naturalPanelsUrlMatcher, naturalProviders, nfcCardHex, onHistoryEvent, possibleComparableOperators, possibleNullComparableOperators, provideErrorHandler, provideIcons, providePanels, provideSeo, provideThemes, relationsToIds, replaceObjectKeepingReference, replaceOperatorByField, replaceOperatorByName, rgbToHex, selectVisible, sessionStorageFactory, sessionStorageProvider, time, toGraphQLDoctrineFilter, toNavigationParameters, toUrl, unique, unselectVisible, upperCaseFirstLetter, url, urlPattern, validTlds, validateAllFormControls, validateColumns, validatePagination, validateSorting, wrapLike, wrapPrefix, wrapSuffix };
11694
+ export { AvatarService, ColorScheme, InvalidWithValueStateMatcher$1 as InvalidWithValueStateMatcher, LOCAL_STORAGE, NATURAL_DROPDOWN_DATA, NATURAL_ICONS_CONFIG, NATURAL_PERSISTENCE_VALIDATOR, NATURAL_SEO_CONFIG, NaturalAbstractDetail, NaturalAbstractEditableList, NaturalAbstractList, NaturalAbstractModelService, NaturalAbstractNavigableList, NaturalAbstractPanel, NaturalAlertService, NaturalAvatarComponent, NaturalBackgroundDensityDirective, NaturalCapitalizePipe, NaturalColorSchemerComponent, NaturalColumnsPickerComponent, NaturalCompactColorSchemerComponent, NaturalConfirmComponent, NaturalDataSource, NaturalDebounceService, NaturalDetailHeaderComponent, NaturalDialogTriggerComponent, NaturalDropdownRef, NaturalEllipsisPipe, NaturalEnumPipe, NaturalEnumService, NaturalErrorHandler, NaturalErrorMessagePipe, NaturalFileComponent, NaturalFileDropDirective, NaturalFileSelectDirective, NaturalFileService, NaturalFixedButtonComponent, NaturalFixedButtonDetailComponent, NaturalHierarchicSelectorComponent, NaturalHierarchicSelectorDialogComponent, NaturalHierarchicSelectorDialogService, NaturalHierarchicSelectorService, NaturalHttpPrefixDirective, NaturalIconDirective, NaturalLinkMutationService, NaturalLinkableTabDirective, NaturalLoggerConfigExtra, NaturalLoggerConfigUrl, NaturalMatomoService, NaturalMemoryStorage, NaturalPanelsComponent, NaturalPanelsService, NaturalPersistenceService, NaturalQueryVariablesManager, NaturalRelationsComponent, NaturalSearchComponent, NaturalSelectComponent, NaturalSelectEnumComponent, NaturalSelectHierarchicComponent, NaturalSeoService, NaturalSidenavComponent, NaturalSidenavContainerComponent, NaturalSidenavContentComponent, NaturalSidenavService, NaturalSidenavStackService, NaturalSrcDensityDirective, NaturalStampComponent, NaturalSwissParsingDateAdapter, NaturalTableButtonComponent, NaturalThemeChangerComponent, NaturalThemeService, NaturalTimeAgoPipe, NetworkActivityService, PanelsHooksConfig, SESSION_STORAGE, SortingOrder, TypeAccountSelectorComponent, TypeBooleanComponent, TypeDateComponent, TypeDateRangeComponent, TypeHierarchicSelectorComponent, TypeNaturalSelectComponent, TypeNumberComponent, TypeOptionsComponent, TypeSelectComponent, TypeTextComponent, TypedMatCellDef, activityInterceptor, available, cancellableTimeout, cloneDeepButSkipFile, collectErrors, commonImageMimeTypes, copyToClipboard, createHttpLink, debug, decimal, deepFreeze, deliverableEmail, ensureHttpPrefix, fallbackIfNoOpenedPanels, formatIsoDate, formatIsoDateTime, fromUrl, getForegroundColor, getNumberRows, getVisibleSelections, graphqlQuerySigner, greaterThan, hasFilesAndProcessDate, ifValid, integer, isAllVisibleSelected, isFile, isPartiallyVisibleSelected, localStorageFactory, localStorageProvider, makePlural, masterToggleVisible, memoryLocalStorageProvider, memorySessionStorageProvider, mergeOverrideArray, money, naturalPanelsUrlMatcher, naturalProviders, nfcCardHex, onHistoryEvent, possibleComparableOperators, possibleNullComparableOperators, provideErrorHandler, provideIcons, providePanels, provideSeo, provideThemes, relationsToIds, replaceObjectKeepingReference, replaceOperatorByField, replaceOperatorByName, rgbToHex, selectVisible, sessionStorageFactory, sessionStorageProvider, time, toGraphQLDoctrineFilter, toNavigationParameters, toUrl, unique, unselectVisible, upperCaseFirstLetter, url, urlPattern, validTlds, validateAllFormControls, validateColumns, validatePagination, validateSorting, wrapLike, wrapPrefix, wrapSuffix };
11583
11695
  //# sourceMappingURL=ecodev-natural.mjs.map