@smartsoft001/crud-shell-angular 1.1.734 → 1.1.736

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 (210) hide show
  1. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  2. package/{esm2015/lib/+state/crud.actions.js → esm2020/lib/+state/crud.actions.mjs} +0 -0
  3. package/esm2020/lib/+state/crud.effects.mjs +182 -0
  4. package/esm2020/lib/+state/crud.facade.mjs +88 -0
  5. package/esm2020/lib/+state/crud.reducer.mjs +212 -0
  6. package/{esm2015/lib/+state/crud.selectors.js → esm2020/lib/+state/crud.selectors.mjs} +0 -0
  7. package/esm2020/lib/components/components.module.mjs +109 -0
  8. package/esm2020/lib/components/export/export.component.mjs +47 -0
  9. package/esm2020/lib/components/filter/base/base.component.mjs +140 -0
  10. package/esm2020/lib/components/filter/check/check.component.mjs +36 -0
  11. package/esm2020/lib/components/filter/date/date.component.mjs +41 -0
  12. package/esm2020/lib/components/filter/date-with-edit/date-with-edit.component.mjs +45 -0
  13. package/esm2020/lib/components/filter/filter.component.mjs +29 -0
  14. package/esm2020/lib/components/filter/flag/flag.component.mjs +16 -0
  15. package/{esm2015/lib/components/filter/index.js → esm2020/lib/components/filter/index.mjs} +0 -0
  16. package/esm2020/lib/components/filter/int/int.component.mjs +33 -0
  17. package/esm2020/lib/components/filter/radio/radio.component.mjs +16 -0
  18. package/esm2020/lib/components/filter/text/text.component.mjs +16 -0
  19. package/esm2020/lib/components/filters/filters.component.mjs +111 -0
  20. package/esm2020/lib/components/filters-config/filters-config.component.mjs +37 -0
  21. package/esm2020/lib/components/group/group.component.mjs +54 -0
  22. package/{esm2015/lib/components/index.js → esm2020/lib/components/index.mjs} +0 -0
  23. package/esm2020/lib/components/multiselect/multiselect.component.mjs +68 -0
  24. package/esm2020/lib/crud-full.module.mjs +105 -0
  25. package/esm2020/lib/crud.config.mjs +17 -0
  26. package/esm2020/lib/crud.module.mjs +107 -0
  27. package/esm2020/lib/factories/list-pagination/list-pagination.factory.mjs +69 -0
  28. package/{esm2015/lib/models/index.js → esm2020/lib/models/index.mjs} +0 -0
  29. package/{esm2015/lib/models/interfaces.js → esm2020/lib/models/interfaces.mjs} +0 -0
  30. package/esm2020/lib/pages/index.mjs +7 -0
  31. package/esm2020/lib/pages/item/base/base.component.mjs +44 -0
  32. package/esm2020/lib/pages/item/item.component.mjs +393 -0
  33. package/esm2020/lib/pages/item/standard/standard.component.mjs +15 -0
  34. package/esm2020/lib/pages/list/base/base.component.mjs +23 -0
  35. package/esm2020/lib/pages/list/list.component.mjs +343 -0
  36. package/esm2020/lib/pages/list/standard/standard.component.mjs +34 -0
  37. package/esm2020/lib/pipes/form-options/form-options.pipe.mjs +55 -0
  38. package/{esm2015/lib/pipes/index.js → esm2020/lib/pipes/index.mjs} +0 -0
  39. package/esm2020/lib/pipes/pipes.module.mjs +20 -0
  40. package/{esm2015/lib/providers/model-possibilities/model-possibilities.provider.js → esm2020/lib/providers/model-possibilities/model-possibilities.provider.mjs} +0 -0
  41. package/esm2020/lib/services/crud/crud.service.mjs +138 -0
  42. package/esm2020/lib/services/list-group/list-group.service.mjs +60 -0
  43. package/esm2020/lib/services/page/page.service.mjs +41 -0
  44. package/{esm2015/lib/services/search/search.service.js → esm2020/lib/services/search/search.service.mjs} +9 -8
  45. package/esm2020/lib/services/socket/socket.service.mjs +17 -0
  46. package/esm2020/smartsoft001-crud-shell-angular.mjs +5 -0
  47. package/fesm2015/smartsoft001-crud-shell-angular.mjs +2569 -0
  48. package/fesm2015/smartsoft001-crud-shell-angular.mjs.map +1 -0
  49. package/fesm2020/smartsoft001-crud-shell-angular.mjs +2729 -0
  50. package/fesm2020/smartsoft001-crud-shell-angular.mjs.map +1 -0
  51. package/lib/+state/crud.effects.d.ts +3 -0
  52. package/lib/+state/crud.effects.d.ts.map +1 -1
  53. package/lib/+state/crud.facade.d.ts +3 -0
  54. package/lib/+state/crud.facade.d.ts.map +1 -1
  55. package/lib/components/components.module.d.ts +22 -0
  56. package/lib/components/components.module.d.ts.map +1 -1
  57. package/lib/components/export/export.component.d.ts +3 -0
  58. package/lib/components/export/export.component.d.ts.map +1 -1
  59. package/lib/components/filter/base/base.component.d.ts +3 -0
  60. package/lib/components/filter/base/base.component.d.ts.map +1 -1
  61. package/lib/components/filter/check/check.component.d.ts +3 -0
  62. package/lib/components/filter/check/check.component.d.ts.map +1 -1
  63. package/lib/components/filter/date/date.component.d.ts +3 -0
  64. package/lib/components/filter/date/date.component.d.ts.map +1 -1
  65. package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts +3 -0
  66. package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts.map +1 -1
  67. package/lib/components/filter/filter.component.d.ts +3 -0
  68. package/lib/components/filter/filter.component.d.ts.map +1 -1
  69. package/lib/components/filter/flag/flag.component.d.ts +3 -0
  70. package/lib/components/filter/flag/flag.component.d.ts.map +1 -1
  71. package/lib/components/filter/int/int.component.d.ts +3 -0
  72. package/lib/components/filter/int/int.component.d.ts.map +1 -1
  73. package/lib/components/filter/radio/radio.component.d.ts +3 -0
  74. package/lib/components/filter/radio/radio.component.d.ts.map +1 -1
  75. package/lib/components/filter/text/text.component.d.ts +3 -0
  76. package/lib/components/filter/text/text.component.d.ts.map +1 -1
  77. package/lib/components/filters/filters.component.d.ts +3 -0
  78. package/lib/components/filters/filters.component.d.ts.map +1 -1
  79. package/lib/components/filters-config/filters-config.component.d.ts +3 -0
  80. package/lib/components/filters-config/filters-config.component.d.ts.map +1 -1
  81. package/lib/components/group/group.component.d.ts +3 -0
  82. package/lib/components/group/group.component.d.ts.map +1 -1
  83. package/lib/components/multiselect/multiselect.component.d.ts +3 -0
  84. package/lib/components/multiselect/multiselect.component.d.ts.map +1 -1
  85. package/lib/crud-full.module.d.ts +20 -0
  86. package/lib/crud-full.module.d.ts.map +1 -1
  87. package/lib/crud.config.d.ts +5 -0
  88. package/lib/crud.config.d.ts.map +1 -1
  89. package/lib/crud.module.d.ts +13 -0
  90. package/lib/crud.module.d.ts.map +1 -1
  91. package/lib/factories/list-pagination/list-pagination.factory.d.ts +3 -0
  92. package/lib/factories/list-pagination/list-pagination.factory.d.ts.map +1 -1
  93. package/lib/pages/index.d.ts +5 -1
  94. package/lib/pages/index.d.ts.map +1 -1
  95. package/lib/pages/item/base/base.component.d.ts +3 -0
  96. package/lib/pages/item/base/base.component.d.ts.map +1 -1
  97. package/lib/pages/item/item.component.d.ts +3 -0
  98. package/lib/pages/item/item.component.d.ts.map +1 -1
  99. package/lib/pages/item/standard/standard.component.d.ts +3 -0
  100. package/lib/pages/item/standard/standard.component.d.ts.map +1 -1
  101. package/lib/pages/list/base/base.component.d.ts +3 -0
  102. package/lib/pages/list/base/base.component.d.ts.map +1 -1
  103. package/lib/pages/list/list.component.d.ts +3 -0
  104. package/lib/pages/list/list.component.d.ts.map +1 -1
  105. package/lib/pages/list/standard/standard.component.d.ts +3 -0
  106. package/lib/pages/list/standard/standard.component.d.ts.map +1 -1
  107. package/lib/pipes/form-options/form-options.pipe.d.ts +3 -0
  108. package/lib/pipes/form-options/form-options.pipe.d.ts.map +1 -1
  109. package/lib/pipes/pipes.module.d.ts +5 -0
  110. package/lib/pipes/pipes.module.d.ts.map +1 -1
  111. package/lib/services/crud/crud.service.d.ts +3 -0
  112. package/lib/services/crud/crud.service.d.ts.map +1 -1
  113. package/lib/services/list-group/list-group.service.d.ts +3 -0
  114. package/lib/services/list-group/list-group.service.d.ts.map +1 -1
  115. package/lib/services/page/page.service.d.ts +3 -0
  116. package/lib/services/page/page.service.d.ts.map +1 -1
  117. package/lib/services/search/search.service.d.ts +3 -0
  118. package/lib/services/search/search.service.d.ts.map +1 -1
  119. package/lib/services/socket/socket.service.d.ts +5 -0
  120. package/lib/services/socket/socket.service.d.ts.map +1 -1
  121. package/package.json +38 -25
  122. package/smartsoft001-crud-shell-angular.d.ts +1 -17
  123. package/smartsoft001-crud-shell-angular.d.ts.map +1 -1
  124. package/bundles/smartsoft001-crud-shell-angular.umd.js +0 -3332
  125. package/bundles/smartsoft001-crud-shell-angular.umd.js.map +0 -1
  126. package/esm2015/lib/+state/crud.effects.js +0 -178
  127. package/esm2015/lib/+state/crud.facade.js +0 -92
  128. package/esm2015/lib/+state/crud.reducer.js +0 -92
  129. package/esm2015/lib/components/components.module.js +0 -65
  130. package/esm2015/lib/components/export/export.component.js +0 -55
  131. package/esm2015/lib/components/filter/base/base.component.js +0 -144
  132. package/esm2015/lib/components/filter/check/check.component.js +0 -34
  133. package/esm2015/lib/components/filter/date/date.component.js +0 -42
  134. package/esm2015/lib/components/filter/date-with-edit/date-with-edit.component.js +0 -43
  135. package/esm2015/lib/components/filter/filter.component.js +0 -30
  136. package/esm2015/lib/components/filter/flag/flag.component.js +0 -13
  137. package/esm2015/lib/components/filter/int/int.component.js +0 -31
  138. package/esm2015/lib/components/filter/radio/radio.component.js +0 -13
  139. package/esm2015/lib/components/filter/text/text.component.js +0 -13
  140. package/esm2015/lib/components/filters/filters.component.js +0 -124
  141. package/esm2015/lib/components/filters-config/filters-config.component.js +0 -46
  142. package/esm2015/lib/components/group/group.component.js +0 -65
  143. package/esm2015/lib/components/multiselect/multiselect.component.js +0 -74
  144. package/esm2015/lib/crud-full.module.js +0 -83
  145. package/esm2015/lib/crud.config.js +0 -14
  146. package/esm2015/lib/crud.module.js +0 -84
  147. package/esm2015/lib/factories/list-pagination/list-pagination.factory.js +0 -73
  148. package/esm2015/lib/pages/index.js +0 -3
  149. package/esm2015/lib/pages/item/base/base.component.js +0 -44
  150. package/esm2015/lib/pages/item/item.component.js +0 -383
  151. package/esm2015/lib/pages/item/standard/standard.component.js +0 -13
  152. package/esm2015/lib/pages/list/base/base.component.js +0 -30
  153. package/esm2015/lib/pages/list/list.component.js +0 -319
  154. package/esm2015/lib/pages/list/standard/standard.component.js +0 -39
  155. package/esm2015/lib/pipes/form-options/form-options.pipe.js +0 -56
  156. package/esm2015/lib/pipes/pipes.module.js +0 -16
  157. package/esm2015/lib/services/crud/crud.service.js +0 -143
  158. package/esm2015/lib/services/list-group/list-group.service.js +0 -61
  159. package/esm2015/lib/services/page/page.service.js +0 -48
  160. package/esm2015/lib/services/socket/socket.service.js +0 -14
  161. package/esm2015/smartsoft001-crud-shell-angular.js +0 -22
  162. package/fesm2015/smartsoft001-crud-shell-angular.js +0 -2676
  163. package/fesm2015/smartsoft001-crud-shell-angular.js.map +0 -1
  164. package/lib/+state/crud.effects.ngfactory.d.ts.map +0 -1
  165. package/lib/+state/crud.facade.ngfactory.d.ts.map +0 -1
  166. package/lib/components/components.module.ngfactory.d.ts.map +0 -1
  167. package/lib/components/export/export.component.ngfactory.d.ts.map +0 -1
  168. package/lib/components/export/export.component.scss.shim.ngstyle.d.ts.map +0 -1
  169. package/lib/components/filter/check/check.component.ngfactory.d.ts.map +0 -1
  170. package/lib/components/filter/check/check.component.scss.shim.ngstyle.d.ts.map +0 -1
  171. package/lib/components/filter/date/date.component.ngfactory.d.ts.map +0 -1
  172. package/lib/components/filter/date/date.component.scss.shim.ngstyle.d.ts.map +0 -1
  173. package/lib/components/filter/date-with-edit/date-with-edit.component.ngfactory.d.ts.map +0 -1
  174. package/lib/components/filter/date-with-edit/date-with-edit.component.scss.shim.ngstyle.d.ts.map +0 -1
  175. package/lib/components/filter/filter.component.ngfactory.d.ts.map +0 -1
  176. package/lib/components/filter/filter.component.scss.shim.ngstyle.d.ts.map +0 -1
  177. package/lib/components/filter/flag/flag.component.ngfactory.d.ts.map +0 -1
  178. package/lib/components/filter/flag/flag.component.scss.shim.ngstyle.d.ts.map +0 -1
  179. package/lib/components/filter/int/int.component.ngfactory.d.ts.map +0 -1
  180. package/lib/components/filter/int/int.component.scss.shim.ngstyle.d.ts.map +0 -1
  181. package/lib/components/filter/radio/radio.component.ngfactory.d.ts.map +0 -1
  182. package/lib/components/filter/radio/radio.component.scss.shim.ngstyle.d.ts.map +0 -1
  183. package/lib/components/filter/text/text.component.ngfactory.d.ts.map +0 -1
  184. package/lib/components/filter/text/text.component.scss.shim.ngstyle.d.ts.map +0 -1
  185. package/lib/components/filters/filters.component.ngfactory.d.ts.map +0 -1
  186. package/lib/components/filters/filters.component.scss.shim.ngstyle.d.ts.map +0 -1
  187. package/lib/components/filters-config/filters-config.component.ngfactory.d.ts.map +0 -1
  188. package/lib/components/filters-config/filters-config.component.scss.shim.ngstyle.d.ts.map +0 -1
  189. package/lib/components/group/group.component.ngfactory.d.ts.map +0 -1
  190. package/lib/components/group/group.component.scss.shim.ngstyle.d.ts.map +0 -1
  191. package/lib/components/multiselect/multiselect.component.ngfactory.d.ts.map +0 -1
  192. package/lib/components/multiselect/multiselect.component.scss.shim.ngstyle.d.ts.map +0 -1
  193. package/lib/crud-full.module.ngfactory.d.ts.map +0 -1
  194. package/lib/crud.config.ngfactory.d.ts.map +0 -1
  195. package/lib/crud.module.ngfactory.d.ts.map +0 -1
  196. package/lib/factories/list-pagination/list-pagination.factory.ngfactory.d.ts.map +0 -1
  197. package/lib/pages/item/item.component.ngfactory.d.ts.map +0 -1
  198. package/lib/pages/item/standard/standard.component.ngfactory.d.ts.map +0 -1
  199. package/lib/pages/item/standard/standard.component.scss.shim.ngstyle.d.ts.map +0 -1
  200. package/lib/pages/list/list.component.ngfactory.d.ts.map +0 -1
  201. package/lib/pages/list/standard/standard.component.ngfactory.d.ts.map +0 -1
  202. package/lib/pages/list/standard/standard.component.scss.shim.ngstyle.d.ts.map +0 -1
  203. package/lib/pipes/form-options/form-options.pipe.ngfactory.d.ts.map +0 -1
  204. package/lib/pipes/pipes.module.ngfactory.d.ts.map +0 -1
  205. package/lib/services/crud/crud.service.ngfactory.d.ts.map +0 -1
  206. package/lib/services/list-group/list-group.service.ngfactory.d.ts.map +0 -1
  207. package/lib/services/page/page.service.ngfactory.d.ts.map +0 -1
  208. package/lib/services/search/search.service.ngfactory.d.ts.map +0 -1
  209. package/lib/services/socket/socket.service.ngfactory.d.ts.map +0 -1
  210. package/smartsoft001-crud-shell-angular.metadata.json +0 -1
@@ -1,2676 +0,0 @@
1
- import { createFeatureSelector, createSelector, select as select$1, Store, ActionsSubject, State, StoreModule } from '@ngrx/store';
2
- import * as i0 from '@angular/core';
3
- import { Injectable, Component, ElementRef, Input, InjectionToken, Directive, Optional, Inject, ViewChild, ChangeDetectorRef, Pipe, NgModule, QueryList, Injector, NgModuleRef, ComponentFactoryResolver, ViewContainerRef, TemplateRef, ViewChildren, EventEmitter, Output } from '@angular/core';
4
- import { NgrxStoreService, BaseComponent as BaseComponent$1, PopoverService, StyleService, MenuService, SharedModule, PaginationMode, AuthService, CreateDynamicComponent, ListMode, DynamicComponentLoader, HardwareService, DynamicContentDirective, FormComponent, ToastService, DetailsService, NgrxSharedModule, FILE_SERVICE_CONFIG } from '@smartsoft001/angular';
5
- import { map, tap, first, catchError } from 'rxjs/operators';
6
- import { FieldType, getModelOptions, getModelFieldsWithOptions } from '@smartsoft001/models';
7
- import * as moment from 'moment';
8
- import { __decorate, __metadata, __awaiter } from 'tslib';
9
- import { Debounce, debounce } from 'lodash-decorators';
10
- import { IonDatetime, IonContent } from '@ionic/angular';
11
- import { Subscription, combineLatest, forkJoin, of, BehaviorSubject } from 'rxjs';
12
- import * as _ from 'lodash';
13
- import { FormsModule, FormControl, FormGroup, FormArray } from '@angular/forms';
14
- import { CommonModule, Location } from '@angular/common';
15
- import { HttpClient } from '@angular/common/http';
16
- import 'reflect-metadata';
17
- import { Router, ActivatedRoute, RouterModule } from '@angular/router';
18
- import { TranslateService } from '@ngx-translate/core';
19
-
20
- const getCrudState = (entity) => createFeatureSelector(entity);
21
- const getCrudSelected = (entity) => createSelector(getCrudState(entity), (state) => state.selected);
22
- const getCrudMultiSelected = (entity) => createSelector(getCrudState(entity), (state) => state.multiSelected);
23
- const getCrudList = (entity) => createSelector(getCrudState(entity), (state) => state.list);
24
- const getCrudTotalCount = (entity) => createSelector(getCrudState(entity), (state) => state.totalCount);
25
- const getCrudLinks = (entity) => createSelector(getCrudState(entity), (state) => state.links);
26
- const getCrudLoaded = (entity) => createSelector(getCrudState(entity), (state) => state.loaded);
27
- const getCrudFilter = (entity) => createSelector(getCrudState(entity), (state) => state.filter);
28
- const getCrudError = (entity) => createSelector(getCrudState(entity), (state) => state.error);
29
-
30
- class CrudConfig {
31
- }
32
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
33
- CrudConfig.decorators = [
34
- { type: Injectable }
35
- ];
36
- class CrudFullConfig extends CrudConfig {
37
- }
38
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
39
- CrudFullConfig.decorators = [
40
- { type: Injectable }
41
- ];
42
-
43
- /*
44
- * Create
45
- */
46
- const create = function (entity, item) {
47
- return {
48
- type: `[${entity}] Create`,
49
- item
50
- };
51
- };
52
- const createSuccess = function (entity, item) {
53
- return {
54
- type: `[${entity}] Create Success`,
55
- item
56
- };
57
- };
58
- const createFailure = function (entity, item, error) {
59
- return {
60
- type: `[${entity}] Create Failure`,
61
- item,
62
- error
63
- };
64
- };
65
- /*
66
- * Create many
67
- */
68
- const createMany = function (entity, data) {
69
- return {
70
- type: `[${entity}] Create Many`,
71
- data
72
- };
73
- };
74
- const createManySuccess = function (entity, data) {
75
- return {
76
- type: `[${entity}] Create Many Success`,
77
- data
78
- };
79
- };
80
- const createManyFailure = function (entity, data, error) {
81
- return {
82
- type: `[${entity}] Create Many Failure`,
83
- data,
84
- error
85
- };
86
- };
87
- /*
88
- * Read
89
- */
90
- const read = function (entity, filter = null) {
91
- return {
92
- type: `[${entity}] Read`,
93
- filter
94
- };
95
- };
96
- const readSuccess = function (entity, filter, result) {
97
- return {
98
- type: `[${entity}] Read Success`,
99
- result,
100
- filter
101
- };
102
- };
103
- const readFailure = function (entity, filter, error) {
104
- return {
105
- type: `[${entity}] Read Failure`,
106
- filter,
107
- error
108
- };
109
- };
110
- /*
111
- * Export
112
- */
113
- const exportList = function (entity, filter = null, format) {
114
- return {
115
- type: `[${entity}] Export`,
116
- filter,
117
- format
118
- };
119
- };
120
- const exportListSuccess = function (entity, filter) {
121
- return {
122
- type: `[${entity}] Export Success`,
123
- filter
124
- };
125
- };
126
- const exportListFailure = function (entity, filter, error) {
127
- return {
128
- type: `[${entity}] Export Failure`,
129
- filter,
130
- error
131
- };
132
- };
133
- /*
134
- * Select
135
- */
136
- const select = function (entity, id) {
137
- return {
138
- type: `[${entity}] Select`,
139
- id
140
- };
141
- };
142
- const selectSuccess = function (entity, id, item) {
143
- return {
144
- type: `[${entity}] Select Success`,
145
- id,
146
- item
147
- };
148
- };
149
- const selectFailure = function (entity, id, error) {
150
- return {
151
- type: `[${entity}] Select Failure`,
152
- id,
153
- error
154
- };
155
- };
156
- const unselect = function (entity) {
157
- return {
158
- type: `[${entity}] Unselect`
159
- };
160
- };
161
- /*
162
- * MultiSelect
163
- */
164
- const multiSelect = function (entity, items) {
165
- return {
166
- type: `[${entity}] MultiSelect`,
167
- items
168
- };
169
- };
170
- /*
171
- * Update
172
- */
173
- const update = function (entity, item) {
174
- return {
175
- type: `[${entity}] Update`,
176
- item
177
- };
178
- };
179
- const updateSuccess = function (entity, item) {
180
- return {
181
- type: `[${entity}] Update Success`,
182
- item
183
- };
184
- };
185
- const updateFailure = function (entity, item, error) {
186
- return {
187
- type: `[${entity}] Update Failure`,
188
- item,
189
- error
190
- };
191
- };
192
- /*
193
- * Update partial
194
- */
195
- const updatePartial = function (entity, item) {
196
- return {
197
- type: `[${entity}] Update partial`,
198
- item
199
- };
200
- };
201
- const updatePartialSuccess = function (entity, item) {
202
- return {
203
- type: `[${entity}] Update partial Success`,
204
- item
205
- };
206
- };
207
- const updatePartialFailure = function (entity, item, error) {
208
- return {
209
- type: `[${entity}] Update partial Failure`,
210
- item,
211
- error
212
- };
213
- };
214
- /*
215
- * Update partial many
216
- */
217
- const updatePartialMany = function (entity, items) {
218
- return {
219
- type: `[${entity}] Update partial many`,
220
- items
221
- };
222
- };
223
- const updatePartialManySuccess = function (entity, items) {
224
- return {
225
- type: `[${entity}] Update partial many Success`,
226
- items
227
- };
228
- };
229
- const updatePartialManyFailure = function (entity, items, error) {
230
- return {
231
- type: `[${entity}] Update partial many Failure`,
232
- items,
233
- error
234
- };
235
- };
236
- /*
237
- * Delete
238
- */
239
- const deleteItem = function (entity, id) {
240
- return {
241
- type: `[${entity}] Delete`,
242
- id
243
- };
244
- };
245
- const deleteSuccess = function (entity, id) {
246
- return {
247
- type: `[${entity}] Delete Success`,
248
- id
249
- };
250
- };
251
- const deleteFailure = function (entity, id, error) {
252
- return {
253
- type: `[${entity}] Delete Failure`,
254
- id,
255
- error
256
- };
257
- };
258
-
259
- class CrudFacade {
260
- constructor(store, config) {
261
- this.store = store;
262
- this.config = config;
263
- this.loaded$ = this.store.pipe(select$1(getCrudLoaded(this.config.entity)));
264
- this.loading$ = this.store.pipe(select$1(getCrudLoaded(this.config.entity)), map(l => !l));
265
- this.selected$ = this.store.pipe(select$1(getCrudSelected(this.config.entity)), tap(s => {
266
- this.selected = s;
267
- }));
268
- this.multiSelected$ = this.store.pipe(select$1(getCrudMultiSelected(this.config.entity)), tap(s => {
269
- this.multiSelected = s;
270
- }));
271
- this.list$ = this.store.pipe(select$1(getCrudList(this.config.entity)), tap(l => {
272
- this.list = l;
273
- }));
274
- this.filter$ = this.store.pipe(select$1(getCrudFilter(this.config.entity)), tap(f => {
275
- this.filter = f;
276
- }));
277
- this.totalCount$ = this.store.pipe(select$1(getCrudTotalCount(this.config.entity)));
278
- this.links$ = this.store.pipe(select$1(getCrudLinks(this.config.entity)));
279
- this.error$ = this.store.pipe(select$1(getCrudError(this.config.entity)));
280
- if (NgrxStoreService.store) {
281
- this.store = NgrxStoreService.store;
282
- }
283
- }
284
- create(item) {
285
- this.store.dispatch(create(this.config.entity, item));
286
- }
287
- createMany(items, options) {
288
- this.store.dispatch(createMany(this.config.entity, { items, options }));
289
- }
290
- read(filter = null) {
291
- let baseQuery = [];
292
- if (this.config.baseQuery) {
293
- baseQuery = this.config.baseQuery;
294
- }
295
- const fullFilter = Object.assign(Object.assign({}, (filter ? filter : {})), { query: filter && filter.query ? filter.query : baseQuery });
296
- this.store.dispatch(read(this.config.entity, fullFilter));
297
- }
298
- select(id) {
299
- this.store.dispatch(select(this.config.entity, id));
300
- }
301
- unselect() {
302
- this.store.dispatch(unselect(this.config.entity));
303
- }
304
- multiSelect(items) {
305
- this.store.dispatch(multiSelect(this.config.entity, items));
306
- }
307
- update(item) {
308
- this.getStore().dispatch(update(this.config.entity, item));
309
- }
310
- export(filter = null, format = null) {
311
- this.getStore().dispatch(exportList(this.config.entity, filter, format));
312
- }
313
- updatePartial(item) {
314
- this.getStore().dispatch(updatePartial(this.config.entity, item));
315
- }
316
- updatePartialMany(items) {
317
- this.getStore().dispatch(updatePartialMany(this.config.entity, items));
318
- }
319
- delete(id) {
320
- this.getStore().dispatch(deleteItem(this.config.entity, id));
321
- }
322
- getStore() {
323
- if (NgrxStoreService.store)
324
- return NgrxStoreService.store;
325
- return this.store;
326
- }
327
- }
328
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
329
- CrudFacade.decorators = [
330
- { type: Injectable }
331
- ];
332
- /**
333
- * @type {function(): !Array<(null|{
334
- * type: ?,
335
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
336
- * })>}
337
- * @nocollapse
338
- */
339
- CrudFacade.ctorParameters = () => [
340
- { type: Store },
341
- { type: CrudConfig }
342
- ];
343
-
344
- class ExportComponent extends BaseComponent$1 {
345
- constructor(facade, popoverService, styleService, elementRef) {
346
- super();
347
- this.facade = facade;
348
- this.popoverService = popoverService;
349
- this.styleService = styleService;
350
- this.elementRef = elementRef;
351
- this.buttonExportCsvOptions = this.initButtonExportOptions('csv');
352
- this.buttonExportXlsxOptions = this.initButtonExportOptions('xlsx');
353
- this.loading$ = this.facade.loading$;
354
- }
355
- ngOnInit() {
356
- this.styleService.init(this.elementRef);
357
- }
358
- initButtonExportOptions(format) {
359
- return {
360
- click: () => {
361
- this.facade.export(Object.assign(Object.assign({}, this.facade.filter), { offset: null, limit: null }), format);
362
- const subscription = this.facade.loaded$.subscribe(val => {
363
- if (!val)
364
- return;
365
- this.popoverService.close();
366
- subscription.unsubscribe();
367
- });
368
- },
369
- loading$: this.facade.loading$,
370
- expand: 'block'
371
- };
372
- }
373
- }
374
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
375
- ExportComponent.decorators = [
376
- { type: Component, args: [{
377
- selector: 'smart-crud-export',
378
- template: "<div class=\"smart-content\">\n <p>\n <smart-button [options]=\"buttonExportCsvOptions\">CSV</smart-button>\n </p>\n <p>\n <smart-button [options]=\"buttonExportXlsxOptions\">XLSX</smart-button>\n </p>\n</div>",
379
- styles: [".smart-content{padding:1.2rem}.smart-content p{margin:.6rem 0}.smart-content smart-button{width:100%;display:block}\n"]
380
- },] }
381
- ];
382
- /**
383
- * @type {function(): !Array<(null|{
384
- * type: ?,
385
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
386
- * })>}
387
- * @nocollapse
388
- */
389
- ExportComponent.ctorParameters = () => [
390
- { type: CrudFacade },
391
- { type: PopoverService },
392
- { type: StyleService },
393
- { type: ElementRef }
394
- ];
395
-
396
- class FilterComponent {
397
- constructor() {
398
- this.FieldType = FieldType;
399
- }
400
- ngOnInit() { }
401
- }
402
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
403
- FilterComponent.decorators = [
404
- { type: Component, args: [{
405
- selector: "smart-crud-filter",
406
- template: "<ion-item [ngSwitch]=\"item.fieldType\">\n <smart-crud-filter-date\n *ngSwitchCase=\"FieldType.date\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-date>\n\n <smart-crud-filter-date-with-edit\n *ngSwitchCase=\"FieldType.dateWithEdit\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-date-with-edit>\n\n <smart-crud-filter-radio\n *ngSwitchCase=\"FieldType.radio\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-radio>\n\n <smart-crud-filter-check\n *ngSwitchCase=\"FieldType.check\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-check>\n\n <smart-crud-filter-flag\n *ngSwitchCase=\"FieldType.flag\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-flag>\n\n <smart-crud-filter-int\n *ngSwitchCase=\"FieldType.int\"\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-int>\n\n <smart-crud-filter-text\n *ngSwitchDefault\n [item]=\"item\"\n [filter]=\"filter\"\n ></smart-crud-filter-text>\n</ion-item>\n",
407
- styles: [""]
408
- },] }
409
- ];
410
- /**
411
- * @type {function(): !Array<(null|{
412
- * type: ?,
413
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
414
- * })>}
415
- * @nocollapse
416
- */
417
- FilterComponent.ctorParameters = () => [];
418
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
419
- FilterComponent.propDecorators = {
420
- item: [{ type: Input }],
421
- filter: [{ type: Input }]
422
- };
423
-
424
- /**
425
- * @deprecated - please, use IModelPossibilitiesProvider from @smartsoft001/angular
426
- */
427
- class ICrudModelPossibilitiesProvider {
428
- }
429
- /**
430
- * @deprecated - please, use MODEL_POSSIBILITIES_PROVIDER from @smartsoft001/angular
431
- */
432
- const CRUD_MODEL_POSSIBILITIES_PROVIDER = new InjectionToken("CRUD_MODEL_POSSIBILITIES_PROVIDER");
433
-
434
- class BaseComponent {
435
- constructor(facade, config, modelPossibilitiesProvider) {
436
- this.facade = facade;
437
- this.config = config;
438
- this.modelPossibilitiesProvider = modelPossibilitiesProvider;
439
- }
440
- get value() {
441
- if (this.isArrayType()) {
442
- return this.filter.query
443
- .filter((q) => q.key === this.item.key && q.type === this.item.type)
444
- .map(q => q.value);
445
- }
446
- const query = this.filter.query.find((q) => q.key === this.item.key && q.type === this.item.type);
447
- return query === null || query === void 0 ? void 0 : query.value;
448
- }
449
- set value(val) {
450
- this.refresh(val);
451
- }
452
- get minValue() {
453
- if (this.isArrayType()) {
454
- return this.filter.query
455
- .filter((q) => q.key === this.item.key && q.type === ">=")
456
- .map(q => q.value);
457
- }
458
- const query = this.filter.query.find((q) => q.key === this.item.key && q.type === ">=");
459
- return query === null || query === void 0 ? void 0 : query.value;
460
- }
461
- set minValue(val) {
462
- this.refresh(val, ">=");
463
- }
464
- get maxValue() {
465
- if (this.isArrayType()) {
466
- return this.filter.query
467
- .filter((q) => q.key === this.item.key && q.type === "<=")
468
- .map(q => q.value);
469
- }
470
- const query = this.filter.query.find((q) => q.key === this.item.key && q.type === "<=");
471
- return query === null || query === void 0 ? void 0 : query.value;
472
- }
473
- set maxValue(val) {
474
- this.refresh(val, "<=");
475
- }
476
- refresh(val, type = null) {
477
- if (!type)
478
- type = this.item.type;
479
- if (this.isArrayType()) {
480
- this.refreshForArray(val, type);
481
- return;
482
- }
483
- let query = this.filter.query.find((q) => q.key === this.item.key && q.type === type);
484
- if (val === null || val === undefined || val === '') {
485
- const index = this.filter.query.indexOf(query);
486
- if (index > -1) {
487
- this.filter.query.splice(index, 1);
488
- }
489
- this.facade.read(this.filter);
490
- return;
491
- }
492
- if (!query) {
493
- query = {
494
- key: this.item.key,
495
- type: type,
496
- value: null,
497
- };
498
- this.filter.query.push(query);
499
- }
500
- query.value = val;
501
- query.label = this.item.label;
502
- this.facade.read(this.filter);
503
- }
504
- ngOnInit() {
505
- this.initPossibilities();
506
- }
507
- initPossibilities() {
508
- let possibilities = this.item.possibilities$;
509
- if (this.modelPossibilitiesProvider) {
510
- const possibilitiesFromProvider = this.modelPossibilitiesProvider.get(this.config.type);
511
- if (possibilitiesFromProvider && possibilitiesFromProvider[this.item.key])
512
- possibilities = possibilitiesFromProvider[this.item.key];
513
- }
514
- this.possibilities$ = possibilities;
515
- }
516
- isArrayType() {
517
- var _a;
518
- return (((_a = this.item) === null || _a === void 0 ? void 0 : _a.fieldType) === FieldType.check);
519
- }
520
- refreshForArray(vals, type) {
521
- const queries = this.filter.query.filter((q) => q.key === this.item.key && q.type === type);
522
- queries.forEach(query => {
523
- const index = this.filter.query.indexOf(query);
524
- if (index > -1) {
525
- this.filter.query.splice(index, 1);
526
- }
527
- });
528
- if (vals === null || vals === undefined || !vals.length) {
529
- this.facade.read(this.filter);
530
- return;
531
- }
532
- vals.forEach(val => {
533
- const query = {
534
- key: this.item.key,
535
- type: type,
536
- value: val,
537
- };
538
- this.filter.query.push(query);
539
- });
540
- this.facade.read(this.filter);
541
- }
542
- }
543
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
544
- BaseComponent.decorators = [
545
- { type: Directive }
546
- ];
547
- /**
548
- * @type {function(): !Array<(null|{
549
- * type: ?,
550
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
551
- * })>}
552
- * @nocollapse
553
- */
554
- BaseComponent.ctorParameters = () => [
555
- { type: CrudFacade },
556
- { type: CrudConfig },
557
- { type: ICrudModelPossibilitiesProvider, decorators: [{ type: Optional }, { type: Inject, args: [CRUD_MODEL_POSSIBILITIES_PROVIDER,] }] }
558
- ];
559
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
560
- BaseComponent.propDecorators = {
561
- item: [{ type: Input }],
562
- filter: [{ type: Input }]
563
- };
564
- __decorate([
565
- Debounce(500),
566
- __metadata("design:type", Function),
567
- __metadata("design:paramtypes", [Object, Object]),
568
- __metadata("design:returntype", void 0)
569
- ], BaseComponent.prototype, "refresh", null);
570
-
571
- class FilterDateComponent extends BaseComponent {
572
- get allowAdvanced() {
573
- var _a;
574
- return ((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) === '=';
575
- }
576
- set customValue(val) {
577
- var _a;
578
- const momentDate = moment(val);
579
- this.value = ((_a = val) === null || _a === void 0 ? void 0 : _a.length) >= 10 && momentDate.isValid() ? momentDate.format('YYYY-MM-DD') : val;
580
- }
581
- get customValue() {
582
- return this.value;
583
- }
584
- set customMinValue(val) {
585
- var _a;
586
- const momentDate = moment(val);
587
- this.minValue = ((_a = val) === null || _a === void 0 ? void 0 : _a.length) >= 10 && momentDate.isValid() ? momentDate.format('YYYY-MM-DD') : val;
588
- }
589
- get customMinValue() {
590
- return this.minValue;
591
- }
592
- set customMaxValue(val) {
593
- var _a;
594
- const momentDate = moment(val);
595
- this.maxValue = ((_a = val) === null || _a === void 0 ? void 0 : _a.length) >= 10 && momentDate.isValid() ? momentDate.format('YYYY-MM-DD') : val;
596
- }
597
- get customMaxValue() {
598
- return this.maxValue;
599
- }
600
- }
601
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
602
- FilterDateComponent.decorators = [
603
- { type: Component, args: [{
604
- selector: 'smart-crud-filter-date',
605
- template: "<ion-row>\n <ion-col>\n <ion-label position=\"floating\">\n {{ item.label | translate }}\n </ion-label>\n <ion-datetime displayFormat=\"YYYY-MM-DD\"\n pickerFormat=\"YYYY-MM-DD\"\n [(ngModel)]=\"customValue\"></ion-datetime>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>",
606
- styles: [":host{width:100%}:host .squere-button{height:var(--smart-button-height)!important;margin:.8rem}\n"]
607
- },] }
608
- ];
609
-
610
- class FilterDateWithEditComponent extends FilterDateComponent {
611
- constructor() {
612
- super(...arguments);
613
- this._subscriptions = new Subscription();
614
- this.advanced = false;
615
- }
616
- open() {
617
- this.dateTimePicker.open();
618
- }
619
- ngOnInit() {
620
- super.ngOnInit();
621
- if (this.dateTimePicker) {
622
- this._subscriptions.add(this.dateTimePicker.ionChange.subscribe((val) => {
623
- this.customValue = val.detail.value;
624
- }));
625
- }
626
- else {
627
- console.error('dateTimePicker not found!');
628
- }
629
- }
630
- ngOnDestroy() {
631
- if (this._subscriptions) {
632
- this._subscriptions.unsubscribe();
633
- }
634
- }
635
- }
636
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
637
- FilterDateWithEditComponent.decorators = [
638
- { type: Component, args: [{
639
- selector: 'smart-crud-filter-date-with-edit',
640
- template: "<ion-row>\n <ion-col>\n <ion-label>\n {{ item.label | translate }}\n </ion-label>\n\n <ion-input placeholder=\"YYYY-MM-DD\"\n [(ngModel)]=\"customValue\"\n [pattern]=\"'([12]\\\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\\\d|3[01]))'\"\n ></ion-input>\n <ion-datetime [hidden]=\"true\"\n displayFormat=\"YYYY-MM-DD\"\n pickerFormat=\"YYYY-MM-DD\"\n [(ngModel)]=\"customValue\"></ion-datetime>\n </ion-col>\n <ion-col size=\"auto\">\n <ion-button (click)=\"open()\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"calendar-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"allowAdvanced\">\n <ion-button (click)=\"advanced = !advanced\" class=\"squere-button\" [disabled]=\"minValue || maxValue\">\n <ion-icon *ngIf=\"!advanced\" slot=\"icon-only\" name=\"settings-outline\"></ion-icon>\n <ion-icon *ngIf=\"advanced\" slot=\"icon-only\" name=\"settings\"></ion-icon>\n </ion-button>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>\n<ion-row *ngIf=\"(advanced || minValue || maxValue) && allowAdvanced\">\n <ion-col>\n <ion-item>\n <ion-label>\n {{ 'from' | translate }}\n </ion-label>\n <ion-input placeholder=\"YYYY-MM-DD\"\n [(ngModel)]=\"customMinValue\"\n [pattern]=\"'([12]\\\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\\\d|3[01]))'\"\n ></ion-input>\n <ion-datetime [hidden]=\"true\"\n [(ngModel)]=\"customMinValue\"\n displayFormat=\"YYYY-MM-DD\"\n pickerFormat=\"YYYY-MM-DD\"></ion-datetime>\n </ion-item>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"customMinValue\">\n <ion-button color=\"danger\" (click)=\"refresh(null, '>=')\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n <ion-col>\n <ion-item>\n <ion-label>\n {{ 'to' | translate }}\n </ion-label>\n <ion-input placeholder=\"YYYY-MM-DD\"\n [(ngModel)]=\"customMaxValue\"\n [pattern]=\"'([12]\\\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\\\d|3[01]))'\"\n ></ion-input>\n <ion-datetime [hidden]=\"true\"\n displayFormat=\"YYYY-MM-DD\"\n pickerFormat=\"YYYY-MM-DD\"\n [(ngModel)]=\"customMaxValue\"></ion-datetime>\n </ion-item>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"customMaxValue\">\n <ion-button color=\"danger\" (click)=\"refresh(null, '<=')\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>",
641
- styles: [":host{width:100%}:host .squere-button{height:var(--smart-button-height)!important;margin:.8rem}\n"]
642
- },] }
643
- ];
644
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
645
- FilterDateWithEditComponent.propDecorators = {
646
- dateTimePicker: [{ type: ViewChild, args: [IonDatetime, { read: IonDatetime, static: false },] }]
647
- };
648
-
649
- class FilterRadioComponent extends BaseComponent {
650
- }
651
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
652
- FilterRadioComponent.decorators = [
653
- { type: Component, args: [{
654
- selector: 'smart-crud-filter-radio',
655
- template: "<ion-row>\n <ion-col>\n <ion-radio-group [(ngModel)]=\"value\">\n <ion-item-divider>\n <ion-icon slot=\"start\" name=\"filter-outline\"></ion-icon>\n <ion-label>\n {{ item.label | translate }}\n </ion-label>\n <ion-button *ngIf=\"value\" slot=\"end\" color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-item-divider>\n\n <ion-item *ngFor=\"let item of possibilities$ | async\">\n <ion-label>{{ item.text | translate }}</ion-label>\n <ion-radio [value]=\"item.id\"></ion-radio>\n </ion-item>\n </ion-radio-group>\n </ion-col>\n <!-- <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col> -->\n</ion-row>",
656
- styles: [":host{width:100%;margin-bottom:1.2rem}:host ion-radio{margin-right:2.4rem}:host ion-item-divider{font-weight:300;--padding-end: .8rem;font-size:1.2rem;--ion-background-color: linear-gradient(90deg, transparent, var(--ion-color-light))}:host ion-item-divider ion-icon{margin-right:1.6rem;font-size:1.6rem;--color: var(--ion-color-primary)}:host ion-item-divider ion-label{--padding: var(--smart-button-padding-left)/2 var(--smart-button-padding-top)/2 var(--smart-button-padding-right)/2 var(--smart-button-padding-bottom)/2}:host ion-item-divider .squere-button{margin:0;font-size:18px;height:36px;width:36px;padding:0;--padding-start: .2em;--padding-end: .2em}:host ion-item-divider .squere-button ion-icon{margin:0;padding:0}\n"]
657
- },] }
658
- ];
659
-
660
- class FilterTextComponent extends BaseComponent {
661
- }
662
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
663
- FilterTextComponent.decorators = [
664
- { type: Component, args: [{
665
- selector: 'smart-crud-filter-text',
666
- template: "<ion-row>\n <ion-col>\n <ion-label position=\"floating\">\n {{ item.label | translate }}\n </ion-label>\n <ion-input [(ngModel)]=\"value\"></ion-input>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>",
667
- styles: [":host{width:100%}:host .squere-button{height:var(--smart-button-height)!important;margin:.8rem}\n"]
668
- },] }
669
- ];
670
-
671
- class FilterFlagComponent extends BaseComponent {
672
- }
673
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
674
- FilterFlagComponent.decorators = [
675
- { type: Component, args: [{
676
- selector: 'smart-crud-filter-flag',
677
- template: "<ion-row>\n <ion-col>\n <div class=\"flag-container\">\n <ion-label position=\"static\">\n {{ item.label | translate }}\n </ion-label>\n <ion-checkbox [(ngModel)]=\"value\" slot=\"end\"></ion-checkbox>\n </div>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>",
678
- styles: [":host{width:100%}:host .flag-container{width:100%;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;padding:0 1.2rem 0 0}:host .flag-container ion-label{--color: var(--smart-color-dark);vertical-align:middle;padding:1.6rem 0}:host .squere-button{height:var(--smart-button-height)!important;margin:.8rem}\n"]
679
- },] }
680
- ];
681
-
682
- class FilterCheckComponent extends BaseComponent {
683
- ngAfterContentInit() {
684
- this.list$ = combineLatest([this.possibilities$, this.facade.filter$]).pipe((map(([possibilities]) => {
685
- return possibilities.map(pos => ({
686
- value: pos,
687
- isCheck: this.value.some(r => r === pos.id)
688
- }));
689
- })));
690
- }
691
- onCheckChange(checked, entry) {
692
- if (checked && !this.value.some(r => r === entry.value.id)) {
693
- this.value = [
694
- ...this.value,
695
- entry.value.id
696
- ];
697
- }
698
- if (!checked && this.value.some(r => r === entry.value.id)) {
699
- this.value = this.value.filter(r => r !== entry.value.id);
700
- }
701
- }
702
- }
703
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
704
- FilterCheckComponent.decorators = [
705
- { type: Component, args: [{
706
- selector: 'smart-crud-filter-check',
707
- template: "<ion-row>\n <ion-col>\n <ion-item-divider>\n <ion-icon slot=\"start\" name=\"filter-outline\"></ion-icon>\n <ion-label>\n {{ item.label | translate }}\n </ion-label>\n <ion-button *ngIf=\"value && value.length\" slot=\"end\" color=\"danger\" (click)=\"refresh([])\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-item-divider>\n <ion-item *ngFor=\"let entry of list$ | async\">\n <ion-label>{{entry.value.text | translate}}</ion-label>\n <ion-checkbox slot=\"end\" [checked]=\"entry.isCheck\" (ionChange)=\"onCheckChange($event.detail.checked, entry)\"></ion-checkbox>\n </ion-item>\n </ion-col>\n <!-- <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col> -->\n</ion-row>",
708
- styles: [":host{width:100%;margin-bottom:1.2rem}:host ion-radio{margin-right:2.4rem}:host ion-item-divider{font-weight:300;--padding-end: .8rem;font-size:1.2rem;--ion-background-color: linear-gradient(90deg, transparent, var(--ion-color-light))}:host ion-item-divider ion-icon{margin-right:1.6rem;font-size:1.6rem;--color: var(--ion-color-primary)}:host ion-item-divider ion-label{--padding: var(--smart-button-padding-left)/2 var(--smart-button-padding-top)/2 var(--smart-button-padding-right)/2 var(--smart-button-padding-bottom)/2}:host ion-item-divider .squere-button{margin:0;font-size:18px;height:36px;width:36px;padding:0;--padding-start: .2em;--padding-end: .2em}:host ion-item-divider .squere-button ion-icon{margin:0;padding:0}\n"]
709
- },] }
710
- ];
711
-
712
- class FilterIntComponent extends BaseComponent {
713
- constructor() {
714
- super(...arguments);
715
- this._subscriptions = new Subscription();
716
- this.advanced = false;
717
- }
718
- get allowAdvanced() {
719
- var _a;
720
- return ((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) === '=';
721
- }
722
- ngOnInit() {
723
- super.ngOnInit();
724
- }
725
- ngOnDestroy() {
726
- if (this._subscriptions) {
727
- this._subscriptions.unsubscribe();
728
- }
729
- }
730
- }
731
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
732
- FilterIntComponent.decorators = [
733
- { type: Component, args: [{
734
- selector: 'smart-crud-filter-int',
735
- template: "<ion-row>\n <ion-col>\n <ion-label>\n {{ item.label | translate }}\n </ion-label>\n <ion-input [(ngModel)]=\"value\" type=\"number\" step=\"1\"></ion-input>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"allowAdvanced\">\n <ion-button (click)=\"advanced = !advanced\" class=\"squere-button\" [disabled]=\"minValue || maxValue\">\n <ion-icon *ngIf=\"!advanced\" slot=\"icon-only\" name=\"settings-outline\"></ion-icon>\n <ion-icon *ngIf=\"advanced\" slot=\"icon-only\" name=\"settings\"></ion-icon>\n </ion-button>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"value\">\n <ion-button color=\"danger\" (click)=\"refresh(null)\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>\n<ion-row *ngIf=\"(advanced || minValue || maxValue) && allowAdvanced\">\n <ion-col>\n <ion-item>\n <ion-label>\n {{ 'from' | translate }}\n </ion-label>\n <ion-input [(ngModel)]=\"minValue\" type=\"number\" step=\"1\"></ion-input>\n </ion-item>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"minValue\">\n <ion-button color=\"danger\" (click)=\"refresh(null, '>=')\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n <ion-col>\n <ion-item>\n <ion-label>\n {{ 'to' | translate }}\n </ion-label>\n <ion-input [(ngModel)]=\"maxValue\" type=\"number\" step=\"1\"></ion-input>\n </ion-item>\n </ion-col>\n <ion-col size=\"auto\" *ngIf=\"maxValue\">\n <ion-button color=\"danger\" (click)=\"refresh(null, '<=')\" class=\"squere-button\">\n <ion-icon slot=\"icon-only\" name=\"close-outline\"></ion-icon>\n </ion-button>\n </ion-col>\n</ion-row>",
736
- styles: [":host{width:100%}:host .squere-button{height:var(--smart-button-height)!important;margin:.8rem}\n"]
737
- },] }
738
- ];
739
-
740
- /**
741
- * This component is only to use in crud module
742
- * @requires CrudModule
743
- * @example
744
- *
745
- * html: <smart-crud-filters></smart-crud-filters>
746
- *
747
- * use on the model:
748
- * @Model({
749
- titleKey: 'body',
750
- filters: [
751
- {
752
- label: 'testNegation',
753
- key: 'body',
754
- type: '!=',
755
- },
756
- {
757
- label: 'fromDate',
758
- key: 'createDate',
759
- type: '<=',
760
- fieldType: FieldType.dateWithEdit
761
- },
762
- {
763
- label: 'select',
764
- key: 'type',
765
- type: '=',
766
- fieldType: FieldType.radio,
767
- possibilities$: of([
768
- {
769
- id: 1, text: 'Test 1'
770
- },
771
- {
772
- id: 2, text: 'Test 2'
773
- }
774
- ])
775
- }
776
- ]
777
- })
778
- *
779
- * use on the field (list.filter property):
780
- * @Field({
781
- create: modifyMetdata,
782
- update: {
783
- ...modifyMetdata,
784
- multi: true
785
- },
786
- type: FieldType.longText,
787
- details: true,
788
- list: {
789
- order: 2,
790
- filter: true
791
- }
792
- })
793
- body: string;
794
- */
795
- class FiltersComponent {
796
- constructor(menuService, config, facade, styleService, elementRef) {
797
- this.menuService = menuService;
798
- this.config = config;
799
- this.facade = facade;
800
- this.styleService = styleService;
801
- this.elementRef = elementRef;
802
- }
803
- onClose() {
804
- return __awaiter(this, void 0, void 0, function* () {
805
- yield this.menuService.closeEnd();
806
- });
807
- }
808
- ngOnInit() {
809
- this.styleService.init(this.elementRef);
810
- const modelFilters = getModelOptions(this.config.type).filters;
811
- this.list = [
812
- ...(modelFilters ? modelFilters.map(item => {
813
- if (!item.label) {
814
- item.label = 'MODEL.' + item.key;
815
- }
816
- return item;
817
- }) : []),
818
- ...getModelFieldsWithOptions(new this.config.type())
819
- .filter(item => { var _a, _b; return (_b = (_a = item.options) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.filter; })
820
- .map(item => ({
821
- key: item.key,
822
- type: item.options.type === FieldType.text || item.options.type === FieldType.longText
823
- ? '~=' : '=',
824
- label: 'MODEL.' + item.key,
825
- fieldType: item.options.type
826
- }))
827
- ];
828
- this.filter$ = this.facade.filter$;
829
- }
830
- }
831
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
832
- FiltersComponent.decorators = [
833
- { type: Component, args: [{
834
- selector: 'smart-crud-filters',
835
- template: "<ion-header [hidden]=\"hideMenu\">\n <ion-toolbar>\n <ion-buttons slot=\"end\">\n <ion-button (click)=\"onClose()\">\n <ion-icon slot=\"icon-only\" name=\"close\"> </ion-icon>\n </ion-button>\n </ion-buttons>\n <ion-title>{{ 'filters' | translate }}</ion-title>\n </ion-toolbar>\n</ion-header>\n<div class=\"filter-content\">\n <ng-container *ngIf=\"filter$ | async; let filter\">\n <ng-container *ngFor=\"let item of list\">\n <smart-crud-filter [item]=\"item\" [filter]=\"filter\"></smart-crud-filter>\n </ng-container>\n </ng-container>\n <div class=\"menu-bottom-space\">\n &nbsp;\n </div>\n</div>",
836
- styles: [":host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}ion-modal :host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){:host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}ion-modal :host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}}@media only screen and (max-width: 420px){:host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}ion-modal :host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}}:host ion-toolbar.ios{height:4.6rem;--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){:host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}:host ion-toolbar.ios ion-title{text-align:left;padding-left:5.2rem}:host ion-toolbar.ios ion-icon{color:var(--ion-color-light)}}@media only screen and (max-width: 420px){:host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}:host ion-toolbar.ios ion-title{text-align:left;padding-left:5.2rem}:host ion-toolbar.ios ion-icon{color:var(--ion-color-light)}}.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-title{text-align:left;padding-left:1.2rem}.modal-wrapper :host ion-toolbar.ios ion-icon{color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-buttons{margin:0}}@media only screen and (max-width: 420px){.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-title{text-align:left;padding-left:1.2rem}.modal-wrapper :host ion-toolbar.ios ion-icon{color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-buttons{margin:0}}:host ion-toolbar.ios.toolbar-searchbar ion-buttons{height:var(--smart-button-height);margin:.4rem}:host ion-toolbar ion-menu-button{color:var(--ion-color-light)}:host ion-toolbar ion-buttons.ios{height:var(--smart-button-height);margin:0}:host .filter-content{display:block;overflow:auto;overflow-x:hidden}:host .menu-bottom-space{height:75px}\n"]
837
- },] }
838
- ];
839
- /**
840
- * @type {function(): !Array<(null|{
841
- * type: ?,
842
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
843
- * })>}
844
- * @nocollapse
845
- */
846
- FiltersComponent.ctorParameters = () => [
847
- { type: MenuService },
848
- { type: CrudConfig },
849
- { type: CrudFacade },
850
- { type: StyleService },
851
- { type: ElementRef }
852
- ];
853
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
854
- FiltersComponent.propDecorators = {
855
- hideMenu: [{ type: Input }]
856
- };
857
-
858
- class FiltersConfigComponent {
859
- constructor(facade, styleService, elementRef) {
860
- this.facade = facade;
861
- this.styleService = styleService;
862
- this.elementRef = elementRef;
863
- }
864
- onRemoveQuery(item) {
865
- const index = this.facade.filter.query.indexOf(item);
866
- if (index > -1) {
867
- this.facade.filter.query.splice(index, 1);
868
- }
869
- this.facade.read(this.facade.filter);
870
- }
871
- ngOnInit() {
872
- this.styleService.init(this.elementRef);
873
- this.query$ = this.facade.filter$.pipe(map(filter => {
874
- var _a;
875
- return (_a = filter === null || filter === void 0 ? void 0 : filter.query) === null || _a === void 0 ? void 0 : _a.filter(i => !i.hidden);
876
- }));
877
- }
878
- }
879
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
880
- FiltersConfigComponent.decorators = [
881
- { type: Component, args: [{
882
- selector: 'smart-crud-filters-config',
883
- template: " <ng-container *ngIf=\"query$ | async; let query\">\n <ion-toolbar *ngIf=\"query?.length\">\n <ion-chip *ngFor=\"let item of query\" (click)=\"onRemoveQuery(item)\" color=\"medium\" outline=\"true\">\n <ion-icon name=\"filter-circle-outline\" color=\"primary\"></ion-icon>\n <ion-label>{{ 'MODEL.' + item.key | translate }} {{ item.type }} {{ item.value | translate }}</ion-label>\n <ion-icon name=\"close\" color=\"danger\"></ion-icon>\n </ion-chip>\n </ion-toolbar>\n</ng-container>",
884
- styles: [":host ion-label{font-size:calc(var(--default-font-size) - 2px)}\n"]
885
- },] }
886
- ];
887
- /**
888
- * @type {function(): !Array<(null|{
889
- * type: ?,
890
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
891
- * })>}
892
- * @nocollapse
893
- */
894
- FiltersConfigComponent.ctorParameters = () => [
895
- { type: CrudFacade },
896
- { type: StyleService },
897
- { type: ElementRef }
898
- ];
899
-
900
- class MultiselectComponent {
901
- constructor(facade, config, menuService) {
902
- this.facade = facade;
903
- this.config = config;
904
- this.menuService = menuService;
905
- this.buttonOptions = {
906
- click: () => __awaiter(this, void 0, void 0, function* () {
907
- const result = this._list.map(item => {
908
- return Object.assign(Object.assign({}, this._changes), { id: item.id });
909
- });
910
- this.facade.updatePartialMany(result);
911
- yield this.menuService.closeEnd();
912
- }),
913
- confirm: true
914
- };
915
- this.list$ = this.facade.multiSelected$.pipe(tap(list => {
916
- this.lock = true;
917
- const model = new this.config.type();
918
- const fieldsWithOptions = getModelFieldsWithOptions(model)
919
- .filter(f => { var _a; return (_a = f.options.update) === null || _a === void 0 ? void 0 : _a.multi; });
920
- fieldsWithOptions.forEach(({ key }) => {
921
- const uniques = _.uniq(list.map(i => i[key]));
922
- if (uniques.length === 1) {
923
- model[key] = uniques[0];
924
- }
925
- });
926
- this.item = model;
927
- }));
928
- }
929
- onClose() {
930
- return __awaiter(this, void 0, void 0, function* () {
931
- yield this.menuService.closeEnd();
932
- });
933
- }
934
- onPartialChange(changes, list) {
935
- this.lock = false;
936
- this._list = list;
937
- this._changes = changes;
938
- }
939
- onValidChange(valid) {
940
- this.valid = valid;
941
- }
942
- ngOnInit() {
943
- }
944
- }
945
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
946
- MultiselectComponent.decorators = [
947
- { type: Component, args: [{
948
- selector: 'smart-crud-multiselect',
949
- template: "<ng-container *ngIf=\"list$ | async; let list\">\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot=\"end\">\n <ion-button (click)=\"onClose()\">\n <ion-icon slot=\"icon-only\" name=\"close\"> </ion-icon>\n </ion-button>\n </ion-buttons>\n <ion-title>{{ 'selected' | translate }}: {{ list?.length }}</ion-title>\n </ion-toolbar>\n </ion-header>\n\n <div *ngIf=\"item\">\n <smart-form [options]=\"item | smartFormOptions : 'multiUpdate' : config.type\" (valuePartialChange)=\"onPartialChange($event, list)\" (validChange)=\"onValidChange($event)\"></smart-form>\n\n <smart-button style=\"float: right\" [disabled]=\"lock || !valid\" [options]=\"buttonOptions\">{{ 'change' | translate }}</smart-button>\n </div>\n</ng-container>",
950
- styles: [":host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){:host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}}@media only screen and (max-width: 420px){:host ion-toolbar{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}}:host ion-toolbar.ios{height:4.6rem;--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){:host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}:host ion-toolbar.ios ion-title{text-align:left;padding-left:5.2rem}:host ion-toolbar.ios ion-icon{color:var(--ion-color-light)}}@media only screen and (max-width: 420px){:host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-primary), var(--ion-color-tertiary));--color: var(--ion-color-light)}:host ion-toolbar.ios ion-title{text-align:left;padding-left:5.2rem}:host ion-toolbar.ios ion-icon{color:var(--ion-color-light)}}.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));--color: var(--ion-color-dark)}@media only screen and (max-width: 992px){.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-title{text-align:left;padding-left:1.2rem}.modal-wrapper :host ion-toolbar.ios ion-icon{color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-buttons{margin:0}}@media only screen and (max-width: 420px){.modal-wrapper :host ion-toolbar.ios{--background: linear-gradient(33deg, var(--ion-color-light), var(--ion-color-light-shade));color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-title{text-align:left;padding-left:1.2rem}.modal-wrapper :host ion-toolbar.ios ion-icon{color:var(--ion-color-dark)}.modal-wrapper :host ion-toolbar.ios ion-buttons{margin:0}}:host ion-toolbar ion-menu-button{color:var(--ion-color-light)}:host ion-toolbar ion-buttons.ios{height:var(--smart-button-height);margin:0}\n"]
951
- },] }
952
- ];
953
- /**
954
- * @type {function(): !Array<(null|{
955
- * type: ?,
956
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
957
- * })>}
958
- * @nocollapse
959
- */
960
- MultiselectComponent.ctorParameters = () => [
961
- { type: CrudFacade },
962
- { type: CrudConfig },
963
- { type: MenuService }
964
- ];
965
-
966
- class CrudListGroupService {
967
- constructor(facade) {
968
- this.facade = facade;
969
- this._destroyed = [];
970
- }
971
- change(val, item, groups, force) {
972
- if (val || force) {
973
- item.changed = true;
974
- let current = this.facade.filter.query.find(q => q.key === item.key && q.type === '=');
975
- if (!current) {
976
- current = {
977
- key: item.key,
978
- type: "=",
979
- value: null
980
- };
981
- this.facade.filter.query.push(current);
982
- }
983
- current.value = item.value;
984
- current.hidden = true;
985
- this.facade.read(Object.assign(Object.assign({}, this.facade.filter), { offset: 0 }));
986
- }
987
- }
988
- destroy(groups) {
989
- this._destroyed = [
990
- ...(this._destroyed ? this._destroyed : []),
991
- ...groups.filter(g => g.changed)
992
- ];
993
- this.refresh();
994
- }
995
- refresh() {
996
- const list = this._destroyed;
997
- this._destroyed = [];
998
- const newQuery = this.facade.filter.query.filter(q => !list.some(i => q.key === i.key));
999
- this.facade.read(Object.assign(Object.assign({}, this.facade.filter), { query: newQuery }));
1000
- }
1001
- }
1002
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1003
- CrudListGroupService.decorators = [
1004
- { type: Injectable }
1005
- ];
1006
- /**
1007
- * @type {function(): !Array<(null|{
1008
- * type: ?,
1009
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1010
- * })>}
1011
- * @nocollapse
1012
- */
1013
- CrudListGroupService.ctorParameters = () => [
1014
- { type: CrudFacade }
1015
- ];
1016
- __decorate([
1017
- debounce(250),
1018
- __metadata("design:type", Function),
1019
- __metadata("design:paramtypes", []),
1020
- __metadata("design:returntype", void 0)
1021
- ], CrudListGroupService.prototype, "refresh", null);
1022
-
1023
- class GroupComponent extends BaseComponent$1 {
1024
- constructor(styleService, elementRef, facade, cd, groupService) {
1025
- super();
1026
- this.styleService = styleService;
1027
- this.elementRef = elementRef;
1028
- this.facade = facade;
1029
- this.cd = cd;
1030
- this.groupService = groupService;
1031
- }
1032
- change(val, item, force = false) {
1033
- this.groups.filter(i => i.value !== item.value || i.key !== item.key).forEach(i => {
1034
- i.show = false;
1035
- });
1036
- this.groupService.change(val, item, this.groups, force);
1037
- if (val) {
1038
- setTimeout(() => {
1039
- item.show = val;
1040
- this.cd.detectChanges();
1041
- });
1042
- }
1043
- else {
1044
- item.show = val;
1045
- this.cd.detectChanges();
1046
- }
1047
- }
1048
- ngOnInit() {
1049
- this.styleService.init(this.elementRef);
1050
- }
1051
- ngOnDestroy() {
1052
- this.groupService.destroy(this.groups);
1053
- super.ngOnDestroy();
1054
- }
1055
- }
1056
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1057
- GroupComponent.decorators = [
1058
- { type: Component, args: [{
1059
- selector: 'smart-crud-group',
1060
- template: "<smart-accordion *ngFor=\"let item of groups\" [(show)]=\"item.show\" (showChange)=\"change($event, item)\">\n <smart-accordion-header [ngClass]=\"{ 'accordion-show': item.show }\">{{ item.text | translate }}</smart-accordion-header>\n <smart-accordion-body>\n <smart-list *ngIf=\"item.show && !item.children && listOptions\" [options]=\"listOptions\"></smart-list>\n <div *ngIf=\"item.children\" style=\"margin-left: 50px\">\n <smart-crud-group [groups]=\"item.children\" [listOptions]=\"listOptions\"></smart-crud-group>\n </div>\n </smart-accordion-body>\n</smart-accordion>\n<br/><br/><br/>",
1061
- styles: [".accordion-show{font-weight:bolder}\n"]
1062
- },] }
1063
- ];
1064
- /**
1065
- * @type {function(): !Array<(null|{
1066
- * type: ?,
1067
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1068
- * })>}
1069
- * @nocollapse
1070
- */
1071
- GroupComponent.ctorParameters = () => [
1072
- { type: StyleService },
1073
- { type: ElementRef },
1074
- { type: CrudFacade },
1075
- { type: ChangeDetectorRef },
1076
- { type: CrudListGroupService }
1077
- ];
1078
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
1079
- GroupComponent.propDecorators = {
1080
- groups: [{ type: Input }],
1081
- listOptions: [{ type: Input }]
1082
- };
1083
-
1084
- class SocketService {
1085
- }
1086
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1087
- SocketService.decorators = [
1088
- { type: Injectable }
1089
- ];
1090
- class NotSocketService {
1091
- }
1092
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1093
- NotSocketService.decorators = [
1094
- { type: Injectable }
1095
- ];
1096
-
1097
- class FormOptionsPipe {
1098
- constructor(modelPossibilitiesProvider) {
1099
- this.modelPossibilitiesProvider = modelPossibilitiesProvider;
1100
- }
1101
- transform(item, mode, type, uniqueProvider, inputComponents) {
1102
- if (!mode || !type)
1103
- return null;
1104
- let possibilities = {};
1105
- if (type && this.modelPossibilitiesProvider) {
1106
- possibilities = this.modelPossibilitiesProvider.get(type);
1107
- }
1108
- if (mode === "create") {
1109
- return {
1110
- mode: "create",
1111
- possibilities,
1112
- inputComponents,
1113
- uniqueProvider,
1114
- model: new type(),
1115
- };
1116
- }
1117
- else {
1118
- const model = new type();
1119
- if (item) {
1120
- Object.keys(item).forEach((key) => {
1121
- model[key] = item[key];
1122
- });
1123
- }
1124
- return {
1125
- mode: mode,
1126
- uniqueProvider,
1127
- possibilities: possibilities,
1128
- inputComponents,
1129
- model: model,
1130
- };
1131
- }
1132
- }
1133
- }
1134
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1135
- FormOptionsPipe.decorators = [
1136
- { type: Pipe, args: [{
1137
- name: "smartFormOptions",
1138
- },] }
1139
- ];
1140
- /**
1141
- * @type {function(): !Array<(null|{
1142
- * type: ?,
1143
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1144
- * })>}
1145
- * @nocollapse
1146
- */
1147
- FormOptionsPipe.ctorParameters = () => [
1148
- { type: ICrudModelPossibilitiesProvider, decorators: [{ type: Optional }, { type: Inject, args: [CRUD_MODEL_POSSIBILITIES_PROVIDER,] }] }
1149
- ];
1150
-
1151
- class CrudPipesModule {
1152
- }
1153
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1154
- CrudPipesModule.decorators = [
1155
- { type: NgModule, args: [{
1156
- declarations: [
1157
- FormOptionsPipe
1158
- ],
1159
- exports: [
1160
- FormOptionsPipe
1161
- ]
1162
- },] }
1163
- ];
1164
-
1165
- class CrudService {
1166
- constructor(config, http, socket) {
1167
- this.config = config;
1168
- this.http = http;
1169
- this.socket = socket;
1170
- this._formatMap = {
1171
- csv: "text/csv",
1172
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1173
- };
1174
- }
1175
- // changes(criteria: { id?: string } = {}): Observable<ItemChangedData> {
1176
- // this.socket.emit("changes", criteria);
1177
- // return this.socket.fromEvent("changes");
1178
- // }
1179
- // TODO : Location is null
1180
- create(item) {
1181
- return this.http
1182
- .post(this.config.apiUrl, item, { observe: "response" })
1183
- .pipe(map((response) => {
1184
- const location = response.headers["Location"];
1185
- if (!location)
1186
- return null;
1187
- const array = location.split("/");
1188
- return array[array.length - 1];
1189
- }));
1190
- }
1191
- createMany(items, options) {
1192
- return this.http.post(this.config.apiUrl + "/bulk?mode=" + options.mode, items);
1193
- }
1194
- getById(id) {
1195
- return this.http.get(this.config.apiUrl + "/" + id);
1196
- }
1197
- getList(filter = null) {
1198
- return this.http.get(this.config.apiUrl + this.getQuery(filter));
1199
- }
1200
- exportList(filter = null, format) {
1201
- if (!format) {
1202
- format = "csv";
1203
- }
1204
- if (format === "xlsx") {
1205
- return this.http
1206
- .get(this.config.apiUrl + this.getQuery(filter), {
1207
- headers: {
1208
- "Content-Type": this._formatMap[format],
1209
- },
1210
- observe: "response",
1211
- reportProgress: false,
1212
- responseType: "blob",
1213
- })
1214
- .pipe(map((res) => {
1215
- const downloadLink = document.createElement("a");
1216
- const blob = res.body;
1217
- const url = URL.createObjectURL(blob);
1218
- downloadLink.href = url;
1219
- downloadLink.download = "data." + format;
1220
- document.body.appendChild(downloadLink);
1221
- downloadLink.click();
1222
- document.body.removeChild(downloadLink);
1223
- }));
1224
- }
1225
- return this.http
1226
- .get(this.config.apiUrl + this.getQuery(filter), {
1227
- headers: {
1228
- "Content-Type": this._formatMap[format],
1229
- },
1230
- responseType: "text",
1231
- })
1232
- .pipe(map((res) => {
1233
- const downloadLink = document.createElement("a");
1234
- const blob = new Blob(["\ufeff", res]);
1235
- const url = URL.createObjectURL(blob);
1236
- downloadLink.href = url;
1237
- downloadLink.download = "data." + format;
1238
- document.body.appendChild(downloadLink);
1239
- downloadLink.click();
1240
- document.body.removeChild(downloadLink);
1241
- }));
1242
- }
1243
- update(item) {
1244
- return this.http.put(this.config.apiUrl + "/" + item.id, item);
1245
- }
1246
- updatePartial(item) {
1247
- return this.http.patch(this.config.apiUrl + "/" + item.id, item);
1248
- }
1249
- updatePartialMany(items) {
1250
- return forkJoin(items.map(item => {
1251
- return this.updatePartial(item);
1252
- }));
1253
- }
1254
- delete(id) {
1255
- return this.http.delete(this.config.apiUrl + "/" + id);
1256
- }
1257
- getQuery(filter) {
1258
- let query = "";
1259
- if (filter && filter.searchText) {
1260
- query += "&$search=" + filter.searchText;
1261
- }
1262
- if (filter && filter.limit) {
1263
- query += `&limit=${filter.limit}&offset=${filter.offset ? filter.offset : 0}`;
1264
- }
1265
- if (filter && filter.sortBy) {
1266
- query += `&sort=${(filter.sortDesc ? "-" : "") + filter.sortBy}`;
1267
- }
1268
- if (filter && filter.query) {
1269
- filter.query.forEach((q) => {
1270
- if (q.value
1271
- && (typeof q.value === 'string')
1272
- && q.value.match(/^-?\d+$/)
1273
- && q.value[0] !== "'"
1274
- && q.value[0] !== '"') {
1275
- query += "&" + q.key + q.type + `'${q.value}'`;
1276
- }
1277
- else {
1278
- query += "&" + q.key + q.type + q.value;
1279
- }
1280
- });
1281
- }
1282
- return query ? "?" + query.replace("&", "") : "";
1283
- }
1284
- }
1285
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1286
- CrudService.decorators = [
1287
- { type: Injectable }
1288
- ];
1289
- /**
1290
- * @type {function(): !Array<(null|{
1291
- * type: ?,
1292
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1293
- * })>}
1294
- * @nocollapse
1295
- */
1296
- CrudService.ctorParameters = () => [
1297
- { type: CrudConfig },
1298
- { type: HttpClient },
1299
- { type: SocketService, decorators: [{ type: Optional }] }
1300
- ];
1301
-
1302
- class CrudEffects {
1303
- constructor(actions$, service, config, store, state) {
1304
- this.actions$ = actions$;
1305
- this.service = service;
1306
- this.config = config;
1307
- this.store = store;
1308
- this.state = state;
1309
- }
1310
- init() {
1311
- const metadata = Reflect.getMetadata(this.config.entity, CrudEffects);
1312
- if (metadata)
1313
- return;
1314
- Reflect.defineMetadata(this.config.entity, true, CrudEffects);
1315
- this.actions$.subscribe((action) => {
1316
- switch (action.type) {
1317
- case `[${this.config.entity}] Create`:
1318
- this.service
1319
- .create(action.item)
1320
- .pipe(tap(() => this.store.dispatch(createSuccess(this.config.entity, action.item))), catchError((error) => {
1321
- this.store.dispatch(createFailure(this.config.entity, action.item, error));
1322
- return of();
1323
- }))
1324
- .subscribe();
1325
- break;
1326
- case `[${this.config.entity}] Create Success`:
1327
- const createState = this.state.getValue()[this.config.entity];
1328
- this.store.dispatch(read(this.config.entity, createState.filter ? Object.assign(Object.assign({}, createState.filter), { offset: 0 }) : null));
1329
- break;
1330
- case `[${this.config.entity}] Create Many`:
1331
- this.service
1332
- .createMany(action.data.items, action.data.options)
1333
- .pipe(tap(() => this.store.dispatch(createManySuccess(this.config.entity, {
1334
- items: action.data.items,
1335
- options: action.data.options,
1336
- }))), catchError((error) => {
1337
- this.store.dispatch(createManyFailure(this.config.entity, {
1338
- items: action.data.items,
1339
- options: action.data.options,
1340
- }, error));
1341
- return of();
1342
- }))
1343
- .subscribe();
1344
- break;
1345
- case `[${this.config.entity}] Create Many Success`:
1346
- const createManyState = this.state.getValue()[this.config.entity];
1347
- this.store.dispatch(read(this.config.entity, createManyState.filter
1348
- ? Object.assign(Object.assign({}, createManyState.filter), { offset: 0 }) : null));
1349
- break;
1350
- case `[${this.config.entity}] Read`:
1351
- this.service
1352
- .getList(action.filter)
1353
- .pipe(tap((result) => this.store.dispatch(readSuccess(this.config.entity, action.filter, result))), catchError((error) => {
1354
- this.store.dispatch(readFailure(this.config.entity, action.filter, error));
1355
- return of();
1356
- }))
1357
- .subscribe();
1358
- break;
1359
- case `[${this.config.entity}] Export`:
1360
- this.service
1361
- .exportList(action.filter, action.format)
1362
- .pipe(tap((result) => this.store.dispatch(exportListSuccess(this.config.entity, action.filter))), catchError((error) => {
1363
- this.store.dispatch(exportListFailure(this.config.entity, action.filter, error));
1364
- return of();
1365
- }))
1366
- .subscribe();
1367
- break;
1368
- case `[${this.config.entity}] Select`:
1369
- this.service
1370
- .getById(action.id)
1371
- .pipe(tap((result) => this.store.dispatch(selectSuccess(this.config.entity, action.id, result))), catchError((error) => {
1372
- this.store.dispatch(selectFailure(this.config.entity, action.id, error));
1373
- return of();
1374
- }))
1375
- .subscribe();
1376
- break;
1377
- case `[${this.config.entity}] Update`:
1378
- this.service
1379
- .updatePartial(action.item)
1380
- .pipe(tap(() => this.store.dispatch(updateSuccess(this.config.entity, action.item))), catchError((error) => {
1381
- this.store.dispatch(updateFailure(this.config.entity, action.item, error));
1382
- this.store.dispatch(read(this.config.entity));
1383
- return of();
1384
- }))
1385
- .subscribe();
1386
- break;
1387
- case `[${this.config.entity}] Update Success`:
1388
- this.store
1389
- .pipe(select$1(getCrudFilter(this.config.entity)), first())
1390
- .subscribe((filter) => {
1391
- this.store.dispatch(read(this.config.entity, Object.assign(Object.assign({}, filter), { offset: 0 })));
1392
- this.store.dispatch(select(this.config.entity, action.item.id));
1393
- });
1394
- break;
1395
- case `[${this.config.entity}] Update partial`:
1396
- this.service
1397
- .updatePartial(action.item)
1398
- .pipe(tap(() => this.store.dispatch(updatePartialSuccess(this.config.entity, action.item))), catchError((error) => {
1399
- this.store.dispatch(updatePartialFailure(this.config.entity, action.item, error));
1400
- this.store.dispatch(read(this.config.entity));
1401
- return of();
1402
- }))
1403
- .subscribe();
1404
- break;
1405
- case `[${this.config.entity}] Update partial Success`:
1406
- this.store
1407
- .pipe(select$1(getCrudFilter(this.config.entity)), first())
1408
- .subscribe((filter) => {
1409
- this.store.dispatch(read(this.config.entity, Object.assign(Object.assign({}, filter), { offset: 0 })));
1410
- this.store.dispatch(select(this.config.entity, action.item.id));
1411
- });
1412
- break;
1413
- case `[${this.config.entity}] Update partial many`:
1414
- this.service
1415
- .updatePartialMany(action.items)
1416
- .pipe(tap(() => this.store.dispatch(updatePartialManySuccess(this.config.entity, action.items))), catchError((error) => {
1417
- this.store.dispatch(updatePartialManyFailure(this.config.entity, action.items, error));
1418
- this.store.dispatch(read(this.config.entity));
1419
- return of();
1420
- }))
1421
- .subscribe();
1422
- break;
1423
- case `[${this.config.entity}] Update partial many Success`:
1424
- this.store
1425
- .pipe(select$1(getCrudFilter(this.config.entity)), first())
1426
- .subscribe((filter) => {
1427
- this.store.dispatch(read(this.config.entity, Object.assign(Object.assign({}, filter), { offset: 0 })));
1428
- });
1429
- break;
1430
- case `[${this.config.entity}] Delete`:
1431
- this.service
1432
- .delete(action.id)
1433
- .pipe(tap(() => this.store.dispatch(deleteSuccess(this.config.entity, action.id))), catchError((error) => {
1434
- this.store.dispatch(deleteFailure(this.config.entity, action.id, error));
1435
- return of();
1436
- }))
1437
- .subscribe();
1438
- break;
1439
- case `[${this.config.entity}] Delete Success`:
1440
- this.store
1441
- .pipe(select$1(getCrudFilter(this.config.entity)), first())
1442
- .subscribe((filter) => {
1443
- this.store.dispatch(read(this.config.entity, Object.assign(Object.assign({}, filter), { offset: 0 })));
1444
- });
1445
- break;
1446
- default:
1447
- break;
1448
- }
1449
- });
1450
- }
1451
- }
1452
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1453
- CrudEffects.decorators = [
1454
- { type: Injectable }
1455
- ];
1456
- /**
1457
- * @type {function(): !Array<(null|{
1458
- * type: ?,
1459
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1460
- * })>}
1461
- * @nocollapse
1462
- */
1463
- CrudEffects.ctorParameters = () => [
1464
- { type: ActionsSubject },
1465
- { type: CrudService },
1466
- { type: CrudConfig },
1467
- { type: Store },
1468
- { type: State }
1469
- ];
1470
-
1471
- class CrudListPaginationFactory {
1472
- constructor(facade) {
1473
- this.facade = facade;
1474
- }
1475
- create(options) {
1476
- return __awaiter(this, void 0, void 0, function* () {
1477
- return {
1478
- mode: options.mode,
1479
- limit: options.limit,
1480
- loadNextPage: () => {
1481
- if (!options.provider.getLinks() || !options.provider.getLinks().next)
1482
- return Promise.resolve(false);
1483
- return new Promise((res) => {
1484
- const sub = this.facade.loaded$.subscribe((l) => {
1485
- if (l) {
1486
- // if (sub && !sub.closed) sub.unsubscribe();
1487
- setTimeout(() => {
1488
- res(options.provider.getLinks() &&
1489
- options.provider.getLinks().next);
1490
- });
1491
- }
1492
- });
1493
- this.facade.read(Object.assign(Object.assign({}, options.provider.getFilter()), { offset: options.provider.getFilter().offset +
1494
- options.provider.getFilter().limit }));
1495
- });
1496
- },
1497
- loadPrevPage: () => {
1498
- if (!options.provider.getLinks() || !options.provider.getLinks().prev)
1499
- return Promise.resolve(false);
1500
- return new Promise((res) => {
1501
- const sub = this.facade.loaded$.subscribe((l) => {
1502
- if (l) {
1503
- // if (sub && !sub.closed) sub.unsubscribe();
1504
- setTimeout(() => {
1505
- res(options.provider.getLinks() &&
1506
- options.provider.getLinks().prev);
1507
- });
1508
- }
1509
- });
1510
- this.facade.read(Object.assign(Object.assign({}, options.provider.getFilter()), { offset: options.provider.getFilter().offset -
1511
- options.provider.getFilter().limit }));
1512
- });
1513
- },
1514
- page$: this.facade.filter$.pipe(map((f) => {
1515
- return (f === null || f === void 0 ? void 0 : f.limit) ? f.offset / f.limit + 1 : 0;
1516
- })),
1517
- totalPages$: combineLatest(this.facade.filter$, this.facade.totalCount$).pipe(map(([filter, totalCount]) => {
1518
- return (filter === null || filter === void 0 ? void 0 : filter.limit) ? Math.ceil(totalCount / filter.limit) : 0;
1519
- })),
1520
- };
1521
- });
1522
- }
1523
- }
1524
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1525
- CrudListPaginationFactory.decorators = [
1526
- { type: Injectable }
1527
- ];
1528
- /**
1529
- * @type {function(): !Array<(null|{
1530
- * type: ?,
1531
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1532
- * })>}
1533
- * @nocollapse
1534
- */
1535
- CrudListPaginationFactory.ctorParameters = () => [
1536
- { type: CrudFacade }
1537
- ];
1538
-
1539
- const COMPONENTS = [
1540
- ExportComponent,
1541
- FilterComponent,
1542
- FilterTextComponent,
1543
- FiltersConfigComponent,
1544
- FilterDateComponent,
1545
- FilterDateWithEditComponent,
1546
- FilterRadioComponent,
1547
- FiltersComponent,
1548
- FilterFlagComponent,
1549
- FilterCheckComponent,
1550
- FilterIntComponent,
1551
- MultiselectComponent,
1552
- GroupComponent
1553
- ];
1554
- class CrudComponentsModule {
1555
- }
1556
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1557
- CrudComponentsModule.decorators = [
1558
- { type: NgModule, args: [{
1559
- declarations: [
1560
- ...COMPONENTS
1561
- ],
1562
- imports: [
1563
- //AuthSharedModule,
1564
- StoreModule,
1565
- SharedModule,
1566
- CrudPipesModule,
1567
- FormsModule,
1568
- CommonModule
1569
- ],
1570
- exports: [
1571
- CrudPipesModule,
1572
- ...COMPONENTS
1573
- ],
1574
- entryComponents: [
1575
- ...COMPONENTS
1576
- ],
1577
- providers: [
1578
- CrudService,
1579
- CrudEffects,
1580
- CrudFacade,
1581
- SocketService,
1582
- CrudListPaginationFactory,
1583
- ]
1584
- },] }
1585
- ];
1586
-
1587
- const initialState = {
1588
- loaded: false
1589
- };
1590
- const crudReducer = (state = initialState, action, entity) => {
1591
- switch (action.type) {
1592
- case `[${entity}] Create`:
1593
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1594
- case `[${entity}] Create Success`:
1595
- return Object.assign(Object.assign({}, state), { loaded: true, error: null });
1596
- case `[${entity}] Create Failure`:
1597
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1598
- case `[${entity}] Create Many`:
1599
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1600
- case `[${entity}] Create Many Success`:
1601
- return Object.assign(Object.assign({}, state), { loaded: true, error: null });
1602
- case `[${entity}] Create Many Failure`:
1603
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1604
- case `[${entity}] Export`:
1605
- return Object.assign(Object.assign({}, state), { loaded: false });
1606
- case `[${entity}] Export Success`:
1607
- return Object.assign(Object.assign({}, state), { loaded: true });
1608
- case `[${entity}] Export Failure`:
1609
- return Object.assign(Object.assign({}, state), { loaded: true });
1610
- case `[${entity}] Read`:
1611
- return Object.assign(Object.assign({}, state), { loaded: false, filter: action.filter, error: null, totalCount: null, links: null });
1612
- case `[${entity}] Read Success`:
1613
- let list = [];
1614
- if (action.filter
1615
- && action.filter.offset
1616
- && state.list
1617
- && action.filter.paginationMode !== PaginationMode.singlePage) {
1618
- state.list.forEach(i => {
1619
- list.push(i);
1620
- });
1621
- list = [
1622
- ...list,
1623
- ...action.result.data
1624
- ];
1625
- }
1626
- else {
1627
- list = action.result.data;
1628
- }
1629
- return Object.assign(Object.assign({}, state), { loaded: true, list, totalCount: action.result.totalCount, links: action.result.links, error: null });
1630
- case `[${entity}] Read Failure`:
1631
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1632
- case `[${entity}] Select`:
1633
- return Object.assign(Object.assign({}, state), { loaded: false, selected: null, error: null });
1634
- case `[${entity}] Select Success`:
1635
- return Object.assign(Object.assign({}, state), { loaded: true, selected: action.item, error: null });
1636
- case `[${entity}] Select Failure`:
1637
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1638
- case `[${entity}] MultiSelect`:
1639
- return Object.assign(Object.assign({}, state), { multiSelected: [...action.items] });
1640
- case `[${entity}] Unselect`:
1641
- return Object.assign(Object.assign({}, state), { loaded: true, selected: null, error: null });
1642
- case `[${entity}] Update`:
1643
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1644
- case `[${entity}] Update Success`:
1645
- return Object.assign(Object.assign({}, state), { loaded: true, error: null });
1646
- case `[${entity}] Update Failure`:
1647
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1648
- case `[${entity}] Update partial`:
1649
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1650
- case `[${entity}] Update partial Success`:
1651
- return Object.assign(Object.assign({}, state), { loaded: true, error: null });
1652
- case `[${entity}] Update partial Failure`:
1653
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1654
- case `[${entity}] Update partial many`:
1655
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1656
- case `[${entity}] Update partial many Success`:
1657
- return Object.assign(Object.assign({}, state), { multiSelected: [], loaded: true, error: null });
1658
- case `[${entity}] Update partial many Failure`:
1659
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1660
- case `[${entity}] Delete`:
1661
- return Object.assign(Object.assign({}, state), { loaded: false, error: null });
1662
- case `[${entity}] Delete Success`:
1663
- return Object.assign(Object.assign({}, state), { loaded: true, error: null });
1664
- case `[${entity}] Delete Failure`:
1665
- return Object.assign(Object.assign({}, state), { loaded: true, error: action.error });
1666
- default:
1667
- return state;
1668
- }
1669
- };
1670
- const ɵ0 = crudReducer;
1671
- function getReducer(entity) {
1672
- return (state, action) => {
1673
- return crudReducer(state, action, entity);
1674
- };
1675
- }
1676
-
1677
- class PageService {
1678
- constructor(authService, config) {
1679
- this.authService = authService;
1680
- this.config = config;
1681
- }
1682
- checkPermissions() {
1683
- const val = this.config;
1684
- const modelOptions = getModelOptions(val.type);
1685
- if (val.add &&
1686
- modelOptions.create &&
1687
- modelOptions.create.permissions &&
1688
- !this.authService.expectPermissions(modelOptions.create.permissions)) {
1689
- val.add = false;
1690
- }
1691
- if (val.edit &&
1692
- modelOptions.update &&
1693
- modelOptions.update.permissions &&
1694
- !this.authService.expectPermissions(modelOptions.update.permissions)) {
1695
- val.edit = false;
1696
- }
1697
- if (val.remove &&
1698
- modelOptions.remove &&
1699
- modelOptions.remove.permissions &&
1700
- !this.authService.expectPermissions(modelOptions.remove.permissions)) {
1701
- val.remove = false;
1702
- }
1703
- }
1704
- }
1705
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1706
- PageService.decorators = [
1707
- { type: Injectable }
1708
- ];
1709
- /**
1710
- * @type {function(): !Array<(null|{
1711
- * type: ?,
1712
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
1713
- * })>}
1714
- * @nocollapse
1715
- */
1716
- PageService.ctorParameters = () => [
1717
- { type: AuthService },
1718
- { type: CrudFullConfig }
1719
- ];
1720
-
1721
- class CrudSearchService {
1722
- constructor() {
1723
- this._filterSource = new BehaviorSubject(null);
1724
- this._enabledSource = new BehaviorSubject(false);
1725
- this.enabled$ = this._enabledSource.asObservable();
1726
- this.filter$ = combineLatest([
1727
- this._filterSource.asObservable(), this.enabled$
1728
- ]).pipe(map(([filter, enabled]) => {
1729
- if (!enabled)
1730
- return {};
1731
- return filter;
1732
- }));
1733
- }
1734
- get filter() {
1735
- if (!this._enabledSource.value)
1736
- return {};
1737
- return this._filterSource.value;
1738
- }
1739
- get enabled() {
1740
- return this._enabledSource.value;
1741
- }
1742
- setFilter(val) {
1743
- this._filterSource.next(val);
1744
- }
1745
- setEnabled(val) {
1746
- this._enabledSource.next(val);
1747
- }
1748
- }
1749
- /** @nocollapse */ CrudSearchService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CrudSearchService_Factory() { return new CrudSearchService(); }, token: CrudSearchService, providedIn: "root" });
1750
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
1751
- CrudSearchService.decorators = [
1752
- { type: Injectable, args: [{
1753
- providedIn: 'root'
1754
- },] }
1755
- ];
1756
-
1757
- class ListComponent extends CreateDynamicComponent('crud-list-page') {
1758
- constructor(facade, router, dynamicComponentLoader, injector, cd, menuService, hardwareService, paginationFacade, styleService, elementRef, pageService, config, searchService, moduleRef, componentFactoryResolver) {
1759
- super(cd, moduleRef, componentFactoryResolver);
1760
- this.facade = facade;
1761
- this.router = router;
1762
- this.dynamicComponentLoader = dynamicComponentLoader;
1763
- this.injector = injector;
1764
- this.cd = cd;
1765
- this.menuService = menuService;
1766
- this.hardwareService = hardwareService;
1767
- this.paginationFacade = paginationFacade;
1768
- this.styleService = styleService;
1769
- this.elementRef = elementRef;
1770
- this.pageService = pageService;
1771
- this.config = config;
1772
- this.searchService = searchService;
1773
- this.moduleRef = moduleRef;
1774
- this.componentFactoryResolver = componentFactoryResolver;
1775
- this.filter$ = this.facade.filter$.pipe(tap((filter) => {
1776
- this.filter = filter;
1777
- }));
1778
- this.dynamicContents = new QueryList();
1779
- this.facade.links$.pipe(this.takeUntilDestroy).subscribe((links) => {
1780
- this.links = links;
1781
- });
1782
- }
1783
- refreshProperties() {
1784
- this.baseInstance.listOptions = this.listOptions;
1785
- }
1786
- ngOnInit() {
1787
- var _a, _b, _c, _d, _e, _f, _g;
1788
- return __awaiter(this, void 0, void 0, function* () {
1789
- yield this.pageService.checkPermissions();
1790
- let newFilter = null;
1791
- if (((_a = this.config.list) === null || _a === void 0 ? void 0 : _a.resetQuery) === 'beforeInit') {
1792
- newFilter = Object.assign({ query: this.config.baseQuery ? [...this.config.baseQuery] : [], paginationMode: this.config.list.paginationMode, limit: this.config.pagination ? this.config.pagination.limit : null, offset: this.config.pagination ? 0 : null, sortBy: this.config.sort ? this.config.sort["default"] : null, sortDesc: this.config.sort ? this.config.sort["defaultDesc"] : null }, this.searchService.filter);
1793
- }
1794
- else if (this.filter) {
1795
- newFilter = this.filter;
1796
- }
1797
- else {
1798
- newFilter = Object.assign({ paginationMode: this.config.list.paginationMode, limit: ((_b = this.searchService.filter) === null || _b === void 0 ? void 0 : _b.limit) ? this.searchService.filter.limit : this.config.pagination
1799
- ? this.config.pagination.limit : null, offset: ((_c = this.searchService.filter) === null || _c === void 0 ? void 0 : _c.offset) || ((_d = this.searchService.filter) === null || _d === void 0 ? void 0 : _d.offset) === 0
1800
- ? this.searchService.filter.offset : this.config.pagination ? 0 : null, sortBy: ((_e = this.searchService.filter) === null || _e === void 0 ? void 0 : _e.sortBy) ? this.searchService.filter.sortBy : this.config.sort
1801
- ? this.config.sort["default"] : null, sortDesc: ((_f = this.searchService.filter) === null || _f === void 0 ? void 0 : _f.sortDesc) ? this.searchService.filter.sortDesc : this.config.sort
1802
- ? this.config.sort["defaultDesc"] : null, query: this.config.baseQuery ? [...this.config.baseQuery] : [] }, this.searchService.filter);
1803
- }
1804
- this.facade.read(newFilter);
1805
- const endButtons = this.getEndButtons();
1806
- this.pageOptions = {
1807
- title: this.config.title,
1808
- search: this.config.search
1809
- ? {
1810
- text$: this.filter$.pipe(map((f) => (f ? f.searchText : null))),
1811
- set: (txt) => {
1812
- if (txt !== this.filter.searchText)
1813
- this.facade.read(Object.assign(Object.assign({}, this.filter), { searchText: txt, offset: 0 }));
1814
- },
1815
- }
1816
- : null,
1817
- endButtons: endButtons,
1818
- };
1819
- const compiledComponents = yield this.dynamicComponentLoader.getComponentsWithFactories({
1820
- components: [
1821
- ...(this.config.details &&
1822
- this.config.details["components"] &&
1823
- this.config.details["components"].top
1824
- ? [this.config.details["components"].top]
1825
- : []),
1826
- ...(this.config.details &&
1827
- this.config.details["components"] &&
1828
- this.config.details["components"].bottom
1829
- ? [this.config.details["components"].bottom]
1830
- : []),
1831
- ...(this.config.list &&
1832
- this.config.list["components"] &&
1833
- this.config.list["components"].top
1834
- ? [this.config.list["components"].top]
1835
- : []),
1836
- ],
1837
- });
1838
- this.listOptions = {
1839
- provider: {
1840
- getData: (filter) => {
1841
- const global = Object.assign(Object.assign({}, this.filter), filter);
1842
- this.facade.read(global);
1843
- },
1844
- onChangeMultiSelected: (list) => __awaiter(this, void 0, void 0, function* () {
1845
- if (list.length && !this.menuService.openedEnd) {
1846
- yield this.menuService.openEnd({
1847
- injector: this.injector,
1848
- component: MultiselectComponent,
1849
- });
1850
- }
1851
- else if (!list.length && this.menuService.openedEnd) {
1852
- yield this.menuService.closeEnd();
1853
- }
1854
- this.facade.multiSelect(list);
1855
- }),
1856
- list$: this.facade.list$,
1857
- loading$: this.facade.loaded$.pipe(map((l) => !l)),
1858
- },
1859
- cellPipe: this.config.list ? this.config.list.cellPipe : null,
1860
- mode: (_g = this.config.list) === null || _g === void 0 ? void 0 : _g.mode,
1861
- type: this.config.type,
1862
- details: this.config.details
1863
- ? {
1864
- provider: {
1865
- getData: (id) => {
1866
- this.facade.select(id);
1867
- },
1868
- clearData: () => {
1869
- this.facade.unselect();
1870
- },
1871
- item$: this.facade.selected$,
1872
- loading$: this.facade.loaded$.pipe(map((l) => !l)),
1873
- },
1874
- componentFactories: {
1875
- top: this.config.details &&
1876
- this.config.details["components"] &&
1877
- this.config.details["components"].top
1878
- ? compiledComponents.find((cc) => cc.component === this.config.details["components"].top).factory
1879
- : null,
1880
- bottom: this.config.details &&
1881
- this.config.details["components"] &&
1882
- this.config.details["components"].bottom
1883
- ? compiledComponents.find((cc) => cc.component ===
1884
- this.config.details["components"].bottom).factory
1885
- : null,
1886
- },
1887
- }
1888
- : null,
1889
- item: !!this.config.edit || this.config.details
1890
- ? {
1891
- options: {
1892
- routingPrefix: "/" + this.router.routerState.snapshot.url + "/",
1893
- edit: !!this.config.edit,
1894
- },
1895
- }
1896
- : null,
1897
- remove: this.config.remove
1898
- ? {
1899
- provider: {
1900
- invoke: (id) => this.facade.delete(id),
1901
- },
1902
- }
1903
- : null,
1904
- pagination: yield this.paginationFacade.create({
1905
- mode: this.config.list.paginationMode,
1906
- limit: this.config.pagination.limit,
1907
- provider: {
1908
- getFilter: () => {
1909
- return this.filter;
1910
- },
1911
- getLinks: () => this.links,
1912
- },
1913
- }),
1914
- sort: this.config.sort,
1915
- };
1916
- this.cd.detectChanges();
1917
- this.initCloseMenu();
1918
- this.initTopComponent(compiledComponents);
1919
- this.refreshDynamicInstance();
1920
- });
1921
- }
1922
- initCloseMenu() {
1923
- this.router.events.pipe(this.takeUntilDestroy).subscribe(() => __awaiter(this, void 0, void 0, function* () {
1924
- yield this.clear();
1925
- }));
1926
- }
1927
- clear() {
1928
- return __awaiter(this, void 0, void 0, function* () {
1929
- yield this.menuService.closeEnd();
1930
- this.listOptions = Object.assign(Object.assign({}, this.listOptions), { select: null });
1931
- this.facade.multiSelect([]);
1932
- });
1933
- }
1934
- getEndButtons() {
1935
- var _a, _b, _c, _d, _e;
1936
- const fieldsWithOptions = getModelFieldsWithOptions(new this.config.type());
1937
- const modelOptions = getModelOptions(this.config.type);
1938
- const showFilters = fieldsWithOptions.some((x) => { var _a, _b; return (_b = (_a = x.options) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.filter; }) || ((_a = modelOptions === null || modelOptions === void 0 ? void 0 : modelOptions.filters) === null || _a === void 0 ? void 0 : _a.length);
1939
- const showMultiEdit = this.config.edit &&
1940
- fieldsWithOptions.some((x) => { var _a, _b; return (_b = (_a = x.options) === null || _a === void 0 ? void 0 : _a.update) === null || _b === void 0 ? void 0 : _b.multi; }) &&
1941
- !this.hardwareService.isMobile &&
1942
- (!((_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.mode) ||
1943
- ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.list) === null || _e === void 0 ? void 0 : _e.mode) === ListMode.desktop);
1944
- return [
1945
- ...(showMultiEdit
1946
- ? [
1947
- {
1948
- icon: "checkbox-outline",
1949
- text: "multi",
1950
- handler: () => __awaiter(this, void 0, void 0, function* () {
1951
- this.listOptions = Object.assign(Object.assign({}, this.listOptions), { select: this.listOptions.select === "multi" ? null : "multi" });
1952
- this.facade.multiSelect([]);
1953
- if (this.menuService.openedEnd)
1954
- yield this.menuService.closeEnd();
1955
- this.cd.detectChanges();
1956
- }),
1957
- },
1958
- ]
1959
- : []),
1960
- ...(showFilters
1961
- ? [
1962
- {
1963
- icon: "filter-outline",
1964
- text: "filters",
1965
- handler: () => __awaiter(this, void 0, void 0, function* () {
1966
- yield this.menuService.openEnd({
1967
- injector: this.injector,
1968
- component: FiltersComponent,
1969
- });
1970
- }),
1971
- },
1972
- ]
1973
- : []),
1974
- ...(this.config.add
1975
- ? [
1976
- {
1977
- icon: "add",
1978
- text: "add",
1979
- handler: () => {
1980
- this.router.navigate([
1981
- "/" + this.router.routerState.snapshot.url + "/add",
1982
- ]);
1983
- },
1984
- },
1985
- ]
1986
- : []),
1987
- ...(this.config.export
1988
- ? [
1989
- {
1990
- text: "export",
1991
- icon: "download-outline",
1992
- type: "popover",
1993
- component: ExportComponent,
1994
- },
1995
- ]
1996
- : []),
1997
- ...(this.config.buttons ? this.config.buttons : []),
1998
- ];
1999
- }
2000
- initTopComponent(compiledComponents) {
2001
- const factory = this.config.list &&
2002
- this.config.list["components"] &&
2003
- this.config.list["components"].top
2004
- ? compiledComponents.find((cc) => cc.component === this.config.list["components"].top).factory
2005
- : null;
2006
- setTimeout(() => {
2007
- if (factory && !this.topTpl.get(0)) {
2008
- this.topTpl.createComponent(factory);
2009
- }
2010
- });
2011
- }
2012
- }
2013
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2014
- ListComponent.decorators = [
2015
- { type: Component, args: [{
2016
- selector: "smart-crud-list-page",
2017
- template: `
2018
- <smart-page [options]="pageOptions" *ngIf="filter$ | async">
2019
- <div #topTpl></div>
2020
- <smart-crud-list-standard-page *ngIf="template === 'default'" [listOptions]="listOptions">
2021
- <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
2022
- </smart-crud-list-standard-page>
2023
- <ng-template #contentTpl>
2024
- <ng-content></ng-content>
2025
- </ng-template>
2026
- <div class="dynamic-content"></div>
2027
- </smart-page>
2028
- `
2029
- },] }
2030
- ];
2031
- /**
2032
- * @type {function(): !Array<(null|{
2033
- * type: ?,
2034
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2035
- * })>}
2036
- * @nocollapse
2037
- */
2038
- ListComponent.ctorParameters = () => [
2039
- { type: CrudFacade },
2040
- { type: Router },
2041
- { type: DynamicComponentLoader },
2042
- { type: Injector },
2043
- { type: ChangeDetectorRef },
2044
- { type: MenuService },
2045
- { type: HardwareService },
2046
- { type: CrudListPaginationFactory },
2047
- { type: StyleService },
2048
- { type: ElementRef },
2049
- { type: PageService },
2050
- { type: CrudFullConfig },
2051
- { type: CrudSearchService },
2052
- { type: NgModuleRef },
2053
- { type: ComponentFactoryResolver }
2054
- ];
2055
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2056
- ListComponent.propDecorators = {
2057
- topTpl: [{ type: ViewChild, args: ["topTpl", { read: ViewContainerRef, static: false },] }],
2058
- contentTpl: [{ type: ViewChild, args: ["contentTpl", { read: TemplateRef, static: false },] }],
2059
- dynamicContents: [{ type: ViewChildren, args: [DynamicContentDirective, { read: DynamicContentDirective },] }]
2060
- };
2061
-
2062
- class CrudItemPageBaseComponent extends BaseComponent$1 {
2063
- constructor(config, facade) {
2064
- super();
2065
- this.config = config;
2066
- this.facade = facade;
2067
- this.formComponents = new QueryList();
2068
- this.onPartialChange = new EventEmitter();
2069
- this.onChange = new EventEmitter();
2070
- this.onValidChange = new EventEmitter();
2071
- this.selected$ = facade.selected$;
2072
- }
2073
- }
2074
- CrudItemPageBaseComponent.smartType = "crud-item-page";
2075
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2076
- CrudItemPageBaseComponent.decorators = [
2077
- { type: Directive }
2078
- ];
2079
- /**
2080
- * @type {function(): !Array<(null|{
2081
- * type: ?,
2082
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2083
- * })>}
2084
- * @nocollapse
2085
- */
2086
- CrudItemPageBaseComponent.ctorParameters = () => [
2087
- { type: CrudFullConfig },
2088
- { type: CrudFacade }
2089
- ];
2090
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2091
- CrudItemPageBaseComponent.propDecorators = {
2092
- contentTpl: [{ type: ViewChild, args: ["contentTpl", { read: ViewContainerRef, static: true },] }],
2093
- formComponents: [{ type: ViewChildren, args: [FormComponent, { read: FormComponent },] }],
2094
- detailsOptions: [{ type: Input }],
2095
- mode: [{ type: Input }],
2096
- uniqueProvider: [{ type: Input }],
2097
- onPartialChange: [{ type: Output }],
2098
- onChange: [{ type: Output }],
2099
- onValidChange: [{ type: Output }]
2100
- };
2101
-
2102
- class ItemStandardComponent extends CrudItemPageBaseComponent {
2103
- }
2104
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2105
- ItemStandardComponent.decorators = [
2106
- { type: Component, args: [{
2107
- selector: "smart-crud-item-standard-page",
2108
- template: "<ng-container *ngIf=\"mode === 'details'; else editTpl\">\n <smart-details *ngIf=\"detailsOptions\" [options]='detailsOptions'></smart-details>\n</ng-container>\n\n<ng-template #editTpl>\n <smart-form\n [options]=\"\n (selected$ | async)\n | smartFormOptions : mode:config?.type:uniqueProvider : config.inputComponents\n \"\n (valuePartialChange)=\"onPartialChange.emit($event)\"\n (valueChange)=\"onChange.emit($event)\"\n (validChange)=\"onValidChange.emit($event)\"\n ></smart-form>\n</ng-template>\n\n<br/><br/>",
2109
- styles: [""]
2110
- },] }
2111
- ];
2112
-
2113
- class ItemComponent extends CreateDynamicComponent('crud-item-page') {
2114
- constructor(router, activeRoute, facade, service, route, dynamicComponentLoader, translateService, config, location, cd, authService, styleService, elementRef, toastService, pageService, moduleRef, componentFactoryResolver, detailsService) {
2115
- super(cd, moduleRef, componentFactoryResolver);
2116
- this.router = router;
2117
- this.activeRoute = activeRoute;
2118
- this.facade = facade;
2119
- this.service = service;
2120
- this.route = route;
2121
- this.dynamicComponentLoader = dynamicComponentLoader;
2122
- this.translateService = translateService;
2123
- this.config = config;
2124
- this.location = location;
2125
- this.cd = cd;
2126
- this.styleService = styleService;
2127
- this.elementRef = elementRef;
2128
- this.toastService = toastService;
2129
- this.pageService = pageService;
2130
- this.moduleRef = moduleRef;
2131
- this.componentFactoryResolver = componentFactoryResolver;
2132
- this.detailsService = detailsService;
2133
- this.pageOptions = {
2134
- title: "",
2135
- showBackButton: true,
2136
- hideMenuButton: true,
2137
- };
2138
- this.formValid = false;
2139
- this.standardComponents = new QueryList();
2140
- this.dynamicContents = new QueryList();
2141
- this.selected$ = this.facade.selected$;
2142
- }
2143
- set mode(val) {
2144
- this._mode = val;
2145
- this.refreshDynamicInstance();
2146
- }
2147
- get mode() {
2148
- return this._mode;
2149
- }
2150
- refreshProperties() {
2151
- this.baseInstance.detailsOptions = this.detailsOptions;
2152
- this.baseInstance.mode = this.mode;
2153
- this.baseInstance.uniqueProvider = this.uniqueProvider;
2154
- this.baseInstance.onPartialChange.pipe(this.takeUntilDestroy).subscribe(val => this.onPartialChange(val));
2155
- this.baseInstance.onChange.pipe(this.takeUntilDestroy).subscribe(val => this.onChange(val));
2156
- this.baseInstance.onValidChange.pipe(this.takeUntilDestroy).subscribe(val => this.onValidChange(val));
2157
- }
2158
- ngOnInit() {
2159
- return __awaiter(this, void 0, void 0, function* () {
2160
- this.detailsService.init();
2161
- this.styleService.init(this.elementRef);
2162
- this.pageService.checkPermissions();
2163
- if (this.router.routerState.snapshot.url.endsWith("/add")) {
2164
- this.mode = "create";
2165
- yield this.generateComponents('add');
2166
- }
2167
- else {
2168
- this.mode = this.config.details ? "details" : "update";
2169
- if (this.mode === 'update') {
2170
- yield this.generateComponents('edit');
2171
- }
2172
- this.activeRoute.params
2173
- .pipe(this.takeUntilDestroy)
2174
- .subscribe(({ id }) => {
2175
- this.facade.select(id);
2176
- this.id = id;
2177
- });
2178
- this.activeRoute.queryParams
2179
- .pipe(this.takeUntilDestroy)
2180
- .subscribe(({ edit }) => {
2181
- if (edit) {
2182
- this.mode = "update";
2183
- this.generateComponents('edit');
2184
- }
2185
- });
2186
- }
2187
- this.uniqueProvider = (values) => __awaiter(this, void 0, void 0, function* () {
2188
- const filter = {
2189
- query: [],
2190
- };
2191
- Object.keys(values).forEach((key) => {
2192
- filter.query.push({
2193
- key: key,
2194
- value: values[key],
2195
- type: "=",
2196
- });
2197
- });
2198
- if (this.id) {
2199
- filter.query.push({
2200
- key: "id",
2201
- value: this.id,
2202
- type: "!=",
2203
- });
2204
- }
2205
- const { totalCount } = yield this.service.getList(filter).toPromise();
2206
- return !totalCount;
2207
- });
2208
- if (this.config.details) {
2209
- const compiledComponents = yield this.dynamicComponentLoader.getComponentsWithFactories({
2210
- components: [
2211
- ...(this.config.details &&
2212
- this.config.details["components"] &&
2213
- this.config.details["components"].top
2214
- ? [this.config.details["components"].top]
2215
- : []),
2216
- ...(this.config.details &&
2217
- this.config.details["components"] &&
2218
- this.config.details["components"].bottom
2219
- ? [this.config.details["components"].bottom]
2220
- : []),
2221
- ],
2222
- });
2223
- this.detailsOptions = {
2224
- type: this.config.type,
2225
- item$: this.facade.selected$,
2226
- cellPipe: this.config.details ? this.config.details.cellPipe : null,
2227
- componentFactories: {
2228
- top: this.config.details &&
2229
- this.config.details["components"] &&
2230
- this.config.details["components"].top
2231
- ? compiledComponents.find((cc) => cc.component === this.config.details["components"].top).factory
2232
- : null,
2233
- bottom: this.config.details &&
2234
- this.config.details["components"] &&
2235
- this.config.details["components"].bottom
2236
- ? compiledComponents.find((cc) => cc.component === this.config.details["components"].bottom).factory
2237
- : null,
2238
- },
2239
- };
2240
- }
2241
- this.initPageOptions();
2242
- this.facade.selected$.pipe(this.takeUntilDestroy).subscribe(item => {
2243
- this.item = item;
2244
- this.initPageOptions();
2245
- this.cd.detectChanges();
2246
- });
2247
- this.refreshDynamicInstance();
2248
- });
2249
- }
2250
- generateComponents(mode) {
2251
- var _a, _b;
2252
- return __awaiter(this, void 0, void 0, function* () {
2253
- const compiledComponents = yield this.dynamicComponentLoader.getComponentsWithFactories({
2254
- components: [
2255
- ...(this.config[mode] &&
2256
- this.config[mode]["components"] &&
2257
- this.config[mode]["components"].top
2258
- ? [this.config[mode]["components"].top]
2259
- : []),
2260
- ...(this.config[mode] &&
2261
- this.config[mode]["components"] &&
2262
- this.config[mode]["components"].bottom
2263
- ? [this.config[mode]["components"].bottom]
2264
- : []),
2265
- ],
2266
- });
2267
- const topComponentFactory = (_a = compiledComponents.find((cc) => { var _a; return cc.component === ((_a = this.config[mode]["components"]) === null || _a === void 0 ? void 0 : _a.top); })) === null || _a === void 0 ? void 0 : _a.factory;
2268
- const bottomComponentFactory = (_b = compiledComponents.find((cc) => { var _a; return cc.component === ((_a = this.config[mode]["components"]) === null || _a === void 0 ? void 0 : _a.bottom); })) === null || _b === void 0 ? void 0 : _b.factory;
2269
- if (!this.topTpl.get(0) && topComponentFactory) {
2270
- this.topTpl.createComponent(topComponentFactory);
2271
- }
2272
- if (!this.bottomTpl.get(0) && bottomComponentFactory) {
2273
- this.bottomTpl.createComponent(bottomComponentFactory);
2274
- }
2275
- });
2276
- }
2277
- onPartialChange(val) {
2278
- this.formPartialValue = val;
2279
- }
2280
- onChange(val) {
2281
- this.formValue = val;
2282
- }
2283
- onValidChange(val) {
2284
- this.formValid = val;
2285
- }
2286
- initPageOptions() {
2287
- this.pageOptions = Object.assign(Object.assign({}, this.pageOptions), { title: this.getTitle(), endButtons: this.getButtons() });
2288
- }
2289
- getButtons() {
2290
- switch (this.mode) {
2291
- case "create":
2292
- return [
2293
- {
2294
- icon: "add",
2295
- text: "add",
2296
- handler: () => {
2297
- if (this.checkFirstInvalid()) {
2298
- return;
2299
- }
2300
- this.facade.create(this.formValue);
2301
- this.location.back();
2302
- },
2303
- },
2304
- ];
2305
- case "update":
2306
- return [
2307
- ...(this.config.details
2308
- ? [
2309
- {
2310
- icon: "close",
2311
- text: "cancel",
2312
- handler: () => {
2313
- this.mode = "details";
2314
- this.initPageOptions();
2315
- this.topTpl.clear();
2316
- this.bottomTpl.clear();
2317
- },
2318
- disabled$: new BehaviorSubject(false),
2319
- },
2320
- ]
2321
- : []),
2322
- {
2323
- icon: "save",
2324
- text: "save",
2325
- handler: () => {
2326
- if (this.checkFirstInvalid()) {
2327
- return;
2328
- }
2329
- this.formPartialValue.id = this.id;
2330
- this.facade.updatePartial(this.formPartialValue);
2331
- if (this.config.details) {
2332
- this.mode = "details";
2333
- this.initPageOptions();
2334
- }
2335
- else {
2336
- this.location.back();
2337
- }
2338
- },
2339
- },
2340
- ];
2341
- case "details":
2342
- return this.config.edit
2343
- ? [
2344
- {
2345
- icon: "create",
2346
- text: "edit",
2347
- handler: () => {
2348
- this.mode = "update";
2349
- this.generateComponents('edit');
2350
- this.initPageOptions();
2351
- },
2352
- disabled$: new BehaviorSubject(false),
2353
- },
2354
- ]
2355
- : [];
2356
- }
2357
- }
2358
- getTitle() {
2359
- const options = getModelOptions(this.config.type);
2360
- const prefix = options.titleKey && this.item ? this.removeParagraph(this.item[options.titleKey]) + ' - ' : '';
2361
- switch (this.mode) {
2362
- case "create":
2363
- return "add";
2364
- case "update":
2365
- return prefix + this.translateService.instant("change");
2366
- case "details":
2367
- return prefix + this.translateService.instant("details");
2368
- }
2369
- }
2370
- removeParagraph(val) {
2371
- if (!val || val.indexOf('<p>') !== 0)
2372
- return val;
2373
- const div = document.createElement("div");
2374
- div.innerHTML = val;
2375
- const item = div.querySelectorAll("p").item(0);
2376
- return item.innerHTML;
2377
- }
2378
- checkFirstInvalid() {
2379
- this.cd.detectChanges();
2380
- const form = this.template === 'default'
2381
- ? this.standardComponents.first.formComponents.first.form
2382
- : this.baseInstance.formComponents.first.form;
2383
- this.cd.detectChanges();
2384
- if (form.valid)
2385
- return false;
2386
- const invalidFields = [];
2387
- this.getInvalidFields(form, invalidFields, '');
2388
- this.toastService.info({
2389
- title: this.translateService.instant('INPUT.ERRORS.requires'),
2390
- message: invalidFields.slice(0, 3).join('<br/>')
2391
- });
2392
- return true;
2393
- }
2394
- getInvalidFields(control, invalidFields, baseField, key = null) {
2395
- var _a;
2396
- if (control.valid)
2397
- return;
2398
- const field = key ? baseField + ' > ' + this.translateService.instant('MODEL.' + key) : baseField;
2399
- if ((_a = control.errors) === null || _a === void 0 ? void 0 : _a.customMessage) {
2400
- invalidFields.push(field + ` (${control.errors.customMessage})`);
2401
- return;
2402
- }
2403
- if (control instanceof FormControl) {
2404
- invalidFields.push(field);
2405
- }
2406
- if (control instanceof FormGroup) {
2407
- Object.keys(control.controls).forEach(groupKey => {
2408
- this.getInvalidFields(control.controls[groupKey], invalidFields, field, groupKey);
2409
- });
2410
- }
2411
- if (control instanceof FormArray) {
2412
- control.controls.forEach((c, index) => {
2413
- this.getInvalidFields(c, invalidFields, field + `(${index + 1})`);
2414
- });
2415
- }
2416
- }
2417
- }
2418
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2419
- ItemComponent.decorators = [
2420
- { type: Component, args: [{
2421
- selector: "smart-crud-item-page",
2422
- template: `
2423
- <smart-page [options]="pageOptions">
2424
- <div #topTpl class="top-content"></div>
2425
- <smart-crud-item-standard-page *ngIf="template === 'default'"
2426
- [detailsOptions]="detailsOptions"
2427
- [mode]="mode"
2428
- [uniqueProvider]="uniqueProvider"
2429
- (onPartialChange)="onPartialChange($event)"
2430
- (onChange)="onChange($event)"
2431
- (onValidChange)="onValidChange($event)"
2432
- >
2433
- <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
2434
- </smart-crud-item-standard-page>
2435
- <ng-template #contentTpl>
2436
- <ng-content></ng-content>
2437
- </ng-template>
2438
- <div class="dynamic-content"></div>
2439
- <div #bottomTpl class="bottom-content"></div>
2440
- </smart-page>
2441
- `
2442
- },] }
2443
- ];
2444
- /**
2445
- * @type {function(): !Array<(null|{
2446
- * type: ?,
2447
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2448
- * })>}
2449
- * @nocollapse
2450
- */
2451
- ItemComponent.ctorParameters = () => [
2452
- { type: Router },
2453
- { type: ActivatedRoute },
2454
- { type: CrudFacade },
2455
- { type: CrudService },
2456
- { type: ActivatedRoute },
2457
- { type: DynamicComponentLoader },
2458
- { type: TranslateService },
2459
- { type: CrudFullConfig },
2460
- { type: Location },
2461
- { type: ChangeDetectorRef },
2462
- { type: AuthService },
2463
- { type: StyleService },
2464
- { type: ElementRef },
2465
- { type: ToastService },
2466
- { type: PageService },
2467
- { type: NgModuleRef },
2468
- { type: ComponentFactoryResolver },
2469
- { type: DetailsService }
2470
- ];
2471
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2472
- ItemComponent.propDecorators = {
2473
- standardComponents: [{ type: ViewChildren, args: [ItemStandardComponent, { read: ItemStandardComponent },] }],
2474
- content: [{ type: ViewChild, args: [IonContent, { static: true },] }],
2475
- contentTpl: [{ type: ViewChild, args: ["contentTpl", { read: TemplateRef, static: false },] }],
2476
- topTpl: [{ type: ViewChild, args: ["topTpl", { read: ViewContainerRef, static: true },] }],
2477
- bottomTpl: [{ type: ViewChild, args: ["bottomTpl", { read: ViewContainerRef, static: true },] }],
2478
- dynamicContents: [{ type: ViewChildren, args: [DynamicContentDirective, { read: DynamicContentDirective },] }]
2479
- };
2480
-
2481
- class CrudListPageBaseComponent extends BaseComponent$1 {
2482
- constructor(config) {
2483
- super();
2484
- this.config = config;
2485
- }
2486
- }
2487
- CrudListPageBaseComponent.smartType = "crud-list-page";
2488
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2489
- CrudListPageBaseComponent.decorators = [
2490
- { type: Directive }
2491
- ];
2492
- /**
2493
- * @type {function(): !Array<(null|{
2494
- * type: ?,
2495
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2496
- * })>}
2497
- * @nocollapse
2498
- */
2499
- CrudListPageBaseComponent.ctorParameters = () => [
2500
- { type: CrudFullConfig }
2501
- ];
2502
- /** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
2503
- CrudListPageBaseComponent.propDecorators = {
2504
- contentTpl: [{ type: ViewChild, args: ["contentTpl", { read: ViewContainerRef, static: true },] }],
2505
- listOptions: [{ type: Input }]
2506
- };
2507
-
2508
- class ListStandardComponent extends CrudListPageBaseComponent {
2509
- constructor(facade, config) {
2510
- super(config);
2511
- this.facade = facade;
2512
- this.config = config;
2513
- this.isSearch$ = this.facade.filter$.pipe(map(filter => {
2514
- return !!(filter === null || filter === void 0 ? void 0 : filter.searchText);
2515
- }));
2516
- }
2517
- }
2518
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2519
- ListStandardComponent.decorators = [
2520
- { type: Component, args: [{
2521
- selector: "smart-crud-list-standard-page",
2522
- template: "<smart-crud-filters-config></smart-crud-filters-config>\n<smart-list *ngIf=\"listOptions\"\n [hidden]=\"!(!config.list?.groups || (isSearch$ | async))\"\n [options]=\"listOptions\"\n></smart-list>\n<smart-crud-group *ngIf=\"config.list?.groups && !(isSearch$ | async)\"\n [groups]=\"config.list?.groups\"\n [listOptions]=\"listOptions\"\n>\n</smart-crud-group>",
2523
- providers: [
2524
- CrudListGroupService
2525
- ],
2526
- styles: [""]
2527
- },] }
2528
- ];
2529
- /**
2530
- * @type {function(): !Array<(null|{
2531
- * type: ?,
2532
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2533
- * })>}
2534
- * @nocollapse
2535
- */
2536
- ListStandardComponent.ctorParameters = () => [
2537
- { type: CrudFacade },
2538
- { type: CrudFullConfig }
2539
- ];
2540
-
2541
- const PAGES = [
2542
- ItemComponent,
2543
- ListComponent,
2544
- ListStandardComponent,
2545
- ItemStandardComponent
2546
- ];
2547
- class CrudFullModule {
2548
- constructor(store, config, effects) {
2549
- NgrxStoreService.addReducer(config.entity, config.reducerFactory
2550
- ? config.reducerFactory()
2551
- : getReducer(config.entity));
2552
- effects.init();
2553
- }
2554
- }
2555
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2556
- CrudFullModule.decorators = [
2557
- { type: NgModule, args: [{
2558
- declarations: [
2559
- ...PAGES
2560
- ],
2561
- imports: [
2562
- StoreModule,
2563
- SharedModule,
2564
- CrudPipesModule,
2565
- RouterModule.forChild([
2566
- { path: '', component: ListComponent },
2567
- { path: 'add', component: ItemComponent },
2568
- { path: ':id', component: ItemComponent }
2569
- ]),
2570
- FormsModule,
2571
- CommonModule,
2572
- CrudComponentsModule
2573
- ],
2574
- exports: [
2575
- ...PAGES,
2576
- CrudComponentsModule
2577
- ],
2578
- entryComponents: [
2579
- ...PAGES
2580
- ],
2581
- providers: [
2582
- CrudService,
2583
- CrudListGroupService,
2584
- PageService,
2585
- CrudEffects,
2586
- CrudFacade,
2587
- CrudListPaginationFactory,
2588
- ]
2589
- },] }
2590
- ];
2591
- /**
2592
- * @type {function(): !Array<(null|{
2593
- * type: ?,
2594
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2595
- * })>}
2596
- * @nocollapse
2597
- */
2598
- CrudFullModule.ctorParameters = () => [
2599
- { type: Store },
2600
- { type: CrudConfig },
2601
- { type: CrudEffects }
2602
- ];
2603
-
2604
- class CrudCoreModule {
2605
- constructor(config, effects) {
2606
- NgrxStoreService.addReducer(config.entity, config.reducerFactory
2607
- ? config.reducerFactory()
2608
- : getReducer(config.entity));
2609
- effects.init();
2610
- }
2611
- }
2612
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2613
- CrudCoreModule.decorators = [
2614
- { type: NgModule, args: [{
2615
- imports: [
2616
- //AuthSharedModule,
2617
- StoreModule,
2618
- SharedModule,
2619
- CrudPipesModule,
2620
- FormsModule,
2621
- CommonModule,
2622
- CrudComponentsModule,
2623
- NgrxSharedModule,
2624
- ],
2625
- exports: [CrudComponentsModule],
2626
- providers: [
2627
- CrudService,
2628
- CrudListGroupService,
2629
- PageService,
2630
- CrudEffects,
2631
- CrudFacade,
2632
- SocketService,
2633
- CrudListPaginationFactory,
2634
- ],
2635
- },] }
2636
- ];
2637
- /**
2638
- * @type {function(): !Array<(null|{
2639
- * type: ?,
2640
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
2641
- * })>}
2642
- * @nocollapse
2643
- */
2644
- CrudCoreModule.ctorParameters = () => [
2645
- { type: CrudConfig },
2646
- { type: CrudEffects }
2647
- ];
2648
- class CrudModule {
2649
- static forFeature(options) {
2650
- return {
2651
- ngModule: options.routing ? CrudFullModule : CrudCoreModule,
2652
- providers: [
2653
- { provide: CrudConfig, useValue: options.config },
2654
- { provide: CrudFullConfig, useValue: options.config },
2655
- {
2656
- provide: FILE_SERVICE_CONFIG,
2657
- useValue: { apiUrl: options.config.apiUrl },
2658
- },
2659
- ...(options.socket
2660
- ? [SocketService]
2661
- : [{ provide: SocketService, useClass: NotSocketService }]),
2662
- ],
2663
- };
2664
- }
2665
- }
2666
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
2667
- CrudModule.decorators = [
2668
- { type: NgModule, args: [{},] }
2669
- ];
2670
-
2671
- /**
2672
- * Generated bundle index. Do not edit.
2673
- */
2674
-
2675
- export { CRUD_MODEL_POSSIBILITIES_PROVIDER, CrudComponentsModule, CrudConfig, CrudCoreModule, CrudEffects, CrudFacade, CrudFullConfig, CrudFullModule, CrudItemPageBaseComponent, CrudListPageBaseComponent, CrudListPaginationFactory, CrudModule, CrudPipesModule, CrudSearchService, CrudService, ExportComponent, FilterCheckComponent, FilterComponent, FilterDateComponent, FilterDateWithEditComponent, FilterFlagComponent, FilterIntComponent, FilterRadioComponent, FilterTextComponent, FiltersComponent, FiltersConfigComponent, FormOptionsPipe, GroupComponent, ICrudModelPossibilitiesProvider, MultiselectComponent, PageService, create, createFailure, createMany, createManyFailure, createManySuccess, createSuccess, deleteFailure, deleteItem, deleteSuccess, exportList, exportListFailure, exportListSuccess, getCrudError, getCrudFilter, getCrudLinks, getCrudList, getCrudLoaded, getCrudMultiSelected, getCrudSelected, getCrudState, getCrudTotalCount, getReducer, initialState, multiSelect, read, readFailure, readSuccess, select, selectFailure, selectSuccess, unselect, update, updateFailure, updatePartial, updatePartialFailure, updatePartialMany, updatePartialManyFailure, updatePartialManySuccess, updatePartialSuccess, updateSuccess, ɵ0, CrudPipesModule as ɵa, FormOptionsPipe as ɵb, CrudComponentsModule as ɵc, ExportComponent as ɵd, FilterComponent as ɵe, FilterTextComponent as ɵf, FiltersConfigComponent as ɵg, FilterDateComponent as ɵh, FilterDateWithEditComponent as ɵi, FilterRadioComponent as ɵj, FiltersComponent as ɵk, FilterFlagComponent as ɵl, FilterCheckComponent as ɵm, FilterIntComponent as ɵn, MultiselectComponent as ɵo, GroupComponent as ɵp, CrudListGroupService as ɵq, SocketService as ɵr, NotSocketService as ɵs, ItemComponent as ɵt, ItemStandardComponent as ɵu, CrudItemPageBaseComponent as ɵv, ListComponent as ɵw, ListStandardComponent as ɵx, CrudListPageBaseComponent as ɵy };
2676
- //# sourceMappingURL=smartsoft001-crud-shell-angular.js.map