appproject-components 1.0.47 → 1.0.48

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 (153) hide show
  1. package/esm2022/appproject-components.mjs +5 -0
  2. package/esm2022/lib/appproject-components.component.mjs +22 -0
  3. package/esm2022/lib/appproject-components.module.mjs +159 -0
  4. package/esm2022/lib/appproject-components.service.mjs +14 -0
  5. package/esm2022/lib/baseInputComponent.mjs +69 -0
  6. package/esm2022/lib/buttons/baseBtnComponent.mjs +63 -0
  7. package/esm2022/lib/buttons/btn-action/btn-action.component.mjs +55 -0
  8. package/esm2022/lib/buttons/btn-cancelar/btn-cancelar.component.mjs +25 -0
  9. package/esm2022/lib/buttons/btn-excluir/btn-excluir.component.mjs +29 -0
  10. package/esm2022/lib/buttons/btn-novo/btn-novo.component.mjs +33 -0
  11. package/esm2022/lib/buttons/btn-salvar/btn-salvar.component.mjs +19 -0
  12. package/esm2022/lib/entity-edit/entity-edit.component.mjs +53 -0
  13. package/esm2022/lib/grid-view/grid-view.component.mjs +275 -0
  14. package/esm2022/lib/input-area/input-area.component.mjs +72 -0
  15. package/esm2022/lib/input-arquivo/input-arquivo.component.mjs +154 -0
  16. package/esm2022/lib/input-cep/input-cep.component.mjs +180 -0
  17. package/esm2022/lib/input-checkbox/input-checkbox.component.mjs +51 -0
  18. package/esm2022/lib/input-format/input-format.component.mjs +138 -0
  19. package/esm2022/lib/input-pesquisa/input-pesquisa.component.mjs +557 -0
  20. package/esm2022/lib/input-radio/input-radio.component.mjs +58 -0
  21. package/esm2022/lib/input-select/input-select.component.mjs +110 -0
  22. package/esm2022/lib/input-text/input-text.component.mjs +88 -0
  23. package/esm2022/lib/input-valor/input-valor.component.mjs +161 -0
  24. package/esm2022/lib/lib-config.mjs +2 -0
  25. package/esm2022/lib/model-treeview/model-treeview.component.mjs +126 -0
  26. package/esm2022/lib/tree-view/tree-view.component.mjs +104 -0
  27. package/esm2022/lib/tree-view-nivel/tree-view-nivel.component.mjs +50 -0
  28. package/esm2022/public-api.mjs +30 -0
  29. package/fesm2022/appproject-components.mjs +2531 -0
  30. package/fesm2022/appproject-components.mjs.map +1 -0
  31. package/index.d.ts +5 -0
  32. package/lib/appproject-components.component.d.ts +8 -0
  33. package/lib/appproject-components.module.d.ts +36 -0
  34. package/lib/appproject-components.service.d.ts +6 -0
  35. package/lib/baseInputComponent.d.ts +28 -0
  36. package/lib/buttons/baseBtnComponent.d.ts +19 -0
  37. package/lib/buttons/btn-action/btn-action.component.d.ts +21 -0
  38. package/lib/buttons/btn-cancelar/btn-cancelar.component.d.ts +10 -0
  39. package/lib/buttons/btn-excluir/btn-excluir.component.d.ts +12 -0
  40. package/lib/buttons/btn-novo/btn-novo.component.d.ts +13 -0
  41. package/lib/buttons/btn-salvar/btn-salvar.component.d.ts +9 -0
  42. package/lib/entity-edit/entity-edit.component.d.ts +22 -0
  43. package/lib/grid-view/grid-view.component.d.ts +52 -0
  44. package/lib/input-area/input-area.component.d.ts +24 -0
  45. package/lib/input-arquivo/input-arquivo.component.d.ts +43 -0
  46. package/lib/input-cep/input-cep.component.d.ts +29 -0
  47. package/lib/input-checkbox/input-checkbox.component.d.ts +21 -0
  48. package/lib/input-format/input-format.component.d.ts +27 -0
  49. package/lib/input-pesquisa/input-pesquisa.component.d.ts +69 -0
  50. package/lib/input-radio/input-radio.component.d.ts +23 -0
  51. package/lib/input-select/input-select.component.d.ts +32 -0
  52. package/lib/input-text/input-text.component.d.ts +33 -0
  53. package/lib/input-valor/input-valor.component.d.ts +29 -0
  54. package/{src/lib/lib-config.ts → lib/lib-config.d.ts} +3 -4
  55. package/lib/model-treeview/model-treeview.component.d.ts +39 -0
  56. package/lib/tree-view/tree-view.component.d.ts +23 -0
  57. package/lib/tree-view-nivel/tree-view-nivel.component.d.ts +17 -0
  58. package/package.json +26 -15
  59. package/{src/public-api.ts → public-api.d.ts} +24 -30
  60. package/karma.conf.js +0 -44
  61. package/ng-package.json +0 -7
  62. package/src/lib/appproject-components.component.spec.ts +0 -23
  63. package/src/lib/appproject-components.component.ts +0 -20
  64. package/src/lib/appproject-components.module.ts +0 -106
  65. package/src/lib/appproject-components.service.spec.ts +0 -16
  66. package/src/lib/appproject-components.service.ts +0 -9
  67. package/src/lib/baseComponent.scss +0 -162
  68. package/src/lib/baseInputComponent.ts +0 -35
  69. package/src/lib/buttons/baseBtnComponent.ts +0 -38
  70. package/src/lib/buttons/btn-action/btn-action.component.html +0 -11
  71. package/src/lib/buttons/btn-action/btn-action.component.scss +0 -7
  72. package/src/lib/buttons/btn-action/btn-action.component.spec.ts +0 -24
  73. package/src/lib/buttons/btn-action/btn-action.component.ts +0 -31
  74. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.html +0 -14
  75. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.scss +0 -5
  76. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.spec.ts +0 -24
  77. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.ts +0 -19
  78. package/src/lib/buttons/btn-excluir/btn-excluir.component.html +0 -6
  79. package/src/lib/buttons/btn-excluir/btn-excluir.component.scss +0 -5
  80. package/src/lib/buttons/btn-excluir/btn-excluir.component.spec.ts +0 -24
  81. package/src/lib/buttons/btn-excluir/btn-excluir.component.ts +0 -18
  82. package/src/lib/buttons/btn-novo/btn-novo.component.html +0 -14
  83. package/src/lib/buttons/btn-novo/btn-novo.component.scss +0 -8
  84. package/src/lib/buttons/btn-novo/btn-novo.component.spec.ts +0 -24
  85. package/src/lib/buttons/btn-novo/btn-novo.component.ts +0 -20
  86. package/src/lib/buttons/btn-salvar/btn-salvar.component.html +0 -8
  87. package/src/lib/buttons/btn-salvar/btn-salvar.component.scss +0 -5
  88. package/src/lib/buttons/btn-salvar/btn-salvar.component.spec.ts +0 -24
  89. package/src/lib/buttons/btn-salvar/btn-salvar.component.ts +0 -16
  90. package/src/lib/entity-edit/entity-edit.component.html +0 -143
  91. package/src/lib/entity-edit/entity-edit.component.scss +0 -4
  92. package/src/lib/entity-edit/entity-edit.component.spec.ts +0 -23
  93. package/src/lib/entity-edit/entity-edit.component.ts +0 -43
  94. package/src/lib/grid-view/grid-view.component.html +0 -116
  95. package/src/lib/grid-view/grid-view.component.scss +0 -47
  96. package/src/lib/grid-view/grid-view.component.spec.ts +0 -23
  97. package/src/lib/grid-view/grid-view.component.ts +0 -292
  98. package/src/lib/input-area/input-area.component.html +0 -30
  99. package/src/lib/input-area/input-area.component.scss +0 -68
  100. package/src/lib/input-area/input-area.component.spec.ts +0 -23
  101. package/src/lib/input-area/input-area.component.ts +0 -69
  102. package/src/lib/input-arquivo/input-arquivo.component.html +0 -11
  103. package/src/lib/input-arquivo/input-arquivo.component.scss +0 -0
  104. package/src/lib/input-arquivo/input-arquivo.component.spec.ts +0 -23
  105. package/src/lib/input-arquivo/input-arquivo.component.ts +0 -140
  106. package/src/lib/input-cep/input-cep.component.html +0 -38
  107. package/src/lib/input-cep/input-cep.component.scss +0 -0
  108. package/src/lib/input-cep/input-cep.component.spec.ts +0 -23
  109. package/src/lib/input-cep/input-cep.component.ts +0 -186
  110. package/src/lib/input-checkbox/input-checkbox.component.html +0 -12
  111. package/src/lib/input-checkbox/input-checkbox.component.scss +0 -11
  112. package/src/lib/input-checkbox/input-checkbox.component.spec.ts +0 -23
  113. package/src/lib/input-checkbox/input-checkbox.component.ts +0 -48
  114. package/src/lib/input-format/input-format.component.html +0 -32
  115. package/src/lib/input-format/input-format.component.scss +0 -47
  116. package/src/lib/input-format/input-format.component.spec.ts +0 -23
  117. package/src/lib/input-format/input-format.component.ts +0 -139
  118. package/src/lib/input-pesquisa/input-pesquisa.component.html +0 -77
  119. package/src/lib/input-pesquisa/input-pesquisa.component.scss +0 -127
  120. package/src/lib/input-pesquisa/input-pesquisa.component.spec.ts +0 -23
  121. package/src/lib/input-pesquisa/input-pesquisa.component.ts +0 -558
  122. package/src/lib/input-radio/input-radio.component.html +0 -21
  123. package/src/lib/input-radio/input-radio.component.scss +0 -3
  124. package/src/lib/input-radio/input-radio.component.spec.ts +0 -23
  125. package/src/lib/input-radio/input-radio.component.ts +0 -49
  126. package/src/lib/input-select/input-select.component.html +0 -29
  127. package/src/lib/input-select/input-select.component.scss +0 -62
  128. package/src/lib/input-select/input-select.component.spec.ts +0 -23
  129. package/src/lib/input-select/input-select.component.ts +0 -96
  130. package/src/lib/input-text/input-text.component.html +0 -48
  131. package/src/lib/input-text/input-text.component.scss +0 -63
  132. package/src/lib/input-text/input-text.component.spec.ts +0 -23
  133. package/src/lib/input-text/input-text.component.ts +0 -78
  134. package/src/lib/input-valor/input-valor.component.html +0 -32
  135. package/src/lib/input-valor/input-valor.component.scss +0 -47
  136. package/src/lib/input-valor/input-valor.component.spec.ts +0 -23
  137. package/src/lib/input-valor/input-valor.component.ts +0 -164
  138. package/src/lib/model-treeview/model-treeview.component.html +0 -20
  139. package/src/lib/model-treeview/model-treeview.component.scss +0 -0
  140. package/src/lib/model-treeview/model-treeview.component.spec.ts +0 -23
  141. package/src/lib/model-treeview/model-treeview.component.ts +0 -152
  142. package/src/lib/tree-view/tree-view.component.html +0 -96
  143. package/src/lib/tree-view/tree-view.component.scss +0 -50
  144. package/src/lib/tree-view/tree-view.component.spec.ts +0 -23
  145. package/src/lib/tree-view/tree-view.component.ts +0 -92
  146. package/src/lib/tree-view-nivel/tree-view-nivel.component.html +0 -17
  147. package/src/lib/tree-view-nivel/tree-view-nivel.component.scss +0 -8
  148. package/src/lib/tree-view-nivel/tree-view-nivel.component.spec.ts +0 -23
  149. package/src/lib/tree-view-nivel/tree-view-nivel.component.ts +0 -43
  150. package/src/test.ts +0 -15
  151. package/tsconfig.lib.json +0 -15
  152. package/tsconfig.lib.prod.json +0 -10
  153. package/tsconfig.spec.json +0 -17
@@ -1,558 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { Component, EventEmitter, Inject, Input, OnInit, Predicate, ViewChild } from '@angular/core';
3
- import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
4
- import { IonSelect, ModalController } from '@ionic/angular';
5
- import { Subject, Subscription, of } from 'rxjs';
6
- import { BaseInputComponent } from '../baseInputComponent';
7
- import { debounceTime, switchMap } from 'rxjs/operators'
8
- import { ModelTreeviewComponent } from '../model-treeview/model-treeview.component';
9
- import { LibConfig } from '../lib-config';
10
- //import { LibConfig, LibConfigService } from '../appproject-components.module';
11
-
12
- @Component({
13
- selector: 'kb-input-pesquisa',
14
- templateUrl: './input-pesquisa.component.html',
15
- styleUrls: ['./input-pesquisa.component.scss', './../baseComponent.scss'],
16
- providers: [{
17
- provide: NG_VALUE_ACCESSOR,
18
- useExisting: InputPesquisaComponent,
19
- multi: true
20
- }]
21
- })
22
- export class InputPesquisaComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
23
-
24
- podePesquisar: boolean = true;
25
- @Input() textoPesquisa: string = '';
26
- selectElementVisivel: boolean = false;
27
- listaPesquisa: any[] = [];
28
- selectedItem: any;
29
- @Input() override max: string = '30';
30
- private pesquisaSubject: Subject<string> = new Subject();
31
-
32
- @Input() filterFunction: Predicate<any> | null = null;
33
- @Input() selectId: string = 'selectElement';
34
- @Input() campoId: string = 'Id';
35
- @Input() campoPaiId: string = 'PaiId';
36
- @Input() campoDisplay: string = 'Descricao';
37
- @Input() tipo: string = '';
38
- //@ViewChild('selectElement', { read: ElementRef, static: true }) selectElement;
39
- @ViewChild('selectElement', { static: false }) selectElement: IonSelect | null = null;
40
-
41
- @Input() pesquisaChange = new EventEmitter();
42
- @Input() pesquisaAction?: Function;
43
- @Input() limpar?: Function;
44
- //parametros para chamada API
45
- //endpoint para pesquisa por digitação
46
- @Input() url: string = '';
47
- @Input() urlItem: string = '';
48
- //endpoint para montar a arvore, se estiver vazia será usado o campo 'url'
49
- @Input() urlTree: string = '';
50
- @Input() empresa: number = 0;
51
- @Input() loadInit: boolean = false;
52
- @Input() treeTitulo: string;
53
-
54
- //planoContas: number;
55
-
56
- //control value acessor
57
- public data: number | any;
58
- private onChange: Function = (data: number) => { };
59
- private onTouch: Function = () => { };
60
- private disabled: boolean = false;
61
- public console = console;
62
-
63
- modelChanged: Subject<any> = new Subject<any>();
64
- modelChangeSubscription?: Subscription;
65
-
66
- writeValue(value: number | any): void {
67
- //console.log('write value', value);
68
- this.onChange(value);
69
- this.data = value;
70
- if (value == null || value == 0) {
71
- this.writePesquisa('');
72
- this.selectedItem = null;
73
- } else {
74
- if (this.loadInit == true) {
75
- this.loadInit = false;
76
- this.modelChanged.next(value);
77
- //this.carregaItemIdParaLista(value);
78
- } else {
79
- //console.log(this.selectedItem);
80
- if (!this.selectedItem || (this.selectedItem && this.selectedItem[this.campoId] != value)) {
81
- console.log('Id diferente');
82
- this.modelChanged.next(value);
83
- //this.carregaItemIdParaLista(value);
84
- }
85
- }
86
- }
87
-
88
- }
89
- registerOnChange(fn: any): void {
90
- this.onChange = fn;
91
- }
92
- registerOnTouched(fn: any): void {
93
- this.onTouch = fn;
94
- }
95
- setDisabledState?(isDisabled: boolean): void {
96
- this.disabled = this.disabled;
97
- }
98
-
99
- BASE_API = this.config.apiUrl;
100
-
101
- constructor(@Inject('LibConfigService') private config: LibConfig,
102
- private httpClient: HttpClient,
103
- private modalCtrl: ModalController) {
104
- super();
105
-
106
- this.modelChangeSubscription = this.modelChanged
107
- .pipe(debounceTime(500)
108
- )
109
- .subscribe(data => {
110
- this.carregaItemIdParaLista(data);
111
- });
112
- }
113
-
114
- onBlur(event: any) {
115
- console.log('blur', event);
116
- //console.log(event.detail.relatedTarget);
117
- if (event.detail.relatedTarget == null || event.detail.relatedTarget.id.indexOf(this.selectId + 'IonItem') == -1) {
118
- //console.log("true", event.detail.relatedTarget.id);
119
- //pesquisar item na lista
120
- if (!this.existeNaListaTexto(this.textoPesquisa, true)) {
121
- this.limparClick();
122
- }
123
-
124
- this.dropDownPesquisa(0);
125
- if (this.form) {
126
- this.form.get(this.formControlName)?.markAsTouched();
127
- }
128
- }
129
- }
130
-
131
- override ngOnInit() {
132
- //tratar urls
133
- this.url = this.url.startsWith('http') ? this.url : `${this.BASE_API}/${this.url}`;
134
- this.urlItem = this.urlItem.startsWith('http') ? this.urlItem : `${this.BASE_API}/${this.urlItem}`;
135
-
136
- this.pesquisaSubject.pipe(switchMap((url) => {
137
- //this.console.log('subject url:', url);
138
- if (!this.isEmpty(url)) {
139
- return this.httpClient.get(url);
140
- //return of(url);
141
- }
142
- else
143
- return of([]);
144
- }))
145
- .subscribe({
146
- next: (result: any) => {
147
- //this.listaPesquisa = result;
148
- this.console.log('subject subscribe result:', result);
149
- this.listaPesquisa = [];
150
-
151
- if (result && result.length > 0) {
152
- if (this.filterFunction) {
153
- result = result.filter(this.filterFunction);
154
- }
155
-
156
- result.forEach((ent: any, index: any) => {
157
- this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
158
- });
159
- }
160
-
161
- this.podePesquisar = true;
162
- if (this.listaPesquisa.length > 0) {
163
- this.dropDownPesquisa(this.listaPesquisa.length);
164
- }
165
- }
166
- , error: (error) => {
167
- this.podePesquisar = true;
168
- console.log('erro pesquisa', error);
169
- }
170
- });
171
- }
172
-
173
- writePesquisa(value: string | any): void {
174
- //console.log('write pesquisa', value);
175
- this.textoPesquisa = value;
176
- }
177
-
178
- showPesquisa(e: any): void {
179
- //console.log('show pesquisa', e.keyCode);
180
- var self = this;
181
- const index = e.target.selectionStart >= 1 ? (e.target.selectionStart - 1) : 0;
182
- //console.log(index, 'valor ', event.target.value, 'char ', event.target.value.charCodeAt(index));
183
- const keyAt = e.target.value.charCodeAt(index);
184
- /*
185
- if ((e.keyCode >= 48 && e.keyCode <= 57) ||
186
- (keyAt >= 48 && keyAt <= 57) ||
187
- (e.keyCode >= 65 && e.keyCode <= 90) ||
188
- (e.keyCode >= 96 && e.keyCode <= 105) ||
189
- (e.keyCode == 8)) {
190
- */
191
- if (e.keyCode != 40 && e.keyCode != 38) {
192
- if (!self.podePesquisar) {
193
- return;
194
- }
195
- let filtro = self.textoPesquisa;
196
- if (filtro != null && filtro != '' && filtro.length >= 2) {
197
- self.pesquisarEntidade(filtro);
198
-
199
- }
200
- else {
201
- if (e.keyCode == 8 && !filtro) {
202
- this.limparClick();
203
- }
204
- }
205
- }
206
-
207
- else {
208
- if (e.keyCode == 40 || e.keyCode == 38) {
209
- self.dropDownPesquisa(self.listaPesquisa.length);
210
- if (self.selectElementVisivel == true) {
211
- //let select = self.selectElement; //document.getElementById(self.TemplateSelect1Id());
212
-
213
- //ion-list
214
- //selecionado
215
- //console.log(self.listaPesquisa);
216
- let inc = e.keyCode == 40 ? 1 : -1;
217
- let selected = self.listaPesquisa.find(s => s['Selected'] === true);
218
- let cur = 0;
219
- if (selected != null) {
220
- cur = selected['Index'];
221
- //desmarcar o atual
222
- selected['Selected'] = false;
223
- cur = cur + inc;
224
- } else {
225
- cur = 0;
226
- }
227
-
228
- if (cur < 0) {
229
- cur = self.listaPesquisa.length - 1;
230
- } else if (cur >= self.listaPesquisa.length) {
231
- cur = 0;
232
- }
233
-
234
- let novoSelected = self.listaPesquisa.find(n => n['Index'] === cur);
235
- if (novoSelected != null) {
236
- novoSelected['Selected'] = true;
237
- self.selectedItem = novoSelected;
238
- self.textoPesquisa = novoSelected[self.campoDisplay];
239
- }
240
- /*
241
- let select = document.getElementById(this.selectId) as any;
242
- console.log('select Element', select)
243
- if (select != null) {
244
- let inc = e.keyCode == 40 ? 1 : -1;
245
- let cur = select.selectedIndex;
246
- if (cur == NaN) cur = -1;
247
- select.selectedIndex = cur + inc;
248
- if (select.selectedIndex >= 0 && select.selectedIndex < self.listaPesquisa.length) {
249
- self.selectedItem = self.listaPesquisa[select.selectedIndex];
250
- if (self.selectedItem != null) {
251
- self.textoPesquisa = self.selectedItem[self.campoDisplay];
252
- }
253
- }
254
- }
255
- */
256
- }
257
-
258
- } else
259
- if (e.keyCode == 13) {
260
- console.log('enter key', e)
261
- //self.selecionarComboClick(e);
262
- self.selecionarComboClick(null);
263
- //return false;
264
- } else if (e.keyCode == 27) {
265
- //ESC
266
- self.dropDownPesquisa(0);
267
- }
268
- }
269
-
270
- }
271
-
272
- highlight(texto: string): string {
273
- let index = texto.toLowerCase().indexOf(this.textoPesquisa.toLowerCase());
274
- //console.log(index);
275
- if (index >= 0) {
276
- return texto.substring(0, index) + '<strong>' + texto.substring(index, index + this.textoPesquisa.length) + '</strong>' + texto.substring(index + this.textoPesquisa.length); //texto.replace(this.textoPesquisa, `<strong>${this.textoPesquisa}</strong>`);
277
- } else {
278
- return texto;
279
- }
280
- }
281
-
282
- selecionarComboClick(item: any) {
283
- // console.log(item);
284
- var self = this;
285
- // console.log('combo click', self);
286
-
287
- /*
288
- let select = document.getElementById(this.selectId) as any;
289
- if (select.selectedIndex >= 0) {
290
- self.selectedItem = self.listaPesquisa[select.selectedIndex];
291
- }
292
- console.log('selected', this.selectedItem);
293
- //self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
294
- if (self.selectedItem != null) {
295
- self.textoPesquisa = self.selectedItem[self.campoDisplay];
296
- self.writeValue(self.selectedItem[self.campoId]);
297
- if (e != null) {
298
- self.selectElementVisivel = false;
299
- if (self.action != null) {
300
- self.action(self.selectedItem(), e);
301
- }
302
- }
303
- }
304
- else {
305
- self.selectElementVisivel = false;
306
- }
307
- */
308
- // pesquisar selecionado
309
- // console.log(this.listaPesquisa);
310
- let selected = this.listaPesquisa.find(s => s['Selected'] === true);
311
-
312
- // if (!selected) {
313
- // console.log(this.campoId, item);
314
- // selected = this.listaPesquisa.filter( s => s[this.campoId] == item[this.campoId]);
315
- // }
316
-
317
- //se o item form passado como parametro (click no ion-item)
318
- if (item != null) {
319
- if (selected != null) {
320
- selected['Selected'] = false;
321
- }
322
- item['Selected'] = true;
323
- selected = item;
324
- }
325
- if (selected != null) {
326
- self.selectedItem = selected;
327
- self.textoPesquisa = selected[self.campoDisplay];
328
- self.writeValue(selected[self.campoId]);
329
- self.selectElementVisivel = false;
330
- //console.log('action', self.change);
331
- if (self.pesquisaChange != null) {
332
- self.pesquisaChange.emit(self.selectedItem);
333
- }
334
- } else {
335
- self.selectElementVisivel = false;
336
- }
337
- // this.listaPesquisa.forEach( pesquisa => {
338
- // console.log(pesquisa, self.data);
339
- // } );
340
- // console.log(this.textoPesquisa);
341
- }
342
-
343
- selecionarComboChange(e: any) {
344
- var self = this;
345
- console.log('combo change', e);
346
- self.selectedItem = this.listaPesquisa.find(i => i[this.campoId] == e);
347
- if (self.selectedItem != null) {
348
- self.writeValue(e);
349
- self.textoPesquisa = self.selectedItem[self.campoDisplay];
350
- if (e != null) {
351
- self.selectElementVisivel = false;
352
- if (self.pesquisaChange != null) {
353
- self.pesquisaChange.emit(self.selectedItem);
354
- }
355
- }
356
- }
357
- else {
358
- self.selectElementVisivel = false;
359
- }
360
- }
361
-
362
- dropDownPesquisa(length: number) {
363
- var self = this;
364
- if (self.listaPesquisa != null && self.listaPesquisa.length > 0) {
365
- if (length == -1) {
366
- length = self.listaPesquisa.length;
367
- }
368
- self.selectElementVisivel = length == 0 ? false : true;
369
-
370
- //console.log(this.selectElement);
371
- //this.selectElement.open();
372
-
373
- /*
374
- //let element = this.selectElement;
375
- let element = document.getElementById(this.selectId);
376
- console.log('dropDown', element);
377
- (element as any).size = length + 1;
378
- if (length == 0) {
379
- self.selectElementVisivel = false;
380
- } else {
381
- self.selectElementVisivel = true;
382
- }
383
- */
384
- }
385
- }
386
-
387
- pesquisarEntidade(filtro: string) {
388
- let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
389
- console.log('pesquisarEntidade url', url);
390
- this.podePesquisar = false;
391
- this.pesquisaSubject.next(url);
392
- }
393
-
394
- pesquisarEntidadeOld(filtro: string) {
395
- let url = this.url.replace('<<FILTRO>>', filtro).replace('<<EMPRESA>>', this.empresa.toString());
396
- console.log('pesquisarEntidade url', url);
397
- this.podePesquisar = false;
398
- this.httpClient.get<any>(url)
399
- .subscribe({ next: (result: any) => {
400
- //this.listaPesquisa = result;
401
- if (this.filterFunction) {
402
- result = result.filter(this.filterFunction);
403
- }
404
- this.listaPesquisa = [];
405
- result.forEach((ent: any, index: number) => {
406
- this.listaPesquisa.push({ ...ent, Index: index, Selected: false });
407
- });
408
-
409
- this.podePesquisar = true;
410
- if (this.listaPesquisa.length > 0) {
411
- this.dropDownPesquisa(this.listaPesquisa.length);
412
- }
413
- }, error: error => {
414
- console.log('erro pesquisa', error);
415
- this.podePesquisar = true;
416
- }});
417
- }
418
-
419
- existeNaLista(id: number, setRegistro: boolean = false): boolean {
420
- if (this.listaPesquisa && this.listaPesquisa.length > 0) {
421
- let existe = this.listaPesquisa.find(l => l[this.campoId] === id);
422
- if (existe) {
423
- if (setRegistro) {
424
- this.selectedItem = existe;
425
- this.selecionarComboClick(this.selectedItem);
426
- }
427
- return true;
428
- } else {
429
- return false;
430
- }
431
- } else {
432
- return false;
433
- }
434
- }
435
-
436
- existeNaListaTexto(texto: string, setRegistro: boolean = false): boolean {
437
- console.log("existe texto:", texto, this.campoDisplay, this.listaPesquisa);
438
- if (this.listaPesquisa && this.listaPesquisa.length > 0) {
439
- let existe = this.listaPesquisa.find(l => l[this.campoDisplay].toUpperCase() === texto.toUpperCase());
440
- if (existe) {
441
- if (setRegistro) {
442
- this.selectedItem = existe;
443
- this.selecionarComboClick(this.selectedItem);
444
- }
445
- return true;
446
- } else {
447
- return false;
448
- }
449
- } else {
450
- return false;
451
- }
452
- }
453
-
454
- validarItemSelecionado(setarRegistro: boolean = false): boolean {
455
- console.log('validar selecionado');
456
- //passar pela função de filtro
457
- let valido = false;
458
- if (this.selectedItem) {
459
- if (this.filterFunction) {
460
- let existe = [{ ...this.selectedItem }].filter(this.filterFunction);
461
- if (existe != null && existe.length > 0) {
462
- valido = true;
463
- }
464
- } else {
465
- valido = true;
466
- }
467
- if (valido && setarRegistro) {
468
- this.selecionarComboClick(this.selectedItem);
469
- }
470
-
471
- return valido;
472
- } else {
473
- return false;
474
- }
475
- }
476
-
477
- carregaItemIdParaLista(id: number) {
478
- let url = this.urlItem.replace('<<ID>>', id.toString());
479
- console.log(this.urlItem);
480
- console.log('pesquisar ID url', url);
481
- this.podePesquisar = false;
482
- this.httpClient.get<any>(url)
483
- .subscribe({ next: (result: any) => {
484
- this.listaPesquisa = [];
485
- this.listaPesquisa.push({ ...result, Index: 0, Selected: true });
486
- this.podePesquisar = true;
487
- if (this.listaPesquisa.length > 0) {
488
- this.selectedItem = this.listaPesquisa[0];
489
- this.selecionarComboClick(this.selectedItem);
490
- }
491
- }, error: error => {
492
- console.log('erro pesquisa', error);
493
- this.podePesquisar = true;
494
- }});
495
- }
496
-
497
- limparClick() {
498
- this.writeValue(null);
499
- this.writePesquisa(null);
500
- this.listaPesquisa = [];
501
- this.dropDownPesquisa(0);
502
- //this.podePesquisar = true;
503
- this.pesquisaSubject.next('');
504
- if (this.limpar) {
505
- this.limpar();
506
- }
507
- }
508
-
509
- verificarPesquisa() {
510
- //TODO: verificar se o texto corresponde com um item da lista
511
- this.selecionarComboClick(null);
512
- }
513
-
514
- async pesquisarClick() {
515
- /*
516
- if (this.pesquisaAction != null) {
517
- this.pesquisaAction();
518
- }
519
- */
520
- //pesquisaCategoria
521
- console.log(this.filterFunction, this.url, this.urlTree);
522
-
523
- const modal = await this.modalCtrl.create({
524
- component: ModelTreeviewComponent,
525
- componentProps: {
526
- //campoId: this.campoId,
527
- //campoPai: this.campoPaiId,
528
- //campoLabel: this.campoDisplay,
529
- textoPesquisa: this.textoPesquisa,
530
- filterFunction: this.filterFunction,
531
- empresaSelecionadaId: this.empresa,
532
- tipo: this.tipo,
533
- //especifico
534
- //planoContas: this.planoContas,
535
- url: this.isEmpty(this.urlTree) ? this.url : this.urlTree,
536
- titulo: this.treeTitulo,
537
- campoLabel: this.campoDisplay,
538
- campoId: this.campoId,
539
- campoPai: this.campoPaiId
540
- },
541
- cssClass: 'my-custom-modal-pesquisa'
542
- });
543
-
544
- modal.onDidDismiss().then(data => {
545
- let result = data['data'];
546
- console.log(result);
547
- if (result != null && result.Id > 0) {
548
- this.carregaItemIdParaLista(result.Id);
549
- }
550
- });
551
- modal.present();
552
-
553
- }
554
-
555
- isEmpty(valor: string | any) {
556
- return valor == null || valor == undefined || valor == ''
557
- }
558
- }
@@ -1,21 +0,0 @@
1
- <div>
2
- <ion-item lines="none" style="--background: inherited; --background-focused: transparent; padding-right: 0px;" [class]="itemClass"
3
- [style.opacity]="readonly ? '0.5' : '1'">
4
- <ion-radio-group [disabled]="readonly" #inputRadio
5
- [value]="data"
6
- (ionChange)="writeValue(inputRadio.value)">
7
- <span style="font-size: 13px">
8
- {{ label }}
9
- </span>
10
- <ion-row>
11
- <ion-col *ngFor="let item of itens">
12
- <ion-radio style="margin-right: 12px;" [color]="color"
13
- labelPlacement="end"
14
- justify="start"
15
- [value]="item[itemId]">
16
- {{ item[itemNome] }}</ion-radio><br />
17
- </ion-col>
18
- </ion-row>
19
- </ion-radio-group>
20
- </ion-item>
21
- </div>
@@ -1,3 +0,0 @@
1
- ion-item {
2
- --min-height: var(--checkbox-min-height, 48px) !important;
3
- }
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { InputRadioComponent } from './input-radio.component';
4
-
5
- describe('InputRadioComponent', () => {
6
- let component: InputRadioComponent;
7
- let fixture: ComponentFixture<InputRadioComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [InputRadioComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(InputRadioComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,49 +0,0 @@
1
- import { Component, Input, OnInit } from '@angular/core';
2
- import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
- import { BaseInputComponent } from '../baseInputComponent';
4
-
5
- @Component({
6
- selector: 'kb-input-radio',
7
- templateUrl: './input-radio.component.html',
8
- styleUrls: ['./input-radio.component.scss', './../baseComponent.scss'],
9
- providers: [{
10
- provide: NG_VALUE_ACCESSOR,
11
- useExisting: InputRadioComponent,
12
- multi: true
13
- }]
14
- })
15
- export class InputRadioComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
16
- @Input() itens: any[] = [];
17
- @Input() itemId: string = "Id";
18
- @Input() itemNome: string = "Nome";
19
- @Input() color: string = "primary";
20
- //control value acessor
21
- public data!: string | undefined;
22
- private onChange: Function = (data: string) => { };
23
- private onTouch: Function = () => { };
24
- private disabled: boolean = false;
25
- public console = console;
26
-
27
- writeValue(value?: any): void {
28
- //console.log('write value', value);
29
- this.onChange(value);
30
- this.data = value;
31
- }
32
- registerOnChange(fn: any): void {
33
- this.onChange = fn;
34
- }
35
- registerOnTouched(fn: any): void {
36
- this.onTouch = fn;
37
- }
38
- setDisabledState?(isDisabled: boolean): void {
39
- this.disabled = this.disabled;
40
- }
41
- constructor() {
42
- super();
43
- }
44
-
45
- override ngOnInit(): void {
46
- }
47
-
48
-
49
- }
@@ -1,29 +0,0 @@
1
- <!--
2
- <div [formGroup]="form">
3
- -->
4
- <div>
5
- <ion-item lines="none" style="--background: inherited; --background-focused: transparent;" [class]="itemClass" #itemSelect
6
- [ngClass]="form?.get(formControlName)?.errors && (form?.get(formControlName)?.dirty || form?.get(formControlName)?.touched) ? 'error-shake' : '' "
7
- >
8
- <ion-label *ngIf="label" [position]="labelPosition" class="focus-label">{{ label }}</ion-label>
9
- <!-- formControlName="{{ formControlName }}" -->
10
- <select #inputSelect
11
- style="width: 100%;" (change)="onSelectChange(inputSelect.value)"
12
- (blur)="onBlur()" (focus)="onEnter()" [disabled]="readonly">
13
- <option *ngIf="itemNull" [value]="''" selected>{{ opcaoDefault }}</option>
14
- <option *ngFor="let item of itens" [value]="item[itemId]" [selected]="item[itemId] == data">{{ item[itemNome] }}
15
- </option>
16
- </select>
17
- </ion-item>
18
-
19
-
20
- <div class="validation-errors" *ngIf="form">
21
- <ng-container *ngFor="let validation of validation_messages">
22
- <div class="error-message"
23
- *ngIf="form && form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.touched)">
24
- &#8226; {{ validation.message }}
25
- </div>
26
- </ng-container>
27
- </div>
28
-
29
- </div>