appproject-components 1.0.46 → 1.0.47

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/karma.conf.js +44 -0
  2. package/ng-package.json +7 -0
  3. package/package.json +15 -26
  4. package/src/lib/appproject-components.component.spec.ts +23 -0
  5. package/src/lib/appproject-components.component.ts +20 -0
  6. package/src/lib/appproject-components.module.ts +106 -0
  7. package/src/lib/appproject-components.service.spec.ts +16 -0
  8. package/src/lib/appproject-components.service.ts +9 -0
  9. package/src/lib/baseComponent.scss +162 -0
  10. package/src/lib/baseInputComponent.ts +35 -0
  11. package/src/lib/buttons/baseBtnComponent.ts +38 -0
  12. package/src/lib/buttons/btn-action/btn-action.component.html +11 -0
  13. package/src/lib/buttons/btn-action/btn-action.component.scss +7 -0
  14. package/src/lib/buttons/btn-action/btn-action.component.spec.ts +24 -0
  15. package/src/lib/buttons/btn-action/btn-action.component.ts +31 -0
  16. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.html +14 -0
  17. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.scss +5 -0
  18. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.spec.ts +24 -0
  19. package/src/lib/buttons/btn-cancelar/btn-cancelar.component.ts +19 -0
  20. package/src/lib/buttons/btn-excluir/btn-excluir.component.html +6 -0
  21. package/src/lib/buttons/btn-excluir/btn-excluir.component.scss +5 -0
  22. package/src/lib/buttons/btn-excluir/btn-excluir.component.spec.ts +24 -0
  23. package/src/lib/buttons/btn-excluir/btn-excluir.component.ts +18 -0
  24. package/src/lib/buttons/btn-novo/btn-novo.component.html +14 -0
  25. package/src/lib/buttons/btn-novo/btn-novo.component.scss +8 -0
  26. package/src/lib/buttons/btn-novo/btn-novo.component.spec.ts +24 -0
  27. package/src/lib/buttons/btn-novo/btn-novo.component.ts +20 -0
  28. package/src/lib/buttons/btn-salvar/btn-salvar.component.html +8 -0
  29. package/src/lib/buttons/btn-salvar/btn-salvar.component.scss +5 -0
  30. package/src/lib/buttons/btn-salvar/btn-salvar.component.spec.ts +24 -0
  31. package/src/lib/buttons/btn-salvar/btn-salvar.component.ts +16 -0
  32. package/src/lib/entity-edit/entity-edit.component.html +143 -0
  33. package/src/lib/entity-edit/entity-edit.component.scss +4 -0
  34. package/src/lib/entity-edit/entity-edit.component.spec.ts +23 -0
  35. package/src/lib/entity-edit/entity-edit.component.ts +43 -0
  36. package/src/lib/grid-view/grid-view.component.html +116 -0
  37. package/src/lib/grid-view/grid-view.component.scss +47 -0
  38. package/src/lib/grid-view/grid-view.component.spec.ts +23 -0
  39. package/src/lib/grid-view/grid-view.component.ts +292 -0
  40. package/src/lib/input-area/input-area.component.html +30 -0
  41. package/src/lib/input-area/input-area.component.scss +68 -0
  42. package/src/lib/input-area/input-area.component.spec.ts +23 -0
  43. package/src/lib/input-area/input-area.component.ts +69 -0
  44. package/src/lib/input-arquivo/input-arquivo.component.html +11 -0
  45. package/src/lib/input-arquivo/input-arquivo.component.scss +0 -0
  46. package/src/lib/input-arquivo/input-arquivo.component.spec.ts +23 -0
  47. package/src/lib/input-arquivo/input-arquivo.component.ts +140 -0
  48. package/src/lib/input-cep/input-cep.component.html +38 -0
  49. package/src/lib/input-cep/input-cep.component.scss +0 -0
  50. package/src/lib/input-cep/input-cep.component.spec.ts +23 -0
  51. package/src/lib/input-cep/input-cep.component.ts +186 -0
  52. package/src/lib/input-checkbox/input-checkbox.component.html +12 -0
  53. package/src/lib/input-checkbox/input-checkbox.component.scss +11 -0
  54. package/src/lib/input-checkbox/input-checkbox.component.spec.ts +23 -0
  55. package/src/lib/input-checkbox/input-checkbox.component.ts +48 -0
  56. package/src/lib/input-format/input-format.component.html +32 -0
  57. package/src/lib/input-format/input-format.component.scss +47 -0
  58. package/src/lib/input-format/input-format.component.spec.ts +23 -0
  59. package/src/lib/input-format/input-format.component.ts +139 -0
  60. package/src/lib/input-pesquisa/input-pesquisa.component.html +77 -0
  61. package/src/lib/input-pesquisa/input-pesquisa.component.scss +127 -0
  62. package/src/lib/input-pesquisa/input-pesquisa.component.spec.ts +23 -0
  63. package/src/lib/input-pesquisa/input-pesquisa.component.ts +558 -0
  64. package/src/lib/input-radio/input-radio.component.html +21 -0
  65. package/src/lib/input-radio/input-radio.component.scss +3 -0
  66. package/src/lib/input-radio/input-radio.component.spec.ts +23 -0
  67. package/src/lib/input-radio/input-radio.component.ts +49 -0
  68. package/src/lib/input-select/input-select.component.html +29 -0
  69. package/src/lib/input-select/input-select.component.scss +62 -0
  70. package/src/lib/input-select/input-select.component.spec.ts +23 -0
  71. package/src/lib/input-select/input-select.component.ts +96 -0
  72. package/src/lib/input-text/input-text.component.html +48 -0
  73. package/src/lib/input-text/input-text.component.scss +63 -0
  74. package/src/lib/input-text/input-text.component.spec.ts +23 -0
  75. package/src/lib/input-text/input-text.component.ts +78 -0
  76. package/src/lib/input-valor/input-valor.component.html +32 -0
  77. package/src/lib/input-valor/input-valor.component.scss +47 -0
  78. package/src/lib/input-valor/input-valor.component.spec.ts +23 -0
  79. package/src/lib/input-valor/input-valor.component.ts +164 -0
  80. package/{lib/lib-config.d.ts → src/lib/lib-config.ts} +4 -3
  81. package/src/lib/model-treeview/model-treeview.component.html +20 -0
  82. package/src/lib/model-treeview/model-treeview.component.scss +0 -0
  83. package/src/lib/model-treeview/model-treeview.component.spec.ts +23 -0
  84. package/src/lib/model-treeview/model-treeview.component.ts +152 -0
  85. package/src/lib/tree-view/tree-view.component.html +96 -0
  86. package/src/lib/tree-view/tree-view.component.scss +50 -0
  87. package/src/lib/tree-view/tree-view.component.spec.ts +23 -0
  88. package/src/lib/tree-view/tree-view.component.ts +92 -0
  89. package/src/lib/tree-view-nivel/tree-view-nivel.component.html +17 -0
  90. package/src/lib/tree-view-nivel/tree-view-nivel.component.scss +8 -0
  91. package/src/lib/tree-view-nivel/tree-view-nivel.component.spec.ts +23 -0
  92. package/src/lib/tree-view-nivel/tree-view-nivel.component.ts +43 -0
  93. package/{public-api.d.ts → src/public-api.ts} +30 -24
  94. package/src/test.ts +15 -0
  95. package/tsconfig.lib.json +15 -0
  96. package/tsconfig.lib.prod.json +10 -0
  97. package/tsconfig.spec.json +17 -0
  98. package/esm2022/appproject-components.mjs +0 -5
  99. package/esm2022/lib/appproject-components.component.mjs +0 -22
  100. package/esm2022/lib/appproject-components.module.mjs +0 -159
  101. package/esm2022/lib/appproject-components.service.mjs +0 -14
  102. package/esm2022/lib/baseInputComponent.mjs +0 -69
  103. package/esm2022/lib/buttons/baseBtnComponent.mjs +0 -63
  104. package/esm2022/lib/buttons/btn-action/btn-action.component.mjs +0 -55
  105. package/esm2022/lib/buttons/btn-cancelar/btn-cancelar.component.mjs +0 -25
  106. package/esm2022/lib/buttons/btn-excluir/btn-excluir.component.mjs +0 -29
  107. package/esm2022/lib/buttons/btn-novo/btn-novo.component.mjs +0 -33
  108. package/esm2022/lib/buttons/btn-salvar/btn-salvar.component.mjs +0 -19
  109. package/esm2022/lib/entity-edit/entity-edit.component.mjs +0 -53
  110. package/esm2022/lib/grid-view/grid-view.component.mjs +0 -275
  111. package/esm2022/lib/input-area/input-area.component.mjs +0 -72
  112. package/esm2022/lib/input-arquivo/input-arquivo.component.mjs +0 -154
  113. package/esm2022/lib/input-cep/input-cep.component.mjs +0 -180
  114. package/esm2022/lib/input-checkbox/input-checkbox.component.mjs +0 -51
  115. package/esm2022/lib/input-format/input-format.component.mjs +0 -138
  116. package/esm2022/lib/input-pesquisa/input-pesquisa.component.mjs +0 -557
  117. package/esm2022/lib/input-radio/input-radio.component.mjs +0 -58
  118. package/esm2022/lib/input-select/input-select.component.mjs +0 -110
  119. package/esm2022/lib/input-text/input-text.component.mjs +0 -88
  120. package/esm2022/lib/input-valor/input-valor.component.mjs +0 -161
  121. package/esm2022/lib/lib-config.mjs +0 -2
  122. package/esm2022/lib/model-treeview/model-treeview.component.mjs +0 -126
  123. package/esm2022/lib/tree-view/tree-view.component.mjs +0 -104
  124. package/esm2022/lib/tree-view-nivel/tree-view-nivel.component.mjs +0 -50
  125. package/esm2022/public-api.mjs +0 -30
  126. package/fesm2022/appproject-components.mjs +0 -2531
  127. package/fesm2022/appproject-components.mjs.map +0 -1
  128. package/index.d.ts +0 -5
  129. package/lib/appproject-components.component.d.ts +0 -8
  130. package/lib/appproject-components.module.d.ts +0 -36
  131. package/lib/appproject-components.service.d.ts +0 -6
  132. package/lib/baseInputComponent.d.ts +0 -28
  133. package/lib/buttons/baseBtnComponent.d.ts +0 -19
  134. package/lib/buttons/btn-action/btn-action.component.d.ts +0 -21
  135. package/lib/buttons/btn-cancelar/btn-cancelar.component.d.ts +0 -10
  136. package/lib/buttons/btn-excluir/btn-excluir.component.d.ts +0 -12
  137. package/lib/buttons/btn-novo/btn-novo.component.d.ts +0 -13
  138. package/lib/buttons/btn-salvar/btn-salvar.component.d.ts +0 -9
  139. package/lib/entity-edit/entity-edit.component.d.ts +0 -22
  140. package/lib/grid-view/grid-view.component.d.ts +0 -52
  141. package/lib/input-area/input-area.component.d.ts +0 -24
  142. package/lib/input-arquivo/input-arquivo.component.d.ts +0 -43
  143. package/lib/input-cep/input-cep.component.d.ts +0 -29
  144. package/lib/input-checkbox/input-checkbox.component.d.ts +0 -21
  145. package/lib/input-format/input-format.component.d.ts +0 -27
  146. package/lib/input-pesquisa/input-pesquisa.component.d.ts +0 -69
  147. package/lib/input-radio/input-radio.component.d.ts +0 -23
  148. package/lib/input-select/input-select.component.d.ts +0 -32
  149. package/lib/input-text/input-text.component.d.ts +0 -33
  150. package/lib/input-valor/input-valor.component.d.ts +0 -29
  151. package/lib/model-treeview/model-treeview.component.d.ts +0 -39
  152. package/lib/tree-view/tree-view.component.d.ts +0 -23
  153. package/lib/tree-view-nivel/tree-view-nivel.component.d.ts +0 -17
@@ -0,0 +1,292 @@
1
+ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
2
+ import { GridColuna, GridTabela, LibService } from 'appproject-lib';
3
+
4
+ @Component({
5
+ selector: 'kb-grid-view',
6
+ templateUrl: './grid-view.component.html',
7
+ styleUrl: './grid-view.component.scss'
8
+ })
9
+ export class GridViewComponent implements OnInit, OnChanges {
10
+ @Input() empresaId: number;
11
+ @Input() tabelaCampos: GridTabela;
12
+ @Input() dataSet: Array<any>;
13
+ @Input() minHeight: string = '400px';
14
+ @Input() inMemoryPagination: boolean = false;
15
+
16
+ @Output() selecionarItem = new EventEmitter();
17
+ @Output() excluirItem = new EventEmitter();
18
+ @Output() selecionarChecked = new EventEmitter();
19
+
20
+ selectedItem: any;
21
+ //inputs = inject(new InjectionToken<any>('title inputs'));
22
+ grupos: any[] = [{ Coluna: '', Tabela: null, Dados: null, Nivel: 0 }];
23
+
24
+ // tabelaCampos = {
25
+ // Selecionar: false,
26
+ // Exportar: true,
27
+ // Colunas: [
28
+ // { Campo: 'Id', Titulo: 'Id', Tamanho: '10%', Ordem: true, Grupo: false, Filtrar: true, OrdemStatus: 0, Tipo: 'number', Valores: [], FiltroOperador: '=', FiltroValor: '', FiltroVisivel: false },
29
+ // { Campo: 'Marca', Titulo: 'Marca', Tamanho: '25%', Ordem: true, Grupo: true, Filtrar: true, OrdemStatus: 0, Tipo: 'string', Valores: [], FiltroOperador: '=', FiltroValor: '', FiltroVisivel: false },
30
+ // { Campo: 'Descricao', Titulo: 'Descrição', Tamanho: '25%', Ordem: true, Grupo: true, Filtrar: true, OrdemStatus: 0, Tipo: 'string', Valores: [], FiltroOperador: '=', FiltroValor: '', FiltroVisivel: false },
31
+ // { Campo: 'Data', Titulo: 'Data', Tamanho: '20%', Ordem: true, Grupo: true, Filtrar: true, OrdemStatus: 0, Tipo: 'date', Valores: [], FiltroOperador: '=', FiltroValor: '', FiltroVisivel: false },
32
+ // { Campo: 'Valor', Titulo: 'Valor', Tamanho: '20%', Ordem: true, Grupo: false, Filtrar: true, OrdemStatus: 0, Tipo: 'number', Valores: [], FiltroOperador: '=', FiltroValor: '', FiltroVisivel: false },
33
+ // ]
34
+ // }
35
+
36
+ // dataSet: Array<any> = [
37
+ // { Id: 1, Marca: 'Apple', Descricao: 'IPhone 14', Data: '2023-05-01', Valor: 7899.99 },
38
+ // { Id: 2, Marca: 'Apple', Descricao: 'MacBook Pro', Data: '2023-06-01', Valor: 17999.99 },
39
+ // { Id: 3, Marca: 'Samsung', Descricao: 'Galaxy S23', Data: '2023-05-01', Valor: 6899.99 },
40
+ // { Id: 4, Marca: 'Sony', Descricao: 'PS 5', Data: '2023-06-01', Valor: 4899.99 },
41
+ // { Id: 5, Marca: 'Samsung', Descricao: 'Watch 23', Data: '2023-05-01', Valor: 1899.99 },
42
+ // ]
43
+
44
+
45
+
46
+ groups = []
47
+ @Input() filteredDataSet = [];
48
+ pageDataSet = [];
49
+
50
+
51
+ //array com os campos filtrados para display
52
+ camposDisplay = [];
53
+
54
+ //filtro
55
+ isFiltroOpen: boolean = false;
56
+ selectedColuna: any;
57
+ todosSelecionados: boolean = false;
58
+
59
+ //pagination
60
+ //página atual
61
+ page: number = 1;
62
+ //registros por página
63
+ @Input() pageOffset: number = 20;
64
+ //total de registros
65
+ totalRec: number;
66
+ //total de páginas
67
+ totalPages: number;
68
+ //indexador de paginas
69
+ pages: number[];
70
+ start: number;
71
+
72
+
73
+ constructor() { }
74
+
75
+ valoresFiltro() {
76
+ this.tabelaCampos.Colunas.forEach(c => {
77
+ if (c.Filtrar) {
78
+ //projetar a coluna
79
+ let initial = [];
80
+ let valores = this.dataSet.map(d => d[c.Campo]);
81
+ c.Valores = valores.filter((value, index, self) => {
82
+ return self.indexOf(value) === index;
83
+ }).map(v => { return { Selecionado: false, Valor: v } });
84
+ // console.log(c.Campo, valores);
85
+ // console.log(c.Valores)
86
+ }
87
+ })
88
+ }
89
+
90
+ ngOnInit() {
91
+
92
+
93
+ //this.inicializaGrupo();
94
+ //this.agrupar('Marca');
95
+ //console.log('inputs', this.inputs);
96
+ //console.log('Input empresa', this.empresaId);
97
+ GridTabela.init(this.tabelaCampos);
98
+ this.valoresFiltro();
99
+ this.filteredDataSet = this.dataSet;
100
+ console.log('Init Tabela campos', this.tabelaCampos);
101
+ }
102
+
103
+ ngOnChanges(changes: SimpleChanges) {
104
+ console.log('On changes Tabela campos', this.tabelaCampos);
105
+ //evento chamado quando o dataset for atualizado
106
+ //inicializar vars de paginação
107
+ this.initPage();
108
+ this.todosSelecionados = false;
109
+ }
110
+
111
+ initPage() {
112
+ this.page = 1;
113
+ this.totalRec = this.filteredDataSet.length;
114
+ this.totalPages = Math.ceil(this.totalRec / this.pageOffset);
115
+
116
+ if (this.inMemoryPagination === true) {
117
+ this.getRegistrosPage();
118
+ } else {
119
+ this.pageDataSet = this.filteredDataSet;
120
+ }
121
+ }
122
+
123
+ getRegistrosPage() {
124
+ this.start = (this.page - 1) * this.pageOffset;
125
+ console.log('dataset', this.filteredDataSet);
126
+ console.log('start', this.start);
127
+ console.log('offset', this.pageOffset);
128
+ this.pageDataSet = this.filteredDataSet.slice(this.start, (this.start + this.pageOffset));
129
+ console.log('page dataset', this.pageDataSet);
130
+ }
131
+
132
+ proximo() {
133
+ if (this.page < this.totalPages) {
134
+ this.page++;
135
+ this.getRegistrosPage();
136
+ this.gerarArrayPags();
137
+ }
138
+ }
139
+
140
+ anterior() {
141
+ if (this.page > 1) {
142
+ this.page--;
143
+ this.getRegistrosPage();
144
+ this.gerarArrayPags();
145
+ }
146
+ }
147
+
148
+ gerarArrayPags() {
149
+
150
+ }
151
+
152
+ inicializaGrupo() {
153
+ //inicializar o primeiro grupo 'default'
154
+ this.camposDisplay = this.tabelaCampos.Colunas;
155
+ this.grupos[0].Tabela = this.camposDisplay;
156
+ this.grupos[0].Dados = this.dataSet;
157
+ }
158
+
159
+ agrupar(campo: string) {
160
+ this.groups.push(campo);
161
+ let level = 0;
162
+ for (let g in this.groups) {
163
+ console.log(g);
164
+ //filtrar os dados
165
+ let result = this.dataSet.reduce((group, data) => {
166
+ const { g } = data;
167
+ group[g] = group[campo] ?? [];
168
+ group[g].push(data);
169
+ return group;
170
+ }, {});
171
+ console.log(result);
172
+ }
173
+
174
+ }
175
+
176
+ filtrarCampos(coluna = '') {
177
+ if (coluna != '') {
178
+
179
+ } else {
180
+
181
+ }
182
+ }
183
+
184
+ filtrar(col: GridColuna) {
185
+ //console.log('filtrar', col);
186
+ if (col.Valores && col.Valores.find(v => v.Selecionado) != null) {
187
+ const valores = col.Valores.filter(v => v.Selecionado).map(v => v.Valor);
188
+
189
+ //filtrar por valores selecionados
190
+ this.filteredDataSet = this.dataSet.filter(d => valores.indexOf(d[col.Campo]) > -1);
191
+ } else if (col.FiltroOperador && col.FiltroValor) {
192
+ //console.log(col.FiltroOperador, col.FiltroValor)
193
+ try {
194
+ this.filteredDataSet = this.dataSet.filter(d => {
195
+ switch (col.FiltroOperador) {
196
+ case "=":
197
+ return d[col.Campo] == col.FiltroValor;
198
+ case ">=":
199
+ if (col.Tipo == 'number') {
200
+ return LibService.stringToDecimal(d[col.Campo], true) >= LibService.stringToDecimal(col.FiltroValor, true);
201
+ } else if (col.Tipo == 'data') {
202
+ return new Date(this.dataToString(d[col.Campo])) >= new Date(this.dataToString(col.FiltroValor));
203
+ } else
204
+ return d[col.Campo] >= col.FiltroValor;
205
+ case "<=":
206
+ if (col.Tipo == 'number') {
207
+ return LibService.stringToDecimal(d[col.Campo], true) <= LibService.stringToDecimal(col.FiltroValor, true);
208
+ } else
209
+ return d[col.Campo] <= col.FiltroValor;
210
+ case "tem":
211
+ return d[col.Campo].toString().toLowerCase().indexOf(col.FiltroValor.toLowerCase()) > -1;
212
+ default:
213
+ return true;
214
+ }
215
+
216
+ });
217
+ } catch(ex) {
218
+ console.log(ex);
219
+ this.filteredDataSet = this.dataSet;
220
+ }
221
+ }
222
+ col.FiltroVisivel = false;
223
+
224
+ this.initPage();
225
+ }
226
+
227
+ getPage() {
228
+
229
+ }
230
+
231
+ limpar() {
232
+ this.filteredDataSet = this.dataSet;
233
+ }
234
+
235
+ dataToString(data: string): string {
236
+ if (data) {
237
+ return data.split('/').reverse().join('-');
238
+ } else {
239
+ return "";
240
+ }
241
+ }
242
+
243
+ ordenar(col: GridColuna) {
244
+ if (col.OrdemStatus == 0 || col.OrdemStatus == -1) {
245
+ if (col.Tipo == 'data') {
246
+ this.filteredDataSet.sort((a, b) => this.dataToString(a[col.Campo]) > this.dataToString(b[col.Campo]) ? 1 : (this.dataToString(a[col.Campo]) < this.dataToString(b[col.Campo]) ? -1 : 0));
247
+ } else if (col.Tipo == 'number') {
248
+ this.filteredDataSet.sort((a, b) => LibService.stringToDecimal(a[col.Campo]) > LibService.stringToDecimal(b[col.Campo]) ? 1 : (LibService.stringToDecimal(a[col.Campo]) < LibService.stringToDecimal(b[col.Campo]) ? -1 : 0));
249
+ } else
250
+ this.filteredDataSet.sort((a, b) => a[col.Campo] > b[col.Campo] ? 1 : (a[col.Campo] < b[col.Campo] ? -1 : 0));
251
+ col.OrdemStatus = 1; //asc
252
+ } else {
253
+ if (col.Tipo == 'data') {
254
+ this.filteredDataSet.sort((a, b) => this.dataToString(a[col.Campo]) < this.dataToString(b[col.Campo]) ? 1 : (this.dataToString(a[col.Campo]) > this.dataToString(b[col.Campo]) ? -1 : 0));
255
+ } else if (col.Tipo == 'number') {
256
+ this.filteredDataSet.sort((a, b) => LibService.stringToDecimal(a[col.Campo], true) < LibService.stringToDecimal(b[col.Campo], true) ? 1 : (LibService.stringToDecimal(a[col.Campo], true) > LibService.stringToDecimal(b[col.Campo], true) ? -1 : 0));
257
+ } else
258
+ this.filteredDataSet.sort((a, b) => a[col.Campo] < b[col.Campo] ? 1 : (a[col.Campo] > b[col.Campo] ? -1 : 0));
259
+ col.OrdemStatus = -1; //desc
260
+ }
261
+ }
262
+
263
+ setFiltroOpen(col: any) {
264
+ col.FiltroVisivel = !col.FiltroVisivel
265
+ if (col.FiltroVisivel) {
266
+ this.selectedColuna = col;
267
+ //console.log(this.selectedColuna);
268
+ }
269
+ }
270
+
271
+ selecionarTodos() {
272
+ //this.todosSelecionados = !this.todosSelecionados;
273
+ this.filteredDataSet.forEach(item => {
274
+ item[this.tabelaCampos.CampoSelecionar] = this.todosSelecionados;
275
+ });
276
+ this.selecionarChecked.emit();
277
+ }
278
+
279
+ selecionarLinha(item: any) {
280
+ this.selecionarItem.emit(item);
281
+ this.selectedItem = item;
282
+ }
283
+
284
+ excluirLinha(item: any) {
285
+ this.excluirItem.emit(item);
286
+ }
287
+
288
+ //check
289
+ selecionadoChecked() {
290
+ this.selecionarChecked.emit();
291
+ }
292
+ }
@@ -0,0 +1,30 @@
1
+ <!--
2
+ maxlength="{{ max }}"
3
+ -->
4
+ <div>
5
+ <ion-item lines="none" style="--background-focused: transparent;" [class]="itemClass" #itemArea>
6
+ <ion-label position="{{ labelPosition }}">{{ label }}</ion-label>
7
+ <!-- formControlName="{{ formControlName }}" -->
8
+ <textarea #inputArea
9
+ [placeholder]="placeholder"
10
+ [maxLength]="max"
11
+ (ionBlur)="onBlur()"
12
+ [value]="data"
13
+ [rows]="linhas"
14
+ (input)="writeValue(inputArea.value)"
15
+ [disabled]="readonly"
16
+ (focus)="entered()"
17
+ ></textarea>
18
+ </ion-item>
19
+
20
+ <div class="validation-errors" *ngIf="form">
21
+
22
+ <ng-container *ngFor="let validation of validation_messages">
23
+ <div class="error-message"
24
+ *ngIf="form.get(formControlName)?.hasError(validation.type) && (form.get(formControlName)?.dirty || form.get(formControlName)?.touched)">
25
+ &#8226; {{ validation.message }}
26
+ </div>
27
+ </ng-container>
28
+
29
+ </div>
30
+ </div>
@@ -0,0 +1,68 @@
1
+ ion-label {
2
+ margin-bottom: 4px !important;
3
+ }
4
+
5
+ ion-textarea {
6
+ //padding: 4px;
7
+ padding: var(--input-padding, 8px) !important;
8
+ border: 1px solid darkgray;
9
+ border-radius: 4px;
10
+ width: 100%;
11
+ margin-top: 2px;
12
+ /*max-height: 29px;*/
13
+ }
14
+
15
+ textarea {
16
+ //padding: 4px;
17
+ padding: var(--input-padding, 8px) !important;
18
+ border: 1px solid darkgray;
19
+ border-radius: 4px;
20
+ width: 100%;
21
+ margin-top: 2px;
22
+ resize: none;
23
+ /*max-height: 29px;*/
24
+ background-color: white;
25
+
26
+ //scrollbar-width: thin; /* or auto for default width */
27
+ //scrollbar-color: #4CAF50 #f1f1f1; /* thumb and track colors */
28
+
29
+ }
30
+
31
+ //ion-item::part(native) {
32
+ /* não funcionou */
33
+
34
+ textarea::-webkit-scrollbar {
35
+ //width: 0.5em !important;
36
+ width: 10px;
37
+ height: 10px;
38
+ }
39
+
40
+ textarea::-webkit-scrollbar-track {
41
+ //-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
42
+ background: #f1f1f1;
43
+ }
44
+
45
+ textarea::-webkit-scrollbar-thumb {
46
+ //background-color: darkgrey;
47
+ //outline: 1px solid slategrey;
48
+ border-radius: 12px;
49
+ background: var(--scroll-color-thumb, #808080);
50
+ }
51
+ textarea::-webkit-scrollbar-thumb:hover {
52
+ background: var(--scroll-color-hover, #5c5c5c);
53
+ }
54
+
55
+ textarea:focus {
56
+ outline: none !important;
57
+ //--focus-color: blue;
58
+ border: 1px solid lightblue !important;
59
+ ion-label{
60
+ color: var(--ion-color-label-focus, blue) !important;
61
+ }
62
+ }
63
+ //}
64
+ .item-has-focus {
65
+ ion-label {
66
+ color: var(--ion-color-label-focus, blue) !important;
67
+ }
68
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { InputAreaComponent } from './input-area.component';
4
+
5
+ describe('InputAreaComponent', () => {
6
+ let component: InputAreaComponent;
7
+ let fixture: ComponentFixture<InputAreaComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ InputAreaComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(InputAreaComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,69 @@
1
+ import { Component, ElementRef, Input, OnInit, Renderer2, ViewChild } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { BaseInputComponent } from '../baseInputComponent';
4
+
5
+ @Component({
6
+ selector: 'kb-input-area',
7
+ templateUrl: './input-area.component.html',
8
+ styleUrls: ['./input-area.component.scss', './../baseComponent.scss'],
9
+ providers: [{
10
+ provide: NG_VALUE_ACCESSOR,
11
+ useExisting: InputAreaComponent,
12
+ multi: true
13
+ }]
14
+ })
15
+ export class InputAreaComponent extends BaseInputComponent implements OnInit, ControlValueAccessor {
16
+ @Input() linhas: number = 5;
17
+
18
+ @ViewChild("itemArea", {read: ElementRef}) itemArea: any;
19
+ //control value acessor
20
+ public data: string | any;
21
+ private onChange: Function = (data: string) => {};
22
+ private onTouch: Function = () => {};
23
+ private disabled: boolean = false;
24
+ public console = console;
25
+
26
+ writeValue(value: string | any): void {
27
+ //console.log('write value', value);
28
+ this.onChange(value);
29
+ this.data = value;
30
+ }
31
+ registerOnChange(fn: any): void {
32
+ this.onChange = fn;
33
+ }
34
+ registerOnTouched(fn: any): void {
35
+ this.onTouch = fn;
36
+ }
37
+ setDisabledState?(isDisabled: boolean): void {
38
+ this.disabled = this.disabled;
39
+ }
40
+ constructor(private renderer: Renderer2) {
41
+ super();
42
+ }
43
+
44
+ override ngOnInit() {}
45
+
46
+ onBlur() {
47
+ //remover classe do ion-item
48
+ setTimeout(() => {
49
+ //this.renderer.addClass(document.getElementById("item-select"), "item-has-focus");
50
+ this.renderer.removeClass(this.itemArea.nativeElement, "item-has-focus");
51
+ //console.log('select focused', document.getElementById("item-select"));
52
+ }, 200);
53
+
54
+ if (this.form) {
55
+ this.form.get(this.formControlName)?.markAsTouched();
56
+ }
57
+ }
58
+
59
+ entered() {
60
+ //adicionar classe ao ion-item
61
+ // console.log('select focused');
62
+ setTimeout(() => {
63
+ //this.renderer.addClass(document.getElementById("item-select"), "item-has-focus");
64
+ this.renderer.addClass(this.itemArea.nativeElement, "item-has-focus");
65
+ //console.log('select focused', document.getElementById("item-select"));
66
+ }, 200);
67
+
68
+ }
69
+ }
@@ -0,0 +1,11 @@
1
+ <!-- style="box-shadow: #4c8dff 0px 3px 3px 0.05px" -->
2
+ <div style="text-align:center;">
3
+ <ion-button [fill]="btnFill" size="normal" [color]="btnColor"
4
+ (click)="showImageBrowser()" [expand]="btnExpand" [disabled]="readOnly">
5
+ <ion-icon *ngIf="showIcon" class="ion-padding-end" [slot]="iconSlot" [src]="iconSrc" [name]="icon"></ion-icon>
6
+ {{ caption }}
7
+ </ion-button>
8
+ <input type="file" id="upimgfile" name="uploadfile" #inputNome [accept]="arquivoTipos" (change)="loadImagem()"
9
+ style="display: none;" />
10
+ </div>
11
+
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { InputArquivoComponent } from './input-arquivo.component';
4
+
5
+ describe('InputArquivoComponent', () => {
6
+ let component: InputArquivoComponent;
7
+ let fixture: ComponentFixture<InputArquivoComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ InputArquivoComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(InputArquivoComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,140 @@
1
+ import { Component, Input, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { Subject } from 'rxjs';
4
+
5
+ @Component({
6
+ selector: 'kb-input-arquivo',
7
+ templateUrl: './input-arquivo.component.html',
8
+ styleUrls: ['./input-arquivo.component.scss'],
9
+ providers: [{
10
+ provide: NG_VALUE_ACCESSOR,
11
+ useExisting: InputArquivoComponent,
12
+ multi: true
13
+ }]
14
+ })
15
+ export class InputArquivoComponent implements OnInit, ControlValueAccessor {
16
+ @Input() nomeArquivo: string;
17
+
18
+ //@Input() disabled: boolean = false;
19
+
20
+ @Input() caption: string;
21
+ @Input() pasta: string;
22
+ @Input() subir: boolean = false;
23
+ @Input() callback = new EventEmitter();
24
+ @Input() tipoArquivo: string = "image/*";
25
+ @Output() fileSelected = new EventEmitter();
26
+ @Input() form: boolean = false;
27
+ @Input() showIcon: boolean = false;
28
+ @Input() icon: string;
29
+ @Input() iconSrc: string; ///assets/icon/image_primary_24dp.svg
30
+ @Input() btnExpand: string = "block";
31
+ @Input() btnColor: string = "primary";
32
+ @Input() btnFill: string = "outline";
33
+ @Input() iconSlot: string = "start";
34
+ @Input() arquivoTipos: string = "image/*";
35
+ @Input() readOnly: boolean = false;
36
+
37
+ //imagem
38
+ @ViewChild('inputNome', { read: ElementRef, static: true }) myInput;
39
+ captureDataUrl: string;
40
+ public formFile: any;
41
+ public sucessoEvent: Subject<boolean> = new Subject();
42
+
43
+ data: string;
44
+ filename: string;
45
+
46
+ private onChange: Function = (selectedColor: string) => { };
47
+ private onTouch: Function = () => { };
48
+ private disabled: boolean = false;
49
+
50
+ showImageBrowser() {
51
+ this.myInput.nativeElement.click();
52
+ }
53
+
54
+ writeValue(value: string): void {
55
+ this.onChange(value);
56
+ this.data = value;
57
+ if (this.callback)
58
+ this.callback.emit(this.filename);
59
+ }
60
+ registerOnChange(fn: any): void {
61
+ this.onChange = fn;
62
+ }
63
+ registerOnTouched(fn: any): void {
64
+ this.onTouch = fn;
65
+ }
66
+ setDisabledState?(isDisabled: boolean): void {
67
+ this.disabled = this.disabled;
68
+ }
69
+
70
+ constructor() {
71
+
72
+ }
73
+
74
+ ngOnInit(): void {
75
+
76
+ }
77
+
78
+ loadImagem() {
79
+ //console.log(this.myInput);
80
+ this.formFile = this.myInput.nativeElement.files[0];
81
+
82
+ if (this.fileSelected) {
83
+ this.fileSelected.emit({ content: this.formFile, name: this.myInput.nativeElement.files[0].name });
84
+ }
85
+
86
+ if (this.form) {
87
+ //this.formFile = this.myInput.nativeElement.files[0];
88
+ this.sucessoEvent.next(true);
89
+
90
+ } else {
91
+ //this.formFile = this.myInput.nativeElement.files[0];
92
+ this.getBase64FromFile(this.myInput.nativeElement.files[0])
93
+ .then(result => {
94
+ //console.log('file: ', result.toString());
95
+ //console.log('nome do arquivo: ', this.nomeArquivo.toLowerCase());
96
+ let searchstr = result.toString().substring(0, result.toString().indexOf('base64,')) + 'base64,';
97
+ console.log('searchstring', searchstr);
98
+ if (this.subir) {
99
+ this.captureDataUrl = result.toString().replace(searchstr, '');
100
+ } else {
101
+ this.captureDataUrl = result.toString();
102
+ }
103
+ //this.utils.showToast('Imagem carregada em memória.');
104
+ this.sucessoEvent.next(true);
105
+ console.log('file', this.myInput.nativeElement.files[0]);
106
+ this.filename = this.myInput.nativeElement.files[0].name;
107
+ this.writeValue(this.captureDataUrl);
108
+
109
+
110
+
111
+ // if (this.nomeArquivo && this.subir) {
112
+ // this.arquivoService.setImagem({ Nome: this.nomeArquivo, Conteudo: this.captureDataUrl, Status: 0, Pasta: this.pasta })
113
+ // .subscribe(result => {
114
+ // console.log('result set imagem', result);
115
+ // if (result.Status == 200) {
116
+ // this.utils.showToast('Sucesso!');
117
+ // } else {
118
+ // this.utils.showAlert('Erro. Tente mais tarde.' + result.Conteudo);
119
+ // }
120
+ // }, error => {
121
+ // this.utils.showAlert('Erro. Tente mais tarde.');
122
+ // })
123
+ // }
124
+
125
+ }).catch(error => {
126
+ this.sucessoEvent.next(false);
127
+ })
128
+ }
129
+ }
130
+
131
+ //util
132
+ getBase64FromFile(file: File) {
133
+ return new Promise((resolve, reject) => {
134
+ const reader = new FileReader();
135
+ reader.readAsDataURL(file);
136
+ reader.onload = () => resolve(reader.result);
137
+ reader.onerror = error => reject(error);
138
+ });
139
+ }
140
+ }