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