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,58 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { ModuleOptions } from '@schematics/angular/utility/find-module';
3
+ /**
4
+ * Aggiunge l'export nell'index.ts e index.d.ts
5
+ */
6
+ export declare function addExport(options: {
7
+ clazz: string;
8
+ }, file: string): Rule;
9
+ /**
10
+ * Aggiorna l'interfaccia dell'interfaccia
11
+ */
12
+ export declare function updateState(newLine: string, file: string): Rule;
13
+ /**
14
+ * Aggiunge l'import nella parte del file.
15
+ */
16
+ export declare function addImport(file: string, importString: string): Rule;
17
+ /**
18
+ * Aggiunge al selettore principale RootSelector, i riferimenti allo store appena creato.
19
+ */
20
+ export declare function addRootSelector(options: {
21
+ clazz: string;
22
+ }, file: string): Rule;
23
+ /**
24
+ * viene aggiornato un un file che contiene un json
25
+ */
26
+ /**
27
+ * Aggiunge una linea all'interno di un file.
28
+ * Il punto dove viene aggiunto viene indicato passando una serie di pattern a comporre un percorso univoco all'interno del file.
29
+ * La linea verrà aggiunta immediatamento dopo l'ultimo pattern.
30
+ *
31
+ * @param content attuale contenuto testuale del file a cui aggiungerela linea
32
+ * @param patterns sequenza di chiavi che servono a identificare il punto dove aggiungere la linea, come per i css
33
+ * @param newLine linea da aggiungere
34
+ */
35
+ export declare function addLine(content: string, patterns: string[], newLine: string): string;
36
+ /**
37
+ * Aggiunge il modulo del nuovo store creato, come dipendenza del modulo Root
38
+ */
39
+ export declare function addDeclarationToNgModule(options: ModuleOptions): Rule;
40
+ /**
41
+ * Aggiunge il modulo del nuovo store creato, come dipendenza del modulo Root
42
+ */
43
+ export declare function addRouteDeclarationToNgModule(options: {
44
+ module: string;
45
+ routeLiteral: string;
46
+ }): Rule;
47
+ /**
48
+ *
49
+ * Returns the name of the installed graphics library.:
50
+ * - primeng
51
+ * - ionic
52
+ *
53
+ */
54
+ /**
55
+ *
56
+ */
57
+ export declare function render(options: any, sourceTemplate: string, path: string): Rule;
58
+ export declare function updateTsConfigSelector(): Rule;
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsConfigSelector = exports.render = exports.addRouteDeclarationToNgModule = exports.addDeclarationToNgModule = exports.addLine = exports.addRootSelector = exports.addImport = exports.updateState = exports.addExport = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const core_1 = require("@angular-devkit/core");
6
+ const ts = require("typescript/lib/tsserverlibrary");
7
+ const change_1 = require("@schematics/angular/utility/change");
8
+ const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
9
+ /**
10
+ * Aggiunge l'export nell'index.ts e index.d.ts
11
+ */
12
+ function addExport(options, file) {
13
+ return (tree, _context) => {
14
+ const content = tree.read(file);
15
+ let strContent = '';
16
+ if (content) {
17
+ strContent = content.toString();
18
+ }
19
+ const dirName = `${core_1.strings.dasherize(options.clazz)}-store`;
20
+ const updatedContent = strContent.concat('\nexport * from \'./' + dirName + '\';');
21
+ tree.overwrite(file, updatedContent);
22
+ return tree;
23
+ };
24
+ }
25
+ exports.addExport = addExport;
26
+ /**
27
+ * Aggiorna l'interfaccia dell'interfaccia
28
+ */
29
+ function updateState(newLine, file) {
30
+ return (tree, _context) => {
31
+ const content = tree.read(file);
32
+ let strContent = '';
33
+ if (content) {
34
+ strContent = content.toString();
35
+ }
36
+ const startIndex = strContent.indexOf('export');
37
+ const endIndex = strContent.indexOf('{', startIndex);
38
+ strContent = strContent.slice(0, endIndex + 1) + '\n' + newLine + strContent.slice(endIndex + 1);
39
+ tree.overwrite(file, strContent);
40
+ return tree;
41
+ };
42
+ }
43
+ exports.updateState = updateState;
44
+ /**
45
+ * Aggiunge l'import nella parte del file.
46
+ */
47
+ function addImport(file, importString) {
48
+ return (tree, _context) => {
49
+ const content = tree.read(file);
50
+ let strContent = '';
51
+ if (content) {
52
+ strContent = content.toString();
53
+ }
54
+ strContent = importString + '\n' + strContent;
55
+ tree.overwrite(file, strContent);
56
+ return tree;
57
+ };
58
+ }
59
+ exports.addImport = addImport;
60
+ /**
61
+ * Aggiunge al selettore principale RootSelector, i riferimenti allo store appena creato.
62
+ */
63
+ function addRootSelector(options, file) {
64
+ return (tree) => {
65
+ const content = tree.read(file);
66
+ let strContent = '';
67
+ if (content) {
68
+ strContent = content.toString();
69
+ }
70
+ strContent = addLine(strContent, ['selectError', 'createSelectorFactory', 'customMemoizer', '('], `${options.clazz}StoreSelectors.selectError,`);
71
+ strContent = addLine(strContent, ['selectIsLoading', 'createSelectorFactory', 'customMemoizer', '('], `${options.clazz}StoreSelectors.selectIsLoading,`);
72
+ tree.overwrite(file, strContent);
73
+ return tree;
74
+ };
75
+ }
76
+ exports.addRootSelector = addRootSelector;
77
+ /**
78
+ * viene aggiornato un un file che contiene un json
79
+ */
80
+ // export function updateJson(objToMerge: any, file: string): Rule {
81
+ // return (tree: Tree) => {
82
+ // const content: Buffer | null = tree.read(file);
83
+ // let strContent: string = '';
84
+ // if (content) {
85
+ // strContent = content.toString();
86
+ // }
87
+ // const obj = JSON.parse(strContent);
88
+ //
89
+ // const objB = merge(obj, objToMerge);
90
+ //
91
+ // const result = JSON.stringify(objB);
92
+ // tree.overwrite(file, result);
93
+ // return tree;
94
+ // };
95
+ // }
96
+ /**
97
+ * Aggiunge una linea all'interno di un file.
98
+ * Il punto dove viene aggiunto viene indicato passando una serie di pattern a comporre un percorso univoco all'interno del file.
99
+ * La linea verrà aggiunta immediatamento dopo l'ultimo pattern.
100
+ *
101
+ * @param content attuale contenuto testuale del file a cui aggiungerela linea
102
+ * @param patterns sequenza di chiavi che servono a identificare il punto dove aggiungere la linea, come per i css
103
+ * @param newLine linea da aggiungere
104
+ */
105
+ function addLine(content, patterns, newLine) {
106
+ let index = 0;
107
+ patterns.forEach(value => {
108
+ index = content.indexOf(value, index) + value.length;
109
+ });
110
+ return content.slice(0, index + 1) + newLine + content.slice(index);
111
+ }
112
+ exports.addLine = addLine;
113
+ /**
114
+ * Aggiunge il modulo del nuovo store creato, come dipendenza del modulo Root
115
+ */
116
+ function addDeclarationToNgModule(options) {
117
+ return (host) => {
118
+ if (!options.module) {
119
+ return host;
120
+ }
121
+ const modulePath = options.module;
122
+ const text = host.read(modulePath);
123
+ if (text === null) {
124
+ throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
125
+ }
126
+ const sourceText = text.toString();
127
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
128
+ // const relativePath = buildRelativeModulePath(options, modulePath);
129
+ // @ts-ignore
130
+ const changes = ast_utils_1.addImportToModule(source, modulePath, core_1.strings.classify(`${options.name}Module`), options.path);
131
+ const recorder = host.beginUpdate(modulePath);
132
+ for (const change of changes) {
133
+ if (change instanceof change_1.InsertChange) {
134
+ recorder.insertLeft(change.pos, change.toAdd);
135
+ }
136
+ }
137
+ host.commitUpdate(recorder);
138
+ return host;
139
+ };
140
+ }
141
+ exports.addDeclarationToNgModule = addDeclarationToNgModule;
142
+ /**
143
+ * Aggiunge il modulo del nuovo store creato, come dipendenza del modulo Root
144
+ */
145
+ function addRouteDeclarationToNgModule(options) {
146
+ return (host) => {
147
+ if (!options.module) {
148
+ return host;
149
+ }
150
+ const modulePath = options.module;
151
+ const text = host.read(modulePath);
152
+ if (text === null) {
153
+ throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
154
+ }
155
+ const sourceText = text.toString();
156
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
157
+ // @ts-ignore
158
+ const change = ast_utils_1.addRouteDeclarationToModule(source, modulePath, options.routeLiteral);
159
+ const recorder = host.beginUpdate(modulePath);
160
+ if (change instanceof change_1.InsertChange) {
161
+ recorder.insertLeft(change.pos, change.toAdd);
162
+ }
163
+ host.commitUpdate(recorder);
164
+ return host;
165
+ };
166
+ }
167
+ exports.addRouteDeclarationToNgModule = addRouteDeclarationToNgModule;
168
+ /**
169
+ *
170
+ * Returns the name of the installed graphics library.:
171
+ * - primeng
172
+ * - ionic
173
+ *
174
+ */
175
+ /*export function getGraphicsLibraryName(tree: Tree): string {
176
+ const content: Buffer | null = tree.read('package.json');
177
+ let strContent: string = '';
178
+ if (content) {
179
+ strContent = content.toString();
180
+ }
181
+ if (strContent.indexOf('ionic') !== -1) {
182
+ return 'ionic';
183
+ }
184
+ if (strContent.indexOf('primeng') !== -1) {
185
+ return 'primeng';
186
+ }
187
+ return 'no-libs';
188
+ }*/
189
+ /**
190
+ *
191
+ */
192
+ function render(options, sourceTemplate, path) {
193
+ return (_tree, _context) => {
194
+ const _sourceTemplate = schematics_1.url(sourceTemplate);
195
+ const _path = core_1.normalize(path);
196
+ const sourceTemplateParametrized = schematics_1.apply(_sourceTemplate, [
197
+ schematics_1.template(Object.assign(Object.assign({}, options), core_1.strings)),
198
+ schematics_1.move(_path)
199
+ ]);
200
+ return schematics_1.mergeWith(sourceTemplateParametrized);
201
+ };
202
+ }
203
+ exports.render = render;
204
+ function updateTsConfigSelector() {
205
+ console.log('updateTsConfigSelector.updateTsConfigSelector()');
206
+ return (tree) => {
207
+ console.log('00');
208
+ const content = tree.read('/tsconfig.json');
209
+ console.log('content', content);
210
+ let strContent = '';
211
+ if (content) {
212
+ strContent = content.toString();
213
+ }
214
+ const comment = '/* To learn more about this file see: https://angular.io/config/tsconfig. */';
215
+ let comment_delete = false;
216
+ if (strContent.substring(0, 76) === comment) {
217
+ strContent = strContent.replace(strContent.substring(0, 77), '');
218
+ comment_delete = true;
219
+ console.log('strContent', strContent);
220
+ }
221
+ const tsconfigJson = JSON.parse(strContent);
222
+ console.log('strContent+', strContent);
223
+ const compilerOptionsPaths = tsconfigJson.compilerOptions.paths || {};
224
+ console.log('compilerOptionsPaths', compilerOptionsPaths);
225
+ const compilerOptionsPathsB = {
226
+ '@components/*': [
227
+ 'src/app/main/components/*'
228
+ ],
229
+ '@services/*': [
230
+ 'src/app/main/services/*'
231
+ ],
232
+ '@models/*': [
233
+ 'src/app/main/models/*'
234
+ ],
235
+ '@views/*': [
236
+ 'src/app/main/views/*'
237
+ ],
238
+ '@core/*': [
239
+ 'src/app/core/*'
240
+ ],
241
+ '@root-store/*': [
242
+ 'src/app/root-store/*'
243
+ ]
244
+ };
245
+ console.log('compilerOptionsPathsB', compilerOptionsPathsB);
246
+ tsconfigJson.compilerOptions.paths = Object.assign(Object.assign({}, compilerOptionsPaths), compilerOptionsPathsB);
247
+ console.log('tsconfigJson', tsconfigJson);
248
+ let strContentB = JSON.stringify(tsconfigJson);
249
+ if (comment_delete) {
250
+ strContentB = comment.concat(strContentB);
251
+ }
252
+ tree.overwrite('/tsconfig.json', strContentB);
253
+ return tree;
254
+ };
255
+ }
256
+ exports.updateTsConfigSelector = updateTsConfigSelector;
257
+ //# sourceMappingURL=my-utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AC,cAAc,EAAE,YAAY,CAAC,CAAC;QAC1C,IAAI,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;QAC9C,IAAI,cAAc,EAAE;YAClB,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC3C;QACD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAnDD,wDAmDC"}
@@ -0,0 +1,8 @@
1
+ import {RootStoreModule} from './root-store.module';
2
+ import * as RootStoreSelectors from './selectors';
3
+ import * as RootStoreState from './state';
4
+
5
+ export {RootStoreState, RootStoreSelectors, RootStoreModule};
6
+
7
+ export * from './router-store';
8
+ export * from './slide-menu-store';
@@ -0,0 +1,8 @@
1
+ import {RootStoreModule} from './root-store.module';
2
+ import * as RootStoreSelectors from './selectors';
3
+ import * as RootStoreState from './state';
4
+
5
+ export {RootStoreState, RootStoreSelectors, RootStoreModule};
6
+
7
+ export * from './router-store';
8
+ export * from './slide-menu-store';
@@ -0,0 +1,11 @@
1
+ import {ActionReducerMap, MetaReducer} from '@ngrx/store';
2
+ import {State} from '@root-store/state';
3
+ import {environment} from '../../environments/environment';
4
+
5
+
6
+ export interface AppState {
7
+ }
8
+
9
+ export const reducers: ActionReducerMap<AppState> = {};
10
+
11
+ export const metaReducers: MetaReducer<State>[] = !environment.production ? [] : [];
@@ -0,0 +1,29 @@
1
+ import {NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {StoreModule} from '@ngrx/store';
4
+ import {EffectsModule} from '@ngrx/effects';
5
+ import {metaReducers, reducers} from '@root-store/root-reducer';
6
+ import {RouterStoreModule} from './router-store';
7
+ import {environment} from '../../environments/environment';
8
+ import {StoreDevtoolsModule} from '@ngrx/store-devtools';
9
+ import {SlideMenuStoreModule} from '@root-store/slide-menu-store';
10
+
11
+ @NgModule({
12
+ imports: [
13
+ CommonModule,
14
+ RouterStoreModule,
15
+ SlideMenuStoreModule,
16
+ StoreModule.forRoot(reducers, {
17
+ metaReducers,
18
+ runtimeChecks: {strictStateImmutability: true, strictActionImmutability: true}
19
+ }),
20
+ EffectsModule.forRoot([]),
21
+ StoreDevtoolsModule.instrument({
22
+ maxAge: 25, // Retains last 25 states
23
+ logOnly: environment.production, // Restrict extension to log-only mode
24
+ }),
25
+ ],
26
+ declarations: []
27
+ })
28
+ export class RootStoreModule {
29
+ }
@@ -0,0 +1,27 @@
1
+ import {Action, createAction, props} from '@ngrx/store';
2
+ import {NavigationExtras} from '@angular/router';
3
+
4
+ export const RouterGo = createAction(`[Router] Go`, props<{
5
+ path: any[];
6
+ extras?: NavigationExtras;
7
+ data?: any;
8
+ }>());
9
+
10
+ export const RouterGoPerformed = createAction(`[Router] Go performed`, props<{
11
+ extras?: NavigationExtras;
12
+ primary?: any;
13
+ }>());
14
+
15
+ export const RouterGoPopUp = createAction(`[Router] Go popUP`, props<{
16
+ path: any[];
17
+ extras?: NavigationExtras;
18
+ data?: any;
19
+ }>());
20
+
21
+ export const RouterGoPopUpPerformed = createAction(`[Router] Go popUP performed`, props<{
22
+ extras?: NavigationExtras;
23
+ popUp?: any;
24
+ }>());
25
+
26
+ export const RouterPopState = createAction(`[Router] Pop`);
27
+ export const RouterBack = createAction(`[Router] Back`);
@@ -0,0 +1,65 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {Actions, createEffect, ofType} from '@ngrx/effects';
3
+ import {Store} from '@ngrx/store';
4
+ import {filter, map, tap} from 'rxjs/operators';
5
+ import * as actions from './actions';
6
+ import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
7
+ import {Location} from '@angular/common';
8
+
9
+ @Injectable()
10
+ export class RouterEffects {
11
+
12
+ navigate$ = createEffect(() =>
13
+ this.actions$.pipe(
14
+ ofType(actions.RouterGo),
15
+ tap(({path, extras}) => this.router.navigate(path, extras)),
16
+ map(({extras, data}) => {
17
+ console.log('RouterEffects.()');
18
+ return actions.RouterGoPerformed({primary: data, extras});
19
+ })
20
+ )
21
+ );
22
+
23
+ navigatePopUp$ = createEffect(() =>
24
+ this.actions$.pipe(
25
+ ofType(actions.RouterGoPopUp),
26
+ tap(({path, extras}) => this.router.navigate(path, extras)),
27
+ map(({extras, data}) => {
28
+ console.log('RouterEffects.()');
29
+ return actions.RouterGoPopUpPerformed({popUp: data, extras});
30
+ }
31
+ )
32
+ )
33
+ );
34
+
35
+ navigateBack$ = createEffect(() =>
36
+ this.actions$.pipe(
37
+ ofType(actions.RouterBack),
38
+ tap(() => this.location.back())
39
+ ),
40
+ {dispatch: false}
41
+ );
42
+
43
+ constructor(
44
+ private actions$: Actions,
45
+ private router: Router,
46
+ private location: Location,
47
+ private route: ActivatedRoute,
48
+ private store: Store<any>
49
+ ) {
50
+ this.listenToRouter();
51
+ }
52
+
53
+ private listenToRouter() {
54
+ this.router.events.pipe(
55
+ // navigationTrigger === 'popstate' corrisponde alle azioni per navigare nella history
56
+ // non è possibile distinguere la pressione del tasto back da forward
57
+ // nel reducer cancello eventuali stati futuri, impedendo la possibilità di premere su forward
58
+ // in questo modonavigationTrigger === 'popstate' corrisponde alla pressione del tasto back.
59
+ filter(event => (event as NavigationStart).navigationTrigger === 'popstate'),
60
+ tap(event => {
61
+ this.store.dispatch(actions.RouterPopState());
62
+ })
63
+ ).subscribe();
64
+ }
65
+ }
@@ -0,0 +1,11 @@
1
+ import * as RouterStoreActions from './actions';
2
+ import * as RouterStoreSelectors from './selectors';
3
+
4
+ export {
5
+ RouterStoreModule
6
+ } from './router-store.module';
7
+
8
+ export {
9
+ RouterStoreActions,
10
+ RouterStoreSelectors
11
+ };
@@ -0,0 +1,11 @@
1
+ import * as RouterStoreActions from './actions';
2
+ import * as RouterStoreSelectors from './selectors';
3
+
4
+ export {
5
+ RouterStoreModule
6
+ } from './router-store.module';
7
+
8
+ export {
9
+ RouterStoreActions,
10
+ RouterStoreSelectors
11
+ };
@@ -0,0 +1,83 @@
1
+ import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';
2
+ import {Store} from '@ngrx/store';
3
+ import {RouterStoreActions, RouterStoreSelectors} from '@root-store/router-store/index';
4
+ import {take} from 'rxjs/operators';
5
+ import {evalData} from '@core/utils/j-utils';
6
+ import {Subscription} from 'rxjs';
7
+ import {ConfirmationService} from 'primeng/api';
8
+ import {State} from '@root-store/state';
9
+ import {FormBuilder} from '@angular/forms';
10
+
11
+ @Component({
12
+ selector: 'app-pop-up-base',
13
+ template: ``,
14
+ styles: []
15
+ })
16
+ export class PopUpBaseComponent<T> implements OnInit, OnDestroy {
17
+
18
+ public title: string;
19
+ public route: string;
20
+ public confirmMessage = 'Are you sure that you want to perform this action?';
21
+ protected state: PopUpData<T>;
22
+ private subscription: Subscription;
23
+
24
+ constructor(protected store$: Store<State>,
25
+ protected ref: ChangeDetectorRef,
26
+ protected confirmationService: ConfirmationService,
27
+ protected fb: FormBuilder,
28
+ ) {
29
+ ref.detach();
30
+ }
31
+
32
+ ngOnInit() {
33
+ this.subscription = this.store$.select(RouterStoreSelectors.selectPopUp).pipe(
34
+ take(1),
35
+ ).subscribe(
36
+ data => this.setState(evalData(() => data as PopUpData<T>, null))
37
+ );
38
+ }
39
+
40
+ ngOnDestroy(): void {
41
+ this.subscription.unsubscribe();
42
+ }
43
+
44
+ setState(value: PopUpData<T>): void {
45
+ if (value.props) {
46
+ this.title = value.props.title || this.title;
47
+ this.route = value.props.route || this.route;
48
+ this.confirmMessage = value.props.confirmMessage || this.confirmMessage;
49
+ }
50
+
51
+ this.setItemPerform(value.item);
52
+ this.ref.reattach();
53
+ this.ref.markForCheck();
54
+ }
55
+
56
+ submit(value): void {
57
+ this.confirmationService.confirm({
58
+ message: this.confirmMessage,
59
+ accept: () => {
60
+ this.acceptPerform(value);
61
+ }
62
+ });
63
+ }
64
+
65
+ setItemPerform(value: T): void {
66
+ throw new Error('Metodo da sovrascrivere');
67
+ }
68
+
69
+ acceptPerform(item: T): void {
70
+ throw new Error('Metodo da sovrascrivere');
71
+ }
72
+
73
+ cancel(): void {
74
+ this.store$.dispatch(closePopUpAction);
75
+ }
76
+ }
77
+
78
+ export class PopUpData<T> {
79
+ item: T;
80
+ props: Partial<{ title: string, route: string, confirmMessage: string }>;
81
+ }
82
+
83
+ export const closePopUpAction = RouterStoreActions.RouterBack();
@@ -0,0 +1,24 @@
1
+ import {NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {PopUpBaseComponent} from '@root-store/router-store/pop-up-base.component';
4
+ import {PipesModule} from '@core/pipe/pipes.module';
5
+ import {DialogModule} from 'primeng/dialog';
6
+ import {InputTextModule} from 'primeng/inputtext';
7
+ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
8
+
9
+ @NgModule({
10
+ declarations: [PopUpBaseComponent],
11
+ imports: [
12
+ CommonModule,
13
+ DialogModule,
14
+ PipesModule.forRoot(),
15
+ InputTextModule,
16
+ FormsModule,
17
+ ReactiveFormsModule,
18
+ ],
19
+ providers: [],
20
+ entryComponents: [],
21
+ exports: [PopUpBaseComponent]
22
+ })
23
+ export class PopUpBaseModule {
24
+ }
@@ -0,0 +1,31 @@
1
+ import {initialState, State} from './state';
2
+ import {createReducer, on} from '@ngrx/store';
3
+ import * as actions from './actions';
4
+ import {routerCancelAction, routerErrorAction, routerNavigationAction, routerReducer} from '@ngrx/router-store';
5
+
6
+ export const past: State[] = [];
7
+
8
+ export const featureReducer = createReducer<State>(initialState,
9
+ on(actions.RouterGoPerformed, (state, {primary, extras}) => {
10
+ past.push(state);
11
+ return {...state, ...{primary, extras}};
12
+ }),
13
+ on(actions.RouterGoPopUpPerformed, (state, {popUp, extras}) => {
14
+ past.push(state);
15
+ return {...state, ...{popUp, extras}};
16
+ }),
17
+ on(routerNavigationAction, routerErrorAction, routerCancelAction, (state, action) => {
18
+ return {...state, ...routerReducer(state, action) as State};
19
+ }),
20
+ on(actions.RouterPopState, (state, values) => {
21
+ // rimuovo la possibilità di premere il tasto forward.
22
+ // prendere in considerazione la possibilità di gestire la storicizzazione in entrambi le direzioni.
23
+ setTimeout(() => {
24
+ history.pushState(null, null, null);
25
+ }, 10);
26
+ const result = past.pop();
27
+ return (result);
28
+ }),
29
+ )
30
+ ;
31
+