@smartsoft001/crud-shell-angular 2.97.0 → 2.99.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.
@@ -284,7 +284,7 @@ const getCrudList = (entity) => createSelector(getCrudState(entity), (state) =>
284
284
  const getCrudTotalCount = (entity) => createSelector(getCrudState(entity), (state) => state.totalCount);
285
285
  const getCrudLinks = (entity) => createSelector(getCrudState(entity), (state) => state.links);
286
286
  const getCrudLoaded = (entity) => createSelector(getCrudState(entity), (state) => state.loaded);
287
- const getCrudFilter = (entity) => createSelector(getCrudState(entity), (state) => state.filter);
287
+ const getCrudFilter = (entity) => createSelector(getCrudState(entity), (state) => state?.filter);
288
288
  const getCrudError = (entity) => createSelector(getCrudState(entity), (state) => state.error);
289
289
 
290
290
  class CrudFacade {
@@ -536,7 +536,7 @@ class BaseComponent {
536
536
  const item = this.item();
537
537
  if (!filter || !item || !filter.query)
538
538
  return;
539
- filter.query = filter.query.filter((q) => q.key !== item.key);
539
+ filter.query = filter.query?.filter((q) => q.key !== item.key);
540
540
  filter.offset = 0;
541
541
  this.facade.read(filter);
542
542
  }
@@ -560,7 +560,7 @@ class BaseComponent {
560
560
  return;
561
561
  if (!filter.query)
562
562
  filter.query = [];
563
- const queries = filter.query.filter((q) => q.key === item.key && q.type === type);
563
+ const queries = filter.query?.filter((q) => q.key === item.key && q.type === type) || [];
564
564
  queries.forEach((query) => {
565
565
  const index = filter.query.indexOf(query);
566
566
  if (index > -1) {
@@ -610,7 +610,7 @@ class FilterCheckComponent extends BaseComponent {
610
610
  this.value = [...this.value, entry.value.id];
611
611
  }
612
612
  if (!checked && this.value.some((r) => r === entry.value.id)) {
613
- this.value = this.value.filter((r) => r !== entry.value.id);
613
+ this.value = this.value?.filter((r) => r !== entry.value.id);
614
614
  }
615
615
  }
616
616
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FilterCheckComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -1094,7 +1094,7 @@ class FiltersComponent {
1094
1094
  ngOnInit() {
1095
1095
  this.styleService.init(this.elementRef);
1096
1096
  this.list = signal([], ...(ngDevMode ? [{ debugName: "list" }] : []));
1097
- const modelFilters = getModelOptions(this.config.type).filters;
1097
+ const modelFilters = getModelOptions(this.config.type)?.filters;
1098
1098
  this.list.set([
1099
1099
  ...(modelFilters
1100
1100
  ? modelFilters.map((item) => {
@@ -1328,7 +1328,7 @@ class MultiselectComponent {
1328
1328
  const list = this.facade.multiSelected() || [];
1329
1329
  this.lock = true;
1330
1330
  const model = new this.config.type();
1331
- const fieldsWithOptions = getModelFieldsWithOptions(model).filter((f) => f.options.update?.multi);
1331
+ const fieldsWithOptions = getModelFieldsWithOptions(model)?.filter((f) => f.options.update?.multi);
1332
1332
  this.showForm = !!fieldsWithOptions.length;
1333
1333
  fieldsWithOptions.forEach(({ key }) => {
1334
1334
  const uniques = _.uniq(list.map((i) => i[key]));
@@ -1840,17 +1840,17 @@ const crudReducer = (state, action, entity) => {
1840
1840
  return {
1841
1841
  ...state,
1842
1842
  loaded: false,
1843
- filter: action.filter,
1843
+ filter: action?.filter,
1844
1844
  error: null,
1845
1845
  totalCount: null,
1846
1846
  links: null,
1847
1847
  };
1848
1848
  case `[${entity}] Read Success`: {
1849
1849
  let list = [];
1850
- if (action.filter &&
1851
- action.filter.offset &&
1850
+ if (action?.filter &&
1851
+ action?.filter.offset &&
1852
1852
  state.list &&
1853
- action.filter.paginationMode !== PaginationMode.singlePage) {
1853
+ action?.filter.paginationMode !== PaginationMode.singlePage) {
1854
1854
  state.list.forEach((i) => {
1855
1855
  list.push(i);
1856
1856
  });
@@ -2021,7 +2021,7 @@ class CrudEffects {
2021
2021
  break;
2022
2022
  case `[${this.config.entity}] Create Success`: {
2023
2023
  const createState = this.state.getValue()[this.config.entity];
2024
- this.store.dispatch(read(this.config.entity, createState.filter ? { ...createState.filter, offset: 0 } : null));
2024
+ this.store.dispatch(read(this.config.entity, createState?.filter ? { ...createState.filter, offset: 0 } : null));
2025
2025
  break;
2026
2026
  }
2027
2027
  case `[${this.config.entity}] Create Many`:
@@ -2040,25 +2040,25 @@ class CrudEffects {
2040
2040
  break;
2041
2041
  case `[${this.config.entity}] Create Many Success`: {
2042
2042
  const createManyState = this.state.getValue()[this.config.entity];
2043
- this.store.dispatch(read(this.config.entity, createManyState.filter
2043
+ this.store.dispatch(read(this.config.entity, createManyState?.filter
2044
2044
  ? { ...createManyState.filter, offset: 0 }
2045
2045
  : null));
2046
2046
  break;
2047
2047
  }
2048
2048
  case `[${this.config.entity}] Read`:
2049
2049
  this.service
2050
- .getList(action.filter)
2051
- .then((result) => this.store.dispatch(readSuccess(this.config.entity, action.filter, result)))
2050
+ .getList(action?.filter)
2051
+ .then((result) => this.store.dispatch(readSuccess(this.config.entity, action?.filter, result)))
2052
2052
  .catch((error) => {
2053
- this.store.dispatch(readFailure(this.config.entity, action.filter, error));
2053
+ this.store.dispatch(readFailure(this.config.entity, action?.filter, error));
2054
2054
  });
2055
2055
  break;
2056
2056
  case `[${this.config.entity}] Export`:
2057
2057
  this.service
2058
- .exportList(action.filter, action.format)
2059
- .then(() => this.store.dispatch(exportListSuccess(this.config.entity, action.filter)))
2058
+ .exportList(action?.filter, action.format)
2059
+ .then(() => this.store.dispatch(exportListSuccess(this.config.entity, action?.filter)))
2060
2060
  .catch((error) => {
2061
- this.store.dispatch(exportListFailure(this.config.entity, action.filter, error));
2061
+ this.store.dispatch(exportListFailure(this.config.entity, action?.filter, error));
2062
2062
  });
2063
2063
  break;
2064
2064
  case `[${this.config.entity}] Select`: