ngrx-entity-crud 12.0.6-beta.2

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.
Files changed (184) hide show
  1. package/README.md +259 -0
  2. package/bundles/ngrx-entity-crud.umd.js +1829 -0
  3. package/bundles/ngrx-entity-crud.umd.js.map +1 -0
  4. package/esm2015/lib/actions.js +88 -0
  5. package/esm2015/lib/base-crud-gql.service.js +71 -0
  6. package/esm2015/lib/base-crud.service.js +136 -0
  7. package/esm2015/lib/create_adapter.js +14 -0
  8. package/esm2015/lib/effect.js +467 -0
  9. package/esm2015/lib/entity_state.js +23 -0
  10. package/esm2015/lib/ibase-crud-service.js +2 -0
  11. package/esm2015/lib/j-ngrx-filter.js +133 -0
  12. package/esm2015/lib/models.js +17 -0
  13. package/esm2015/lib/reducer.js +353 -0
  14. package/esm2015/lib/state_selectors.js +56 -0
  15. package/esm2015/lib/utils.js +19 -0
  16. package/esm2015/ngrx-entity-crud.js +5 -0
  17. package/esm2015/public-api.js +7 -0
  18. package/fesm2015/ngrx-entity-crud.js +1367 -0
  19. package/fesm2015/ngrx-entity-crud.js.map +1 -0
  20. package/lib/actions.d.ts +5 -0
  21. package/lib/actions.d.ts.map +1 -0
  22. package/lib/base-crud-gql.service.d.ts +19 -0
  23. package/lib/base-crud-gql.service.d.ts.map +1 -0
  24. package/lib/base-crud.service.d.ts +34 -0
  25. package/lib/base-crud.service.d.ts.map +1 -0
  26. package/lib/create_adapter.d.ts +6 -0
  27. package/lib/create_adapter.d.ts.map +1 -0
  28. package/lib/effect.d.ts +132 -0
  29. package/lib/effect.d.ts.map +1 -0
  30. package/lib/entity_state.d.ts +9 -0
  31. package/lib/entity_state.d.ts.map +1 -0
  32. package/lib/ibase-crud-service.d.ts +13 -0
  33. package/lib/ibase-crud-service.d.ts.map +1 -0
  34. package/lib/j-ngrx-filter.d.ts +14 -0
  35. package/lib/j-ngrx-filter.d.ts.map +1 -0
  36. package/lib/models.d.ts +494 -0
  37. package/lib/models.d.ts.map +1 -0
  38. package/lib/reducer.d.ts +11 -0
  39. package/lib/reducer.d.ts.map +1 -0
  40. package/lib/state_selectors.d.ts +5 -0
  41. package/lib/state_selectors.d.ts.map +1 -0
  42. package/lib/utils.d.ts +8 -0
  43. package/lib/utils.d.ts.map +1 -0
  44. package/ngrx-entity-crud.d.ts +5 -0
  45. package/ngrx-entity-crud.d.ts.map +1 -0
  46. package/ngrx-entity-crud.metadata.json +1 -0
  47. package/package.json +41 -0
  48. package/public-api.d.ts +7 -0
  49. package/public-api.d.ts.map +1 -0
  50. package/schematics/auth/files/model/auth.ts +17 -0
  51. package/schematics/auth/files/store/auth-store/actions.ts +30 -0
  52. package/schematics/auth/files/store/auth-store/auth-mock.service.ts +95 -0
  53. package/schematics/auth/files/store/auth-store/auth-store.module.ts +34 -0
  54. package/schematics/auth/files/store/auth-store/auth.guard.ts +44 -0
  55. package/schematics/auth/files/store/auth-store/auth.service.ts +28 -0
  56. package/schematics/auth/files/store/auth-store/conf.ts +2 -0
  57. package/schematics/auth/files/store/auth-store/effects.ts +53 -0
  58. package/schematics/auth/files/store/auth-store/index.d.ts +13 -0
  59. package/schematics/auth/files/store/auth-store/index.ts +13 -0
  60. package/schematics/auth/files/store/auth-store/names.ts +3 -0
  61. package/schematics/auth/files/store/auth-store/reducer.ts +16 -0
  62. package/schematics/auth/files/store/auth-store/selectors.ts +51 -0
  63. package/schematics/auth/files/store/auth-store/state.ts +16 -0
  64. package/schematics/auth/files/views/login/components/logout-button/logout-button.component.ts +49 -0
  65. package/schematics/auth/files/views/login/login-main/login-main.component.html +25 -0
  66. package/schematics/auth/files/views/login/login-main/login-main.component.ts +57 -0
  67. package/schematics/auth/files/views/login/login-routing.module.ts +30 -0
  68. package/schematics/auth/files/views/login/login.module.ts +30 -0
  69. package/schematics/auth/index.d.ts +2 -0
  70. package/schematics/auth/index.js +77 -0
  71. package/schematics/auth/index.js.map +1 -0
  72. package/schematics/auth/schema.json +21 -0
  73. package/schematics/auth0/files/store/auth-store/actions.ts +21 -0
  74. package/schematics/auth0/files/store/auth-store/auth-store.module.ts +32 -0
  75. package/schematics/auth0/files/store/auth-store/auth.guard.ts +44 -0
  76. package/schematics/auth0/files/store/auth-store/authentication.service.ts +32 -0
  77. package/schematics/auth0/files/store/auth-store/conf.ts +2 -0
  78. package/schematics/auth0/files/store/auth-store/effects.ts +59 -0
  79. package/schematics/auth0/files/store/auth-store/index.d.ts +13 -0
  80. package/schematics/auth0/files/store/auth-store/index.ts +13 -0
  81. package/schematics/auth0/files/store/auth-store/login.component.ts +75 -0
  82. package/schematics/auth0/files/store/auth-store/names.ts +3 -0
  83. package/schematics/auth0/files/store/auth-store/profile.ts +12 -0
  84. package/schematics/auth0/files/store/auth-store/reducer.ts +23 -0
  85. package/schematics/auth0/files/store/auth-store/selectors.ts +24 -0
  86. package/schematics/auth0/files/store/auth-store/state.ts +11 -0
  87. package/schematics/auth0/index.d.ts +2 -0
  88. package/schematics/auth0/index.js +67 -0
  89. package/schematics/auth0/index.js.map +1 -0
  90. package/schematics/auth0/schema.json +21 -0
  91. package/schematics/collection.json +30 -0
  92. package/schematics/my-utility.d.ts +58 -0
  93. package/schematics/my-utility.js +257 -0
  94. package/schematics/my-utility.js.map +1 -0
  95. package/schematics/ng-add/files/root-store/index.d.ts +8 -0
  96. package/schematics/ng-add/files/root-store/index.ts +8 -0
  97. package/schematics/ng-add/files/root-store/root-reducer.ts +11 -0
  98. package/schematics/ng-add/files/root-store/root-store.module.ts +29 -0
  99. package/schematics/ng-add/files/root-store/router-store/actions.ts +27 -0
  100. package/schematics/ng-add/files/root-store/router-store/effects.ts +65 -0
  101. package/schematics/ng-add/files/root-store/router-store/index.d.ts +11 -0
  102. package/schematics/ng-add/files/root-store/router-store/index.ts +11 -0
  103. package/schematics/ng-add/files/root-store/router-store/pop-up-base.component.ts +83 -0
  104. package/schematics/ng-add/files/root-store/router-store/pop-up-base.module.ts +24 -0
  105. package/schematics/ng-add/files/root-store/router-store/reducer.ts +31 -0
  106. package/schematics/ng-add/files/root-store/router-store/router-store.module.ts +30 -0
  107. package/schematics/ng-add/files/root-store/router-store/selectors.ts +63 -0
  108. package/schematics/ng-add/files/root-store/router-store/state.ts +18 -0
  109. package/schematics/ng-add/files/root-store/selectors.ts +20 -0
  110. package/schematics/ng-add/files/root-store/slide-menu-store/actions.ts +11 -0
  111. package/schematics/ng-add/files/root-store/slide-menu-store/effects.ts +10 -0
  112. package/schematics/ng-add/files/root-store/slide-menu-store/index.d.ts +13 -0
  113. package/schematics/ng-add/files/root-store/slide-menu-store/index.ts +13 -0
  114. package/schematics/ng-add/files/root-store/slide-menu-store/names.ts +3 -0
  115. package/schematics/ng-add/files/root-store/slide-menu-store/operators.ts +24 -0
  116. package/schematics/ng-add/files/root-store/slide-menu-store/reducer.ts +8 -0
  117. package/schematics/ng-add/files/root-store/slide-menu-store/selectors.ts +41 -0
  118. package/schematics/ng-add/files/root-store/slide-menu-store/slide-menu-store.module.ts +27 -0
  119. package/schematics/ng-add/files/root-store/slide-menu-store/state.ts +14 -0
  120. package/schematics/ng-add/files/root-store/state.ts +5 -0
  121. package/schematics/ng-add/index.d.ts +2 -0
  122. package/schematics/ng-add/index.js +78 -0
  123. package/schematics/ng-add/index.js.map +1 -0
  124. package/schematics/ng-add/schema.json +22 -0
  125. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +52 -0
  126. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +57 -0
  127. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +7 -0
  128. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +50 -0
  129. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +15 -0
  130. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +23 -0
  131. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  132. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__.module.ts +33 -0
  133. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +1 -0
  134. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +16 -0
  135. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +1 -0
  136. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +27 -0
  137. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +1 -0
  138. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +18 -0
  139. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  140. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__.module.ts +26 -0
  141. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +38 -0
  142. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +50 -0
  143. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +30 -0
  144. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +101 -0
  145. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +12 -0
  146. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +21 -0
  147. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +37 -0
  148. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__.module.ts +49 -0
  149. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-create-many-test-__clazz@dasherize__.component.ts +46 -0
  150. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-delete-__clazz@dasherize__.component.ts +35 -0
  151. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-edit-many-test-__clazz@dasherize__.component.ts +45 -0
  152. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-new-__clazz@dasherize__.component.ts +45 -0
  153. package/schematics/section/index.d.ts +2 -0
  154. package/schematics/section/index.js +56 -0
  155. package/schematics/section/index.js.map +1 -0
  156. package/schematics/section/schema.json +39 -0
  157. package/schematics/store/files/base-model/__clazz@dasherize__.ts +8 -0
  158. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  159. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +9 -0
  160. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +11 -0
  161. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  162. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +8 -0
  163. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +18 -0
  164. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +6 -0
  165. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.d.ts +13 -0
  166. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.ts +13 -0
  167. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.criteria.ts +39 -0
  168. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.graphql +34 -0
  169. package/schematics/store/files/crud-model/__clazz@dasherize__.ts +8 -0
  170. package/schematics/store/files/crud-service/__clazz@dasherize__.service.ts +11 -0
  171. package/schematics/store/files/crud-service-graphql/__clazz@dasherize__.service.ts +16 -0
  172. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  173. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +55 -0
  174. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +90 -0
  175. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  176. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +103 -0
  177. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +26 -0
  178. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +11 -0
  179. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.d.ts +15 -0
  180. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.ts +15 -0
  181. package/schematics/store/index.d.ts +2 -0
  182. package/schematics/store/index.js +100 -0
  183. package/schematics/store/index.js.map +1 -0
  184. package/schematics/store/schema.json +45 -0
@@ -0,0 +1,30 @@
1
+ import {InjectionToken, NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {EffectsModule} from '@ngrx/effects';
4
+ import {RouterEffects} from './effects';
5
+ import {State} from './state';
6
+ import {ActionReducer, StoreModule} from '@ngrx/store';
7
+ import {routerReducer, StoreRouterConnectingModule} from '@ngrx/router-store';
8
+ import {featureReducer} from './reducer';
9
+
10
+ export const INJECTION_TOKEN = new InjectionToken<ActionReducer<State>>(`router-store Reducers`);
11
+
12
+ @NgModule({
13
+ imports: [
14
+ CommonModule,
15
+ StoreModule.forFeature('router', INJECTION_TOKEN),
16
+ EffectsModule.forFeature([RouterEffects]),
17
+ StoreRouterConnectingModule.forRoot({stateKey: 'router'})
18
+ ],
19
+ declarations: [],
20
+ providers: [
21
+ RouterEffects,
22
+ {
23
+ provide: INJECTION_TOKEN,
24
+ useFactory: (): ActionReducer<State> => featureReducer
25
+ },
26
+ ]
27
+
28
+ })
29
+ export class RouterStoreModule {
30
+ }
@@ -0,0 +1,63 @@
1
+ import {createFeatureSelector, createSelector, MemoizedSelector} from '@ngrx/store';
2
+ import * as fromRouter from '@ngrx/router-store';
3
+ import {Data, NavigationExtras, Params} from '@angular/router';
4
+ import {State} from './state';
5
+ import {evalData} from '@core/utils/j-utils';
6
+
7
+ export const selectRouterState: MemoizedSelector<object, State> = createFeatureSelector<State>('router');
8
+ const getOptions = (state: State): any => state.state.root.firstChild.params.options;
9
+ const getHasPopUp = (state: State): any => evalData<string>(() => state.state.url, '').indexOf('//popUp') !== -1;
10
+ const getPrimary = (state: State): any => evalData(() => state.primary, null);
11
+ const getPopUp = (state: State): any => evalData(() => state.popUp, null);
12
+
13
+ export const selectOptions: MemoizedSelector<object, any> = createSelector(
14
+ selectRouterState,
15
+ getOptions
16
+ );
17
+
18
+ export const selectPrimary: MemoizedSelector<object, any> = createSelector(
19
+ selectRouterState,
20
+ getPrimary
21
+ );
22
+
23
+ export const selectPopUp: MemoizedSelector<object, any> = createSelector(
24
+ selectRouterState,
25
+ getPopUp
26
+ );
27
+
28
+ export const hasPopUp: MemoizedSelector<object, NavigationExtras> = createSelector(
29
+ selectRouterState,
30
+ getHasPopUp
31
+ );
32
+
33
+ export const {
34
+ selectQueryParams, // select the current route query params
35
+ selectQueryParam, // factory function to select a query param
36
+ selectRouteParams, // select the current route params
37
+ selectRouteParam, // factory function to select a route param
38
+ selectRouteData, // select the current route data
39
+ selectUrl, // select the current url
40
+ } = fromRouter.getSelectors(selectRouterState);
41
+
42
+ export const all: MemoizedSelector<object, RuoteData> = createSelector(
43
+ selectQueryParams,
44
+ selectRouteParams,
45
+ selectRouteData,
46
+ selectUrl,
47
+ (selectQueryParamsA, selectRouteParamsA, selectRouteDataA, selectUrlA) => {
48
+ return {
49
+ selectQueryParams: selectQueryParamsA,
50
+ selectRouteParams: selectRouteParamsA,
51
+ selectRouteData: selectRouteDataA,
52
+ selectUrl: selectUrlA
53
+ };
54
+ }
55
+ );
56
+
57
+ export interface RuoteData {
58
+ selectQueryParams: Params;
59
+ selectRouteParams: Params;
60
+ selectRouteData: Data;
61
+ selectUrl: string;
62
+ }
63
+
@@ -0,0 +1,18 @@
1
+ import {RouterReducerState, SerializedRouterStateSnapshot} from '@ngrx/router-store';
2
+ import {NavigationExtras} from '@angular/router';
3
+ import {PopUpData} from '@root-store/router-store/pop-up-base.component';
4
+
5
+ export interface State extends RouterReducerState<SerializedRouterStateSnapshot> {
6
+ extras: NavigationExtras;
7
+ primary: any;
8
+ popUp: PopUpData<any>;
9
+ }
10
+
11
+ export const initialState: State = {
12
+ state: null,
13
+ navigationId: null,
14
+ extras: null,
15
+ primary: null,
16
+ popUp: null,
17
+ };
18
+
@@ -0,0 +1,20 @@
1
+ import {createSelectorFactory, defaultMemoize} from '@ngrx/store';
2
+
3
+ const customMemoizer = (aFn) => defaultMemoize(aFn, (a: any, b: any) => a === b);
4
+
5
+ export const selectError =
6
+ createSelectorFactory(customMemoizer)(
7
+ (...args: string[]) => {
8
+ console.log('selectError.args', args);
9
+ return args.join('');
10
+ }
11
+ );
12
+
13
+ export const selectIsLoading =
14
+ createSelectorFactory(customMemoizer)(
15
+ (...args: boolean[]) => {
16
+ console.log('selectIsLoading.args', args);
17
+ return args.find((value => value));
18
+ }
19
+ );
20
+
@@ -0,0 +1,11 @@
1
+ import {SlideMenuItem} from '@models/vo/slide-menu-item';
2
+ import {createAction, props} from '@ngrx/store';
3
+
4
+
5
+ export enum ActionTypes {
6
+ SELECT = '[SlideMenu] Select',
7
+ OPEN = '[SlideMenu] Open',
8
+ }
9
+
10
+ export const Open = createAction(ActionTypes.OPEN, props<{ open: boolean }>());
11
+ export const Select = createAction(ActionTypes.SELECT, props<{ item: SlideMenuItem }>());
@@ -0,0 +1,10 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {Actions} from '@ngrx/effects';
3
+
4
+ @Injectable()
5
+ export class SlideMenuStoreEffects {
6
+
7
+ constructor(private readonly actions$: Actions) {
8
+ }
9
+
10
+ }
@@ -0,0 +1,13 @@
1
+ import * as SlideMenuStoreActions from './actions';
2
+ import * as SlideMenuStoreSelectors from './selectors';
3
+ import * as SlideMenuStoreState from './state';
4
+
5
+ export {
6
+ SlideMenuStoreModule
7
+ } from './slide-menu-store.module';
8
+
9
+ export {
10
+ SlideMenuStoreActions,
11
+ SlideMenuStoreSelectors,
12
+ SlideMenuStoreState
13
+ };
@@ -0,0 +1,13 @@
1
+ import * as SlideMenuStoreActions from './actions';
2
+ import * as SlideMenuStoreSelectors from './selectors';
3
+ import * as SlideMenuStoreState from './state';
4
+
5
+ export {
6
+ SlideMenuStoreModule
7
+ } from './slide-menu-store.module';
8
+
9
+ export {
10
+ SlideMenuStoreActions,
11
+ SlideMenuStoreSelectors,
12
+ SlideMenuStoreState
13
+ };
@@ -0,0 +1,3 @@
1
+ export class Names {
2
+ static NAME = 'slide_menu';
3
+ }
@@ -0,0 +1,24 @@
1
+ import {MenuItem} from 'primeng/api';
2
+ import {map} from 'rxjs/operators';
3
+
4
+ export const menuItemsDecoratorFn: (itemsA: MenuItem[], store$) => MenuItem[] = (itemsA: MenuItem[], store$) => {
5
+ return itemsA.map(value => {
6
+ const result: any = {...value};
7
+ if (!!result.command) {
8
+ result.store$ = store$;
9
+ }
10
+ if (!!result.items) {
11
+ result.items = menuItemsDecoratorFn(result.items, store$);
12
+ }
13
+ return result;
14
+ }
15
+ );
16
+ };
17
+
18
+ export const menuItemsDecorator = (store$: any) => {
19
+ return input$ => input$.pipe(
20
+ map((items: MenuItem[]) => {
21
+ return menuItemsDecoratorFn(items, store$);
22
+ })
23
+ );
24
+ };
@@ -0,0 +1,8 @@
1
+ import {initialState, State} from './state';
2
+ import * as actions from './actions';
3
+ import {createReducer, on} from '@ngrx/store';
4
+
5
+ export const featureReducer = createReducer<State>(initialState,
6
+ on(actions.Open, (state, {open}) => ({...state, ...{open}})),
7
+ on(actions.Select, (state, {item}) => ({...state, ...{item}})),
8
+ );
@@ -0,0 +1,41 @@
1
+ import {createFeatureSelector, createSelector, MemoizedSelector} from '@ngrx/store';
2
+
3
+ import {State} from './state';
4
+ import {Names} from './names';
5
+ import {SlideMenuItem} from '@models/vo/slide-menu-item';
6
+ import {MenuItem} from 'primeng/api';
7
+
8
+ const getOpen = (state: State): boolean => state.open;
9
+ const getItem = (state: State): SlideMenuItem => state.item;
10
+ const getItems = (state: State): MenuItem[] => state.items;
11
+ const getBreadcrumb = (value: SlideMenuItem): string[] => value.breadcrumb;
12
+
13
+ export const selectState: MemoizedSelector<object, State> = createFeatureSelector<State>(Names.NAME);
14
+
15
+ export const selectItems: MemoizedSelector<object, MenuItem[]> = createSelector(
16
+ selectState,
17
+ getItems
18
+ );
19
+
20
+ export const selectItem: MemoizedSelector<object, SlideMenuItem> = createSelector(
21
+ selectState,
22
+ getItem
23
+ );
24
+
25
+
26
+ export const selectOpen: MemoizedSelector<object, boolean> = createSelector(
27
+ selectState,
28
+ getOpen
29
+ );
30
+
31
+ export const selectBreadcrumb: MemoizedSelector<object, string[]> = createSelector(
32
+ selectItem,
33
+ getBreadcrumb
34
+ );
35
+
36
+ export const selectBreadcrumbRenderized: MemoizedSelector<object, string> = createSelector(
37
+ selectBreadcrumb,
38
+ (values: string[]): string => {
39
+ return values.join(' > ');
40
+ }
41
+ );
@@ -0,0 +1,27 @@
1
+ import {InjectionToken, NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {ActionReducer, StoreModule} from '@ngrx/store';
4
+ import {Names} from './names';
5
+ import {State} from './state';
6
+ import {EffectsModule} from '@ngrx/effects';
7
+ import {SlideMenuStoreEffects} from './effects';
8
+ import {featureReducer} from './reducer';
9
+
10
+ export const CLIENT_TOKEN = new InjectionToken<ActionReducer<State>>(Names.NAME + ' Reducers');
11
+
12
+ @NgModule({
13
+ imports: [
14
+ CommonModule,
15
+ StoreModule.forFeature(Names.NAME, CLIENT_TOKEN),
16
+ EffectsModule.forFeature([SlideMenuStoreEffects])
17
+ ],
18
+ declarations: [],
19
+ providers: [SlideMenuStoreEffects,
20
+ {
21
+ provide: CLIENT_TOKEN,
22
+ useFactory: (): ActionReducer<State> => featureReducer
23
+ }
24
+ ]
25
+ })
26
+ export class SlideMenuStoreModule {
27
+ }
@@ -0,0 +1,14 @@
1
+ import {SlideMenuItem} from '@models/vo/slide-menu-item';
2
+ import {MenuItem} from 'primeng/api';
3
+
4
+ export interface State {
5
+ open: boolean;
6
+ item: SlideMenuItem;
7
+ items: MenuItem[];
8
+ }
9
+
10
+ export const initialState: State = {
11
+ open: false,
12
+ item: {breadcrumb: [], data: null},
13
+ items: []
14
+ };
@@ -0,0 +1,5 @@
1
+ import {SlideMenuStoreState} from '@root-store/slide-menu-store';
2
+
3
+ export interface State {
4
+ slide_menu: SlideMenuStoreState.State;
5
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export declare function ngAdd(options: any): Rule;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const my_utility_1 = require("../my-utility");
6
+ // Just return the tree
7
+ function ngAdd(options) {
8
+ return (tree, context) => {
9
+ console.log('makeStore(options: CrudStore): Rule');
10
+ console.log('context', context);
11
+ const workspaceConfig = tree.read('/angular.json');
12
+ if (!workspaceConfig) {
13
+ throw new schematics_1.SchematicsException('Could not find Angular workspace configuration');
14
+ }
15
+ // convert workspace to string
16
+ const workspaceContent = workspaceConfig.toString();
17
+ // parse workspace string into JSON object
18
+ console.log('1');
19
+ const workspace = JSON.parse(workspaceContent);
20
+ if (!options.project) {
21
+ options.project = workspace.defaultProject;
22
+ }
23
+ console.log('2');
24
+ let pathApp = 'src/app';
25
+ let pathStore = 'src/app/root-store';
26
+ let pathView = 'src/app/main/views';
27
+ let pathService = 'src/app/main/services';
28
+ let pathVo = 'src/app/main/models/vo/';
29
+ const conf = tree.read('/ngrx-entity-crud.conf.json');
30
+ if (conf) {
31
+ console.log('3');
32
+ const confData = JSON.parse(conf.toString());
33
+ pathView = confData.pathView;
34
+ pathStore = confData.pathStore;
35
+ pathApp = confData.pathApp;
36
+ pathService = confData.pathService;
37
+ pathVo = confData.pathVo;
38
+ }
39
+ console.log('pathView', pathView);
40
+ console.log('pathStore', pathStore);
41
+ console.log('pathApp', pathApp);
42
+ console.log('pathService', pathService);
43
+ console.log('pathVo', pathVo);
44
+ /* const genericRules: Rule[] = [
45
+ addExport(options, normalize(`${pathStore}/index.ts`)),
46
+ addExport(options, normalize(`${pathStore}/index.d.ts`)),
47
+ ];*/
48
+ /* const crudRules: Rule[] = [
49
+ addImport(normalize(`${pathStore}/state.ts`), `import {${options.clazz}StoreState} from '@root-store/${strings.dasherize(options.clazz)}-store';`),
50
+ updateState(`${strings.underscore(options.name)}:${options.clazz}StoreState.State;`, normalize(`${pathStore}/state.ts`)),
51
+ addImport(normalize(`${pathStore}/selectors.ts`), `import {${options.clazz}StoreSelectors} from '@root-store/${strings.dasherize(options.clazz)}-store';`),
52
+ addRootSelector(options, normalize(`${pathStore}/selectors.ts`)),
53
+ render(options, './files/crud-store', pathStore),
54
+ render(options, './files/crud-service', pathService),
55
+ render(options, './files/crud-model', pathVo),
56
+ addDeclarationToNgModule({
57
+ module: `${pathStore}/root-store.module.ts`,
58
+ name: `${options.clazz}Store`,
59
+ path: `@root-store/${strings.dasherize(options.clazz)}-store`
60
+ })
61
+ ];*/
62
+ // updateTsConfigSelector()
63
+ const baseRules = [
64
+ // addImport(normalize(`${pathStore}/state.ts`), `import {${options.clazz}} from '@models/vo/${strings.dasherize(options.clazz)}';`),
65
+ // updateState(`${strings.underscore(options.name)}:${options.clazz};`, normalize(`${pathStore}/state.ts`)),
66
+ my_utility_1.render(options, './files', pathStore),
67
+ my_utility_1.addDeclarationToNgModule({
68
+ module: `${pathApp}/app.module.ts`,
69
+ name: `RootStore`,
70
+ path: `./root-store/root-store`
71
+ }),
72
+ my_utility_1.updateTsConfigSelector()
73
+ ];
74
+ return schematics_1.chain(baseRules);
75
+ };
76
+ }
77
+ exports.ngAdd = ngAdd;
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngrx-entity-crud/schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoG;AACpG,8CAAuF;AAEvF,uBAAuB;AACvB,SAAgB,KAAK,CAAC,OAAY;IAChC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,EAAE;YACpB,MAAM,IAAI,gCAAmB,CAAC,gDAAgD,CAAC,CAAC;SACjF;QAED,8BAA8B;QAC9B,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;QAEpD,0CAA0C;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC;SAC5C;QACL,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,IAAI,OAAO,GAAW,SAAS,CAAC;QAChC,IAAI,SAAS,GAAW,oBAAoB,CAAC;QAC7C,IAAI,QAAQ,GAAW,oBAAoB,CAAC;QAC5C,IAAI,WAAW,GAAW,uBAAuB,CAAC;QAClD,IAAI,MAAM,GAAW,yBAAyB,CAAC;QAE/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QACtD,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7C,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YAC7B,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;YAC/B,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC3B,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;YACnC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;SAC1B;QAED,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9B;;;gBAGQ;QACR;;;;;;;;;;;;;gBAaQ;QAER,2BAA2B;QAC3B,MAAM,SAAS,GAAW;YACxB,qIAAqI;YACrI,4GAA4G;YAC5G,mBAAM,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;YACrC,qCAAwB,CAAC;gBACvB,MAAM,EAAE,GAAG,OAAO,gBAAgB;gBAClC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC;YACF,mCAAsB,EAAE;SACzB,CAAC;QAEF,OAAO,kBAAK,CAAC,SAAS,CAAC,CAAC;IAE1B,CAAC,CAAC;AACJ,CAAC;AA7ED,sBA6EC"}
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "id": "ng add",
4
+ "title": "ng add",
5
+ "type": "object",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "format": "path",
10
+ "description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
11
+ "visible": false
12
+ },
13
+ "project": {
14
+ "type": "string",
15
+ "description": "The name of the project.",
16
+ "$default": {
17
+ "$source": "projectName"
18
+ }
19
+ }
20
+ },
21
+ "required": []
22
+ }
@@ -0,0 +1,52 @@
1
+ <ion-header>
2
+ <ion-toolbar>
3
+ <ion-buttons slot="start">
4
+ <ion-back-button></ion-back-button>
5
+ </ion-buttons>
6
+ <ion-title>
7
+ Edit
8
+ </ion-title>
9
+ </ion-toolbar>
10
+ </ion-header>
11
+ <ion-content fullscreen>
12
+ <ion-card>
13
+ <ion-title>
14
+ Form
15
+ </ion-title>
16
+ <ion-card-content>
17
+ <form [formGroup]="form">
18
+ <ion-item *ngFor="let key of keys">
19
+ <ion-label position="floating">{{key}}</ion-label>
20
+ <ion-input [formControlName]="key"></ion-input>
21
+ </ion-item>
22
+ </form>
23
+ </ion-card-content>
24
+ </ion-card>
25
+ <ion-card>
26
+ <ion-title>
27
+ Form data
28
+ </ion-title>
29
+ <ion-card-content>
30
+ <pre>
31
+ {{form | jsonForm | json}}
32
+ </pre>
33
+ </ion-card-content>
34
+ </ion-card>
35
+ </ion-content>
36
+ <ion-footer>
37
+ <ion-toolbar>
38
+ <ion-button color="success" (click)="onSave(form.getRawValue())">
39
+ <ion-icon name="save"></ion-icon>
40
+ Save
41
+ </ion-button>
42
+ <ion-button color="success" (click)="onCopy(form.getRawValue())">
43
+ <ion-icon name="copy"></ion-icon>
44
+ Clone
45
+ </ion-button>
46
+ <ion-button color="success" (click)="onDelete(form.getRawValue())">
47
+ <ion-icon name="delete"></ion-icon>
48
+ Delete
49
+ </ion-button>
50
+ <ion-button color="danger" (click)="cancel()">Cancel</ion-button>
51
+ </ion-toolbar>
52
+ </ion-footer>
@@ -0,0 +1,57 @@
1
+ import {Component} from '@angular/core';
2
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
3
+ import {<%= clazz %>StoreActions} from '@root-store/<%= dasherize(clazz) %>-store';
4
+
5
+ import {FormGroup} from '@angular/forms';
6
+ import {EditBaseComponent} from '@components/edit-base/edit-base.component';
7
+ import * as RouterStoreActions from '@root-store/router-store/actions';
8
+
9
+ @Component({
10
+ selector: 'app-<%= dasherize(clazz) %>-edit',
11
+ templateUrl: './<%= dasherize(clazz) %>-edit.component.html',
12
+ styles: [``]
13
+ })
14
+ export class <%= clazz %>EditComponent extends EditBaseComponent<<%= clazz %>> {
15
+
16
+ form: FormGroup;
17
+ keys: string[];
18
+
19
+ setItemPerform(value: <%= clazz %>): void {
20
+ const group = this.fb.group({});
21
+ this.keys = Object.keys(value);
22
+ this.keys.forEach(key => group.addControl(key, this.fb.control({value: value[key], disabled: key === 'id'})));
23
+ this.form = group;
24
+ }
25
+
26
+ onSavePerform(item: <%= clazz %>): void {
27
+ this.store$.dispatch(<%= clazz %>StoreActions.EditRequest({
28
+ item, onResult: [
29
+ // azione che verrà invocata al result della chiamata all'interno dell'effect.
30
+ RouterStoreActions.RouterBack()
31
+ ]
32
+ }));
33
+ }
34
+
35
+ onCopyPerform(item: <%= clazz %>): void {
36
+ this.store$.dispatch(<%= clazz %>StoreActions.CreateRequest({
37
+ item, onResult: [
38
+ // azione che verrà invocata al result della chiamata all'interno dell'effect.
39
+ RouterStoreActions.RouterBack()
40
+ ]
41
+ }));
42
+ }
43
+
44
+ onDeletePerform(item) {
45
+ this.store$.dispatch(<%= clazz %>StoreActions.DeleteRequest({
46
+ item, onResult: [
47
+ // azione che verrà invocata al result della chiamata all'interno dell'effect.
48
+ RouterStoreActions.RouterBack()
49
+ ]
50
+ }));
51
+ }
52
+
53
+ cancel(): void {
54
+ this.store$.dispatch(RouterStoreActions.RouterBack());
55
+ }
56
+
57
+ }
@@ -0,0 +1,7 @@
1
+ <ion-list>
2
+ <ion-item *ngFor="let item of collection$ | async" detail (click)="onSelect(item)">
3
+ <ion-label>
4
+ <pre>{{item | json}}</pre>
5
+ </ion-label>
6
+ </ion-item>
7
+ </ion-list>
@@ -0,0 +1,50 @@
1
+ import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
2
+ import {Store} from '@ngrx/store';
3
+ import {<%= clazz %>StoreActions, <%= clazz %>StoreSelectors, RootStoreState} from '@root-store/index';
4
+ import {Observable} from 'rxjs';
5
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
6
+ import {RouterStoreActions} from '@root-store/router-store/index';
7
+
8
+ @Component({
9
+ selector: 'app-<%= dasherize(clazz) %>-list',
10
+ templateUrl: `<%= dasherize(clazz) %>-list.component.html`,
11
+ styles: [``],
12
+ changeDetection: ChangeDetectionStrategy.OnPush
13
+ })
14
+ export class <%= clazz %>ListComponent implements OnInit {
15
+
16
+
17
+ collection$: Observable<<%= clazz %>[]>;
18
+ cols: any;
19
+
20
+ constructor(private store$: Store<RootStoreState.State>) {
21
+ console.log('<%= clazz %>ListComponent.constructor()');
22
+ }
23
+
24
+
25
+ ngOnInit() {
26
+ console.log('<%= clazz %>ListComponent.ngOnInit()');
27
+
28
+ this.collection$ = this.store$.select(
29
+ <%= clazz %>StoreSelectors.selectAll
30
+ );
31
+
32
+ }
33
+
34
+ onSelect(item) {
35
+ console.log('<%= clazz %>ListComponent.onEdit()');
36
+
37
+ const state = {
38
+ item,
39
+ props: {}
40
+ };
41
+
42
+ // apro la popUP
43
+ this.store$.dispatch(RouterStoreActions.RouterGo({
44
+ path: ['<%= dasherize(clazz) %>', 'edit'],
45
+ extras: {state}
46
+ }));
47
+
48
+ }
49
+
50
+ }
@@ -0,0 +1,15 @@
1
+ <ion-header>
2
+ <ion-toolbar>
3
+ <ion-buttons slot="start">
4
+ <ion-menu-button></ion-menu-button>
5
+ </ion-buttons>
6
+ <ion-title>
7
+ List
8
+ </ion-title>
9
+ </ion-toolbar>
10
+ </ion-header>
11
+
12
+ <ion-content fullscreen>
13
+ <app-search [actions]="actions"></app-search>
14
+ <app-<%= dasherize(clazz) %>-list></app-<%= dasherize(clazz) %>-list>
15
+ </ion-content>
@@ -0,0 +1,23 @@
1
+ import {Component, OnInit} from '@angular/core';
2
+ import {Store} from '@ngrx/store';
3
+ import {<%= clazz %>StoreActions, RootStoreState} from '@root-store/index';
4
+ import {Actions} from 'ngrx-entity-crud';
5
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
6
+
7
+ @Component({
8
+ selector: 'app-<%= dasherize(clazz) %>-main',
9
+ templateUrl: '<%= dasherize(clazz) %>-main.component.html',
10
+ styles: []
11
+ })
12
+ export class <%= clazz %>MainComponent implements OnInit {
13
+
14
+ constructor(private readonly store$: Store<RootStoreState.State>) {
15
+ }
16
+
17
+ actions: Actions<<%= clazz %>> = <%= clazz %>StoreActions.actions;
18
+
19
+ ngOnInit() {
20
+
21
+ }
22
+
23
+ }