imng-kendo-schematics 19.231.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 +1 -1
- package/schematics/imng-crud/files/add.component.ts.template +0 -1
- package/schematics/imng-crud/files/crud.facade.spec.ts.template +15 -11
- package/schematics/imng-crud/files/crud.facade.ts.template +7 -5
- package/schematics/imng-crud/files/edit.component.ts.template +1 -4
- package/schematics/imng-list/files/list.component.html.template +16 -6
- package/schematics/imng-list/files/list.component.spec.ts.template +7 -4
- package/schematics/imng-list/files/list.component.ts.template +2 -1
- package/schematics/imng-list/files/list.facade.spec.ts.template +0 -5
- package/schematics/imng-list/files/list.facade.ts.template +1 -6
package/package.json
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
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
|
|
63
|
-
expect(
|
|
63
|
+
let currentModalState = await readFirst(facade.currentModalState$);
|
|
64
|
+
expect(currentModalState).toBeUndefined();
|
|
64
65
|
|
|
65
66
|
facade.clearCurrentEntity();
|
|
66
|
-
|
|
67
|
+
currentModalState = await readFirst(facade.currentModalState$);
|
|
67
68
|
|
|
68
|
-
expect(
|
|
69
|
+
expect(currentModalState).toBeUndefined();
|
|
69
70
|
expect(await readFirst(store)).toMatchSnapshot();
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
test('
|
|
73
|
-
|
|
74
|
-
test('
|
|
75
|
-
|
|
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))
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
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(
|
|
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(
|
|
79
|
-
expect(
|
|
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.
|
|
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)
|
|
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
|
}
|