@smartsoft001/crud-shell-angular 1.2.91 → 2.69.0

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 (214) hide show
  1. package/.storybook/addons.js +1 -0
  2. package/.storybook/config.js +5 -0
  3. package/.storybook/tsconfig.json +8 -0
  4. package/.storybook/webpack.config.js +7 -0
  5. package/jest.config.ts +38 -0
  6. package/ng-package.json +7 -0
  7. package/package.json +12 -23
  8. package/project.json +49 -0
  9. package/src/index.ts +13 -0
  10. package/src/lib/+state/crud.facade.ts +82 -0
  11. package/src/lib/+state/crud.feature.methods.ts +258 -0
  12. package/src/lib/+state/crud.feature.store.ts +77 -0
  13. package/src/lib/components/components.module.ts +58 -0
  14. package/src/lib/components/export/export.component.ts +69 -0
  15. package/src/lib/components/filter/base/base.component.ts +175 -0
  16. package/src/lib/components/filter/check/check.component.scss +25 -0
  17. package/src/lib/components/filter/check/check.component.ts +72 -0
  18. package/src/lib/components/filter/date/date.component.html +30 -0
  19. package/src/lib/components/filter/date/date.component.ts +70 -0
  20. package/src/lib/components/filter/date-time/date-time.component.html +62 -0
  21. package/src/lib/components/filter/date-time/date-time.component.ts +56 -0
  22. package/src/lib/components/filter/date-with-edit/date-with-edit.component.html +109 -0
  23. package/src/lib/components/filter/date-with-edit/date-with-edit.component.ts +70 -0
  24. package/src/lib/components/filter/filter.component.html +52 -0
  25. package/src/lib/components/filter/filter.component.ts +34 -0
  26. package/src/lib/components/filter/flag/flag.component.ts +55 -0
  27. package/src/lib/components/filter/index.ts +9 -0
  28. package/src/lib/components/filter/int/int.component.html +74 -0
  29. package/src/lib/components/filter/int/int.component.ts +57 -0
  30. package/src/lib/components/filter/radio/radio.component.ts +74 -0
  31. package/src/lib/components/filter/text/text.component.ts +46 -0
  32. package/src/lib/components/filters/filters.component.scss +150 -0
  33. package/src/lib/components/filters/filters.component.ts +157 -0
  34. package/src/lib/components/filters-config/filters-config.component.ts +69 -0
  35. package/src/lib/components/group/group.component.ts +93 -0
  36. package/src/lib/components/index.ts +7 -0
  37. package/src/lib/components/multiselect/multiselect.component.html +41 -0
  38. package/src/lib/components/multiselect/multiselect.component.scss +125 -0
  39. package/src/lib/components/multiselect/multiselect.component.ts +104 -0
  40. package/src/lib/crud-full.module.ts +51 -0
  41. package/src/lib/crud.config.ts +79 -0
  42. package/src/lib/crud.module.ts +72 -0
  43. package/src/lib/factories/list-pagination/list-pagination.factory.ts +77 -0
  44. package/src/lib/models/index.ts +1 -0
  45. package/src/lib/models/interfaces.ts +34 -0
  46. package/src/lib/pages/index.ts +6 -0
  47. package/src/lib/pages/item/base/base.component.ts +54 -0
  48. package/src/lib/pages/item/item.component.ts +513 -0
  49. package/src/lib/pages/item/standard/standard.component.scss +0 -0
  50. package/src/lib/pages/item/standard/standard.component.ts +50 -0
  51. package/src/lib/pages/list/base/base.component.ts +29 -0
  52. package/src/lib/pages/list/list.component.stories.ts +77 -0
  53. package/src/lib/pages/list/list.component.ts +438 -0
  54. package/src/lib/pages/list/standard/standard.component.ts +42 -0
  55. package/src/lib/pipes/form-options/form-options.pipe.ts +61 -0
  56. package/src/lib/pipes/index.ts +2 -0
  57. package/src/lib/pipes/pipes.module.ts +9 -0
  58. package/src/lib/providers/model-possibilities/model-possibilities.provider.ts +19 -0
  59. package/src/lib/services/crud/crud.service.spec.ts +303 -0
  60. package/src/lib/services/crud/crud.service.ts +178 -0
  61. package/src/lib/services/list-group/list-group.service.spec.ts +87 -0
  62. package/src/lib/services/list-group/list-group.service.ts +65 -0
  63. package/src/lib/services/page/page.service.spec.ts +143 -0
  64. package/src/lib/services/page/page.service.ts +44 -0
  65. package/src/lib/services/search/search.service.spec.ts +134 -0
  66. package/src/lib/services/search/search.service.ts +42 -0
  67. package/test-setup.ts +0 -0
  68. package/tsconfig.json +13 -0
  69. package/tsconfig.lib.json +31 -0
  70. package/tsconfig.lib.prod.json +11 -0
  71. package/tsconfig.spec.json +10 -0
  72. package/tslint.json +10 -0
  73. package/esm2022/index.mjs +0 -18
  74. package/esm2022/lib/+state/crud.actions.mjs +0 -224
  75. package/esm2022/lib/+state/crud.effects.mjs +0 -182
  76. package/esm2022/lib/+state/crud.facade.mjs +0 -91
  77. package/esm2022/lib/+state/crud.reducer.mjs +0 -214
  78. package/esm2022/lib/+state/crud.selectors.mjs +0 -11
  79. package/esm2022/lib/components/components.module.mjs +0 -110
  80. package/esm2022/lib/components/export/export.component.mjs +0 -47
  81. package/esm2022/lib/components/filter/base/base.component.mjs +0 -152
  82. package/esm2022/lib/components/filter/check/check.component.mjs +0 -36
  83. package/esm2022/lib/components/filter/date/date.component.mjs +0 -47
  84. package/esm2022/lib/components/filter/date-time/date-time.component.mjs +0 -43
  85. package/esm2022/lib/components/filter/date-with-edit/date-with-edit.component.mjs +0 -49
  86. package/esm2022/lib/components/filter/filter.component.mjs +0 -30
  87. package/esm2022/lib/components/filter/flag/flag.component.mjs +0 -16
  88. package/esm2022/lib/components/filter/index.mjs +0 -10
  89. package/esm2022/lib/components/filter/int/int.component.mjs +0 -38
  90. package/esm2022/lib/components/filter/radio/radio.component.mjs +0 -16
  91. package/esm2022/lib/components/filter/text/text.component.mjs +0 -16
  92. package/esm2022/lib/components/filters/filters.component.mjs +0 -111
  93. package/esm2022/lib/components/filters-config/filters-config.component.mjs +0 -37
  94. package/esm2022/lib/components/group/group.component.mjs +0 -54
  95. package/esm2022/lib/components/index.mjs +0 -8
  96. package/esm2022/lib/components/multiselect/multiselect.component.mjs +0 -71
  97. package/esm2022/lib/crud-full.module.mjs +0 -103
  98. package/esm2022/lib/crud.config.mjs +0 -17
  99. package/esm2022/lib/crud.module.mjs +0 -106
  100. package/esm2022/lib/factories/list-pagination/list-pagination.factory.mjs +0 -69
  101. package/esm2022/lib/models/index.mjs +0 -2
  102. package/esm2022/lib/models/interfaces.mjs +0 -2
  103. package/esm2022/lib/pages/index.mjs +0 -7
  104. package/esm2022/lib/pages/item/base/base.component.mjs +0 -44
  105. package/esm2022/lib/pages/item/item.component.mjs +0 -395
  106. package/esm2022/lib/pages/item/standard/standard.component.mjs +0 -15
  107. package/esm2022/lib/pages/list/base/base.component.mjs +0 -23
  108. package/esm2022/lib/pages/list/list.component.mjs +0 -355
  109. package/esm2022/lib/pages/list/standard/standard.component.mjs +0 -34
  110. package/esm2022/lib/pipes/form-options/form-options.pipe.mjs +0 -55
  111. package/esm2022/lib/pipes/index.mjs +0 -3
  112. package/esm2022/lib/pipes/pipes.module.mjs +0 -20
  113. package/esm2022/lib/providers/model-possibilities/model-possibilities.provider.mjs +0 -11
  114. package/esm2022/lib/services/crud/crud.service.mjs +0 -138
  115. package/esm2022/lib/services/list-group/list-group.service.mjs +0 -60
  116. package/esm2022/lib/services/page/page.service.mjs +0 -41
  117. package/esm2022/lib/services/search/search.service.mjs +0 -41
  118. package/esm2022/lib/services/socket/socket.service.mjs +0 -17
  119. package/esm2022/smartsoft001-crud-shell-angular.mjs +0 -5
  120. package/fesm2022/smartsoft001-crud-shell-angular.mjs +0 -2810
  121. package/fesm2022/smartsoft001-crud-shell-angular.mjs.map +0 -1
  122. package/index.d.ts +0 -18
  123. package/index.d.ts.map +0 -1
  124. package/lib/+state/crud.actions.d.ts +0 -152
  125. package/lib/+state/crud.actions.d.ts.map +0 -1
  126. package/lib/+state/crud.effects.d.ts +0 -18
  127. package/lib/+state/crud.effects.d.ts.map +0 -1
  128. package/lib/+state/crud.facade.d.ts +0 -44
  129. package/lib/+state/crud.facade.d.ts.map +0 -1
  130. package/lib/+state/crud.reducer.d.ts +0 -43
  131. package/lib/+state/crud.reducer.d.ts.map +0 -1
  132. package/lib/+state/crud.selectors.d.ts +0 -10
  133. package/lib/+state/crud.selectors.d.ts.map +0 -1
  134. package/lib/components/components.module.d.ts +0 -27
  135. package/lib/components/components.module.d.ts.map +0 -1
  136. package/lib/components/export/export.component.d.ts +0 -21
  137. package/lib/components/export/export.component.d.ts.map +0 -1
  138. package/lib/components/filter/base/base.component.d.ts +0 -39
  139. package/lib/components/filter/base/base.component.d.ts.map +0 -1
  140. package/lib/components/filter/check/check.component.d.ts +0 -19
  141. package/lib/components/filter/check/check.component.d.ts.map +0 -1
  142. package/lib/components/filter/date/date.component.d.ts +0 -16
  143. package/lib/components/filter/date/date.component.d.ts.map +0 -1
  144. package/lib/components/filter/date-time/date-time.component.d.ts +0 -15
  145. package/lib/components/filter/date-time/date-time.component.d.ts.map +0 -1
  146. package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts +0 -17
  147. package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts.map +0 -1
  148. package/lib/components/filter/filter.component.d.ts +0 -14
  149. package/lib/components/filter/filter.component.d.ts.map +0 -1
  150. package/lib/components/filter/flag/flag.component.d.ts +0 -8
  151. package/lib/components/filter/flag/flag.component.d.ts.map +0 -1
  152. package/lib/components/filter/index.d.ts +0 -10
  153. package/lib/components/filter/index.d.ts.map +0 -1
  154. package/lib/components/filter/int/int.component.d.ts +0 -15
  155. package/lib/components/filter/int/int.component.d.ts.map +0 -1
  156. package/lib/components/filter/radio/radio.component.d.ts +0 -8
  157. package/lib/components/filter/radio/radio.component.d.ts.map +0 -1
  158. package/lib/components/filter/text/text.component.d.ts +0 -8
  159. package/lib/components/filter/text/text.component.d.ts.map +0 -1
  160. package/lib/components/filters/filters.component.d.ts +0 -83
  161. package/lib/components/filters/filters.component.d.ts.map +0 -1
  162. package/lib/components/filters-config/filters-config.component.d.ts +0 -19
  163. package/lib/components/filters-config/filters-config.component.d.ts.map +0 -1
  164. package/lib/components/group/group.component.d.ts +0 -23
  165. package/lib/components/group/group.component.d.ts.map +0 -1
  166. package/lib/components/index.d.ts +0 -8
  167. package/lib/components/index.d.ts.map +0 -1
  168. package/lib/components/multiselect/multiselect.component.d.ts +0 -28
  169. package/lib/components/multiselect/multiselect.component.d.ts.map +0 -1
  170. package/lib/crud-full.module.d.ts +0 -28
  171. package/lib/crud-full.module.d.ts.map +0 -1
  172. package/lib/crud.config.d.ts +0 -65
  173. package/lib/crud.config.d.ts.map +0 -1
  174. package/lib/crud.module.d.ts +0 -34
  175. package/lib/crud.module.d.ts.map +0 -1
  176. package/lib/factories/list-pagination/list-pagination.factory.d.ts +0 -20
  177. package/lib/factories/list-pagination/list-pagination.factory.d.ts.map +0 -1
  178. package/lib/models/index.d.ts +0 -2
  179. package/lib/models/index.d.ts.map +0 -1
  180. package/lib/models/interfaces.d.ts +0 -30
  181. package/lib/models/interfaces.d.ts.map +0 -1
  182. package/lib/pages/index.d.ts +0 -7
  183. package/lib/pages/index.d.ts.map +0 -1
  184. package/lib/pages/item/base/base.component.d.ts +0 -25
  185. package/lib/pages/item/base/base.component.d.ts.map +0 -1
  186. package/lib/pages/item/item.component.d.ts +0 -70
  187. package/lib/pages/item/item.component.d.ts.map +0 -1
  188. package/lib/pages/item/standard/standard.component.d.ts +0 -8
  189. package/lib/pages/item/standard/standard.component.d.ts.map +0 -1
  190. package/lib/pages/list/base/base.component.d.ts +0 -15
  191. package/lib/pages/list/base/base.component.d.ts.map +0 -1
  192. package/lib/pages/list/list.component.d.ts +0 -54
  193. package/lib/pages/list/list.component.d.ts.map +0 -1
  194. package/lib/pages/list/standard/standard.component.d.ts +0 -14
  195. package/lib/pages/list/standard/standard.component.d.ts.map +0 -1
  196. package/lib/pipes/form-options/form-options.pipe.d.ts +0 -15
  197. package/lib/pipes/form-options/form-options.pipe.d.ts.map +0 -1
  198. package/lib/pipes/index.d.ts +0 -3
  199. package/lib/pipes/index.d.ts.map +0 -1
  200. package/lib/pipes/pipes.module.d.ts +0 -8
  201. package/lib/pipes/pipes.module.d.ts.map +0 -1
  202. package/lib/providers/model-possibilities/model-possibilities.provider.d.ts +0 -18
  203. package/lib/providers/model-possibilities/model-possibilities.provider.d.ts.map +0 -1
  204. package/lib/services/crud/crud.service.d.ts +0 -38
  205. package/lib/services/crud/crud.service.d.ts.map +0 -1
  206. package/lib/services/list-group/list-group.service.d.ts +0 -15
  207. package/lib/services/list-group/list-group.service.d.ts.map +0 -1
  208. package/lib/services/page/page.service.d.ts +0 -12
  209. package/lib/services/page/page.service.d.ts.map +0 -1
  210. package/lib/services/search/search.service.d.ts +0 -16
  211. package/lib/services/search/search.service.d.ts.map +0 -1
  212. package/lib/services/socket/socket.service.d.ts +0 -10
  213. package/lib/services/socket/socket.service.d.ts.map +0 -1
  214. package/smartsoft001-crud-shell-angular.d.ts.map +0 -1
@@ -0,0 +1,69 @@
1
+ import { Component, ElementRef, inject, OnInit } from '@angular/core';
2
+
3
+ import {
4
+ BaseComponent,
5
+ ButtonComponent,
6
+ IButtonOptions,
7
+ PopoverService,
8
+ StyleService,
9
+ } from '@smartsoft001/angular';
10
+ import { IEntity } from '@smartsoft001/domain-core';
11
+
12
+ import { CrudFacade } from '../../+state/crud.facade';
13
+
14
+ @Component({
15
+ selector: 'smart-crud-export',
16
+ template: `
17
+ <div class="p-5">
18
+ <p class="my-2.5 mx-0">
19
+ <smart-button [options]="buttonExportCsvOptions" class="w-full block"
20
+ >CSV</smart-button
21
+ >
22
+ </p>
23
+ <p>
24
+ <smart-button [options]="buttonExportXlsxOptions" class="w-full block"
25
+ >XLSX</smart-button
26
+ >
27
+ </p>
28
+ </div>
29
+ `,
30
+ imports: [ButtonComponent],
31
+ })
32
+ export class ExportComponent<T extends IEntity<string>>
33
+ extends BaseComponent
34
+ implements OnInit
35
+ {
36
+ private facade = inject(CrudFacade<T>);
37
+ private popoverService = inject(PopoverService);
38
+ private styleService = inject(StyleService);
39
+ private elementRef = inject(ElementRef);
40
+
41
+ buttonExportCsvOptions: IButtonOptions = this.initButtonExportOptions('csv');
42
+ buttonExportXlsxOptions: IButtonOptions =
43
+ this.initButtonExportOptions('xlsx');
44
+
45
+ ngOnInit(): void {
46
+ this.styleService.init(this.elementRef);
47
+ }
48
+
49
+ private initButtonExportOptions(format: string): IButtonOptions {
50
+ return {
51
+ click: () => {
52
+ this.facade.export(
53
+ {
54
+ ...this.facade.filter(),
55
+ offset: null,
56
+ limit: null,
57
+ },
58
+ format,
59
+ );
60
+
61
+ const loading = this.facade.loading();
62
+ if (loading) return;
63
+ this.popoverService.close();
64
+ },
65
+ loading: this.facade.loading,
66
+ expand: 'block',
67
+ };
68
+ }
69
+ }
@@ -0,0 +1,175 @@
1
+ import {
2
+ Directive,
3
+ inject,
4
+ input,
5
+ InputSignal,
6
+ OnInit,
7
+ Signal,
8
+ } from '@angular/core';
9
+ import { TranslateService } from '@ngx-translate/core';
10
+ import { Debounce } from 'lodash-decorators';
11
+
12
+ import { IEntity } from '@smartsoft001/domain-core';
13
+ import { FieldType, IModelFilter } from '@smartsoft001/models';
14
+
15
+ import { CrudFacade } from '../../../+state/crud.facade';
16
+ import { ICrudFilter } from '../../../models';
17
+
18
+ @Directive()
19
+ export class BaseComponent<T extends IEntity<string>> implements OnInit {
20
+ protected facade = inject(CrudFacade<T>);
21
+ protected translateService = inject(TranslateService);
22
+
23
+ possibilities: Signal<{ id: any; text: string }[]>;
24
+
25
+ readonly item: InputSignal<IModelFilter> = input<IModelFilter>();
26
+ readonly filter: InputSignal<ICrudFilter> = input<ICrudFilter>();
27
+
28
+ get value(): any {
29
+ if (this.isArrayType()) {
30
+ return this.filter()
31
+ .query.filter(
32
+ (q) => q.key === this.item().key && q.type === this.item().type,
33
+ )
34
+ .map((q) => q.value);
35
+ }
36
+
37
+ const query = this.filter().query.find(
38
+ (q) => q.key === this.item().key && q.type === this.item().type,
39
+ );
40
+ return query?.value;
41
+ }
42
+
43
+ set value(val: any) {
44
+ this.refresh(val);
45
+ }
46
+
47
+ get minValue(): any {
48
+ if (this.isArrayType()) {
49
+ return this.filter()
50
+ .query.filter((q) => q.key === this.item().key && q.type === '>=')
51
+ .map((q) => q.value);
52
+ }
53
+
54
+ const query = this.filter().query.find(
55
+ (q) => q.key === this.item().key && q.type === '>=',
56
+ );
57
+ return query?.value;
58
+ }
59
+
60
+ set minValue(val: any) {
61
+ this.refresh(val, '>=');
62
+ }
63
+
64
+ get maxValue(): any {
65
+ if (this.isArrayType()) {
66
+ return this.filter()
67
+ .query.filter((q) => q.key === this.item().key && q.type === '<=')
68
+ .map((q) => q.value);
69
+ }
70
+
71
+ const query = this.filter().query.find(
72
+ (q) => q.key === this.item().key && q.type === '<=',
73
+ );
74
+ return query?.value;
75
+ }
76
+
77
+ set maxValue(val: any) {
78
+ this.refresh(val, '<=');
79
+ }
80
+
81
+ get lang(): string {
82
+ return this.translateService.currentLang;
83
+ }
84
+
85
+ @Debounce(500)
86
+ refresh(val: any, type = null): void {
87
+ if (!type) type = this.item().type;
88
+
89
+ this.filter().offset = 0;
90
+
91
+ if (this.isArrayType()) {
92
+ this.refreshForArray(val as [], type);
93
+ return;
94
+ }
95
+
96
+ let query = this.filter().query.find(
97
+ (q) => q.key === this.item().key && q.type === type,
98
+ );
99
+
100
+ if (val === null || val === undefined || val === '') {
101
+ const index = this.filter().query.indexOf(query);
102
+ if (index > -1) {
103
+ this.filter().query.splice(index, 1);
104
+ }
105
+
106
+ this.facade.read(this.filter());
107
+ return;
108
+ }
109
+
110
+ if (!query) {
111
+ query = {
112
+ key: this.item().key,
113
+ type: type,
114
+ value: null,
115
+ };
116
+
117
+ this.filter().query.push(query);
118
+ }
119
+
120
+ query.value = val;
121
+ query.label = this.item().label;
122
+
123
+ this.facade.read(this.filter());
124
+ }
125
+
126
+ clear(): void {
127
+ this.filter().query = this.filter().query.filter(
128
+ (q) => q.key !== this.item().key,
129
+ );
130
+ this.filter().offset = 0;
131
+ this.facade.read(this.filter());
132
+ }
133
+
134
+ ngOnInit(): void {
135
+ this.initPossibilities();
136
+ }
137
+
138
+ private initPossibilities(): void {
139
+ this.possibilities = this.item().possibilities;
140
+ }
141
+
142
+ private isArrayType(): boolean {
143
+ return this.item()?.fieldType === FieldType.check;
144
+ }
145
+
146
+ private refreshForArray(vals: [], type): void {
147
+ const queries = this.filter().query.filter(
148
+ (q) => q.key === this.item().key && q.type === type,
149
+ );
150
+
151
+ queries.forEach((query) => {
152
+ const index = this.filter().query.indexOf(query);
153
+ if (index > -1) {
154
+ this.filter().query.splice(index, 1);
155
+ }
156
+ });
157
+
158
+ if (vals === null || vals === undefined || !vals.length) {
159
+ this.facade.read(this.filter());
160
+ return;
161
+ }
162
+
163
+ vals.forEach((val) => {
164
+ const query = {
165
+ key: this.item().key,
166
+ type: type,
167
+ value: val,
168
+ };
169
+
170
+ this.filter().query.push(query);
171
+ });
172
+
173
+ this.facade.read(this.filter());
174
+ }
175
+ }
@@ -0,0 +1,25 @@
1
+ :host {
2
+ width: 100%;
3
+ margin-bottom: 1.2rem;
4
+
5
+ ion-item-divider {
6
+ //--padding-end: 0.8rem;
7
+ //--ion-background-color: linear-gradient(
8
+ // 90deg,
9
+ // transparent,
10
+ // var(--ion-color-light)
11
+ //);
12
+ ion-icon {
13
+ //--color: var(--ion-color-primary);
14
+ }
15
+ ion-label {
16
+ //--padding: var(--smart-button-padding-left) / 2
17
+ // var(--smart-button-padding-top) / 2 var(--smart-button-padding-right) /
18
+ // 2 var(--smart-button-padding-bottom) / 2;
19
+ }
20
+ .square-button {
21
+ //--padding-start: 0.2em;
22
+ //--padding-end: 0.2em;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,72 @@
1
+ import { AfterContentInit, Component, computed, Signal } from '@angular/core';
2
+ import { TranslatePipe } from '@ngx-translate/core';
3
+
4
+ import { IEntity } from '@smartsoft001/domain-core';
5
+
6
+ import { BaseComponent } from '../base/base.component';
7
+
8
+ @Component({
9
+ selector: 'smart-crud-filter-check',
10
+ template: `
11
+ <!-- <ion-row>-->
12
+ <!-- <ion-col>-->
13
+ <!-- <ion-item-divider class="text-xl font-light">-->
14
+ <!-- <ion-icon class="mr-6 text-2xl" slot="start" name="filter-outline"></ion-icon>-->
15
+ <!-- <ion-label>-->
16
+ {{ item().label | translate }}
17
+ <!-- </ion-label>-->
18
+ @if (value?.length) {
19
+ <!-- <ion-button-->
20
+ <!-- slot="end"-->
21
+ <!-- color="danger"-->
22
+ <!-- (click)="refresh([])"-->
23
+ <!-- class="square-button m-0 p-0 text-lg h-9 w-9"-->
24
+ <!-- >-->
25
+ <!-- <ion-icon class="text-2xl m-0 p-0" slot="icon-only" name="close-outline"></ion-icon>-->
26
+ <!-- </ion-button>-->
27
+ }
28
+ <!-- </ion-item-divider>-->
29
+
30
+ @for (entry of list(); track entry) {
31
+ <!-- <ion-item>-->
32
+ <!--<ion-label>-->{{ entry.value.text | translate
33
+ }}<!--</ion-label>-->
34
+ <!-- <ion-checkbox-->
35
+ <!-- slot="end"-->
36
+ <!-- [checked]="entry.isCheck"-->
37
+ <!-- (ionChange)="onCheckChange($event.detail.checked, entry)"-->
38
+ <!-- ></ion-checkbox>-->
39
+ <!-- </ion-item>-->
40
+ }
41
+ <!-- </ion-col>-->
42
+ <!-- </ion-row>-->
43
+ `,
44
+ imports: [TranslatePipe],
45
+ styleUrls: ['./check.component.scss'],
46
+ })
47
+ export class FilterCheckComponent<T extends IEntity<string>>
48
+ extends BaseComponent<T>
49
+ implements AfterContentInit
50
+ {
51
+ list: Signal<{ value: any; isCheck: boolean }[]>;
52
+
53
+ ngAfterContentInit(): void {
54
+ this.list = computed(() => {
55
+ const possibilities = this.possibilities();
56
+ return possibilities.map((pos) => ({
57
+ value: pos,
58
+ isCheck: this.value.some((r) => r === pos.id),
59
+ }));
60
+ });
61
+ }
62
+
63
+ onCheckChange(checked: boolean, entry: { value: any; isCheck: boolean }) {
64
+ if (checked && !this.value.some((r) => r === entry.value.id)) {
65
+ this.value = [...this.value, entry.value.id];
66
+ }
67
+
68
+ if (!checked && this.value.some((r) => r === entry.value.id)) {
69
+ this.value = this.value.filter((r) => r !== entry.value.id);
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,30 @@
1
+ <!--<ion-row>-->
2
+ <!-- <ion-col>-->
3
+ <!-- <ion-label>-->
4
+ {{ item().label | translate }}
5
+ <!-- </ion-label>-->
6
+ <!-- <ion-item button="true" id="open-date-input-{{ id }}" color="primary">-->
7
+ <!-- <ion-text>-->
8
+ {{ customValue ? customValue : ('select' | translate) }}
9
+ <!-- </ion-text>-->
10
+ <!-- <ion-popover trigger="open-date-input-{{ id }}" show-backdrop="false">-->
11
+ <ng-template>
12
+ <!-- <ion-datetime-->
13
+ <!-- displayFormat="YYYY-MM-DD"-->
14
+ <!-- pickerFormat="YYYY-MM-DD"-->
15
+ <!-- [(ngModel)]="customValue"-->
16
+ <!-- presentation="date"-->
17
+ <!-- ></ion-datetime>-->
18
+ </ng-template>
19
+ <!-- </ion-popover>-->
20
+ <!-- </ion-item>-->
21
+ <!-- </ion-col>-->
22
+
23
+ @if (value) {
24
+ <!-- <ion-col size="auto">-->
25
+ <!-- <ion-button color="danger" (click)="refresh(null)" class="square-button m-3">-->
26
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
27
+ <!-- </ion-button>-->
28
+ <!-- </ion-col>-->
29
+ }
30
+ <!--</ion-row>-->
@@ -0,0 +1,70 @@
1
+ import { Component } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { TranslatePipe } from '@ngx-translate/core';
4
+ import moment from 'moment';
5
+
6
+ import { IEntity } from '@smartsoft001/domain-core';
7
+ import { GuidService } from '@smartsoft001/utils';
8
+
9
+ import { BaseComponent } from '../base/base.component';
10
+
11
+ @Component({
12
+ selector: 'smart-crud-filter-date',
13
+ templateUrl: './date.component.html',
14
+ imports: [FormsModule, TranslatePipe],
15
+ styles: [
16
+ `
17
+ :host {
18
+ width: 100%;
19
+ .square-button {
20
+ height: var(--smart-button-height) !important;
21
+ }
22
+ }
23
+ `,
24
+ ],
25
+ })
26
+ export class FilterDateComponent<
27
+ T extends IEntity<string>,
28
+ > extends BaseComponent<T> {
29
+ id = GuidService.create();
30
+
31
+ get allowAdvanced(): boolean {
32
+ return this.item()?.type === '=';
33
+ }
34
+
35
+ set customValue(val) {
36
+ const momentDate = moment(val);
37
+ this.value =
38
+ (val as string)?.length >= 10 && momentDate.isValid()
39
+ ? momentDate.format('YYYY-MM-DD')
40
+ : val;
41
+ }
42
+
43
+ get customValue(): any {
44
+ return this.value;
45
+ }
46
+
47
+ set customMinValue(val) {
48
+ const momentDate = moment(val);
49
+ this.minValue =
50
+ (val as string)?.length >= 10 && momentDate.isValid()
51
+ ? momentDate.format('YYYY-MM-DD')
52
+ : val;
53
+ }
54
+
55
+ get customMinValue(): any {
56
+ return this.minValue;
57
+ }
58
+
59
+ set customMaxValue(val) {
60
+ const momentDate = moment(val);
61
+ this.maxValue =
62
+ (val as string)?.length >= 10 && momentDate.isValid()
63
+ ? momentDate.format('YYYY-MM-DD')
64
+ : val;
65
+ }
66
+
67
+ get customMaxValue(): any {
68
+ return this.maxValue;
69
+ }
70
+ }
@@ -0,0 +1,62 @@
1
+ <!--<ion-row>-->
2
+ <!-- <ion-col>-->
3
+ <!-- <ion-label>-->
4
+ {{ item().label | translate }}
5
+ <!-- </ion-label>-->
6
+ <!-- </ion-col>-->
7
+ @if (value || minValue || maxValue) {
8
+ <!-- <ion-col size="auto">-->
9
+ <!-- <ion-button color="danger" (click)="clear()" class="square-button m-3">-->
10
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
11
+ <!-- </ion-button>-->
12
+ <!-- </ion-col>-->
13
+ }
14
+ <!--</ion-row>-->
15
+ <!--<ion-row>-->
16
+ <!-- <ion-col>-->
17
+ <!-- <ion-item>-->
18
+ <!-- <ion-label>-->
19
+ {{ 'from' | translate }}
20
+ <!-- </ion-label>-->
21
+ <!-- <ion-input-->
22
+ <!-- placeholder="YYYY-MM-DD HH:mm:ss"-->
23
+ <!-- [(ngModel)]="customMinValue"-->
24
+ <!-- pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$"-->
25
+ <!-- ></ion-input>-->
26
+ <!-- </ion-item>-->
27
+ <!-- </ion-col>-->
28
+ @if (customMinValue) {
29
+ <!-- <ion-col size="auto">-->
30
+ <!-- <ion-button-->
31
+ <!-- color="danger"-->
32
+ <!-- (click)="refresh(null, '>=')"-->
33
+ <!-- class="square-button m-3"-->
34
+ <!-- >-->
35
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
36
+ <!-- </ion-button>-->
37
+ <!-- </ion-col>-->
38
+ }
39
+ <!-- <ion-col>-->
40
+ <!-- <ion-item>-->
41
+ <!-- <ion-label>-->
42
+ {{ 'to' | translate }}
43
+ <!-- </ion-label>-->
44
+ <!-- <ion-input-->
45
+ <!-- placeholder="YYYY-MM-DD HH:mm:ss"-->
46
+ <!-- [(ngModel)]="customMaxValue"-->
47
+ <!-- pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$"-->
48
+ <!-- ></ion-input>-->
49
+ <!-- </ion-item>-->
50
+ <!-- </ion-col>-->
51
+ @if (customMaxValue) {
52
+ <!-- <ion-col size="auto">-->
53
+ <!-- <ion-button-->
54
+ <!-- color="danger"-->
55
+ <!-- (click)="refresh(null, '<=')"-->
56
+ <!-- class="square-button m-3"-->
57
+ <!-- >-->
58
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
59
+ <!-- </ion-button>-->
60
+ <!-- </ion-col>-->
61
+ }
62
+ <!--</ion-row>-->
@@ -0,0 +1,56 @@
1
+ import { Component, OnDestroy, OnInit } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { TranslatePipe } from '@ngx-translate/core';
4
+ import { Subscription } from 'rxjs';
5
+
6
+ import { IEntity } from '@smartsoft001/domain-core';
7
+ import { GuidService } from '@smartsoft001/utils';
8
+
9
+ import { FilterDateComponent } from '../date/date.component';
10
+
11
+ @Component({
12
+ selector: 'smart-crud-filter-date-time',
13
+ templateUrl: './date-time.component.html',
14
+ imports: [TranslatePipe, FormsModule],
15
+ styles: [
16
+ `
17
+ :host {
18
+ width: 100%;
19
+ .square-button {
20
+ height: var(--smart-button-height) !important;
21
+ }
22
+ }
23
+ `,
24
+ ],
25
+ })
26
+ export class FilterDateTimeComponent<T extends IEntity<string>>
27
+ extends FilterDateComponent<T>
28
+ implements OnInit, OnDestroy
29
+ {
30
+ private _subscriptions = new Subscription();
31
+
32
+ id = GuidService.create();
33
+
34
+ // @ViewChild(IonDatetime, { read: IonDatetime, static: false })
35
+ // dateTimePicker: IonDatetime;
36
+
37
+ ngOnInit(): void {
38
+ super.ngOnInit();
39
+
40
+ // if (this.dateTimePicker) {
41
+ // this._subscriptions.add(
42
+ // this.dateTimePicker.ionChange.subscribe((val: CustomEvent) => {
43
+ // this.customValue = val.detail.value;
44
+ // }),
45
+ // );
46
+ // } else {
47
+ // console.error('dateTimePicker not found!');
48
+ // }
49
+ }
50
+
51
+ ngOnDestroy(): void {
52
+ if (this._subscriptions) {
53
+ this._subscriptions.unsubscribe();
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,109 @@
1
+ <!--<ion-row>-->
2
+ <!-- <ion-col>-->
3
+ <!-- <ion-label>-->
4
+ {{ item().label | translate }}
5
+ <!-- </ion-label>-->
6
+
7
+ @if (!advanced()) {
8
+ <!-- <ion-input-->
9
+ <!-- placeholder="YYYY-MM-DD"-->
10
+ <!-- [(ngModel)]="customValue"-->
11
+ <!-- [pattern]="'([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))'"-->
12
+ <!-- ></ion-input>-->
13
+ }
14
+ <!-- </ion-col>-->
15
+
16
+ @if (!advanced()) {
17
+ <!-- <ion-col size="auto">-->
18
+ <!-- <ion-button id="open-date-input-{{ id }}" class="square-button m-3">-->
19
+ <!-- <ion-icon slot="icon-only" name="calendar-outline"></ion-icon>-->
20
+ <!-- <ion-popover trigger="open-date-input-{{ id }}" show-backdrop="false">-->
21
+ <ng-template>
22
+ <!-- <ion-datetime-->
23
+ <!-- displayFormat="YYYY-MM-DD"-->
24
+ <!-- pickerFormat="YYYY-MM-DD"-->
25
+ <!-- [(ngModel)]="customValue"-->
26
+ <!-- presentation="date"-->
27
+ <!-- first-day-of-week="1"-->
28
+ <!-- locale="{{ lang }}"-->
29
+ <!-- ></ion-datetime>-->
30
+ </ng-template>
31
+ <!-- </ion-popover>-->
32
+ <!-- </ion-button>-->
33
+ <!-- </ion-col>-->
34
+ }
35
+ @if (allowAdvanced) {
36
+ <!-- <ion-col size="auto">-->
37
+ <!-- <ion-button-->
38
+ <!-- (click)="toggleAdvanced()"-->
39
+ <!-- class="square-button m-3"-->
40
+ <!-- [disabled]="minValue || maxValue"-->
41
+ <!-- >-->
42
+ @if (!advanced()) {
43
+ <!-- <ion-icon slot="icon-only" name="settings-outline"></ion-icon>-->
44
+ } @else {
45
+ <!-- <ion-icon slot="icon-only" name="settings"></ion-icon>-->
46
+ }
47
+ <!-- </ion-button>-->
48
+ <!-- </ion-col>-->
49
+ }
50
+ @if (value || minValue || maxValue) {
51
+ <!-- <ion-col size="auto">-->
52
+ <!-- <ion-button color="danger" (click)="clear()" class="square-button m-3">-->
53
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
54
+ <!-- </ion-button>-->
55
+ <!-- </ion-col>-->
56
+ }
57
+ <!--</ion-row>-->
58
+
59
+ @if ((advanced() || minValue || maxValue) && allowAdvanced) {
60
+ <!-- <ion-row>-->
61
+ <!-- <ion-col>-->
62
+ <!-- <ion-item>-->
63
+ <!-- <ion-label>-->
64
+ {{ 'from' | translate }}
65
+ <!-- </ion-label>-->
66
+ <!-- <ion-input-->
67
+ <!-- placeholder="YYYY-MM-DD"-->
68
+ <!-- [(ngModel)]="customMinValue"-->
69
+ <!-- [pattern]="'([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))'"-->
70
+ <!-- ></ion-input>-->
71
+ <!-- </ion-item>-->
72
+ <!-- </ion-col>-->
73
+ @if (customMinValue) {
74
+ <!-- <ion-col size="auto">-->
75
+ <!-- <ion-button-->
76
+ <!-- color="danger"-->
77
+ <!-- (click)="refresh(null, '>=')"-->
78
+ <!-- class="square-button m-3"-->
79
+ <!-- >-->
80
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
81
+ <!-- </ion-button>-->
82
+ <!-- </ion-col>-->
83
+ }
84
+ <!-- <ion-col>-->
85
+ <!-- <ion-item>-->
86
+ <!-- <ion-label>-->
87
+ {{ 'to' | translate }}
88
+ <!-- </ion-label>-->
89
+ <!-- <ion-input-->
90
+ <!-- placeholder="YYYY-MM-DD"-->
91
+ <!-- [(ngModel)]="customMaxValue"-->
92
+ <!-- [pattern]="'([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))'"-->
93
+ <!-- ></ion-input>-->
94
+ <!-- </ion-item>-->
95
+ <!-- </ion-col>-->
96
+
97
+ @if (customMaxValue) {
98
+ <!-- <ion-col size="auto">-->
99
+ <!-- <ion-button-->
100
+ <!-- color="danger"-->
101
+ <!-- (click)="refresh(null, '<=')"-->
102
+ <!-- class="square-button m-3"-->
103
+ <!-- >-->
104
+ <!-- <ion-icon slot="icon-only" name="close-outline"></ion-icon>-->
105
+ <!-- </ion-button>-->
106
+ <!-- </ion-col>-->
107
+ }
108
+ <!-- </ion-row>-->
109
+ }