@smartsoft001/crud-shell-angular 2.92.0 → 2.94.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.
@@ -1,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, inject, ElementRef, Component, input, Directive, computed, signal, InjectionToken, Pipe, NgModule, viewChild, viewChildren, output, ChangeDetectorRef, effect, Injector } from '@angular/core';
3
- import { NgrxStoreService, BaseComponent as BaseComponent$1, PopoverService, StyleService, ButtonComponent, MenuService, FormComponent, AccordionComponent, AccordionHeaderComponent, AccordionBodyComponent, ListComponent as ListComponent$1, SharedModule, DetailsComponent, AuthService, CreateDynamicComponent, DynamicComponentLoader, ToastService, DetailsService, DynamicContentDirective, PageComponent, HardwareService, ListMode, FILE_SERVICE_CONFIG, PaginationMode } from '@smartsoft001/angular';
3
+ import { NgrxStoreService, BaseComponent as BaseComponent$1, PopoverService, StyleService, ButtonComponent, MenuService, FormComponent, AccordionComponent, AccordionHeaderComponent, AccordionBodyComponent, ListComponent as ListComponent$1, SharedModule, PaginationMode, DetailsComponent, AuthService, CreateDynamicComponent, DynamicComponentLoader, ToastService, DetailsService, DynamicContentDirective, PageComponent, HardwareService, ListMode, FILE_SERVICE_CONFIG } from '@smartsoft001/angular';
4
4
  import { toSignal } from '@angular/core/rxjs-interop';
5
5
  import * as i1 from '@ngrx/store';
6
6
  import { createFeatureSelector, createSelector, select as select$1 } from '@ngrx/store';
7
- import { map } from 'rxjs/operators';
7
+ import { map, first } from 'rxjs/operators';
8
8
  import { FieldType, getModelOptions, getModelFieldsWithOptions } from '@smartsoft001/models';
9
9
  import { TranslateService, TranslatePipe } from '@ngx-translate/core';
10
10
  import { __decorate, __metadata } from 'tslib';
@@ -17,7 +17,8 @@ import { NgComponentOutlet, NgClass, CommonModule, NgTemplateOutlet, Location }
17
17
  import * as _ from 'lodash';
18
18
  import { DynamicIoDirective, DynamicIoModule } from 'ng-dynamic-component';
19
19
  import { HttpClient } from '@angular/common/http';
20
- import * as i1$1 from '@angular/router';
20
+ import 'reflect-metadata';
21
+ import * as i3 from '@angular/router';
21
22
  import { Router, ActivatedRoute, RouterModule } from '@angular/router';
22
23
 
23
24
  class CrudConfig {
@@ -1433,8 +1434,8 @@ class GroupComponent extends BaseComponent$1 {
1433
1434
  styleService = inject(StyleService);
1434
1435
  elementRef = inject(ElementRef);
1435
1436
  groupService = inject((CrudListGroupService));
1436
- groups = input(...(ngDevMode ? [undefined, { debugName: "groups" }] : []));
1437
- listOptions = input(...(ngDevMode ? [undefined, { debugName: "listOptions" }] : []));
1437
+ groups = input(null, ...(ngDevMode ? [{ debugName: "groups" }] : []));
1438
+ listOptions = input(null, ...(ngDevMode ? [{ debugName: "listOptions" }] : []));
1438
1439
  change(val, item, force = false) {
1439
1440
  const groups = this.groups();
1440
1441
  if (groups) {
@@ -1784,6 +1785,388 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
1784
1785
  }]
1785
1786
  }] });
1786
1787
 
1788
+ const initialState = {
1789
+ loaded: false,
1790
+ };
1791
+ const crudReducer = (state, action, entity) => {
1792
+ if (!state) {
1793
+ state = { ...initialState };
1794
+ }
1795
+ switch (action.type) {
1796
+ case `[${entity}] Create`:
1797
+ return {
1798
+ ...state,
1799
+ loaded: false,
1800
+ error: null,
1801
+ };
1802
+ case `[${entity}] Create Success`:
1803
+ return {
1804
+ ...state,
1805
+ loaded: true,
1806
+ error: null,
1807
+ };
1808
+ case `[${entity}] Create Failure`:
1809
+ return {
1810
+ ...state,
1811
+ loaded: true,
1812
+ error: action.error,
1813
+ };
1814
+ case `[${entity}] Create Many`:
1815
+ return {
1816
+ ...state,
1817
+ loaded: false,
1818
+ error: null,
1819
+ };
1820
+ case `[${entity}] Create Many Success`:
1821
+ return {
1822
+ ...state,
1823
+ loaded: true,
1824
+ error: null,
1825
+ };
1826
+ case `[${entity}] Create Many Failure`:
1827
+ return {
1828
+ ...state,
1829
+ loaded: true,
1830
+ error: action.error,
1831
+ };
1832
+ case `[${entity}] Export`:
1833
+ return {
1834
+ ...state,
1835
+ loaded: false,
1836
+ };
1837
+ case `[${entity}] Export Success`:
1838
+ return {
1839
+ ...state,
1840
+ loaded: true,
1841
+ };
1842
+ case `[${entity}] Export Failure`:
1843
+ return {
1844
+ ...state,
1845
+ loaded: true,
1846
+ };
1847
+ case `[${entity}] Read`:
1848
+ return {
1849
+ ...state,
1850
+ loaded: false,
1851
+ filter: action.filter,
1852
+ error: null,
1853
+ totalCount: null,
1854
+ links: null,
1855
+ };
1856
+ case `[${entity}] Read Success`: {
1857
+ let list = [];
1858
+ if (action.filter &&
1859
+ action.filter.offset &&
1860
+ state.list &&
1861
+ action.filter.paginationMode !== PaginationMode.singlePage) {
1862
+ state.list.forEach((i) => {
1863
+ list.push(i);
1864
+ });
1865
+ list = [...list, ...action.result.data];
1866
+ }
1867
+ else {
1868
+ list = action.result.data;
1869
+ }
1870
+ return {
1871
+ ...state,
1872
+ loaded: true,
1873
+ list,
1874
+ totalCount: action.result.totalCount,
1875
+ links: action.result.links,
1876
+ error: null,
1877
+ };
1878
+ }
1879
+ case `[${entity}] Clear`:
1880
+ return { ...initialState };
1881
+ case `[${entity}] Read Failure`:
1882
+ return {
1883
+ ...state,
1884
+ loaded: true,
1885
+ error: action.error,
1886
+ };
1887
+ case `[${entity}] Select`:
1888
+ return {
1889
+ ...state,
1890
+ loaded: false,
1891
+ selected: null,
1892
+ error: null,
1893
+ };
1894
+ case `[${entity}] Select Success`:
1895
+ return {
1896
+ ...state,
1897
+ loaded: true,
1898
+ selected: action.item,
1899
+ error: null,
1900
+ };
1901
+ case `[${entity}] Select Failure`:
1902
+ return {
1903
+ ...state,
1904
+ loaded: true,
1905
+ error: action.error,
1906
+ };
1907
+ case `[${entity}] MultiSelect`:
1908
+ return {
1909
+ ...state,
1910
+ multiSelected: [...action.items],
1911
+ };
1912
+ case `[${entity}] Unselect`:
1913
+ return {
1914
+ ...state,
1915
+ loaded: true,
1916
+ selected: null,
1917
+ error: null,
1918
+ };
1919
+ case `[${entity}] Update`:
1920
+ return {
1921
+ ...state,
1922
+ loaded: false,
1923
+ error: null,
1924
+ };
1925
+ case `[${entity}] Update Success`:
1926
+ return {
1927
+ ...state,
1928
+ loaded: true,
1929
+ error: null,
1930
+ };
1931
+ case `[${entity}] Update Failure`:
1932
+ return {
1933
+ ...state,
1934
+ loaded: true,
1935
+ error: action.error,
1936
+ };
1937
+ case `[${entity}] Update partial`:
1938
+ return {
1939
+ ...state,
1940
+ loaded: false,
1941
+ error: null,
1942
+ };
1943
+ case `[${entity}] Update partial Success`:
1944
+ return {
1945
+ ...state,
1946
+ loaded: true,
1947
+ error: null,
1948
+ };
1949
+ case `[${entity}] Update partial Failure`:
1950
+ return {
1951
+ ...state,
1952
+ loaded: true,
1953
+ error: action.error,
1954
+ };
1955
+ case `[${entity}] Update partial many`:
1956
+ return {
1957
+ ...state,
1958
+ loaded: false,
1959
+ error: null,
1960
+ };
1961
+ case `[${entity}] Update partial many Success`:
1962
+ return {
1963
+ ...state,
1964
+ multiSelected: [],
1965
+ loaded: true,
1966
+ error: null,
1967
+ };
1968
+ case `[${entity}] Update partial many Failure`:
1969
+ return {
1970
+ ...state,
1971
+ loaded: true,
1972
+ error: action.error,
1973
+ };
1974
+ case `[${entity}] Delete`:
1975
+ return {
1976
+ ...state,
1977
+ loaded: false,
1978
+ error: null,
1979
+ };
1980
+ case `[${entity}] Delete Success`:
1981
+ return {
1982
+ ...state,
1983
+ loaded: true,
1984
+ error: null,
1985
+ };
1986
+ case `[${entity}] Delete Failure`:
1987
+ return {
1988
+ ...state,
1989
+ loaded: true,
1990
+ error: action.error,
1991
+ };
1992
+ default:
1993
+ return state;
1994
+ }
1995
+ };
1996
+ function getReducer(entity) {
1997
+ return (state, action) => {
1998
+ return crudReducer(state, action, entity);
1999
+ };
2000
+ }
2001
+
2002
+ class CrudEffects {
2003
+ actions$;
2004
+ service;
2005
+ config;
2006
+ store;
2007
+ state;
2008
+ constructor(actions$, service, config, store, state) {
2009
+ this.actions$ = actions$;
2010
+ this.service = service;
2011
+ this.config = config;
2012
+ this.store = store;
2013
+ this.state = state;
2014
+ }
2015
+ init() {
2016
+ const metadata = Reflect.getMetadata(this.config.entity, CrudEffects);
2017
+ if (metadata)
2018
+ return;
2019
+ Reflect.defineMetadata(this.config.entity, true, CrudEffects);
2020
+ this.actions$.subscribe((action) => {
2021
+ switch (action.type) {
2022
+ case `[${this.config.entity}] Create`:
2023
+ this.service
2024
+ .create(action.item)
2025
+ .then(() => this.store.dispatch(createSuccess(this.config.entity, action.item)))
2026
+ .catch((error) => {
2027
+ this.store.dispatch(createFailure(this.config.entity, action.item, error));
2028
+ });
2029
+ break;
2030
+ case `[${this.config.entity}] Create Success`: {
2031
+ const createState = this.state.getValue()[this.config.entity];
2032
+ this.store.dispatch(read(this.config.entity, createState.filter ? { ...createState.filter, offset: 0 } : null));
2033
+ break;
2034
+ }
2035
+ case `[${this.config.entity}] Create Many`:
2036
+ this.service
2037
+ .createMany(action.data.items, action.data.options)
2038
+ .then(() => this.store.dispatch(createManySuccess(this.config.entity, {
2039
+ items: action.data.items,
2040
+ options: action.data.options,
2041
+ })))
2042
+ .catch((error) => {
2043
+ this.store.dispatch(createManyFailure(this.config.entity, {
2044
+ items: action.data.items,
2045
+ options: action.data.options,
2046
+ }, error));
2047
+ });
2048
+ break;
2049
+ case `[${this.config.entity}] Create Many Success`: {
2050
+ const createManyState = this.state.getValue()[this.config.entity];
2051
+ this.store.dispatch(read(this.config.entity, createManyState.filter
2052
+ ? { ...createManyState.filter, offset: 0 }
2053
+ : null));
2054
+ break;
2055
+ }
2056
+ case `[${this.config.entity}] Read`:
2057
+ this.service
2058
+ .getList(action.filter)
2059
+ .then((result) => this.store.dispatch(readSuccess(this.config.entity, action.filter, result)))
2060
+ .catch((error) => {
2061
+ this.store.dispatch(readFailure(this.config.entity, action.filter, error));
2062
+ });
2063
+ break;
2064
+ case `[${this.config.entity}] Export`:
2065
+ this.service
2066
+ .exportList(action.filter, action.format)
2067
+ .then(() => this.store.dispatch(exportListSuccess(this.config.entity, action.filter)))
2068
+ .catch((error) => {
2069
+ this.store.dispatch(exportListFailure(this.config.entity, action.filter, error));
2070
+ });
2071
+ break;
2072
+ case `[${this.config.entity}] Select`:
2073
+ this.service
2074
+ .getById(action.id)
2075
+ .then((result) => this.store.dispatch(selectSuccess(this.config.entity, action.id, result)))
2076
+ .catch((error) => {
2077
+ this.store.dispatch(selectFailure(this.config.entity, action.id, error));
2078
+ });
2079
+ break;
2080
+ case `[${this.config.entity}] Update`:
2081
+ this.service
2082
+ .updatePartial(action.item)
2083
+ .then(() => this.store.dispatch(updateSuccess(this.config.entity, action.item)))
2084
+ .catch((error) => {
2085
+ this.store.dispatch(updateFailure(this.config.entity, action.item, error));
2086
+ this.store.dispatch(read(this.config.entity));
2087
+ });
2088
+ break;
2089
+ case `[${this.config.entity}] Update Success`:
2090
+ this.store
2091
+ .pipe(select$1(getCrudFilter(this.config.entity)), first())
2092
+ .subscribe((filter) => {
2093
+ this.store.dispatch(read(this.config.entity, {
2094
+ ...filter,
2095
+ offset: 0,
2096
+ }));
2097
+ this.store.dispatch(select(this.config.entity, action.item.id));
2098
+ });
2099
+ break;
2100
+ case `[${this.config.entity}] Update partial`:
2101
+ this.service
2102
+ .updatePartial(action.item)
2103
+ .then(() => this.store.dispatch(updatePartialSuccess(this.config.entity, action.item)))
2104
+ .catch((error) => {
2105
+ this.store.dispatch(updatePartialFailure(this.config.entity, action.item, error));
2106
+ this.store.dispatch(read(this.config.entity));
2107
+ });
2108
+ break;
2109
+ case `[${this.config.entity}] Update partial Success`:
2110
+ this.store
2111
+ .pipe(select$1(getCrudFilter(this.config.entity)), first())
2112
+ .subscribe((filter) => {
2113
+ this.store.dispatch(read(this.config.entity, {
2114
+ ...filter,
2115
+ offset: 0,
2116
+ }));
2117
+ this.store.dispatch(select(this.config.entity, action.item.id));
2118
+ });
2119
+ break;
2120
+ case `[${this.config.entity}] Update partial many`:
2121
+ this.service
2122
+ .updatePartialMany(action.items)
2123
+ .then(() => this.store.dispatch(updatePartialManySuccess(this.config.entity, action.items)))
2124
+ .catch((error) => {
2125
+ this.store.dispatch(updatePartialManyFailure(this.config.entity, action.items, error));
2126
+ this.store.dispatch(read(this.config.entity));
2127
+ });
2128
+ break;
2129
+ case `[${this.config.entity}] Update partial many Success`:
2130
+ this.store
2131
+ .pipe(select$1(getCrudFilter(this.config.entity)), first())
2132
+ .subscribe((filter) => {
2133
+ this.store.dispatch(read(this.config.entity, {
2134
+ ...filter,
2135
+ offset: 0,
2136
+ }));
2137
+ });
2138
+ break;
2139
+ case `[${this.config.entity}] Delete`:
2140
+ this.service
2141
+ .delete(action.id)
2142
+ .then(() => this.store.dispatch(deleteSuccess(this.config.entity, action.id)))
2143
+ .catch((error) => {
2144
+ this.store.dispatch(deleteFailure(this.config.entity, action.id, error));
2145
+ });
2146
+ break;
2147
+ case `[${this.config.entity}] Delete Success`:
2148
+ this.store
2149
+ .pipe(select$1(getCrudFilter(this.config.entity)), first())
2150
+ .subscribe((filter) => {
2151
+ this.store.dispatch(read(this.config.entity, {
2152
+ ...filter,
2153
+ offset: 0,
2154
+ }));
2155
+ });
2156
+ break;
2157
+ default:
2158
+ console.warn(`No effect for action type ${action.type} in entity ${this.config.entity}`);
2159
+ break;
2160
+ }
2161
+ });
2162
+ }
2163
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudEffects, deps: [{ token: i1.ActionsSubject }, { token: CrudService }, { token: CrudConfig }, { token: i1.Store }, { token: i1.State }], target: i0.ɵɵFactoryTarget.Injectable });
2164
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudEffects });
2165
+ }
2166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudEffects, decorators: [{
2167
+ type: Injectable
2168
+ }], ctorParameters: () => [{ type: i1.ActionsSubject }, { type: CrudService }, { type: CrudConfig }, { type: i1.Store }, { type: i1.State }] });
2169
+
1787
2170
  class CrudItemPageBaseComponent extends BaseComponent$1 {
1788
2171
  config = inject((CrudFullConfig));
1789
2172
  facade = inject((CrudFacade));
@@ -2321,7 +2704,7 @@ class ListStandardComponent extends CrudListPageBaseComponent {
2321
2704
  @if (groups && !isSearch()) {
2322
2705
  <smart-crud-group
2323
2706
  [groups]="groups"
2324
- [listOptions]="listOptions()"
2707
+ [listOptions]="listOptions() || null"
2325
2708
  ></smart-crud-group>
2326
2709
  }
2327
2710
  `, isInline: true, dependencies: [{ kind: "component", type: FiltersConfigComponent, selector: "smart-crud-filters-config" }, { kind: "component", type: ListComponent$1, selector: "smart-list", inputs: ["options"] }, { kind: "component", type: GroupComponent, selector: "smart-crud-group", inputs: ["groups", "listOptions"] }] });
@@ -2342,7 +2725,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2342
2725
  @if (groups && !isSearch()) {
2343
2726
  <smart-crud-group
2344
2727
  [groups]="groups"
2345
- [listOptions]="listOptions()"
2728
+ [listOptions]="listOptions() || null"
2346
2729
  ></smart-crud-group>
2347
2730
  }
2348
2731
  `,
@@ -2400,17 +2783,13 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2400
2783
  config = inject((CrudFullConfig));
2401
2784
  searchService = inject(CrudSearchService);
2402
2785
  _cleanMultiSelected$ = new Subject();
2403
- pageOptions;
2404
- listOptions;
2405
- links;
2786
+ pageOptions = signal(null, ...(ngDevMode ? [{ debugName: "pageOptions" }] : []));
2787
+ listOptions = signal(null, ...(ngDevMode ? [{ debugName: "listOptions" }] : []));
2788
+ links = this.facade.links;
2406
2789
  filter = this.facade.filter;
2407
2790
  topTpl = viewChild('topTpl', ...(ngDevMode ? [{ debugName: "topTpl" }] : []));
2408
2791
  contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
2409
2792
  dynamicContents = viewChildren(DynamicContentDirective, ...(ngDevMode ? [{ debugName: "dynamicContents" }] : []));
2410
- constructor() {
2411
- super();
2412
- this.links = this.facade.links();
2413
- }
2414
2793
  refreshProperties() {
2415
2794
  this.baseComponentRef.setInput('listOptions', this.listOptions());
2416
2795
  }
@@ -2468,7 +2847,7 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2468
2847
  }
2469
2848
  this.facade.read(newFilter);
2470
2849
  const endButtons = this.getEndButtons();
2471
- this.pageOptions = computed(() => ({
2850
+ this.pageOptions.set({
2472
2851
  title: this.config.title || '',
2473
2852
  search: this.config.search
2474
2853
  ? {
@@ -2484,7 +2863,7 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2484
2863
  }
2485
2864
  : undefined,
2486
2865
  endButtons: endButtons,
2487
- }), ...(ngDevMode ? [{ debugName: "pageOptions" }] : []));
2866
+ });
2488
2867
  const compiledComponents = await this.dynamicComponentLoader.getComponentsWithFactories({
2489
2868
  components: [
2490
2869
  ...(this.config.details &&
@@ -2592,7 +2971,7 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2592
2971
  getFilter: () => {
2593
2972
  return this.filter() || {};
2594
2973
  },
2595
- getLinks: () => this.links,
2974
+ getLinks: () => this.links(),
2596
2975
  },
2597
2976
  }),
2598
2977
  sort: this.config.sort,
@@ -2637,7 +3016,7 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2637
3016
  setTimeout(async () => {
2638
3017
  this.listOptions.update((val) => ({
2639
3018
  ...val,
2640
- select: val.select === 'multi' ? undefined : 'multi',
3019
+ select: val?.select === 'multi' ? undefined : 'multi',
2641
3020
  }));
2642
3021
  if (this.menuService.openedEnd)
2643
3022
  await this.menuService.closeEnd();
@@ -2700,13 +3079,13 @@ class ListComponent extends CreateDynamicComponent('crud-list-page') {
2700
3079
  }
2701
3080
  });
2702
3081
  }
2703
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3082
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
2704
3083
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListComponent, isStandalone: true, selector: "smart-crud-list-page", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }, { propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }, { propertyName: "dynamicContents", predicate: DynamicContentDirective, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
2705
- @if (filter()) {
3084
+ @if (filter() && pageOptions()) {
2706
3085
  <smart-page [options]="pageOptions()">
2707
3086
  <div #topTpl></div>
2708
3087
 
2709
- @if (template() === 'default') {
3088
+ @if (template() === 'default' && listOptions()) {
2710
3089
  <smart-crud-list-standard-page [listOptions]="listOptions()">
2711
3090
  <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
2712
3091
  </smart-crud-list-standard-page>
@@ -2725,11 +3104,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2725
3104
  selector: 'smart-crud-list-page',
2726
3105
  imports: [PageComponent, ListStandardComponent, NgTemplateOutlet],
2727
3106
  template: `
2728
- @if (filter()) {
3107
+ @if (filter() && pageOptions()) {
2729
3108
  <smart-page [options]="pageOptions()">
2730
3109
  <div #topTpl></div>
2731
3110
 
2732
- @if (template() === 'default') {
3111
+ @if (template() === 'default' && listOptions()) {
2733
3112
  <smart-crud-list-standard-page [listOptions]="listOptions()">
2734
3113
  <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
2735
3114
  </smart-crud-list-standard-page>
@@ -2742,7 +3121,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2742
3121
  }
2743
3122
  `,
2744
3123
  }]
2745
- }], ctorParameters: () => [] });
3124
+ }] });
2746
3125
 
2747
3126
  const PAGES = [
2748
3127
  ItemComponent,
@@ -2751,12 +3130,18 @@ const PAGES = [
2751
3130
  ItemStandardComponent,
2752
3131
  ];
2753
3132
  class CrudFullModule {
2754
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudFullModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3133
+ constructor(config, effects) {
3134
+ NgrxStoreService.addReducer(config.entity, config.reducerFactory
3135
+ ? config.reducerFactory()
3136
+ : getReducer(config.entity));
3137
+ effects.init();
3138
+ }
3139
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudFullModule, deps: [{ token: CrudConfig }, { token: CrudEffects }], target: i0.ɵɵFactoryTarget.NgModule });
2755
3140
  static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: CrudFullModule, imports: [ItemComponent,
2756
3141
  ListComponent,
2757
3142
  ListStandardComponent,
2758
3143
  ItemStandardComponent, SharedModule,
2759
- CrudPipesModule, i1$1.RouterModule, FormsModule,
3144
+ CrudPipesModule, i3.RouterModule, FormsModule,
2760
3145
  CommonModule,
2761
3146
  CrudComponentsModule], exports: [ItemComponent,
2762
3147
  ListComponent,
@@ -2767,6 +3152,7 @@ class CrudFullModule {
2767
3152
  CrudListGroupService,
2768
3153
  PageService,
2769
3154
  CrudFacade,
3155
+ CrudEffects,
2770
3156
  CrudListPaginationFactory,
2771
3157
  ], imports: [PAGES, SharedModule,
2772
3158
  CrudPipesModule,
@@ -2801,13 +3187,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2801
3187
  CrudListGroupService,
2802
3188
  PageService,
2803
3189
  CrudFacade,
3190
+ CrudEffects,
2804
3191
  CrudListPaginationFactory,
2805
3192
  ],
2806
3193
  }]
2807
- }] });
3194
+ }], ctorParameters: () => [{ type: CrudConfig }, { type: CrudEffects }] });
2808
3195
 
2809
3196
  class CrudCoreModule {
2810
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3197
+ constructor(config, effects) {
3198
+ NgrxStoreService.addReducer(config.entity, config.reducerFactory
3199
+ ? config.reducerFactory()
3200
+ : getReducer(config.entity));
3201
+ effects.init();
3202
+ }
3203
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudCoreModule, deps: [{ token: CrudConfig }, { token: CrudEffects }], target: i0.ɵɵFactoryTarget.NgModule });
2811
3204
  static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: CrudCoreModule, imports: [SharedModule,
2812
3205
  CrudPipesModule,
2813
3206
  FormsModule,
@@ -2816,6 +3209,7 @@ class CrudCoreModule {
2816
3209
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: CrudCoreModule, providers: [
2817
3210
  CrudService,
2818
3211
  CrudListGroupService,
3212
+ CrudEffects,
2819
3213
  PageService,
2820
3214
  CrudFacade,
2821
3215
  CrudListPaginationFactory,
@@ -2839,12 +3233,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2839
3233
  providers: [
2840
3234
  CrudService,
2841
3235
  CrudListGroupService,
3236
+ CrudEffects,
2842
3237
  PageService,
2843
3238
  CrudFacade,
2844
3239
  CrudListPaginationFactory,
2845
3240
  ],
2846
3241
  }]
2847
- }] });
3242
+ }], ctorParameters: () => [{ type: CrudConfig }, { type: CrudEffects }] });
2848
3243
  class CrudModule {
2849
3244
  static forFeature(options) {
2850
3245
  return {
@@ -2868,220 +3263,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
2868
3263
  args: [{}]
2869
3264
  }] });
2870
3265
 
2871
- const initialState = {
2872
- loaded: false,
2873
- };
2874
- const crudReducer = (state, action, entity) => {
2875
- if (!state) {
2876
- state = { ...initialState };
2877
- }
2878
- switch (action.type) {
2879
- case `[${entity}] Create`:
2880
- return {
2881
- ...state,
2882
- loaded: false,
2883
- error: null,
2884
- };
2885
- case `[${entity}] Create Success`:
2886
- return {
2887
- ...state,
2888
- loaded: true,
2889
- error: null,
2890
- };
2891
- case `[${entity}] Create Failure`:
2892
- return {
2893
- ...state,
2894
- loaded: true,
2895
- error: action.error,
2896
- };
2897
- case `[${entity}] Create Many`:
2898
- return {
2899
- ...state,
2900
- loaded: false,
2901
- error: null,
2902
- };
2903
- case `[${entity}] Create Many Success`:
2904
- return {
2905
- ...state,
2906
- loaded: true,
2907
- error: null,
2908
- };
2909
- case `[${entity}] Create Many Failure`:
2910
- return {
2911
- ...state,
2912
- loaded: true,
2913
- error: action.error,
2914
- };
2915
- case `[${entity}] Export`:
2916
- return {
2917
- ...state,
2918
- loaded: false,
2919
- };
2920
- case `[${entity}] Export Success`:
2921
- return {
2922
- ...state,
2923
- loaded: true,
2924
- };
2925
- case `[${entity}] Export Failure`:
2926
- return {
2927
- ...state,
2928
- loaded: true,
2929
- };
2930
- case `[${entity}] Read`:
2931
- return {
2932
- ...state,
2933
- loaded: false,
2934
- filter: action.filter,
2935
- error: null,
2936
- totalCount: null,
2937
- links: null,
2938
- };
2939
- case `[${entity}] Read Success`: {
2940
- let list = [];
2941
- if (action.filter &&
2942
- action.filter.offset &&
2943
- state.list &&
2944
- action.filter.paginationMode !== PaginationMode.singlePage) {
2945
- state.list.forEach((i) => {
2946
- list.push(i);
2947
- });
2948
- list = [...list, ...action.result.data];
2949
- }
2950
- else {
2951
- list = action.result.data;
2952
- }
2953
- return {
2954
- ...state,
2955
- loaded: true,
2956
- list,
2957
- totalCount: action.result.totalCount,
2958
- links: action.result.links,
2959
- error: null,
2960
- };
2961
- }
2962
- case `[${entity}] Clear`:
2963
- return { ...initialState };
2964
- case `[${entity}] Read Failure`:
2965
- return {
2966
- ...state,
2967
- loaded: true,
2968
- error: action.error,
2969
- };
2970
- case `[${entity}] Select`:
2971
- return {
2972
- ...state,
2973
- loaded: false,
2974
- selected: null,
2975
- error: null,
2976
- };
2977
- case `[${entity}] Select Success`:
2978
- return {
2979
- ...state,
2980
- loaded: true,
2981
- selected: action.item,
2982
- error: null,
2983
- };
2984
- case `[${entity}] Select Failure`:
2985
- return {
2986
- ...state,
2987
- loaded: true,
2988
- error: action.error,
2989
- };
2990
- case `[${entity}] MultiSelect`:
2991
- return {
2992
- ...state,
2993
- multiSelected: [...action.items],
2994
- };
2995
- case `[${entity}] Unselect`:
2996
- return {
2997
- ...state,
2998
- loaded: true,
2999
- selected: null,
3000
- error: null,
3001
- };
3002
- case `[${entity}] Update`:
3003
- return {
3004
- ...state,
3005
- loaded: false,
3006
- error: null,
3007
- };
3008
- case `[${entity}] Update Success`:
3009
- return {
3010
- ...state,
3011
- loaded: true,
3012
- error: null,
3013
- };
3014
- case `[${entity}] Update Failure`:
3015
- return {
3016
- ...state,
3017
- loaded: true,
3018
- error: action.error,
3019
- };
3020
- case `[${entity}] Update partial`:
3021
- return {
3022
- ...state,
3023
- loaded: false,
3024
- error: null,
3025
- };
3026
- case `[${entity}] Update partial Success`:
3027
- return {
3028
- ...state,
3029
- loaded: true,
3030
- error: null,
3031
- };
3032
- case `[${entity}] Update partial Failure`:
3033
- return {
3034
- ...state,
3035
- loaded: true,
3036
- error: action.error,
3037
- };
3038
- case `[${entity}] Update partial many`:
3039
- return {
3040
- ...state,
3041
- loaded: false,
3042
- error: null,
3043
- };
3044
- case `[${entity}] Update partial many Success`:
3045
- return {
3046
- ...state,
3047
- multiSelected: [],
3048
- loaded: true,
3049
- error: null,
3050
- };
3051
- case `[${entity}] Update partial many Failure`:
3052
- return {
3053
- ...state,
3054
- loaded: true,
3055
- error: action.error,
3056
- };
3057
- case `[${entity}] Delete`:
3058
- return {
3059
- ...state,
3060
- loaded: false,
3061
- error: null,
3062
- };
3063
- case `[${entity}] Delete Success`:
3064
- return {
3065
- ...state,
3066
- loaded: true,
3067
- error: null,
3068
- };
3069
- case `[${entity}] Delete Failure`:
3070
- return {
3071
- ...state,
3072
- loaded: true,
3073
- error: action.error,
3074
- };
3075
- default:
3076
- return state;
3077
- }
3078
- };
3079
- function getReducer(entity) {
3080
- return (state, action) => {
3081
- return crudReducer(state, action, entity);
3082
- };
3083
- }
3084
-
3085
3266
  /**
3086
3267
  * Generated bundle index. Do not edit.
3087
3268
  */