imng-kendo-schematics 19.232.3 → 19.232.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imng-kendo-schematics",
3
- "version": "19.232.3",
3
+ "version": "19.232.4",
4
4
  "description": "Angular Schematics facilitating Angular, Kendo, NGRX and imng package integration",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -10,7 +10,6 @@ import { <%= classify(name) %>BaseEntryComponent } from './base-entry.component'
10
10
  })
11
11
  export class <%= classify(name) %>AddComponent extends <%= classify(name) %>BaseEntryComponent implements OnInit, OnDestroy {
12
12
  public dialogTitle = 'Add <%= classify(name) %>';
13
- public active$ = this.facade.isNewActive$;
14
13
 
15
14
  public override initForm(): void {
16
15
  super.initForm();
@@ -5,8 +5,9 @@ import { EffectsModule } from '@ngrx/effects';
5
5
  import { StoreModule, Store } from '@ngrx/store';
6
6
  import { readFirst } from 'imng-ngrx-utils/testing';
7
7
  import {
8
- testAddSetAndClearCurrentEntity,
9
- testEditSetAndClearCurrentEntity,
8
+ testDeleteCurrentEntity,
9
+ testModalStateAddAndClearCurrentEntity,
10
+ testModalStateEditAndClearCurrentEntity,
10
11
  testSaveCurrentEntity,
11
12
  testUpdateCurrentEntity,
12
13
  } from 'imng-kendo-data-entry/testing';
@@ -59,24 +60,27 @@ describe('<%= classify(name) %>CrudFacade', () => {
59
60
  });
60
61
 
61
62
  test('clearCurrentEntity() should set current<%= classify(name) %> to null', async () => {
62
- let isNewActive = await readFirst(facade.isNewActive$);
63
- expect(isNewActive).toBeFalsy();
63
+ let currentModalState = await readFirst(facade.currentModalState$);
64
+ expect(currentModalState).toBeUndefined();
64
65
 
65
66
  facade.clearCurrentEntity();
66
- isNewActive = await readFirst(facade.isNewActive$);
67
+ currentModalState = await readFirst(facade.currentModalState$);
67
68
 
68
- expect(isNewActive).toBeFalsy();
69
+ expect(currentModalState).toBeUndefined();
69
70
  expect(await readFirst(store)).toMatchSnapshot();
70
71
  });
71
72
 
72
- test('New Entity Set And Clear CurrentEntity', async () =>
73
- testAddSetAndClearCurrentEntity<<%= classify(name) %>CrudFacade>(facade));
74
- test('Existing Entity Set And Clear CurrentEntity', async () =>
75
- testEditSetAndClearCurrentEntity<<%= classify(name) %>CrudFacade>(facade));
73
+ test('Add Modal State And Clear CurrentEntity', async () =>
74
+ testModalStateAddAndClearCurrentEntity<<%= classify(name) %>CrudFacade>(facade));
75
+ test('Edit Modal state And Clear CurrentEntity', async () =>
76
+ testModalStateEditAndClearCurrentEntity<<%= classify(name) %>CrudFacade>(facade));
76
77
  test('Save CurrentEntity', async () =>
77
78
  testSaveCurrentEntity<<%= classify(name) %>CrudFacade>(facade, httpClient));
78
79
  test('Update CurrentEntity', async () =>
79
- testUpdateCurrentEntity<<%= classify(name) %>CrudFacade>(facade, httpClient));<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
80
+ testUpdateCurrentEntity<<%= classify(name) %>CrudFacade>(facade, httpClient));
81
+ test('it should handle DeleteItem', async () => {
82
+ await testDeleteCurrentEntity(facade, httpClient);
83
+ });<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
80
84
 
81
85
  test('should load <%= classify(swaggerProperty.pluralizedName) %>', async () => {
82
86
  facade.load<%= classify(swaggerProperty.pluralizedName) %>({});
@@ -1,20 +1,18 @@
1
1
  import { Injectable, inject } from '@angular/core';
2
2
  import { Store } from '@ngrx/store';
3
- import { IDataEntryFacade, ModalStates, isModalState } from 'imng-kendo-data-entry';<% if (hasObjects) { %>
3
+ import { IDataDeleteFacade, IDataEntryFacade } from 'imng-kendo-data-entry';<% if (hasObjects) { %>
4
4
  import { ODataState } from 'imng-kendo-odata';<% } %>
5
5
 
6
6
  import { <%= camelize(pluralizedStoreName) %>Feature, <%= camelize(singularizedStoreName) %>ActionTypes } from '../+state';<% if (modelFolderLocation) { %>
7
7
  import { I<%= classify(singularizedName) %>, <% swaggerObjectProperties.forEach(function(swaggerProperty, i, arr){ %>I<%= classify(swaggerProperty.name) %><% if(arr.length != i + 1) {%>, <%} }); %> } from '<%= modelFolderLocation %>';<% } %>
8
8
 
9
9
  @Injectable()
10
- export class <%= classify(name) %>CrudFacade implements IDataEntryFacade<I<%= classify(name) %>> {
10
+ export class <%= classify(name) %>CrudFacade implements IDataEntryFacade<I<%= classify(name) %>>, IDataDeleteFacade<I<%= classify(name) %>> {
11
11
  private readonly store = inject(Store);
12
12
 
13
13
  loading$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectLoading);
14
14
  currentEntity$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(name) %>);
15
- currentModalState$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(singularizedName) %>ModalState);
16
- isEditActive$ = isModalState(this, ModalStates.EDIT);
17
- isNewActive$ = isModalState(this, ModalStates.ADD);<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
15
+ currentModalState$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(singularizedName) %>ModalState);<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
18
16
  <%= camelize(swaggerProperty.pluralizedName) %>$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.select<%= classify(swaggerProperty.pluralizedName) %>);<% }); %>
19
17
 
20
18
  public setCurrentEntity(item: I<%= classify(name) %>, modalState: string): void {
@@ -37,6 +35,10 @@ export class <%= classify(name) %>CrudFacade implements IDataEntryFacade<I<%= cl
37
35
  public updateExistingEntity(item: I<%= classify(name) %>): void {
38
36
  this.store.dispatch(<%= camelize(singularizedStoreName) %>ActionTypes.update<%= classify(name) %>Request(item));
39
37
  }
38
+
39
+ public deleteExistingEntity(item: I<%= classify(name) %>): void {
40
+ this.store.dispatch(<%= camelize(singularizedStoreName) %>ActionTypes.delete<%= classify(name) %>Request(item));
41
+ }
40
42
  <% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
41
43
  public load<%= classify(swaggerProperty.pluralizedName) %>(state: ODataState): void {
42
44
  this.store.dispatch(<%= camelize(singularizedStoreName) %>ActionTypes.load<%= classify(swaggerProperty.pluralizedName) %>Request(state));
@@ -12,13 +12,10 @@ import { <%= classify(name) %>BaseEntryComponent } from './base-entry.component'
12
12
  })
13
13
  export class <%= classify(name) %>EditComponent extends <%= classify(name) %>BaseEntryComponent implements OnInit, OnDestroy {
14
14
  public dialogTitle = 'Edit <%= classify(name) %>';
15
- public active$ = this.facade.isEditActive$;
16
15
 
17
16
  public override initForm(): void {
18
17
  super.initForm();
19
- if (this.addEditForm) {
20
- this.allSubscriptions.push(this.facade.currentEntity$.pipe(formGroupPatcher(this.addEditForm)).subscribe());
21
- }
18
+ this.allSubscriptions.push(this.facade.currentEntity$.pipe(formGroupPatcher(this.addEditForm)).subscribe());
22
19
  }
23
20
 
24
21
  public save(): void {
@@ -101,9 +101,19 @@
101
101
  </kendo-grid-pdf>
102
102
  <kendo-grid-excel [fileName]="getExportFileName('<%= classify(pluralizedName) %>')" [fetchData]="excelData" />
103
103
  </kendo-grid>
104
- @if (crudFacade.isNewActive$ | async) {
105
- <<%= appPrefix %>-<%= dasherize(name) %>-add />
106
- }
107
- @if (crudFacade.isEditActive$ | async) {
108
- <<%= appPrefix %>-<%= dasherize(name) %>-edit />
109
- }
104
+
105
+ @switch (crudFacade.currentModalState$ | async) {
106
+ @case (modalStates.ADD) {
107
+ <<%= appPrefix %>-<%= dasherize(name) %>-add />
108
+ }
109
+ @case (modalStates.EDIT) {
110
+ <<%= appPrefix %>-<%= dasherize(name) %>-edit />
111
+ }
112
+ @case (modalStates.DELETE) {
113
+ <imng-data-delete-dialog
114
+ [facade]="crudFacade"
115
+ [dataItem]="crudFacade.currentEntity$ | async">
116
+ <div>Are you sure you want to delete this record?</div>
117
+ </imng-data-delete-dialog>
118
+ }
119
+ }
@@ -1,7 +1,7 @@
1
1
  import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
2
2
  import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
3
3
  import { provideRouter } from '@angular/router';
4
- import { createDataEntryMockFacade, createDataDeleteMockFacade } from 'imng-kendo-data-entry/testing';
4
+ import { createDataEntryMockFacade } from 'imng-kendo-data-entry/testing';
5
5
  import { createODataGridMockFacade } from 'imng-kendo-grid-odata/testing';
6
6
  import { provideOidcMockFacade } from 'imng-oidc-client/testing';
7
7
  import { ModalStates } from 'imng-kendo-data-entry';
@@ -23,7 +23,7 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
23
23
  declarations: [<%= classify(singularizedName) %>ListComponent],
24
24
  imports: [],
25
25
  providers: [
26
- { provide: <%= classify(singularizedName) %>ListFacade, useValue: createODataGridMockFacade(createDataDeleteMockFacade()) },
26
+ { provide: <%= classify(singularizedName) %>ListFacade, useValue: createODataGridMockFacade()) },
27
27
  { provide: <%= classify(singularizedName) %>CrudFacade, useValue: createDataEntryMockFacade() },
28
28
  provideRouter(<%= camelize(singularizedName) %>Routes),
29
29
  provideOidcMockFacade(),
@@ -75,7 +75,10 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
75
75
  test('it should handle DeleteItem', () => {
76
76
  const item = createTest<%= classify(singularizedName) %>();
77
77
  component.deleteItem(item);
78
- expect(listFacade.deleteExistingEntity).toHaveBeenCalledTimes(1);
79
- expect(listFacade.deleteExistingEntity).toHaveBeenCalledWith(item);
78
+ expect(crudFacade.setCurrentEntity).toHaveBeenCalledTimes(1);
79
+ expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith(
80
+ item,
81
+ ModalStates.DELETE,
82
+ );
80
83
  });
81
84
  });
@@ -22,6 +22,7 @@ export class <%= classify(singularizedName) %>ListComponent extends KendoODataBa
22
22
  public readonly <%= camelize(swaggerProperty.name) %>Props = <%= classify(swaggerProperty.propertyTypeName) %>Properties;<% }) %><% swaggerObjectProperties.filter(t=> t.enum).forEach(function(swaggerProperty){ %>
23
23
  public readonly <%= camelize(swaggerProperty.pluralizedPropertyTypeName) %> = <%= camelize(swaggerProperty.singularizedPropertyTypeName) %>Values;<% }) %>
24
24
  public currentItem: I<%= classify(singularizedName) %> | undefined;
25
+ public readonly modalStates = ModalStates;
25
26
 
26
27
  constructor() {
27
28
  super(inject(<%= classify(singularizedName) %>ListFacade), <%= camelize(singularizedName) %>GridState, inject(Router));
@@ -36,7 +37,7 @@ export class <%= classify(singularizedName) %>ListComponent extends KendoODataBa
36
37
  }
37
38
 
38
39
  public deleteItem(item: I<%= classify(singularizedName) %>): void {
39
- this.facade.deleteExistingEntity(item);
40
+ this.crudFacade.setCurrentEntity(item, ModalStates.DELETE);
40
41
  }
41
42
 
42
43
  public detailExpanded(evt: DetailExpandEvent): void {
@@ -5,7 +5,6 @@ import { readFirst } from 'imng-ngrx-utils/testing';
5
5
  import { EffectsModule } from '@ngrx/effects';
6
6
  import { StoreModule, Store } from '@ngrx/store';
7
7
  import { ODataState, createODataPayload, createODataResult, ODataService } from 'imng-kendo-odata';
8
- import { testDeleteCurrentEntity } from 'imng-kendo-data-entry/testing';
9
8
  import { Observable, of } from 'rxjs';
10
9
 
11
10
  import { <%= camelize(pluralizedStoreName) %>Feature, <%= classify(singularizedStoreName) %>ListEffects, <%= classify(singularizedStoreName) %>CrudEffects } from '../+state';
@@ -117,9 +116,5 @@ describe('<%= classify(singularizedName) %>ListFacade', () => {
117
116
  list = await readFirst(facade.gridData$);
118
117
  expect(list?.data.length).toBe(2);
119
118
  });
120
-
121
- test('it should handle DeleteItem', async () => {
122
- await testDeleteCurrentEntity(facade, httpClient);
123
- });
124
119
  });
125
120
  });
@@ -1,6 +1,5 @@
1
1
  import { Injectable, inject } from '@angular/core';
2
2
  import { Store } from '@ngrx/store';
3
- import { IDataDeleteFacade } from 'imng-kendo-data-entry';
4
3
  import { IKendoODataGridFacade } from 'imng-kendo-grid-odata';
5
4
  import { ODataState } from 'imng-kendo-odata';
6
5
 
@@ -8,7 +7,7 @@ import { <%= camelize(pluralizedStoreName) %>Feature, <%= camelize(storeName) %>
8
7
  import { I<%= classify(name) %> } from '<%= modelFolderLocation %>';<% } %>
9
8
 
10
9
  @Injectable()
11
- export class <%= classify(singularizedName) %>ListFacade implements IKendoODataGridFacade<I<%= classify(name) %>>, IDataDeleteFacade<I<%= classify(name) %>> {
10
+ export class <%= classify(singularizedName) %>ListFacade implements IKendoODataGridFacade<I<%= classify(name) %>> {
12
11
  private readonly store = inject(Store);
13
12
 
14
13
  loading$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectLoading);
@@ -23,8 +22,4 @@ export class <%= classify(singularizedName) %>ListFacade implements IKendoODataG
23
22
  public reloadEntities(): void {
24
23
  this.store.dispatch(<%= camelize(storeName) %>ActionTypes.reload<%= classify(pluralizedName) %>Request());
25
24
  }
26
-
27
- public deleteExistingEntity(entity: I<%= classify(name) %>): void {
28
- this.store.dispatch(<%= camelize(storeName) %>ActionTypes.delete<%= classify(name) %>Request(entity));
29
- }
30
25
  }