imng-kendo-schematics 19.178.4 → 19.182.5
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 -4
- package/schematics/imng-crud/files/base-entry.component.ts.template +4 -4
- package/schematics/imng-crud/files/crud.facade.ts.template +17 -6
- package/schematics/imng-crud/files/edit.component.ts.template +0 -4
- package/schematics/imng-list/files/list.component.spec.ts.template +3 -2
- package/schematics/imng-list/files/list.component.ts.template +3 -3
- package/schematics/imng-module/files/+state/__singularizedName@dasherize__.actions.ts.template +2 -2
- package/schematics/imng-module/files/+state/__singularizedName@dasherize__.feature.ts.template +11 -3
- package/schematics/imng-module/files/+state/__singularizedName@dasherize__.selectors.ts.template +0 -17
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
-
import { <%= classify(name) %>CrudFacade } from './crud.facade';
|
|
3
2
|
import { <%= classify(name) %>BaseEntryComponent } from './base-entry.component';
|
|
4
3
|
|
|
5
4
|
@Component({
|
|
@@ -13,9 +12,6 @@ export class <%= classify(name) %>AddComponent extends <%= classify(name) %>Base
|
|
|
13
12
|
public dialogTitle = 'Add <%= classify(name) %>';
|
|
14
13
|
public active$ = this.facade.isNewActive$;
|
|
15
14
|
|
|
16
|
-
constructor(facade: <%= classify(name) %>CrudFacade) {
|
|
17
|
-
super(facade);
|
|
18
|
-
}
|
|
19
15
|
public override initForm(): void {
|
|
20
16
|
super.initForm();
|
|
21
17
|
this.addEditForm.patchValue({});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OnInit, Component } from '@angular/core';
|
|
1
|
+
import { OnInit, Component, inject } from '@angular/core';
|
|
2
2
|
import { FormGroup } from '@angular/forms';
|
|
3
3
|
import { BaseDataEntryComponent } from 'imng-kendo-data-entry';<% if (hasObjects) { %>
|
|
4
4
|
import { BehaviorSubject, map, Observable, switchMap } from 'rxjs';<% } %>
|
|
@@ -18,9 +18,9 @@ export abstract class <%= classify(name) %>BaseEntryComponent extends BaseDataEn
|
|
|
18
18
|
public readonly <%= camelize(swaggerProperty.pluralizedName) %>$ = new BehaviorSubject(<%= camelize(swaggerProperty.singularizedPropertyTypeName) %>Values);<% }) %>
|
|
19
19
|
public addEditForm: FormGroup<I<%= classify(name) %>Form>;
|
|
20
20
|
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
23
|
-
this.<%= camelize(swaggerProperty.pluralizedName) %>$ = facade.<%= camelize(swaggerProperty.pluralizedName) %>$.pipe(
|
|
21
|
+
constructor() {
|
|
22
|
+
super(inject(<%= classify(name) %>CrudFacade));<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
23
|
+
this.<%= camelize(swaggerProperty.pluralizedName) %>$ = this.facade.<%= camelize(swaggerProperty.pluralizedName) %>$.pipe(
|
|
24
24
|
switchMap(<%= camelize(swaggerProperty.pluralizedName) %> => this.<%= camelize(swaggerProperty.name) %>Filter$.pipe(
|
|
25
25
|
map(<%= camelize(swaggerProperty.name) %>Filter => <%= camelize(swaggerProperty.name) %>Filter ? <%= camelize(swaggerProperty.pluralizedName) %>
|
|
26
26
|
.filter(<%= camelize(swaggerProperty.name) %> => (<% swaggerProperty.properties.filter(f => f.name !== 'id' && f.htmlInputType !== 'object' && !f.hidden).forEach(function(swaggerSubProperty, i, arr){%>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Injectable, inject } from '@angular/core';
|
|
2
2
|
import { Store } from '@ngrx/store';
|
|
3
|
-
import { IDataEntryFacade } from 'imng-kendo-data-entry';<% if (hasObjects) { %>
|
|
3
|
+
import { IDataEntryFacade, ModalStates } from 'imng-kendo-data-entry';<% if (hasObjects) { %>
|
|
4
4
|
import { ODataState } from 'imng-kendo-odata';<% } %>
|
|
5
|
-
import { <%= camelize(pluralizedStoreName) %>Feature, <%= camelize(singularizedStoreName) %>
|
|
5
|
+
import { <%= camelize(pluralizedStoreName) %>Feature, <%= camelize(singularizedStoreName) %>ActionTypes } from '../+state';
|
|
6
|
+
import { map } from 'rxjs';
|
|
6
7
|
|
|
7
8
|
@Injectable()
|
|
8
9
|
export class <%= classify(name) %>CrudFacade implements IDataEntryFacade<I<%= classify(name) %>> {
|
|
@@ -10,12 +11,22 @@ export class <%= classify(name) %>CrudFacade implements IDataEntryFacade<I<%= cl
|
|
|
10
11
|
|
|
11
12
|
loading$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectLoading);
|
|
12
13
|
currentEntity$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(name) %>);
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
currentModalState$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.selectCurrentModalState);
|
|
15
|
+
isEditActive$ = this.currentModalState$.pipe(
|
|
16
|
+
map((modalState) => modalState === ModalStates.EDIT),
|
|
17
|
+
);
|
|
18
|
+
isNewActive$ = this.currentModalState$.pipe(
|
|
19
|
+
map((modalState) => modalState === ModalStates.ADD),
|
|
20
|
+
);<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
15
21
|
<%= camelize(swaggerProperty.pluralizedName) %>$ = this.store.select(<%= camelize(pluralizedStoreName) %>Feature.select<%= classify(swaggerProperty.pluralizedName) %>);<% }); %>
|
|
16
22
|
|
|
17
|
-
public setCurrentEntity(item: I<%= classify(name)
|
|
18
|
-
this.store.dispatch(
|
|
23
|
+
public setCurrentEntity(item: I<%= classify(name) %>, modalState: string): void {
|
|
24
|
+
this.store.dispatch(
|
|
25
|
+
<%= camelize(singularizedStoreName) %>ActionTypes.setCurrent<%= classify(name) %>({
|
|
26
|
+
modalState,
|
|
27
|
+
entity: item,
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
19
30
|
}
|
|
20
31
|
|
|
21
32
|
public clearCurrentEntity(): void {
|
|
@@ -2,7 +2,6 @@ import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/
|
|
|
2
2
|
import { formGroupPatcher } from 'imng-kendo-data-entry';
|
|
3
3
|
|
|
4
4
|
import { <%= classify(name) %>BaseEntryComponent } from './base-entry.component';
|
|
5
|
-
import { <%= classify(name) %>CrudFacade } from './crud.facade';
|
|
6
5
|
|
|
7
6
|
@Component({
|
|
8
7
|
selector: '<%= appPrefix %>-<%= dasherize(name) %>-edit',
|
|
@@ -15,9 +14,6 @@ export class <%= classify(name) %>EditComponent extends <%= classify(name) %>Bas
|
|
|
15
14
|
public dialogTitle = 'Edit <%= classify(name) %>';
|
|
16
15
|
public active$ = this.facade.isEditActive$;
|
|
17
16
|
|
|
18
|
-
constructor(facade: <%= classify(name) %>CrudFacade) {
|
|
19
|
-
super(facade);
|
|
20
|
-
}
|
|
21
17
|
public override initForm(): void {
|
|
22
18
|
super.initForm();
|
|
23
19
|
if (this.addEditForm) {
|
|
@@ -4,6 +4,7 @@ import { provideRouter } from '@angular/router';
|
|
|
4
4
|
import { createDataEntryMockFacade, createDataDeleteMockFacade } 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
|
+
import { ModalStates } from 'imng-kendo-data-entry';
|
|
7
8
|
|
|
8
9
|
import { <%= classify(singularizedName) %>ListComponent } from './list.component';
|
|
9
10
|
import { <%= classify(singularizedName) %>ListFacade } from './list.facade';
|
|
@@ -60,14 +61,14 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
|
60
61
|
test('it should handle AddItem', () => {
|
|
61
62
|
component.addItem();
|
|
62
63
|
expect(crudFacade.setCurrentEntity).toHaveBeenCalledTimes(1);
|
|
63
|
-
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith({});
|
|
64
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith({}, ModalStates.ADD);
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
test('it should handle EditItem', () => {
|
|
67
68
|
const item = createTest<%= classify(singularizedName) %>();
|
|
68
69
|
component.editItem(item);
|
|
69
70
|
expect(crudFacade.setCurrentEntity).toHaveBeenCalledTimes(1);
|
|
70
|
-
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith(item);
|
|
71
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith(item, ModalStates.EDIT);
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
test('it should handle DeleteItem', () => {
|
|
@@ -2,6 +2,7 @@ import { Component, ChangeDetectionStrategy, inject } from '@angular/core';
|
|
|
2
2
|
import { Router } from '@angular/router';
|
|
3
3
|
import { DetailExpandEvent } from '@progress/kendo-angular-grid';
|
|
4
4
|
import { KendoODataBasedComponent } from 'imng-kendo-grid-odata';
|
|
5
|
+
import { ModalStates } from 'imng-kendo-data-entry';
|
|
5
6
|
|
|
6
7
|
import { <%= classify(singularizedName) %>ListFacade } from './list.facade';
|
|
7
8
|
import { <%= classify(singularizedName) %>CrudFacade } from '../<%= dasherize(pluralizedName) %>-crud';
|
|
@@ -16,7 +17,6 @@ import { <%= camelize(singularizedName) %>GridState } from './list.grid-state';
|
|
|
16
17
|
})
|
|
17
18
|
export class <%= classify(singularizedName) %>ListComponent extends KendoODataBasedComponent<I<%= classify(singularizedName) %>, <%= classify(singularizedName) %>ListFacade> {
|
|
18
19
|
public readonly crudFacade = inject(<%= classify(singularizedName) %>CrudFacade);
|
|
19
|
-
|
|
20
20
|
public readonly props = <%= classify(singularizedName) %>Properties;<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
21
21
|
public readonly <%= camelize(swaggerProperty.name) %>Props = <%= classify(swaggerProperty.propertyTypeName) %>Properties;<% }) %><% swaggerObjectProperties.filter(t=> t.enum).forEach(function(swaggerProperty){ %>
|
|
22
22
|
public readonly <%= camelize(swaggerProperty.pluralizedPropertyTypeName) %> = <%= camelize(swaggerProperty.singularizedPropertyTypeName) %>Values;<% }) %>
|
|
@@ -27,11 +27,11 @@ export class <%= classify(singularizedName) %>ListComponent extends KendoODataBa
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public addItem(): void {
|
|
30
|
-
this.crudFacade.setCurrentEntity({});
|
|
30
|
+
this.crudFacade.setCurrentEntity({}, ModalStates.ADD);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
public editItem(item: I<%= classify(singularizedName) %>): void {
|
|
34
|
-
this.crudFacade.setCurrentEntity(item);
|
|
34
|
+
this.crudFacade.setCurrentEntity(item, ModalStates.EDIT);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
public deleteItem(item: I<%= classify(singularizedName) %>): void {
|
package/schematics/imng-module/files/+state/__singularizedName@dasherize__.actions.ts.template
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAction } from '@ngrx/store';
|
|
2
2
|
import { ODataResult, ODataState } from 'imng-kendo-odata';
|
|
3
|
-
import { createPayloadAction } from 'imng-ngrx-utils';
|
|
3
|
+
import { createModalAction, createPayloadAction } from 'imng-ngrx-utils';
|
|
4
4
|
<% if (openApiJsonUrl || openApiJsonFileName) { %>
|
|
5
5
|
export const load<%= classify(pluralizedName) %>Request = createPayloadAction<ODataState>(
|
|
6
6
|
'[<%= classify(pluralizedName) %>] Load <%= classify(pluralizedName) %> Request');
|
|
@@ -12,7 +12,7 @@ export const reload<%= classify(pluralizedName) %>Success = createPayloadAction<
|
|
|
12
12
|
'[<%= classify(pluralizedName) %>] Reload <%= classify(pluralizedName) %> Success');
|
|
13
13
|
|
|
14
14
|
export const clearCurrent<%= classify(name) %> = createAction('[<%= classify(pluralizedName) %>] Clear Current <%= classify(name) %>');
|
|
15
|
-
export const setCurrent<%= classify(name) %> =
|
|
15
|
+
export const setCurrent<%= classify(name) %> = createModalAction<I<%= classify(name) %>>('[<%= classify(pluralizedName) %>] Set Current <%= classify(name) %>');
|
|
16
16
|
export const save<%= classify(name) %>Request = createPayloadAction<I<%= classify(name) %>>('[<%= classify(pluralizedName) %>] Save <%= classify(name) %> Request');
|
|
17
17
|
export const update<%= classify(name) %>Request = createPayloadAction<I<%= classify(name) %>>('[<%= classify(pluralizedName) %>] Update <%= classify(name) %> Request');
|
|
18
18
|
export const delete<%= classify(name) %>Request = createPayloadAction<I<%= classify(name) %>>('[<%= classify(pluralizedName) %>] Delete <%= classify(name) %> Request');
|
package/schematics/imng-module/files/+state/__singularizedName@dasherize__.feature.ts.template
CHANGED
|
@@ -7,12 +7,14 @@ export const <%= underscore(pluralizedName).toUpperCase() %>_FEATURE_KEY = '<%=
|
|
|
7
7
|
|
|
8
8
|
export interface State extends KendoODataGridState<I<%= classify(singularizedName) %>> {
|
|
9
9
|
current<%= classify(singularizedName) %>: I<%= classify(singularizedName) %> | undefined;<% if(openApiJsonUrl || openApiJsonFileName){ swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
10
|
+
currentModalState: string | undefined;
|
|
10
11
|
<%= camelize(swaggerProperty.pluralizedName) %>: I<%= classify(swaggerProperty.propertyTypeName) %>[];<% })} %>
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const initialState: State = {
|
|
14
15
|
...createKendoODataGridInitialState(),
|
|
15
|
-
current<%= classify(singularizedName) %>: undefined
|
|
16
|
+
current<%= classify(singularizedName) %>: undefined,
|
|
17
|
+
currentModalState: undefined,<% if(openApiJsonUrl || openApiJsonFileName){ swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
16
18
|
<%= camelize(swaggerProperty.pluralizedName) %>: [],<% })} %>
|
|
17
19
|
loading: true,
|
|
18
20
|
};
|
|
@@ -40,9 +42,15 @@ export const <%= camelize(pluralizedStoreName) %>Feature = createFeature({
|
|
|
40
42
|
error: null, })),
|
|
41
43
|
on(<%= camelize(singularizedName) %>ActionTypes.setCurrent<%= classify(singularizedName) %>,
|
|
42
44
|
(state, { payload }) : State =>
|
|
43
|
-
({ ...state,
|
|
45
|
+
({ ...state,
|
|
46
|
+
currentModalState: payload.modalState,
|
|
47
|
+
current<%= classify(singularizedName) %>: payload.entity })),
|
|
44
48
|
on(<%= camelize(singularizedName) %>ActionTypes.clearCurrent<%= classify(singularizedName) %>,
|
|
45
|
-
(state) : State => ({
|
|
49
|
+
(state) : State => ({
|
|
50
|
+
...state,
|
|
51
|
+
current<%= classify(singularizedName) %>: undefined,
|
|
52
|
+
currentModalState: undefined,
|
|
53
|
+
})),
|
|
46
54
|
on(<%= camelize(singularizedName) %>ActionTypes.save<%= classify(singularizedName) %>Request,
|
|
47
55
|
<%= camelize(singularizedName) %>ActionTypes.update<%= classify(singularizedName) %>Request,
|
|
48
56
|
<%= camelize(singularizedName) %>ActionTypes.delete<%= classify(singularizedName) %>Request,
|
package/schematics/imng-module/files/+state/__singularizedName@dasherize__.selectors.ts.template
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createSelector } from '@ngrx/store';
|
|
2
|
-
import { <%= camelize(pluralizedStoreName) %>Feature } from './<%= dasherize(singularizedName) %>.feature';
|
|
3
|
-
import { isTruthy } from 'imng-ngrx-utils';
|
|
4
|
-
<% if (openApiJsonUrl || openApiJsonFileName) { %>
|
|
5
|
-
const selectIsEdit<%= classify(name) %>Active = createSelector(
|
|
6
|
-
<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(name) %>,
|
|
7
|
-
(entity) => isTruthy(entity?.id));
|
|
8
|
-
const selectIsNew<%= classify(name) %>Active = createSelector(
|
|
9
|
-
<%= camelize(pluralizedStoreName) %>Feature.selectCurrent<%= classify(name) %>,
|
|
10
|
-
(entity) => isTruthy(entity) && !isTruthy(entity?.id));
|
|
11
|
-
export const <%= camelize(singularizedName) %>Selectors = {
|
|
12
|
-
selectIsEdit<%= classify(name) %>Active,
|
|
13
|
-
selectIsNew<%= classify(name) %>Active,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
<% } else { %>
|
|
17
|
-
export const <%= camelize(singularizedName) %>Selectors = {};<% } %>
|