ng-firebase-table-kxp 1.2.0 → 1.2.2
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.
- package/{fesm2020 → fesm2022}/ng-firebase-table-kxp.mjs +2762 -2744
- package/fesm2022/ng-firebase-table-kxp.mjs.map +1 -0
- package/index.d.ts +665 -5
- package/package.json +3 -11
- package/esm2020/lib/components/table/table.component.mjs +0 -710
- package/esm2020/lib/components/table-tabs/table-tabs.component.mjs +0 -73
- package/esm2020/lib/components/table-tooltip/table-tooltip.component.mjs +0 -34
- package/esm2020/lib/ng-firebase-table-kxp.component.mjs +0 -11
- package/esm2020/lib/ng-firebase-table-kxp.module.mjs +0 -98
- package/esm2020/lib/ng-firebase-table-kxp.service.mjs +0 -14
- package/esm2020/lib/services/filter.service.mjs +0 -416
- package/esm2020/lib/services/pagination.service.mjs +0 -115
- package/esm2020/lib/services/table.service.mjs +0 -1140
- package/esm2020/lib/services/tooltip.service.mjs +0 -141
- package/esm2020/lib/types/Table.mjs +0 -9
- package/esm2020/lib/utils/table.utils.mjs +0 -75
- package/esm2020/ng-firebase-table-kxp.mjs +0 -5
- package/esm2020/public-api.mjs +0 -22
- package/fesm2015/ng-firebase-table-kxp.mjs +0 -2869
- package/fesm2015/ng-firebase-table-kxp.mjs.map +0 -1
- package/fesm2020/ng-firebase-table-kxp.mjs.map +0 -1
- package/lib/components/table/table.component.d.ts +0 -132
- package/lib/components/table/table.component.d.ts.map +0 -1
- package/lib/components/table-tabs/table-tabs.component.d.ts +0 -34
- package/lib/components/table-tabs/table-tabs.component.d.ts.map +0 -1
- package/lib/components/table-tooltip/table-tooltip.component.d.ts +0 -18
- package/lib/components/table-tooltip/table-tooltip.component.d.ts.map +0 -1
- package/lib/ng-firebase-table-kxp.component.d.ts +0 -5
- package/lib/ng-firebase-table-kxp.component.d.ts.map +0 -1
- package/lib/ng-firebase-table-kxp.module.d.ts +0 -23
- package/lib/ng-firebase-table-kxp.module.d.ts.map +0 -1
- package/lib/ng-firebase-table-kxp.service.d.ts +0 -6
- package/lib/ng-firebase-table-kxp.service.d.ts.map +0 -1
- package/lib/services/filter.service.d.ts +0 -88
- package/lib/services/filter.service.d.ts.map +0 -1
- package/lib/services/pagination.service.d.ts +0 -34
- package/lib/services/pagination.service.d.ts.map +0 -1
- package/lib/services/table.service.d.ts +0 -80
- package/lib/services/table.service.d.ts.map +0 -1
- package/lib/services/tooltip.service.d.ts +0 -73
- package/lib/services/tooltip.service.d.ts.map +0 -1
- package/lib/types/Table.d.ts +0 -162
- package/lib/types/Table.d.ts.map +0 -1
- package/lib/utils/table.utils.d.ts +0 -25
- package/lib/utils/table.utils.d.ts.map +0 -1
- package/ng-firebase-table-kxp.d.ts.map +0 -1
- package/public-api.d.ts +0 -12
- package/public-api.d.ts.map +0 -1
|
@@ -1,2869 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Injectable, Optional, EventEmitter, ChangeDetectionStrategy, Input, Output, ViewChild, NgModule } from '@angular/core';
|
|
3
|
-
import * as i1$1 from '@angular/common';
|
|
4
|
-
import { CommonModule } from '@angular/common';
|
|
5
|
-
import * as i8 from '@angular/forms';
|
|
6
|
-
import { FormGroup, FormControl, FormArray, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
7
|
-
import * as i1$2 from '@angular/router';
|
|
8
|
-
import { RouterModule } from '@angular/router';
|
|
9
|
-
import * as i9 from '@angular/material/table';
|
|
10
|
-
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
|
11
|
-
import * as i10 from '@angular/material/paginator';
|
|
12
|
-
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
13
|
-
import * as i11 from '@angular/material/sort';
|
|
14
|
-
import { MatSort, MatSortModule } from '@angular/material/sort';
|
|
15
|
-
import * as i12 from '@angular/material/form-field';
|
|
16
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
17
|
-
import * as i13 from '@angular/material/input';
|
|
18
|
-
import { MatInputModule } from '@angular/material/input';
|
|
19
|
-
import * as i14 from '@angular/material/select';
|
|
20
|
-
import { MatSelectModule } from '@angular/material/select';
|
|
21
|
-
import * as i16 from '@angular/material/tooltip';
|
|
22
|
-
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
23
|
-
import * as i17 from '@angular/material/progress-spinner';
|
|
24
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
25
|
-
import * as i18 from '@angular/material/icon';
|
|
26
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
27
|
-
import * as i2 from '@angular/material/dialog';
|
|
28
|
-
import { MatDialogModule } from '@angular/material/dialog';
|
|
29
|
-
import { __awaiter } from 'tslib';
|
|
30
|
-
import { firstValueFrom, BehaviorSubject, Subject, debounceTime, takeUntil } from 'rxjs';
|
|
31
|
-
import firebase from 'firebase/compat/app';
|
|
32
|
-
import * as moment from 'moment';
|
|
33
|
-
import * as i1 from '@angular/fire/compat/firestore';
|
|
34
|
-
import * as i3 from 'ngx-toastr';
|
|
35
|
-
import * as i15 from '@angular/material/core';
|
|
36
|
-
|
|
37
|
-
class NgFirebaseTableKxpComponent {
|
|
38
|
-
}
|
|
39
|
-
NgFirebaseTableKxpComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
40
|
-
NgFirebaseTableKxpComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: NgFirebaseTableKxpComponent, selector: "lib-ng-firebase-table-kxp", ngImport: i0, template: ` <p>ng-firebase-table-kxp works!</p> `, isInline: true });
|
|
41
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, decorators: [{
|
|
42
|
-
type: Component,
|
|
43
|
-
args: [{ selector: 'lib-ng-firebase-table-kxp', template: ` <p>ng-firebase-table-kxp works!</p> ` }]
|
|
44
|
-
}] });
|
|
45
|
-
|
|
46
|
-
const TABLE_DEFAULTS = {
|
|
47
|
-
SORT_FIELD: 'createdAt',
|
|
48
|
-
SORT_ORDER: 'desc',
|
|
49
|
-
PAGE_SIZE: 25,
|
|
50
|
-
DEBOUNCE_TIME_MS: 500,
|
|
51
|
-
DEFAULT_BG_COLOR: '#1976d2',
|
|
52
|
-
DEFAULT_TEXT_COLOR: '#ffffff',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Obtém o valor aninhado de um objeto dado um caminho (ex: 'user.address.city')
|
|
57
|
-
*/
|
|
58
|
-
function getNestedValue(obj, path) {
|
|
59
|
-
if (!path)
|
|
60
|
-
return undefined;
|
|
61
|
-
const properties = path.split('.');
|
|
62
|
-
return properties.reduce((acc, currentPart) => acc && acc[currentPart], obj);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Formata um array de objetos em uma string com valores separados por vírgula
|
|
66
|
-
*/
|
|
67
|
-
function formatArrayValue(array, field) {
|
|
68
|
-
if (!Array.isArray(array) || array.length === 0) {
|
|
69
|
-
return '';
|
|
70
|
-
}
|
|
71
|
-
const values = array
|
|
72
|
-
.map((item) => {
|
|
73
|
-
if (typeof item === 'object' && item !== null) {
|
|
74
|
-
return item[field] || '';
|
|
75
|
-
}
|
|
76
|
-
return String(item);
|
|
77
|
-
})
|
|
78
|
-
.filter((value) => value !== '' && value !== null && value !== undefined);
|
|
79
|
-
return values.join(', ');
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Obtém o valor de exibição para uma célula da tabela
|
|
83
|
-
*/
|
|
84
|
-
function getDisplayValue(col, row, withinLimit = false) {
|
|
85
|
-
let value;
|
|
86
|
-
if (col.calculateValue) {
|
|
87
|
-
value = col.calculateValue(row);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
value = getNestedValue(row, col.property);
|
|
91
|
-
}
|
|
92
|
-
if (Array.isArray(value) && col.arrayField) {
|
|
93
|
-
value = formatArrayValue(value, col.arrayField);
|
|
94
|
-
}
|
|
95
|
-
if (col.queryLength && row[col.property]) {
|
|
96
|
-
value = row[col.property];
|
|
97
|
-
}
|
|
98
|
-
value = col.pipe ? col.pipe.transform(value) : value;
|
|
99
|
-
if (value === null || value === undefined) {
|
|
100
|
-
value = '';
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
value = String(value);
|
|
104
|
-
}
|
|
105
|
-
if (withinLimit || !col.charLimit || value.length <= col.charLimit) {
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
return value.substring(0, col.charLimit) + '...';
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Verifica se um valor é string
|
|
112
|
-
*/
|
|
113
|
-
function isString(value) {
|
|
114
|
-
return typeof value === 'string';
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* TrackBy function para colunas
|
|
118
|
-
*/
|
|
119
|
-
function trackByProperty(_index, col) {
|
|
120
|
-
return col.property;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Gera uma chave única para identificar uma imagem em carregamento
|
|
124
|
-
*/
|
|
125
|
-
function getImageKey(row, col) {
|
|
126
|
-
const rowId = row.id || row._id || JSON.stringify(row);
|
|
127
|
-
return `${rowId}-${col.property}`;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
class TableService {
|
|
131
|
-
constructor(ngFire, dialog, toastr) {
|
|
132
|
-
this.ngFire = ngFire;
|
|
133
|
-
this.dialog = dialog;
|
|
134
|
-
this.toastr = toastr;
|
|
135
|
-
this.operators = {
|
|
136
|
-
'==': (a, b) => a === b,
|
|
137
|
-
'!=': (a, b) => a !== b,
|
|
138
|
-
'>': (a, b) => a > b,
|
|
139
|
-
'<': (a, b) => a < b,
|
|
140
|
-
'>=': (a, b) => a >= b,
|
|
141
|
-
'<=': (a, b) => a <= b,
|
|
142
|
-
in: (a, b) => Array.isArray(b) && b.includes(a),
|
|
143
|
-
'not-in': (a, b) => Array.isArray(b) && !b.includes(a),
|
|
144
|
-
'array-contains': (a, b) => Array.isArray(a) && a.includes(b),
|
|
145
|
-
'array-contains-any': (a, b) => Array.isArray(a) &&
|
|
146
|
-
Array.isArray(b) &&
|
|
147
|
-
b.some((item) => a.includes(item)),
|
|
148
|
-
includes: (a, b) => {
|
|
149
|
-
if (typeof a === 'string' && typeof b === 'string') {
|
|
150
|
-
return a.includes(b);
|
|
151
|
-
}
|
|
152
|
-
if (Array.isArray(a)) {
|
|
153
|
-
return a.includes(b);
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
getItems(collection) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
try {
|
|
162
|
-
const querySnapshot = yield collection.get();
|
|
163
|
-
return querySnapshot.docs.map((doc) => {
|
|
164
|
-
const data = doc.data();
|
|
165
|
-
return Object.assign(Object.assign({}, (data !== null && data !== void 0 ? data : {})), { id: doc.id });
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
console.warn('Collection não encontrada:', error);
|
|
170
|
-
return [];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
executeQuery(params) {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
if (params.filterFn) {
|
|
177
|
-
// Lógica com filtro no cliente (filterFn)
|
|
178
|
-
const BATCH_FETCH_SIZE = params.batchSize;
|
|
179
|
-
const GOAL_SIZE = params.batchSize + 1;
|
|
180
|
-
if (params.navigation === 'forward' || params.navigation === 'reload') {
|
|
181
|
-
if (params.navigation === 'reload' && params.doc) {
|
|
182
|
-
params.doc.lastDoc = null;
|
|
183
|
-
}
|
|
184
|
-
let lastDocCursor = params.doc ? params.doc.lastDoc : null;
|
|
185
|
-
let pageResults = [];
|
|
186
|
-
let allFetchedDocs = [];
|
|
187
|
-
let hasMoreDocsInDb = true;
|
|
188
|
-
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
189
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
190
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
191
|
-
if (lastDocCursor) {
|
|
192
|
-
query = query.startAfter(lastDocCursor);
|
|
193
|
-
}
|
|
194
|
-
query = query.limit(BATCH_FETCH_SIZE);
|
|
195
|
-
const snapshot = yield query.get();
|
|
196
|
-
if (snapshot.empty) {
|
|
197
|
-
hasMoreDocsInDb = false;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
lastDocCursor = snapshot.docs[snapshot.docs.length - 1];
|
|
201
|
-
allFetchedDocs.push(...snapshot.docs);
|
|
202
|
-
const batchUsers = snapshot.docs
|
|
203
|
-
.map((doc) => {
|
|
204
|
-
const data = doc.data();
|
|
205
|
-
return Object.assign({ id: doc.id }, (data !== null && data !== void 0 ? data : {}));
|
|
206
|
-
})
|
|
207
|
-
.filter(params.filterFn);
|
|
208
|
-
pageResults.push(...batchUsers);
|
|
209
|
-
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
210
|
-
hasMoreDocsInDb = false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const hasNextPage = pageResults.length > params.batchSize;
|
|
214
|
-
const finalItems = pageResults.slice(0, params.batchSize);
|
|
215
|
-
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
216
|
-
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
217
|
-
return {
|
|
218
|
-
items: finalItems,
|
|
219
|
-
filterLength: null,
|
|
220
|
-
firstDoc: firstDocOfPage,
|
|
221
|
-
lastDoc: lastDocOfPage,
|
|
222
|
-
hasNextPage: hasNextPage,
|
|
223
|
-
hasPreviousPage: !!(params.doc && params.doc.lastDoc) &&
|
|
224
|
-
params.navigation !== 'reload',
|
|
225
|
-
currentClientPageIndex: undefined,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
// Lógica para trás (backward)
|
|
229
|
-
else if (params.navigation === 'backward') {
|
|
230
|
-
if (!params.doc || !params.doc.firstDoc) {
|
|
231
|
-
return {
|
|
232
|
-
items: [],
|
|
233
|
-
filterLength: null,
|
|
234
|
-
firstDoc: null,
|
|
235
|
-
lastDoc: null,
|
|
236
|
-
hasNextPage: true,
|
|
237
|
-
hasPreviousPage: false,
|
|
238
|
-
currentClientPageIndex: undefined,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
let pageResults = [];
|
|
242
|
-
let allFetchedDocs = [];
|
|
243
|
-
let hasMoreDocsInDb = true;
|
|
244
|
-
let boundaryDoc = params.doc.firstDoc;
|
|
245
|
-
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
246
|
-
if (!boundaryDoc)
|
|
247
|
-
break;
|
|
248
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
249
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
250
|
-
query = query.endBefore(boundaryDoc);
|
|
251
|
-
query = query.limitToLast(BATCH_FETCH_SIZE);
|
|
252
|
-
const snapshot = yield query.get();
|
|
253
|
-
if (snapshot.empty) {
|
|
254
|
-
hasMoreDocsInDb = false;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
boundaryDoc = snapshot
|
|
258
|
-
.docs[0];
|
|
259
|
-
allFetchedDocs = [...snapshot.docs, ...allFetchedDocs];
|
|
260
|
-
const batchUsers = snapshot.docs
|
|
261
|
-
.map((doc) => {
|
|
262
|
-
const data = doc.data();
|
|
263
|
-
return Object.assign({ id: doc.id }, (data !== null && data !== void 0 ? data : {}));
|
|
264
|
-
})
|
|
265
|
-
.filter(params.filterFn);
|
|
266
|
-
pageResults = [...batchUsers, ...pageResults];
|
|
267
|
-
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
268
|
-
hasMoreDocsInDb = false;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const finalItems = pageResults.slice(0, params.batchSize);
|
|
272
|
-
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
273
|
-
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
274
|
-
return {
|
|
275
|
-
items: finalItems,
|
|
276
|
-
filterLength: null,
|
|
277
|
-
firstDoc: firstDocOfPage,
|
|
278
|
-
lastDoc: lastDocOfPage,
|
|
279
|
-
hasNextPage: true,
|
|
280
|
-
currentClientPageIndex: undefined,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
let items = [];
|
|
286
|
-
let docs = [];
|
|
287
|
-
let hasNextPage = false;
|
|
288
|
-
let filterLength = null;
|
|
289
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
290
|
-
if (params.conditions) {
|
|
291
|
-
params.conditions.forEach((c) => {
|
|
292
|
-
if (c.operator === '!=') {
|
|
293
|
-
query = query.orderBy(c.firestoreProperty);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
298
|
-
if (params.navigation === 'reload') {
|
|
299
|
-
query = query.limit(params.batchSize + 1);
|
|
300
|
-
if (params.doc && params.doc.firstDoc) {
|
|
301
|
-
query = query.startAt(params.doc.firstDoc);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else if (params.navigation === 'forward') {
|
|
305
|
-
query = query.limit(params.batchSize + 1);
|
|
306
|
-
if (params.doc && params.doc.lastDoc) {
|
|
307
|
-
query = query.startAfter(params.doc.lastDoc);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
// backward
|
|
312
|
-
query = query.limitToLast(params.batchSize + 1);
|
|
313
|
-
if (params.doc && params.doc.firstDoc) {
|
|
314
|
-
query = query.endBefore(params.doc.firstDoc);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const itemCol = yield query.get();
|
|
318
|
-
itemCol.docs.forEach((doc) => docs.push(doc));
|
|
319
|
-
const itemPromises = docs.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
320
|
-
const itemData = item.data();
|
|
321
|
-
items.push(Object.assign({ id: item.id }, (itemData !== null && itemData !== void 0 ? itemData : {})));
|
|
322
|
-
}));
|
|
323
|
-
let lastDoc = docs[docs.length - 1] || null;
|
|
324
|
-
let firstDoc = docs[0];
|
|
325
|
-
if ((items.length > params.batchSize && params.navigation === 'forward') ||
|
|
326
|
-
(params.navigation === 'reload' && items.length > params.batchSize)) {
|
|
327
|
-
lastDoc = docs[docs.length - 2] || null;
|
|
328
|
-
items.pop();
|
|
329
|
-
hasNextPage = true;
|
|
330
|
-
}
|
|
331
|
-
if (items.length > params.batchSize && params.navigation === 'backward') {
|
|
332
|
-
firstDoc = docs[1];
|
|
333
|
-
items.shift();
|
|
334
|
-
hasNextPage = true;
|
|
335
|
-
}
|
|
336
|
-
yield Promise.all(itemPromises);
|
|
337
|
-
return {
|
|
338
|
-
items,
|
|
339
|
-
filterLength,
|
|
340
|
-
lastDoc,
|
|
341
|
-
firstDoc,
|
|
342
|
-
hasNextPage,
|
|
343
|
-
currentClientPageIndex: undefined,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
// Fallback para garantir que sempre retornamos algo
|
|
347
|
-
return {
|
|
348
|
-
items: [],
|
|
349
|
-
filterLength: null,
|
|
350
|
-
firstDoc: null,
|
|
351
|
-
lastDoc: null,
|
|
352
|
-
hasNextPage: false,
|
|
353
|
-
currentClientPageIndex: undefined,
|
|
354
|
-
};
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
applyFilters(query, arrange, conditions) {
|
|
358
|
-
if (conditions) {
|
|
359
|
-
conditions.map((cond) => {
|
|
360
|
-
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
let hasFilterSpecificOrderBy = false;
|
|
364
|
-
let appliedOrderByField = null;
|
|
365
|
-
const equalsFilters = arrange.filters.filter((f) => f.arrange === 'equals' && !!f.filter);
|
|
366
|
-
const otherFilters = arrange.filters.filter((f) => f.arrange !== 'equals');
|
|
367
|
-
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
368
|
-
const prop = current.filter.property;
|
|
369
|
-
if (!acc[prop]) {
|
|
370
|
-
acc[prop] = [];
|
|
371
|
-
}
|
|
372
|
-
acc[prop].push(current.filter.filtering);
|
|
373
|
-
return acc;
|
|
374
|
-
}, {});
|
|
375
|
-
for (const prop in equalsGroupedByProperty) {
|
|
376
|
-
const values = equalsGroupedByProperty[prop];
|
|
377
|
-
if (values.length > 0) {
|
|
378
|
-
query = query.where(prop, 'in', values);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
otherFilters.forEach((filterItem) => {
|
|
382
|
-
var _a, _b;
|
|
383
|
-
// Aplicar filtragem por busca
|
|
384
|
-
if (((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
385
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property) !== '' &&
|
|
386
|
-
filterItem.arrange === 'filter') {
|
|
387
|
-
query = query
|
|
388
|
-
.where(filterItem.filter.property, '>=', filterItem.filter.filtering.trim().toUpperCase())
|
|
389
|
-
.where(filterItem.filter.property, '<=', filterItem.filter.filtering.trim().toUpperCase() + '\uf8ff');
|
|
390
|
-
if (!hasFilterSpecificOrderBy) {
|
|
391
|
-
query = query.orderBy(filterItem.filter.property);
|
|
392
|
-
hasFilterSpecificOrderBy = true;
|
|
393
|
-
appliedOrderByField = filterItem.filter.property;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
// Aplicar filtro do tipo "filterByDate"
|
|
397
|
-
if (filterItem.dateFilter && filterItem.arrange === 'filterByDate') {
|
|
398
|
-
query = query
|
|
399
|
-
.where(arrange.sortBy.field, '>=', filterItem.dateFilter.initial)
|
|
400
|
-
.where(arrange.sortBy.field, '<=', filterItem.dateFilter.final);
|
|
401
|
-
if (!hasFilterSpecificOrderBy) {
|
|
402
|
-
query = query.orderBy(arrange.sortBy.field);
|
|
403
|
-
hasFilterSpecificOrderBy = true;
|
|
404
|
-
appliedOrderByField = arrange.sortBy.field;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
// Aplicar sortBy
|
|
409
|
-
if (arrange.sortBy && arrange.sortBy.field && arrange.sortBy.order) {
|
|
410
|
-
if (appliedOrderByField !== arrange.sortBy.field) {
|
|
411
|
-
query = query.orderBy(arrange.sortBy.field, arrange.sortBy.order);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return query;
|
|
415
|
-
}
|
|
416
|
-
getIdFilter(params) {
|
|
417
|
-
var _a, _b, _c;
|
|
418
|
-
if (!((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters))
|
|
419
|
-
return null;
|
|
420
|
-
const idFilter = params.arrange.filters.find((f) => f.arrange === 'filter' &&
|
|
421
|
-
!!f.filter &&
|
|
422
|
-
f.filter.property === 'id' &&
|
|
423
|
-
!!f.filter.filtering);
|
|
424
|
-
return ((_c = (_b = idFilter === null || idFilter === void 0 ? void 0 : idFilter.filter) === null || _b === void 0 ? void 0 : _b.filtering) === null || _c === void 0 ? void 0 : _c.trim()) || null;
|
|
425
|
-
}
|
|
426
|
-
getDocumentById(collection, docId) {
|
|
427
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
428
|
-
try {
|
|
429
|
-
const docRef = this.ngFire.collection(collection).doc(docId);
|
|
430
|
-
const docSnapshot = yield docRef.get().toPromise();
|
|
431
|
-
if (docSnapshot && docSnapshot.exists) {
|
|
432
|
-
const data = docSnapshot.data();
|
|
433
|
-
return Object.assign({ id: docSnapshot.id }, (data !== null && data !== void 0 ? data : {}));
|
|
434
|
-
}
|
|
435
|
-
return null;
|
|
436
|
-
}
|
|
437
|
-
catch (error) {
|
|
438
|
-
console.warn('Erro ao buscar documento por ID:', error);
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
searchByIdPartial(params, searchTerm) {
|
|
444
|
-
var _a, _b, _c, _d;
|
|
445
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
-
const exactMatch = yield this.getDocumentById(params.collection, searchTerm);
|
|
447
|
-
if (exactMatch) {
|
|
448
|
-
if (params.conditions) {
|
|
449
|
-
const operators = this.operators;
|
|
450
|
-
const passesConditions = params.conditions.every((cond) => {
|
|
451
|
-
const operatorFn = operators[cond.operator];
|
|
452
|
-
return operatorFn
|
|
453
|
-
? operatorFn(exactMatch[cond.firestoreProperty], cond.dashProperty)
|
|
454
|
-
: false;
|
|
455
|
-
});
|
|
456
|
-
if (!passesConditions) {
|
|
457
|
-
return {
|
|
458
|
-
items: [],
|
|
459
|
-
filterLength: 0,
|
|
460
|
-
firstDoc: null,
|
|
461
|
-
lastDoc: null,
|
|
462
|
-
hasNextPage: false,
|
|
463
|
-
hasPreviousPage: false,
|
|
464
|
-
currentClientPageIndex: 0,
|
|
465
|
-
totalPages: 0,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
if (params.filterFn && !params.filterFn(exactMatch)) {
|
|
470
|
-
return {
|
|
471
|
-
items: [],
|
|
472
|
-
filterLength: 0,
|
|
473
|
-
firstDoc: null,
|
|
474
|
-
lastDoc: null,
|
|
475
|
-
hasNextPage: false,
|
|
476
|
-
hasPreviousPage: false,
|
|
477
|
-
currentClientPageIndex: 0,
|
|
478
|
-
totalPages: 0,
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
return {
|
|
482
|
-
items: [exactMatch],
|
|
483
|
-
filterLength: 1,
|
|
484
|
-
firstDoc: null,
|
|
485
|
-
lastDoc: null,
|
|
486
|
-
hasNextPage: false,
|
|
487
|
-
hasPreviousPage: false,
|
|
488
|
-
currentClientPageIndex: 0,
|
|
489
|
-
totalPages: 1,
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
const searchTermLower = searchTerm.toLowerCase();
|
|
493
|
-
const paramsWithoutIdFilter = Object.assign(Object.assign({}, params), { arrange: Object.assign(Object.assign({}, params.arrange), { filters: params.arrange.filters.filter((f) => { var _a; return !(f.arrange === 'filter' && ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) === 'id'); }) }) });
|
|
494
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
495
|
-
// Aplicar conditions
|
|
496
|
-
if (params.conditions) {
|
|
497
|
-
params.conditions.forEach((cond) => {
|
|
498
|
-
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
// Aplicar sortBy
|
|
502
|
-
if (((_b = (_a = params.arrange) === null || _a === void 0 ? void 0 : _a.sortBy) === null || _b === void 0 ? void 0 : _b.field) && ((_d = (_c = params.arrange) === null || _c === void 0 ? void 0 : _c.sortBy) === null || _d === void 0 ? void 0 : _d.order)) {
|
|
503
|
-
query = query.orderBy(params.arrange.sortBy.field, params.arrange.sortBy.order);
|
|
504
|
-
}
|
|
505
|
-
const snapshot = yield query.get();
|
|
506
|
-
let items = snapshot.docs
|
|
507
|
-
.map((doc) => {
|
|
508
|
-
const data = doc.data();
|
|
509
|
-
return Object.assign({ id: doc.id }, (data !== null && data !== void 0 ? data : {}));
|
|
510
|
-
})
|
|
511
|
-
.filter((item) => item.id.toLowerCase().includes(searchTermLower));
|
|
512
|
-
// Separar equals filters e outros filtros
|
|
513
|
-
const equalsFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => f.arrange === 'equals' && !!f.filter);
|
|
514
|
-
const otherFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => {
|
|
515
|
-
var _a;
|
|
516
|
-
return f.arrange !== 'equals' &&
|
|
517
|
-
(f.arrange !== 'filter' || ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) !== 'id');
|
|
518
|
-
});
|
|
519
|
-
// Aplicar equals filters com lógica OR dentro de cada propriedade
|
|
520
|
-
if (equalsFilters.length > 0) {
|
|
521
|
-
// Agrupar por propriedade para aplicar OR
|
|
522
|
-
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
523
|
-
const prop = f.filter.property;
|
|
524
|
-
if (!acc[prop]) {
|
|
525
|
-
acc[prop] = [];
|
|
526
|
-
}
|
|
527
|
-
acc[prop].push(f.filter.filtering);
|
|
528
|
-
return acc;
|
|
529
|
-
}, {});
|
|
530
|
-
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
531
|
-
items = items.filter((item) => {
|
|
532
|
-
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
533
|
-
const itemValue = item[prop];
|
|
534
|
-
return values.includes(itemValue);
|
|
535
|
-
});
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
// Aplicar outros filtros
|
|
539
|
-
otherFilters.forEach((filterItem) => {
|
|
540
|
-
var _a, _b;
|
|
541
|
-
if (filterItem.arrange === 'filter' &&
|
|
542
|
-
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
543
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
544
|
-
const filterValue = String(filterItem.filter.filtering)
|
|
545
|
-
.trim()
|
|
546
|
-
.toLowerCase();
|
|
547
|
-
items = items.filter((item) => {
|
|
548
|
-
var _a;
|
|
549
|
-
const itemValue = String((_a = item[filterItem.filter.property]) !== null && _a !== void 0 ? _a : '').toLowerCase();
|
|
550
|
-
return itemValue.includes(filterValue);
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
// Aplicar filterFn se existir
|
|
555
|
-
if (params.filterFn) {
|
|
556
|
-
items = items.filter(params.filterFn);
|
|
557
|
-
}
|
|
558
|
-
// Paginação
|
|
559
|
-
const pageSize = params.batchSize;
|
|
560
|
-
let currentClientPageIndex = 0;
|
|
561
|
-
if (params.navigation === 'reload') {
|
|
562
|
-
currentClientPageIndex = 0;
|
|
563
|
-
}
|
|
564
|
-
else {
|
|
565
|
-
// Usar o índice passado pelo componente sem incrementar/decrementar
|
|
566
|
-
currentClientPageIndex = params.clientPageIndex || 0;
|
|
567
|
-
}
|
|
568
|
-
const startIndex = currentClientPageIndex * pageSize;
|
|
569
|
-
const endIndex = startIndex + pageSize;
|
|
570
|
-
const paginatedItems = items.slice(startIndex, endIndex);
|
|
571
|
-
const totalPages = Math.ceil(items.length / pageSize);
|
|
572
|
-
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
573
|
-
const hasPreviousPage = currentClientPageIndex > 0;
|
|
574
|
-
return {
|
|
575
|
-
items: paginatedItems,
|
|
576
|
-
filterLength: items.length,
|
|
577
|
-
firstDoc: null,
|
|
578
|
-
lastDoc: null,
|
|
579
|
-
hasNextPage,
|
|
580
|
-
hasPreviousPage,
|
|
581
|
-
currentClientPageIndex,
|
|
582
|
-
totalPages,
|
|
583
|
-
};
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
shouldUseClientSideFallback(params) {
|
|
587
|
-
var _a, _b, _c;
|
|
588
|
-
const hasConditions = params.conditions && params.conditions.length > 0;
|
|
589
|
-
const hasArrangeFilters = ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters) && params.arrange.filters.length > 0;
|
|
590
|
-
const hasSortBy = (_c = (_b = params.arrange) === null || _b === void 0 ? void 0 : _b.sortBy) === null || _c === void 0 ? void 0 : _c.field;
|
|
591
|
-
if (params.filterFn) {
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
if (hasArrangeFilters) {
|
|
595
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && !!f.filter);
|
|
596
|
-
if (equalsFilters.length > 0) {
|
|
597
|
-
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
598
|
-
if (propertiesSet.size > 1) {
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
if (hasConditions && hasArrangeFilters && hasSortBy) {
|
|
604
|
-
return true;
|
|
605
|
-
}
|
|
606
|
-
if (hasConditions && hasArrangeFilters) {
|
|
607
|
-
return true;
|
|
608
|
-
}
|
|
609
|
-
if (hasArrangeFilters && params.arrange.filters.length > 1 && hasSortBy) {
|
|
610
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && !!f.filter);
|
|
611
|
-
if (equalsFilters.length > 0) {
|
|
612
|
-
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
613
|
-
if (propertiesSet.size === 1 &&
|
|
614
|
-
equalsFilters.length === params.arrange.filters.length) {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
return true;
|
|
619
|
-
}
|
|
620
|
-
return false;
|
|
621
|
-
}
|
|
622
|
-
getPaginated(params) {
|
|
623
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
624
|
-
const idFilterValue = this.getIdFilter(params);
|
|
625
|
-
if (idFilterValue) {
|
|
626
|
-
const result = yield this.searchByIdPartial(params, idFilterValue);
|
|
627
|
-
return result;
|
|
628
|
-
}
|
|
629
|
-
// Detectar preventivamente se deve usar fallback
|
|
630
|
-
if (this.shouldUseClientSideFallback(params)) {
|
|
631
|
-
yield this.trackMissingIndexPreventive(params.collection, params.arrange, params.conditions);
|
|
632
|
-
const result = yield this.executeClientSideQuery(params);
|
|
633
|
-
return result;
|
|
634
|
-
}
|
|
635
|
-
try {
|
|
636
|
-
const result = yield this.executeQuery(params);
|
|
637
|
-
return result;
|
|
638
|
-
}
|
|
639
|
-
catch (error) {
|
|
640
|
-
if (error &&
|
|
641
|
-
typeof error === 'object' &&
|
|
642
|
-
'code' in error &&
|
|
643
|
-
error.code === 'failed-precondition') {
|
|
644
|
-
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
645
|
-
const result = yield this.executeClientSideQuery(params);
|
|
646
|
-
return result;
|
|
647
|
-
}
|
|
648
|
-
else if (error &&
|
|
649
|
-
typeof error === 'object' &&
|
|
650
|
-
'code' in error &&
|
|
651
|
-
error.code === 'invalid-argument') {
|
|
652
|
-
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
653
|
-
const result = yield this.executeClientSideQuery(params);
|
|
654
|
-
return result;
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
throw error;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
executeClientSideQuery(params) {
|
|
663
|
-
var _a, _b, _c;
|
|
664
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
665
|
-
// Otimizar usando pelo menos uma cláusula .where() quando possível
|
|
666
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
667
|
-
let appliedCondition = null;
|
|
668
|
-
let hasAppliedWhereClause = false;
|
|
669
|
-
// Primeiro, tenta aplicar condições simples
|
|
670
|
-
if (params.conditions && params.conditions.length > 0) {
|
|
671
|
-
const simpleCondition = params.conditions.find((cond) => ['==', '>', '<', '>=', '<=', 'in', 'array-contains'].includes(cond.operator));
|
|
672
|
-
if (simpleCondition) {
|
|
673
|
-
query = query.where(simpleCondition.firestoreProperty, simpleCondition.operator, simpleCondition.dashProperty);
|
|
674
|
-
appliedCondition = simpleCondition;
|
|
675
|
-
hasAppliedWhereClause = true;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
// Se não há condições disponíveis, tenta aplicar filtros do arrange
|
|
679
|
-
let appliedFirestoreFilter = null;
|
|
680
|
-
if (!hasAppliedWhereClause && ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters)) {
|
|
681
|
-
// Agrupar equals filters por propriedade
|
|
682
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && !!f.filter);
|
|
683
|
-
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
684
|
-
const prop = current.filter.property;
|
|
685
|
-
if (!acc[prop]) {
|
|
686
|
-
acc[prop] = [];
|
|
687
|
-
}
|
|
688
|
-
acc[prop].push(current.filter.filtering);
|
|
689
|
-
return acc;
|
|
690
|
-
}, {});
|
|
691
|
-
// Se há apenas UMA propriedade com múltiplos valores, aplicar no Firestore com 'in'
|
|
692
|
-
const properties = Object.keys(equalsGroupedByProperty);
|
|
693
|
-
if (properties.length === 1 && equalsFilters.length > 0) {
|
|
694
|
-
const prop = properties[0];
|
|
695
|
-
const values = equalsGroupedByProperty[prop];
|
|
696
|
-
query = query.where(prop, 'in', values);
|
|
697
|
-
hasAppliedWhereClause = true;
|
|
698
|
-
// Marcar TODOS os equals filters dessa propriedade como aplicados
|
|
699
|
-
appliedFirestoreFilter = 'all-equals';
|
|
700
|
-
}
|
|
701
|
-
else if (properties.length === 0) {
|
|
702
|
-
const otherFilter = params.arrange.filters.find((f) => {
|
|
703
|
-
var _a, _b, _c, _d;
|
|
704
|
-
return (f.arrange === 'filter' &&
|
|
705
|
-
!!((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
706
|
-
!!((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
707
|
-
(f.arrange === 'filterByDate' &&
|
|
708
|
-
!!((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
709
|
-
!!((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
710
|
-
});
|
|
711
|
-
if (otherFilter) {
|
|
712
|
-
if (otherFilter.arrange === 'filter' && otherFilter.filter) {
|
|
713
|
-
const filterValue = otherFilter.filter.filtering
|
|
714
|
-
.trim()
|
|
715
|
-
.toUpperCase();
|
|
716
|
-
query = query
|
|
717
|
-
.where(otherFilter.filter.property, '>=', filterValue)
|
|
718
|
-
.where(otherFilter.filter.property, '<=', filterValue + '\uf8ff');
|
|
719
|
-
hasAppliedWhereClause = true;
|
|
720
|
-
appliedFirestoreFilter = otherFilter;
|
|
721
|
-
}
|
|
722
|
-
else if (otherFilter.arrange === 'filterByDate' &&
|
|
723
|
-
otherFilter.dateFilter &&
|
|
724
|
-
((_b = params.arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field)) {
|
|
725
|
-
query = query
|
|
726
|
-
.where(params.arrange.sortBy.field, '>=', otherFilter.dateFilter.initial)
|
|
727
|
-
.where(params.arrange.sortBy.field, '<=', otherFilter.dateFilter.final);
|
|
728
|
-
hasAppliedWhereClause = true;
|
|
729
|
-
appliedFirestoreFilter = otherFilter;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
const allDocsSnapshot = yield query.get();
|
|
735
|
-
let items = allDocsSnapshot.docs.map((doc) => {
|
|
736
|
-
const data = doc.data();
|
|
737
|
-
return Object.assign({ id: doc.id }, (data !== null && data !== void 0 ? data : {}));
|
|
738
|
-
});
|
|
739
|
-
// Aplicar condições restantes
|
|
740
|
-
if (params.conditions) {
|
|
741
|
-
const remainingConditions = params.conditions.filter((cond) => cond !== appliedCondition);
|
|
742
|
-
if (remainingConditions.length > 0) {
|
|
743
|
-
const operators = this.operators;
|
|
744
|
-
items = items.filter((item) => {
|
|
745
|
-
return remainingConditions.every((cond) => {
|
|
746
|
-
const operatorFn = operators[cond.operator];
|
|
747
|
-
return operatorFn
|
|
748
|
-
? operatorFn(item[cond.firestoreProperty], cond.dashProperty)
|
|
749
|
-
: false;
|
|
750
|
-
});
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
const { filters, sortBy } = params.arrange;
|
|
755
|
-
// Track which filter was already applied in Firestore to avoid double filtering
|
|
756
|
-
if (hasAppliedWhereClause && !appliedCondition && ((_c = params.arrange) === null || _c === void 0 ? void 0 : _c.filters)) {
|
|
757
|
-
const equalsFilter = params.arrange.filters.find((f) => { var _a; return f.arrange === 'equals' && !!((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering); });
|
|
758
|
-
if (equalsFilter) {
|
|
759
|
-
appliedFirestoreFilter = equalsFilter;
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
const foundFilter = params.arrange.filters.find((f) => {
|
|
763
|
-
var _a, _b, _c, _d;
|
|
764
|
-
return (f.arrange === 'filter' &&
|
|
765
|
-
!!((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
766
|
-
!!((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
767
|
-
(f.arrange === 'filterByDate' &&
|
|
768
|
-
!!((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
769
|
-
!!((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
770
|
-
});
|
|
771
|
-
if (foundFilter) {
|
|
772
|
-
appliedFirestoreFilter = foundFilter;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
const equalsFilters = filters.filter((f) => f.arrange === 'equals');
|
|
777
|
-
const otherFilters = filters.filter((f) => f.arrange !== 'equals');
|
|
778
|
-
// Aplicar equals filters no client-side apenas se não foram aplicados no Firestore
|
|
779
|
-
if (appliedFirestoreFilter !== 'all-equals' && equalsFilters.length > 0) {
|
|
780
|
-
// Agrupar por propriedade para aplicar OR dentro de cada propriedade
|
|
781
|
-
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
782
|
-
if (f.filter) {
|
|
783
|
-
const prop = f.filter.property;
|
|
784
|
-
if (!acc[prop]) {
|
|
785
|
-
acc[prop] = [];
|
|
786
|
-
}
|
|
787
|
-
acc[prop].push(f.filter.filtering);
|
|
788
|
-
}
|
|
789
|
-
return acc;
|
|
790
|
-
}, {});
|
|
791
|
-
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
792
|
-
// (AND entre propriedades, OR dentro de cada propriedade)
|
|
793
|
-
items = items.filter((item) => {
|
|
794
|
-
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
795
|
-
const itemValue = item[prop];
|
|
796
|
-
return values.includes(itemValue);
|
|
797
|
-
});
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
otherFilters.forEach((filterItem) => {
|
|
801
|
-
var _a, _b, _c, _d;
|
|
802
|
-
if (appliedFirestoreFilter === filterItem) {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
if (filterItem.arrange === 'filter' &&
|
|
806
|
-
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
807
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
808
|
-
const filterValue = String(filterItem.filter.filtering)
|
|
809
|
-
.trim()
|
|
810
|
-
.toLowerCase();
|
|
811
|
-
items = items.filter((item) => {
|
|
812
|
-
var _a;
|
|
813
|
-
const itemValue = String((_a = item[filterItem.filter.property]) !== null && _a !== void 0 ? _a : '').toLowerCase();
|
|
814
|
-
return itemValue.includes(filterValue);
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
if (filterItem.arrange === 'filterByDate' &&
|
|
818
|
-
((_c = filterItem.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
819
|
-
((_d = filterItem.dateFilter) === null || _d === void 0 ? void 0 : _d.final) &&
|
|
820
|
-
sortBy.field) {
|
|
821
|
-
items = items.filter((item) => {
|
|
822
|
-
try {
|
|
823
|
-
const fieldValue = item[sortBy.field];
|
|
824
|
-
if (!fieldValue) {
|
|
825
|
-
return false;
|
|
826
|
-
}
|
|
827
|
-
let itemDate;
|
|
828
|
-
const fieldValueObj = fieldValue;
|
|
829
|
-
if (fieldValueObj &&
|
|
830
|
-
typeof fieldValueObj === 'object' &&
|
|
831
|
-
'toDate' in fieldValueObj &&
|
|
832
|
-
typeof fieldValueObj.toDate === 'function') {
|
|
833
|
-
itemDate = fieldValueObj.toDate();
|
|
834
|
-
}
|
|
835
|
-
else if (fieldValueObj instanceof Date) {
|
|
836
|
-
itemDate = fieldValueObj;
|
|
837
|
-
}
|
|
838
|
-
else if (typeof fieldValueObj === 'string') {
|
|
839
|
-
itemDate = new Date(fieldValueObj);
|
|
840
|
-
if (isNaN(itemDate.getTime())) {
|
|
841
|
-
return false;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
else if (typeof fieldValueObj === 'number') {
|
|
845
|
-
itemDate = new Date(fieldValueObj);
|
|
846
|
-
}
|
|
847
|
-
else {
|
|
848
|
-
return false;
|
|
849
|
-
}
|
|
850
|
-
if (!filterItem.dateFilter) {
|
|
851
|
-
return false;
|
|
852
|
-
}
|
|
853
|
-
return (itemDate >= filterItem.dateFilter.initial &&
|
|
854
|
-
itemDate <= filterItem.dateFilter.final);
|
|
855
|
-
}
|
|
856
|
-
catch (error) {
|
|
857
|
-
console.warn('Erro ao processar filtro de data para o item:', item.id, error);
|
|
858
|
-
return false;
|
|
859
|
-
}
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
// Aplicar filterFn se existir
|
|
864
|
-
if (params.filterFn) {
|
|
865
|
-
items = items.filter(params.filterFn);
|
|
866
|
-
}
|
|
867
|
-
if (sortBy && sortBy.field && sortBy.order) {
|
|
868
|
-
items.sort((a, b) => {
|
|
869
|
-
const valA = a[sortBy.field];
|
|
870
|
-
const valB = b[sortBy.field];
|
|
871
|
-
if (valA === null || valA === undefined)
|
|
872
|
-
return 1;
|
|
873
|
-
if (valB === null || valB === undefined)
|
|
874
|
-
return -1;
|
|
875
|
-
if (valA < valB) {
|
|
876
|
-
return sortBy.order === 'asc' ? -1 : 1;
|
|
877
|
-
}
|
|
878
|
-
if (valA > valB) {
|
|
879
|
-
return sortBy.order === 'asc' ? 1 : -1;
|
|
880
|
-
}
|
|
881
|
-
return 0;
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
// Implementação adequada da paginação
|
|
885
|
-
let currentClientPageIndex = 0;
|
|
886
|
-
// Determinar a página atual baseada na navegação
|
|
887
|
-
if (params.navigation === 'reload') {
|
|
888
|
-
currentClientPageIndex = 0;
|
|
889
|
-
}
|
|
890
|
-
else {
|
|
891
|
-
currentClientPageIndex = params.clientPageIndex || 0;
|
|
892
|
-
}
|
|
893
|
-
const pageSize = params.batchSize;
|
|
894
|
-
const startIndex = currentClientPageIndex * pageSize;
|
|
895
|
-
const endIndex = startIndex + pageSize;
|
|
896
|
-
const paginatedItems = items.slice(startIndex, endIndex);
|
|
897
|
-
const totalPages = Math.ceil(items.length / pageSize);
|
|
898
|
-
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
899
|
-
const hasPreviousPage = currentClientPageIndex > 0;
|
|
900
|
-
return {
|
|
901
|
-
items: paginatedItems,
|
|
902
|
-
filterLength: items.length,
|
|
903
|
-
lastDoc: null,
|
|
904
|
-
firstDoc: null,
|
|
905
|
-
hasNextPage: hasNextPage,
|
|
906
|
-
hasPreviousPage: hasPreviousPage,
|
|
907
|
-
currentClientPageIndex: currentClientPageIndex,
|
|
908
|
-
totalPages: totalPages,
|
|
909
|
-
};
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
getItemsData(collection, arrange, conditions = undefined) {
|
|
913
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
914
|
-
try {
|
|
915
|
-
let query = this.ngFire.collection(collection).ref;
|
|
916
|
-
query = this.applyFilters(query, arrange, conditions);
|
|
917
|
-
const snapshot = yield query.get();
|
|
918
|
-
return yield Promise.all(snapshot.docs.map((doc) => __awaiter(this, void 0, void 0, function* () {
|
|
919
|
-
const data = doc.data();
|
|
920
|
-
const id = doc.id;
|
|
921
|
-
return Object.assign({ id }, (data !== null && data !== void 0 ? data : {}));
|
|
922
|
-
})));
|
|
923
|
-
}
|
|
924
|
-
catch (e) {
|
|
925
|
-
throw e;
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
deleteIndex(id, col) {
|
|
930
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
931
|
-
try {
|
|
932
|
-
const batch = this.ngFire.firestore.batch();
|
|
933
|
-
const docRef = this.ngFire.collection(col).doc(id);
|
|
934
|
-
const docSnapshot = (yield firstValueFrom(docRef.get()));
|
|
935
|
-
const doc = docSnapshot.data();
|
|
936
|
-
batch.delete(docRef.ref);
|
|
937
|
-
if (doc && typeof doc['index'] === 'number') {
|
|
938
|
-
yield this.reindex(doc['index'], col, batch);
|
|
939
|
-
}
|
|
940
|
-
yield batch.commit();
|
|
941
|
-
this.toastr.success('Item excluído com sucesso!');
|
|
942
|
-
return true;
|
|
943
|
-
}
|
|
944
|
-
catch (e) {
|
|
945
|
-
const error = e;
|
|
946
|
-
console.error('Erro ao deletar item:', error);
|
|
947
|
-
this.toastr.error('Erro ao deletar item.');
|
|
948
|
-
return false;
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
reindex(index, col, batch) {
|
|
953
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
954
|
-
try {
|
|
955
|
-
const snapshot = (yield firstValueFrom(this.ngFire.collection(col).get()));
|
|
956
|
-
const docs = snapshot.docs;
|
|
957
|
-
for (let doc of docs) {
|
|
958
|
-
const data = doc.data();
|
|
959
|
-
if (data &&
|
|
960
|
-
typeof data['index'] === 'number' &&
|
|
961
|
-
data['index'] > index) {
|
|
962
|
-
data['index'] = (data['index'] - 1);
|
|
963
|
-
const docRef = this.ngFire.collection(col).doc(doc.id).ref;
|
|
964
|
-
batch.update(docRef, data);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
catch (error) {
|
|
969
|
-
console.error('Erro ao reindexar:', error);
|
|
970
|
-
}
|
|
971
|
-
return;
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
dateFormatValidator() {
|
|
975
|
-
return (control) => {
|
|
976
|
-
if (!control.value) {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
const dateStr = control.value.trim();
|
|
980
|
-
const datePattern = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
981
|
-
if (!datePattern.test(dateStr)) {
|
|
982
|
-
return { invalidFormat: true };
|
|
983
|
-
}
|
|
984
|
-
const parts = dateStr.split('/');
|
|
985
|
-
const day = parts[0].padStart(2, '0');
|
|
986
|
-
const month = parts[1].padStart(2, '0');
|
|
987
|
-
const year = parts[2];
|
|
988
|
-
const normalizedDate = `${day}/${month}/${year}`;
|
|
989
|
-
const date = moment(normalizedDate, 'DD/MM/YYYY', true);
|
|
990
|
-
if (!date.isValid()) {
|
|
991
|
-
return { invalidDate: true };
|
|
992
|
-
}
|
|
993
|
-
return null;
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
updateIndex(index, id, col) {
|
|
997
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
998
|
-
yield this.ngFire.collection(col).doc(id).update({ index });
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Extrai o link de criação de índice da mensagem de erro do Firestore
|
|
1003
|
-
*/
|
|
1004
|
-
extractIndexLink(error) {
|
|
1005
|
-
if (!error ||
|
|
1006
|
-
typeof error !== 'object' ||
|
|
1007
|
-
!('message' in error) ||
|
|
1008
|
-
typeof error.message !== 'string')
|
|
1009
|
-
return null;
|
|
1010
|
-
const linkMatch = error.message.match(/(https:\/\/console\.firebase\.google\.com\/[^\s]+)/);
|
|
1011
|
-
return linkMatch ? linkMatch[1] : null;
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Rastreia índices ausentes ao usar fallback preventivo
|
|
1015
|
-
*/
|
|
1016
|
-
trackMissingIndexPreventive(collection, arrange, conditions = undefined) {
|
|
1017
|
-
var _a;
|
|
1018
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1019
|
-
try {
|
|
1020
|
-
const querySignature = this.generateQuerySignature(collection, arrange, conditions);
|
|
1021
|
-
const docId = `${collection}_${querySignature}`;
|
|
1022
|
-
const indexLink = this.generateIndexLink(collection, arrange, conditions);
|
|
1023
|
-
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
1024
|
-
const trackingData = {
|
|
1025
|
-
collection,
|
|
1026
|
-
indexLink,
|
|
1027
|
-
indexInstructions,
|
|
1028
|
-
arrange: {
|
|
1029
|
-
sortBy: arrange.sortBy,
|
|
1030
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
1031
|
-
var _a, _b;
|
|
1032
|
-
return ({
|
|
1033
|
-
arrange: f.arrange,
|
|
1034
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
1035
|
-
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
1036
|
-
});
|
|
1037
|
-
})) || [],
|
|
1038
|
-
},
|
|
1039
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
1040
|
-
property: c.firestoreProperty,
|
|
1041
|
-
operator: c.operator,
|
|
1042
|
-
}))) || [],
|
|
1043
|
-
errorMessage: `Fallback preventivo usado para a collection ${collection}. A query exigiria índice composto.`,
|
|
1044
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1045
|
-
};
|
|
1046
|
-
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
1047
|
-
const doc = yield docRef.get().toPromise();
|
|
1048
|
-
if (doc && doc.exists) {
|
|
1049
|
-
yield docRef.update({
|
|
1050
|
-
count: firebase.firestore.FieldValue.increment(1),
|
|
1051
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1052
|
-
lastError: trackingData['errorMessage'],
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
catch (trackingError) {
|
|
1060
|
-
console.warn('Falha ao rastrear fallback preventivo:', trackingError);
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* Gera uma assinatura única para uma query
|
|
1066
|
-
*/
|
|
1067
|
-
generateQuerySignature(collection, arrange, conditions = undefined) {
|
|
1068
|
-
var _a;
|
|
1069
|
-
const signature = {
|
|
1070
|
-
collection,
|
|
1071
|
-
sortBy: arrange.sortBy,
|
|
1072
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
1073
|
-
var _a;
|
|
1074
|
-
return ({
|
|
1075
|
-
arrange: f.arrange,
|
|
1076
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
1077
|
-
});
|
|
1078
|
-
})) || [],
|
|
1079
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
1080
|
-
property: c.firestoreProperty,
|
|
1081
|
-
operator: c.operator,
|
|
1082
|
-
}))) || [],
|
|
1083
|
-
};
|
|
1084
|
-
return btoa(JSON.stringify(signature))
|
|
1085
|
-
.replace(/[^a-zA-Z0-9]/g, '')
|
|
1086
|
-
.substring(0, 20);
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Gera instruções claras para criar o índice manualmente
|
|
1090
|
-
*/
|
|
1091
|
-
generateIndexInstructions(collection, arrange, conditions = undefined) {
|
|
1092
|
-
var _a;
|
|
1093
|
-
const instructions = {
|
|
1094
|
-
summary: '',
|
|
1095
|
-
collection: collection,
|
|
1096
|
-
fields: [],
|
|
1097
|
-
queryExample: '',
|
|
1098
|
-
stepByStep: [],
|
|
1099
|
-
notes: [],
|
|
1100
|
-
};
|
|
1101
|
-
const fields = [];
|
|
1102
|
-
if (conditions && conditions.length > 0) {
|
|
1103
|
-
conditions.forEach((condition) => {
|
|
1104
|
-
if (condition.firestoreProperty) {
|
|
1105
|
-
fields.push({
|
|
1106
|
-
field: condition.firestoreProperty,
|
|
1107
|
-
order: 'Ascending',
|
|
1108
|
-
type: 'WHERE clause',
|
|
1109
|
-
operator: condition.operator,
|
|
1110
|
-
description: `Filtrar por ${condition.firestoreProperty} usando operador ${condition.operator}`,
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
if (arrange.filters && arrange.filters.length > 0) {
|
|
1116
|
-
arrange.filters.forEach((filter) => {
|
|
1117
|
-
var _a;
|
|
1118
|
-
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1119
|
-
fields.push({
|
|
1120
|
-
field: filter.filter.property,
|
|
1121
|
-
order: 'Ascending',
|
|
1122
|
-
type: 'WHERE clause (filter)',
|
|
1123
|
-
operator: filter.arrange === 'filter' ? 'CONTAINS' : 'RANGE',
|
|
1124
|
-
description: `Filtrar por ${filter.filter.property} usando filtro ${filter.arrange}`,
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1130
|
-
fields.push({
|
|
1131
|
-
field: arrange.sortBy.field,
|
|
1132
|
-
order: arrange.sortBy.order === 'desc' ? 'Descending' : 'Ascending',
|
|
1133
|
-
type: 'ORDER BY clause',
|
|
1134
|
-
operator: 'N/A',
|
|
1135
|
-
description: `Ordenar resultados por ${arrange.sortBy.field} em ordem ${arrange.sortBy.order}`,
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
instructions.fields = fields;
|
|
1139
|
-
const fieldNames = fields.map((f) => f.field).join(' + ');
|
|
1140
|
-
instructions.summary = `Criar índice composto para ${collection}: ${fieldNames}`;
|
|
1141
|
-
let queryExample = `db.collection('${collection}')`;
|
|
1142
|
-
fields.forEach((field, index) => {
|
|
1143
|
-
if (field.type.includes('WHERE')) {
|
|
1144
|
-
if (field.operator === '==') {
|
|
1145
|
-
queryExample += `\n .where('${field.field}', '==', 'value')`;
|
|
1146
|
-
}
|
|
1147
|
-
else if (field.operator === 'CONTAINS') {
|
|
1148
|
-
queryExample += `\n .where('${field.field}', '>=', 'searchText')`;
|
|
1149
|
-
}
|
|
1150
|
-
else {
|
|
1151
|
-
queryExample += `\n .where('${field.field}', '${field.operator}', 'value')`;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
const orderByField = fields.find((f) => f.type.includes('ORDER BY'));
|
|
1156
|
-
if (orderByField) {
|
|
1157
|
-
queryExample += `\n .orderBy('${orderByField.field}', '${orderByField.order.toLowerCase()}')`;
|
|
1158
|
-
}
|
|
1159
|
-
instructions.queryExample = queryExample;
|
|
1160
|
-
instructions.stepByStep = [
|
|
1161
|
-
'1. Ir para Firebase Console → Firestore → Indexes',
|
|
1162
|
-
'2. Clicar em "Create Index"',
|
|
1163
|
-
`3. Definir Collection ID: ${collection}`,
|
|
1164
|
-
'4. Configurar campos nesta ORDEM EXATA:',
|
|
1165
|
-
...fields.map((field, index) => ` ${index + 1}. Campo: ${field.field}, Order: ${field.order}, Array: No`),
|
|
1166
|
-
'5. Definir Query scopes: Collection',
|
|
1167
|
-
'6. Clicar em "Create" e aguardar conclusão',
|
|
1168
|
-
];
|
|
1169
|
-
instructions.notes = [
|
|
1170
|
-
'⚠️ A ordem dos campos é CRÍTICA - deve corresponder exatamente à ordem da query',
|
|
1171
|
-
'⚠️ As cláusulas WHERE devem vir ANTES do campo ORDER BY',
|
|
1172
|
-
'⚠️ Este índice só funcionará para queries com esta combinação EXATA de campos',
|
|
1173
|
-
'⚠️ A criação do índice pode levar vários minutos',
|
|
1174
|
-
];
|
|
1175
|
-
return instructions;
|
|
1176
|
-
}
|
|
1177
|
-
/**
|
|
1178
|
-
* Gera um link de índice baseado na estrutura da query
|
|
1179
|
-
*/
|
|
1180
|
-
generateIndexLink(collection, arrange, conditions = undefined) {
|
|
1181
|
-
var _a, _b, _c, _d;
|
|
1182
|
-
try {
|
|
1183
|
-
const indexFields = [];
|
|
1184
|
-
if (conditions && conditions.length > 0) {
|
|
1185
|
-
conditions.forEach((condition) => {
|
|
1186
|
-
if (condition.firestoreProperty) {
|
|
1187
|
-
indexFields.push(condition.firestoreProperty);
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
if (arrange.filters && arrange.filters.length > 0) {
|
|
1192
|
-
arrange.filters.forEach((filter) => {
|
|
1193
|
-
var _a;
|
|
1194
|
-
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1195
|
-
indexFields.push(filter.filter.property);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1200
|
-
indexFields.push(arrange.sortBy.field);
|
|
1201
|
-
}
|
|
1202
|
-
if (indexFields.length > 1) {
|
|
1203
|
-
// Obter o projectId dinamicamente do Firebase
|
|
1204
|
-
const options = (_d = (_c = (_b = this.ngFire) === null || _b === void 0 ? void 0 : _b.firestore) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.options;
|
|
1205
|
-
const projectId = options === null || options === void 0 ? void 0 : options['projectId'];
|
|
1206
|
-
if (!projectId) {
|
|
1207
|
-
console.warn('Não foi possível obter o projectId do Firebase');
|
|
1208
|
-
return null;
|
|
1209
|
-
}
|
|
1210
|
-
const baseUrl = `https://console.firebase.google.com/project/${projectId}/firestore/indexes`;
|
|
1211
|
-
const queryParams = new URLSearchParams({
|
|
1212
|
-
create_composite: `collection=${collection}&fields=${indexFields.join(',')}`,
|
|
1213
|
-
});
|
|
1214
|
-
const finalLink = `${baseUrl}?${queryParams.toString()}`;
|
|
1215
|
-
return finalLink;
|
|
1216
|
-
}
|
|
1217
|
-
return null;
|
|
1218
|
-
}
|
|
1219
|
-
catch (error) {
|
|
1220
|
-
console.warn('Falha ao gerar link de índice:', error);
|
|
1221
|
-
return null;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
trackMissingIndex(error, collection, arrange, conditions = undefined) {
|
|
1225
|
-
var _a;
|
|
1226
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1227
|
-
try {
|
|
1228
|
-
const indexLink = this.extractIndexLink(error);
|
|
1229
|
-
if (!indexLink)
|
|
1230
|
-
return;
|
|
1231
|
-
const linkHash = btoa(indexLink)
|
|
1232
|
-
.replace(/[^a-zA-Z0-9]/g, '')
|
|
1233
|
-
.substring(0, 20);
|
|
1234
|
-
const docId = `${collection}_${linkHash}`;
|
|
1235
|
-
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
1236
|
-
const trackingData = {
|
|
1237
|
-
collection,
|
|
1238
|
-
indexLink,
|
|
1239
|
-
indexInstructions,
|
|
1240
|
-
arrange: {
|
|
1241
|
-
sortBy: arrange.sortBy,
|
|
1242
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
1243
|
-
var _a, _b;
|
|
1244
|
-
return ({
|
|
1245
|
-
arrange: f.arrange,
|
|
1246
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
1247
|
-
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
1248
|
-
});
|
|
1249
|
-
})) || [],
|
|
1250
|
-
},
|
|
1251
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
1252
|
-
property: c.firestoreProperty,
|
|
1253
|
-
operator: c.operator,
|
|
1254
|
-
}))) || [],
|
|
1255
|
-
errorMessage: error &&
|
|
1256
|
-
typeof error === 'object' &&
|
|
1257
|
-
'message' in error &&
|
|
1258
|
-
typeof error.message === 'string'
|
|
1259
|
-
? error.message
|
|
1260
|
-
: String(error),
|
|
1261
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1262
|
-
};
|
|
1263
|
-
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
1264
|
-
const doc = yield docRef.get().toPromise();
|
|
1265
|
-
const errorMessage = error &&
|
|
1266
|
-
typeof error === 'object' &&
|
|
1267
|
-
'message' in error &&
|
|
1268
|
-
typeof error.message === 'string'
|
|
1269
|
-
? error.message
|
|
1270
|
-
: String(error);
|
|
1271
|
-
if (doc && doc.exists) {
|
|
1272
|
-
yield docRef.update({
|
|
1273
|
-
count: firebase.firestore.FieldValue.increment(1),
|
|
1274
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1275
|
-
lastError: errorMessage,
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
else {
|
|
1279
|
-
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
catch (trackingError) {
|
|
1283
|
-
console.warn('Falha ao rastrear índice ausente:', trackingError);
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
TableService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, deps: [{ token: i1.AngularFirestore, optional: true }, { token: i2.MatDialog, optional: true }, { token: i3.ToastrService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1289
|
-
TableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService });
|
|
1290
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, decorators: [{
|
|
1291
|
-
type: Injectable
|
|
1292
|
-
}], ctorParameters: function () {
|
|
1293
|
-
return [{ type: i1.AngularFirestore, decorators: [{
|
|
1294
|
-
type: Optional
|
|
1295
|
-
}] }, { type: i2.MatDialog, decorators: [{
|
|
1296
|
-
type: Optional
|
|
1297
|
-
}] }, { type: i3.ToastrService, decorators: [{
|
|
1298
|
-
type: Optional
|
|
1299
|
-
}] }];
|
|
1300
|
-
} });
|
|
1301
|
-
|
|
1302
|
-
class FilterService {
|
|
1303
|
-
constructor(tableService) {
|
|
1304
|
-
this.tableService = tableService;
|
|
1305
|
-
}
|
|
1306
|
-
/**
|
|
1307
|
-
* Cria um novo FormGroup para um filtro
|
|
1308
|
-
*/
|
|
1309
|
-
createFilterGroup() {
|
|
1310
|
-
const dateValidator = this.tableService.dateFormatValidator();
|
|
1311
|
-
return new FormGroup({
|
|
1312
|
-
selectFilter: new FormControl(''),
|
|
1313
|
-
typeFilter: new FormControl(''),
|
|
1314
|
-
selectItem: new FormControl(''),
|
|
1315
|
-
initialDate: new FormControl('', [dateValidator]),
|
|
1316
|
-
finalDate: new FormControl('', [dateValidator]),
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* Adiciona um novo filtro ao FormArray
|
|
1321
|
-
*/
|
|
1322
|
-
addFilter(filtersForm, isPaginated, filterData) {
|
|
1323
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1324
|
-
if (isPaginated &&
|
|
1325
|
-
this.hasActiveDateFilter(filtersForm) &&
|
|
1326
|
-
((_a = filterData === null || filterData === void 0 ? void 0 : filterData.selectFilter) === null || _a === void 0 ? void 0 : _a.arrange) === 'filterByDate') {
|
|
1327
|
-
return;
|
|
1328
|
-
}
|
|
1329
|
-
const newFilterGroup = this.createFilterGroup();
|
|
1330
|
-
if (filterData) {
|
|
1331
|
-
if (filterData.selectFilter) {
|
|
1332
|
-
(_b = newFilterGroup.get('selectFilter')) === null || _b === void 0 ? void 0 : _b.setValue(filterData.selectFilter);
|
|
1333
|
-
}
|
|
1334
|
-
if (filterData.typeFilter) {
|
|
1335
|
-
(_c = newFilterGroup.get('typeFilter')) === null || _c === void 0 ? void 0 : _c.setValue(filterData.typeFilter);
|
|
1336
|
-
}
|
|
1337
|
-
if (filterData.selectItem) {
|
|
1338
|
-
(_d = newFilterGroup.get('selectItem')) === null || _d === void 0 ? void 0 : _d.setValue(filterData.selectItem);
|
|
1339
|
-
}
|
|
1340
|
-
if (filterData.initialDate) {
|
|
1341
|
-
(_e = newFilterGroup.get('initialDate')) === null || _e === void 0 ? void 0 : _e.setValue(filterData.initialDate);
|
|
1342
|
-
}
|
|
1343
|
-
if (filterData.finalDate) {
|
|
1344
|
-
(_f = newFilterGroup.get('finalDate')) === null || _f === void 0 ? void 0 : _f.setValue(filterData.finalDate);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
filtersForm.push(newFilterGroup);
|
|
1348
|
-
}
|
|
1349
|
-
/**
|
|
1350
|
-
* Verifica se há um filtro de data ativo
|
|
1351
|
-
*/
|
|
1352
|
-
hasActiveDateFilter(filtersForm) {
|
|
1353
|
-
return filtersForm.controls.some((control) => {
|
|
1354
|
-
var _a;
|
|
1355
|
-
const group = control;
|
|
1356
|
-
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1357
|
-
return (selectedFilter === null || selectedFilter === void 0 ? void 0 : selectedFilter.arrange) === 'filterByDate';
|
|
1358
|
-
});
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Retorna as opções de filtro disponíveis
|
|
1362
|
-
*/
|
|
1363
|
-
getAvailableFilterOptions(dropdownItems, isPaginated, filtersForm) {
|
|
1364
|
-
if (isPaginated && this.hasActiveDateFilter(filtersForm)) {
|
|
1365
|
-
return dropdownItems.filter((item) => item.arrange !== 'filterByDate');
|
|
1366
|
-
}
|
|
1367
|
-
return dropdownItems;
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Remove um filtro do FormArray
|
|
1371
|
-
*/
|
|
1372
|
-
removeFilter(filtersForm, index) {
|
|
1373
|
-
filtersForm.removeAt(index);
|
|
1374
|
-
if (filtersForm.length === 0) {
|
|
1375
|
-
this.addFilter(filtersForm, false);
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Remove todos os filtros do FormArray
|
|
1380
|
-
*/
|
|
1381
|
-
removeAllFilters(filtersForm) {
|
|
1382
|
-
filtersForm.clear();
|
|
1383
|
-
this.addFilter(filtersForm, false);
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Aplica máscara de data (DD/MM/AAAA)
|
|
1387
|
-
*/
|
|
1388
|
-
applyDateMask(event, controlName, filterGroup) {
|
|
1389
|
-
var _a;
|
|
1390
|
-
const input = event.target;
|
|
1391
|
-
let value = input.value.replace(/\D/g, '');
|
|
1392
|
-
if (value.length > 8) {
|
|
1393
|
-
value = value.slice(0, 8);
|
|
1394
|
-
}
|
|
1395
|
-
if (value.length <= 2) {
|
|
1396
|
-
// mantém como está
|
|
1397
|
-
}
|
|
1398
|
-
else if (value.length <= 4) {
|
|
1399
|
-
value = value.slice(0, 2) + '/' + value.slice(2);
|
|
1400
|
-
}
|
|
1401
|
-
else {
|
|
1402
|
-
value =
|
|
1403
|
-
value.slice(0, 2) + '/' + value.slice(2, 4) + '/' + value.slice(4, 8);
|
|
1404
|
-
}
|
|
1405
|
-
(_a = filterGroup.get(controlName)) === null || _a === void 0 ? void 0 : _a.setValue(value, { emitEvent: false });
|
|
1406
|
-
}
|
|
1407
|
-
/**
|
|
1408
|
-
* Aplica filtros client-side aos itens
|
|
1409
|
-
*/
|
|
1410
|
-
applyClientSideFilters(items, filtersForm, sortBy) {
|
|
1411
|
-
let filteredItems = [...items];
|
|
1412
|
-
const dateFiltersByProperty = {};
|
|
1413
|
-
const otherFilters = [];
|
|
1414
|
-
filtersForm.controls.forEach((control) => {
|
|
1415
|
-
var _a, _b, _c;
|
|
1416
|
-
const group = control;
|
|
1417
|
-
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1418
|
-
if (!selectedFilter)
|
|
1419
|
-
return;
|
|
1420
|
-
const arrange = selectedFilter.arrange;
|
|
1421
|
-
if (arrange === 'filterByDate') {
|
|
1422
|
-
const initial = (_b = group.get('initialDate')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1423
|
-
const final = (_c = group.get('finalDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1424
|
-
if (initial && final && initial.trim() && final.trim()) {
|
|
1425
|
-
try {
|
|
1426
|
-
const datePattern = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
1427
|
-
if (!datePattern.test(initial) || !datePattern.test(final)) {
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
const [dayI, monthI, yearI] = initial.split('/');
|
|
1431
|
-
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1432
|
-
const [dayF, monthF, yearF] = final.split('/');
|
|
1433
|
-
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1434
|
-
finalDate.setHours(23, 59, 59);
|
|
1435
|
-
if (isNaN(initialDate.getTime()) || isNaN(finalDate.getTime())) {
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
const dateField = selectedFilter.property || sortBy.field;
|
|
1439
|
-
if (!dateFiltersByProperty[dateField]) {
|
|
1440
|
-
dateFiltersByProperty[dateField] = [];
|
|
1441
|
-
}
|
|
1442
|
-
dateFiltersByProperty[dateField].push({
|
|
1443
|
-
initial: initialDate,
|
|
1444
|
-
final: finalDate,
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
catch (error) {
|
|
1448
|
-
console.warn('Erro ao processar datas do filtro:', error);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
else {
|
|
1453
|
-
otherFilters.push({ group, selectedFilter, arrange });
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
// Aplicar filtros de data
|
|
1457
|
-
Object.keys(dateFiltersByProperty).forEach((dateField) => {
|
|
1458
|
-
const intervals = dateFiltersByProperty[dateField];
|
|
1459
|
-
filteredItems = filteredItems.filter((item) => {
|
|
1460
|
-
try {
|
|
1461
|
-
const fieldValue = item[dateField];
|
|
1462
|
-
if (!fieldValue) {
|
|
1463
|
-
return false;
|
|
1464
|
-
}
|
|
1465
|
-
let itemDate;
|
|
1466
|
-
if (typeof fieldValue.toDate === 'function') {
|
|
1467
|
-
itemDate = fieldValue.toDate();
|
|
1468
|
-
}
|
|
1469
|
-
else if (fieldValue instanceof Date) {
|
|
1470
|
-
itemDate = fieldValue;
|
|
1471
|
-
}
|
|
1472
|
-
else if (typeof fieldValue === 'string') {
|
|
1473
|
-
itemDate = new Date(fieldValue);
|
|
1474
|
-
if (isNaN(itemDate.getTime())) {
|
|
1475
|
-
return false;
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
else if (typeof fieldValue === 'number') {
|
|
1479
|
-
itemDate = new Date(fieldValue);
|
|
1480
|
-
}
|
|
1481
|
-
else {
|
|
1482
|
-
return false;
|
|
1483
|
-
}
|
|
1484
|
-
return intervals.some((interval) => itemDate >= interval.initial && itemDate <= interval.final);
|
|
1485
|
-
}
|
|
1486
|
-
catch (error) {
|
|
1487
|
-
console.warn('Erro ao processar filtro de data para o item:', item.id, error);
|
|
1488
|
-
return false;
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
});
|
|
1492
|
-
// Aplicar outros filtros
|
|
1493
|
-
otherFilters.forEach(({ group, selectedFilter, arrange }) => {
|
|
1494
|
-
var _a, _b;
|
|
1495
|
-
if (arrange === 'filter') {
|
|
1496
|
-
const filterValue = (_a = group.get('typeFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1497
|
-
if (filterValue && filterValue.trim()) {
|
|
1498
|
-
const property = selectedFilter.property;
|
|
1499
|
-
filteredItems = filteredItems.filter((item) => {
|
|
1500
|
-
const value = String(item[property] || '')
|
|
1501
|
-
.trim()
|
|
1502
|
-
.toLocaleLowerCase();
|
|
1503
|
-
return value.includes(filterValue.trim().toLocaleLowerCase());
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
else if (selectedFilter.hasOwnProperty('items') &&
|
|
1508
|
-
arrange === 'equals') {
|
|
1509
|
-
const selectedItems = (_b = group.get('selectItem')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1510
|
-
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1511
|
-
filteredItems = filteredItems.filter((item) => {
|
|
1512
|
-
return selectedItems.some((selectedItem) => {
|
|
1513
|
-
const itemValue = item[selectedItem.property];
|
|
1514
|
-
return itemValue === selectedItem.value;
|
|
1515
|
-
});
|
|
1516
|
-
});
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
});
|
|
1520
|
-
return filteredItems;
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Constrói o objeto Arrange a partir dos filtros ativos
|
|
1524
|
-
*/
|
|
1525
|
-
buildArrangeFromFilters(filtersForm, sortBy) {
|
|
1526
|
-
const activeFilters = filtersForm.controls
|
|
1527
|
-
.flatMap((control) => {
|
|
1528
|
-
var _a, _b, _c, _d, _e;
|
|
1529
|
-
const group = control;
|
|
1530
|
-
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1531
|
-
if (!selectedFilter)
|
|
1532
|
-
return [];
|
|
1533
|
-
const arrange = selectedFilter.arrange;
|
|
1534
|
-
if (arrange === 'filter') {
|
|
1535
|
-
const filterValue = (_b = group.get('typeFilter')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1536
|
-
if (!filterValue)
|
|
1537
|
-
return [];
|
|
1538
|
-
return {
|
|
1539
|
-
arrange,
|
|
1540
|
-
filter: {
|
|
1541
|
-
property: selectedFilter.property,
|
|
1542
|
-
filtering: filterValue,
|
|
1543
|
-
},
|
|
1544
|
-
dateFilter: undefined,
|
|
1545
|
-
};
|
|
1546
|
-
}
|
|
1547
|
-
if (arrange === 'filterByDate') {
|
|
1548
|
-
const initial = (_c = group.get('initialDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1549
|
-
const final = (_d = group.get('finalDate')) === null || _d === void 0 ? void 0 : _d.value;
|
|
1550
|
-
if (initial && final) {
|
|
1551
|
-
try {
|
|
1552
|
-
const [dayI, monthI, yearI] = initial.split('/');
|
|
1553
|
-
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1554
|
-
const [dayF, monthF, yearF] = final.split('/');
|
|
1555
|
-
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1556
|
-
finalDate.setHours(23, 59, 59);
|
|
1557
|
-
return {
|
|
1558
|
-
arrange,
|
|
1559
|
-
filter: undefined,
|
|
1560
|
-
dateFilter: {
|
|
1561
|
-
initial: initialDate,
|
|
1562
|
-
final: finalDate,
|
|
1563
|
-
},
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
catch (error) {
|
|
1567
|
-
return [];
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
return [];
|
|
1571
|
-
}
|
|
1572
|
-
if (selectedFilter.hasOwnProperty('items') && arrange === 'equals') {
|
|
1573
|
-
const selectedItems = (_e = group.get('selectItem')) === null || _e === void 0 ? void 0 : _e.value;
|
|
1574
|
-
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1575
|
-
return selectedItems.map((item) => ({
|
|
1576
|
-
arrange,
|
|
1577
|
-
filter: {
|
|
1578
|
-
property: item.property,
|
|
1579
|
-
filtering: item.value,
|
|
1580
|
-
},
|
|
1581
|
-
dateFilter: undefined,
|
|
1582
|
-
}));
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
return [];
|
|
1586
|
-
})
|
|
1587
|
-
.filter((f) => { var _a; return f && (((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) !== undefined || f.dateFilter); });
|
|
1588
|
-
return {
|
|
1589
|
-
filters: activeFilters,
|
|
1590
|
-
sortBy: sortBy,
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
/**
|
|
1594
|
-
* Extrai filtros ativos para paginação
|
|
1595
|
-
*/
|
|
1596
|
-
extractActiveFilters(filtersForm) {
|
|
1597
|
-
return filtersForm.controls
|
|
1598
|
-
.flatMap((control) => {
|
|
1599
|
-
var _a, _b, _c, _d, _e;
|
|
1600
|
-
const group = control;
|
|
1601
|
-
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1602
|
-
if (!selectedFilter)
|
|
1603
|
-
return [];
|
|
1604
|
-
const arrange = selectedFilter.arrange;
|
|
1605
|
-
if (arrange === 'filter') {
|
|
1606
|
-
const filterValue = (_b = group.get('typeFilter')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1607
|
-
if (!filterValue)
|
|
1608
|
-
return [];
|
|
1609
|
-
return {
|
|
1610
|
-
arrange,
|
|
1611
|
-
filter: {
|
|
1612
|
-
property: selectedFilter.property,
|
|
1613
|
-
filtering: filterValue,
|
|
1614
|
-
},
|
|
1615
|
-
dateFilter: undefined,
|
|
1616
|
-
};
|
|
1617
|
-
}
|
|
1618
|
-
if (arrange === 'filterByDate') {
|
|
1619
|
-
const initial = (_c = group.get('initialDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1620
|
-
const final = (_d = group.get('finalDate')) === null || _d === void 0 ? void 0 : _d.value;
|
|
1621
|
-
if (initial && final) {
|
|
1622
|
-
const [dayI, monthI, yearI] = initial.split('/');
|
|
1623
|
-
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1624
|
-
const [dayF, monthF, yearF] = final.split('/');
|
|
1625
|
-
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1626
|
-
finalDate.setHours(23, 59, 59);
|
|
1627
|
-
return {
|
|
1628
|
-
arrange,
|
|
1629
|
-
filter: undefined,
|
|
1630
|
-
dateFilter: {
|
|
1631
|
-
initial: initialDate,
|
|
1632
|
-
final: finalDate,
|
|
1633
|
-
},
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
return [];
|
|
1637
|
-
}
|
|
1638
|
-
if (selectedFilter.hasOwnProperty('items') && arrange === 'equals') {
|
|
1639
|
-
const selectedItems = (_e = group.get('selectItem')) === null || _e === void 0 ? void 0 : _e.value;
|
|
1640
|
-
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1641
|
-
return selectedItems.map((item) => ({
|
|
1642
|
-
arrange,
|
|
1643
|
-
filter: {
|
|
1644
|
-
property: item.property,
|
|
1645
|
-
filtering: item.value,
|
|
1646
|
-
},
|
|
1647
|
-
dateFilter: undefined,
|
|
1648
|
-
}));
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
return [];
|
|
1652
|
-
})
|
|
1653
|
-
.filter((f) => { var _a; return f && (((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) !== undefined || f.dateFilter); });
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Inicializa os dropdownItems baseado nas colunas
|
|
1657
|
-
*/
|
|
1658
|
-
initializeDropdownItems(displayedColumns) {
|
|
1659
|
-
const dropdownItems = [];
|
|
1660
|
-
const sortableDropdownItems = [];
|
|
1661
|
-
let hasFilterableColumn = false;
|
|
1662
|
-
let hasSortableColumn = false;
|
|
1663
|
-
displayedColumns.forEach((col) => {
|
|
1664
|
-
if (col.isFilterable) {
|
|
1665
|
-
hasFilterableColumn = true;
|
|
1666
|
-
dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filter', title: col.title }));
|
|
1667
|
-
}
|
|
1668
|
-
if (col.isSortable) {
|
|
1669
|
-
hasSortableColumn = true;
|
|
1670
|
-
sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'ascending', title: col.title + ': crescente' }));
|
|
1671
|
-
sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'descending', title: col.title + ': decrescente' }));
|
|
1672
|
-
}
|
|
1673
|
-
if (col.isFilterableByDate) {
|
|
1674
|
-
dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filterByDate', title: col.title + ': filtro por data' }));
|
|
1675
|
-
}
|
|
1676
|
-
});
|
|
1677
|
-
return {
|
|
1678
|
-
dropdownItems,
|
|
1679
|
-
sortableDropdownItems,
|
|
1680
|
-
hasFilterableColumn,
|
|
1681
|
-
hasSortableColumn,
|
|
1682
|
-
};
|
|
1683
|
-
}
|
|
1684
|
-
/**
|
|
1685
|
-
* Adiciona opções de filtro customizadas
|
|
1686
|
-
*/
|
|
1687
|
-
addFilterableOptions(dropdownItems, filterableOptions) {
|
|
1688
|
-
if (filterableOptions &&
|
|
1689
|
-
Array.isArray(filterableOptions) &&
|
|
1690
|
-
filterableOptions.length > 0) {
|
|
1691
|
-
filterableOptions.forEach((option) => dropdownItems.push(Object.assign(Object.assign({}, option), { arrange: 'equals' })));
|
|
1692
|
-
}
|
|
1693
|
-
return dropdownItems;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
FilterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FilterService, deps: [{ token: TableService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1697
|
-
FilterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FilterService, providedIn: 'root' });
|
|
1698
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FilterService, decorators: [{
|
|
1699
|
-
type: Injectable,
|
|
1700
|
-
args: [{
|
|
1701
|
-
providedIn: 'root',
|
|
1702
|
-
}]
|
|
1703
|
-
}], ctorParameters: function () { return [{ type: TableService }]; } });
|
|
1704
|
-
|
|
1705
|
-
class TooltipService {
|
|
1706
|
-
constructor() {
|
|
1707
|
-
this.tooltipTimeout = null;
|
|
1708
|
-
}
|
|
1709
|
-
/**
|
|
1710
|
-
* Cria um estado inicial para o tooltip
|
|
1711
|
-
*/
|
|
1712
|
-
createInitialState() {
|
|
1713
|
-
return {
|
|
1714
|
-
hoveredCell: null,
|
|
1715
|
-
showTooltip: false,
|
|
1716
|
-
tooltipContent: '',
|
|
1717
|
-
tooltipPosition: { x: 0, y: 0 },
|
|
1718
|
-
tooltipBgColor: 'bg-gray-800',
|
|
1719
|
-
tooltipBgStyle: null,
|
|
1720
|
-
tooltipTextColor: 'text-white',
|
|
1721
|
-
tooltipTextStyle: null,
|
|
1722
|
-
};
|
|
1723
|
-
}
|
|
1724
|
-
/**
|
|
1725
|
-
* Processa as cores do tooltip
|
|
1726
|
-
*/
|
|
1727
|
-
processTooltipColors(config) {
|
|
1728
|
-
const result = {
|
|
1729
|
-
bgColor: 'bg-gray-800',
|
|
1730
|
-
bgStyle: null,
|
|
1731
|
-
textColor: 'text-white',
|
|
1732
|
-
textStyle: null,
|
|
1733
|
-
};
|
|
1734
|
-
const tooltipBgColor = (config === null || config === void 0 ? void 0 : config.color) || 'bg-gray-800';
|
|
1735
|
-
if (tooltipBgColor.startsWith('#') || tooltipBgColor.startsWith('rgb')) {
|
|
1736
|
-
result.bgColor = '';
|
|
1737
|
-
result.bgStyle = { 'background-color': tooltipBgColor };
|
|
1738
|
-
}
|
|
1739
|
-
else {
|
|
1740
|
-
result.bgColor = tooltipBgColor;
|
|
1741
|
-
result.bgStyle = null;
|
|
1742
|
-
}
|
|
1743
|
-
const tooltipTextColor = (config === null || config === void 0 ? void 0 : config.text) || 'text-white';
|
|
1744
|
-
if (tooltipTextColor.startsWith('#') ||
|
|
1745
|
-
tooltipTextColor.startsWith('rgb')) {
|
|
1746
|
-
result.textColor = '';
|
|
1747
|
-
result.textStyle = { color: tooltipTextColor };
|
|
1748
|
-
}
|
|
1749
|
-
else {
|
|
1750
|
-
result.textColor = tooltipTextColor;
|
|
1751
|
-
result.textStyle = null;
|
|
1752
|
-
}
|
|
1753
|
-
return result;
|
|
1754
|
-
}
|
|
1755
|
-
/**
|
|
1756
|
-
* Manipula o evento de mouse enter na célula
|
|
1757
|
-
*/
|
|
1758
|
-
handleMouseEnter(event, row, col, getDisplayValue, onShow) {
|
|
1759
|
-
// Só mostrar tooltip se a coluna tiver charLimit definido
|
|
1760
|
-
if (!col.charLimit) {
|
|
1761
|
-
return;
|
|
1762
|
-
}
|
|
1763
|
-
const fullValue = getDisplayValue(col, row, true);
|
|
1764
|
-
// Só mostrar tooltip se o valor completo for maior que o limite
|
|
1765
|
-
if (fullValue.length <= col.charLimit) {
|
|
1766
|
-
return;
|
|
1767
|
-
}
|
|
1768
|
-
const colors = this.processTooltipColors(col.tooltip);
|
|
1769
|
-
const state = {
|
|
1770
|
-
hoveredCell: { row, col },
|
|
1771
|
-
tooltipContent: fullValue,
|
|
1772
|
-
tooltipBgColor: colors.bgColor,
|
|
1773
|
-
tooltipBgStyle: colors.bgStyle,
|
|
1774
|
-
tooltipTextColor: colors.textColor,
|
|
1775
|
-
tooltipTextStyle: colors.textStyle,
|
|
1776
|
-
tooltipPosition: {
|
|
1777
|
-
x: event.clientX + 10,
|
|
1778
|
-
y: event.clientY - 10,
|
|
1779
|
-
},
|
|
1780
|
-
};
|
|
1781
|
-
onShow(state);
|
|
1782
|
-
// Limpar timeout anterior se existir
|
|
1783
|
-
if (this.tooltipTimeout) {
|
|
1784
|
-
clearTimeout(this.tooltipTimeout);
|
|
1785
|
-
}
|
|
1786
|
-
// Timeout para mostrar o tooltip
|
|
1787
|
-
this.tooltipTimeout = setTimeout(() => {
|
|
1788
|
-
onShow({ showTooltip: true });
|
|
1789
|
-
}, 500);
|
|
1790
|
-
}
|
|
1791
|
-
/**
|
|
1792
|
-
* Manipula o evento de mouse leave na célula
|
|
1793
|
-
*/
|
|
1794
|
-
handleMouseLeave(onHide) {
|
|
1795
|
-
if (this.tooltipTimeout) {
|
|
1796
|
-
clearTimeout(this.tooltipTimeout);
|
|
1797
|
-
this.tooltipTimeout = null;
|
|
1798
|
-
}
|
|
1799
|
-
onHide(this.createInitialState());
|
|
1800
|
-
}
|
|
1801
|
-
/**
|
|
1802
|
-
* Manipula o movimento do mouse
|
|
1803
|
-
*/
|
|
1804
|
-
handleMouseMove(event, showTooltip, onMove) {
|
|
1805
|
-
if (showTooltip) {
|
|
1806
|
-
onMove({
|
|
1807
|
-
x: event.clientX + 10,
|
|
1808
|
-
y: event.clientY - 10,
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* Combina estilos do tooltip para aplicação
|
|
1814
|
-
*/
|
|
1815
|
-
getTooltipStyles(state) {
|
|
1816
|
-
const styles = {};
|
|
1817
|
-
if (state.tooltipBgStyle) {
|
|
1818
|
-
Object.assign(styles, state.tooltipBgStyle);
|
|
1819
|
-
}
|
|
1820
|
-
if (state.tooltipTextStyle) {
|
|
1821
|
-
Object.assign(styles, state.tooltipTextStyle);
|
|
1822
|
-
}
|
|
1823
|
-
return styles;
|
|
1824
|
-
}
|
|
1825
|
-
/**
|
|
1826
|
-
* Limpa recursos ao destruir
|
|
1827
|
-
*/
|
|
1828
|
-
destroy() {
|
|
1829
|
-
if (this.tooltipTimeout) {
|
|
1830
|
-
clearTimeout(this.tooltipTimeout);
|
|
1831
|
-
this.tooltipTimeout = null;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
TooltipService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1836
|
-
TooltipService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipService, providedIn: 'root' });
|
|
1837
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipService, decorators: [{
|
|
1838
|
-
type: Injectable,
|
|
1839
|
-
args: [{
|
|
1840
|
-
providedIn: 'root',
|
|
1841
|
-
}]
|
|
1842
|
-
}] });
|
|
1843
|
-
|
|
1844
|
-
class PaginationService {
|
|
1845
|
-
calculateNavigation(event, currentState) {
|
|
1846
|
-
var _a;
|
|
1847
|
-
const previousPageIndex = (_a = event.previousPageIndex) !== null && _a !== void 0 ? _a : 0;
|
|
1848
|
-
const pageIndex = event.pageIndex;
|
|
1849
|
-
const eventPageSize = event.pageSize;
|
|
1850
|
-
const totalItems = currentState.totalItems;
|
|
1851
|
-
const currentComponentPageSize = currentState.pageSize;
|
|
1852
|
-
let navigationDirection = 'reload';
|
|
1853
|
-
let resetDocs = false;
|
|
1854
|
-
let originalPageSize = null;
|
|
1855
|
-
let shouldNavigate = true;
|
|
1856
|
-
let newClientPageIndex = pageIndex;
|
|
1857
|
-
let newPageNumber = currentState.currentPageNumber;
|
|
1858
|
-
const lastPageIndex = Math.max(0, Math.ceil(totalItems / eventPageSize) - 1);
|
|
1859
|
-
// Atualizar número da página
|
|
1860
|
-
if (previousPageIndex !== undefined && pageIndex > previousPageIndex) {
|
|
1861
|
-
newPageNumber++;
|
|
1862
|
-
}
|
|
1863
|
-
else if (previousPageIndex !== undefined &&
|
|
1864
|
-
pageIndex < previousPageIndex) {
|
|
1865
|
-
newPageNumber = Math.max(1, newPageNumber - 1);
|
|
1866
|
-
}
|
|
1867
|
-
// Mudança de tamanho de página
|
|
1868
|
-
if (eventPageSize !== currentComponentPageSize) {
|
|
1869
|
-
navigationDirection = 'forward';
|
|
1870
|
-
resetDocs = true;
|
|
1871
|
-
newClientPageIndex = 0;
|
|
1872
|
-
}
|
|
1873
|
-
// Indo para primeira página
|
|
1874
|
-
else if (pageIndex === 0 &&
|
|
1875
|
-
previousPageIndex !== undefined &&
|
|
1876
|
-
pageIndex < previousPageIndex) {
|
|
1877
|
-
navigationDirection = 'forward';
|
|
1878
|
-
newPageNumber = 1;
|
|
1879
|
-
newClientPageIndex = 0;
|
|
1880
|
-
resetDocs = true;
|
|
1881
|
-
}
|
|
1882
|
-
// Indo para última página (salto)
|
|
1883
|
-
else if (pageIndex === lastPageIndex &&
|
|
1884
|
-
previousPageIndex !== undefined &&
|
|
1885
|
-
pageIndex > previousPageIndex &&
|
|
1886
|
-
pageIndex - previousPageIndex > 1) {
|
|
1887
|
-
navigationDirection = 'backward';
|
|
1888
|
-
resetDocs = true;
|
|
1889
|
-
const itemsExpectedInLastPage = totalItems - lastPageIndex * eventPageSize;
|
|
1890
|
-
if (itemsExpectedInLastPage > 0 &&
|
|
1891
|
-
itemsExpectedInLastPage < eventPageSize) {
|
|
1892
|
-
originalPageSize = currentComponentPageSize;
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
// Próxima página
|
|
1896
|
-
else if (previousPageIndex !== undefined && pageIndex > previousPageIndex) {
|
|
1897
|
-
navigationDirection = 'forward';
|
|
1898
|
-
resetDocs = false;
|
|
1899
|
-
}
|
|
1900
|
-
// Página anterior
|
|
1901
|
-
else if (previousPageIndex !== undefined && pageIndex < previousPageIndex) {
|
|
1902
|
-
navigationDirection = 'backward';
|
|
1903
|
-
resetDocs = false;
|
|
1904
|
-
}
|
|
1905
|
-
// Mesma página (reload)
|
|
1906
|
-
else if (previousPageIndex !== undefined &&
|
|
1907
|
-
pageIndex === previousPageIndex) {
|
|
1908
|
-
navigationDirection = 'reload';
|
|
1909
|
-
resetDocs = false;
|
|
1910
|
-
}
|
|
1911
|
-
// Caso inicial (primeira carga)
|
|
1912
|
-
else if (previousPageIndex === undefined && pageIndex === 0) {
|
|
1913
|
-
shouldNavigate = false;
|
|
1914
|
-
}
|
|
1915
|
-
// Caso não tratado
|
|
1916
|
-
else {
|
|
1917
|
-
console.warn('Condição de navegação não tratada:', event);
|
|
1918
|
-
shouldNavigate = false;
|
|
1919
|
-
}
|
|
1920
|
-
return {
|
|
1921
|
-
direction: navigationDirection,
|
|
1922
|
-
resetDocs,
|
|
1923
|
-
originalPageSize,
|
|
1924
|
-
shouldNavigate,
|
|
1925
|
-
newClientPageIndex,
|
|
1926
|
-
newPageNumber,
|
|
1927
|
-
};
|
|
1928
|
-
}
|
|
1929
|
-
/**
|
|
1930
|
-
* Calcula o número de itens esperados na última página
|
|
1931
|
-
*/
|
|
1932
|
-
calculateLastPageItemCount(totalItems, pageSize) {
|
|
1933
|
-
const lastPageIndex = Math.max(0, Math.ceil(totalItems / pageSize) - 1);
|
|
1934
|
-
return totalItems - lastPageIndex * pageSize;
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* Calcula o índice da última página
|
|
1938
|
-
*/
|
|
1939
|
-
calculateLastPageIndex(totalItems, pageSize) {
|
|
1940
|
-
return Math.max(0, Math.ceil(totalItems / pageSize) - 1);
|
|
1941
|
-
}
|
|
1942
|
-
/**
|
|
1943
|
-
* Verifica se deve mostrar o botão de próxima página
|
|
1944
|
-
*/
|
|
1945
|
-
shouldShowNextButton(hasNextPage, isPaginated) {
|
|
1946
|
-
return hasNextPage || !isPaginated;
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
PaginationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PaginationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1950
|
-
PaginationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PaginationService, providedIn: 'root' });
|
|
1951
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PaginationService, decorators: [{
|
|
1952
|
-
type: Injectable,
|
|
1953
|
-
args: [{
|
|
1954
|
-
providedIn: 'root',
|
|
1955
|
-
}]
|
|
1956
|
-
}] });
|
|
1957
|
-
|
|
1958
|
-
class TableTabsComponent {
|
|
1959
|
-
constructor() {
|
|
1960
|
-
this.tabsData = [];
|
|
1961
|
-
this.selectedTab = 0;
|
|
1962
|
-
this.tabSelected = new EventEmitter();
|
|
1963
|
-
this.TABS_PER_GROUP = 6;
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Retorna os índices dos grupos de tabs (invertidos para exibição vertical)
|
|
1967
|
-
*/
|
|
1968
|
-
getTabGroups() {
|
|
1969
|
-
if (!this.tabsData || this.tabsData.length === 0)
|
|
1970
|
-
return [];
|
|
1971
|
-
const totalGroups = Math.ceil(this.tabsData.length / this.TABS_PER_GROUP);
|
|
1972
|
-
const groups = [];
|
|
1973
|
-
for (let i = totalGroups - 1; i >= 0; i--) {
|
|
1974
|
-
groups.push(i);
|
|
1975
|
-
}
|
|
1976
|
-
return groups;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* Retorna os tabs de um grupo específico
|
|
1980
|
-
*/
|
|
1981
|
-
getTabGroup(groupIndex) {
|
|
1982
|
-
if (!this.tabsData || this.tabsData.length === 0)
|
|
1983
|
-
return [];
|
|
1984
|
-
const startIndex = groupIndex * this.TABS_PER_GROUP;
|
|
1985
|
-
const endIndex = Math.min(startIndex + this.TABS_PER_GROUP, this.tabsData.length);
|
|
1986
|
-
return this.tabsData.slice(startIndex, endIndex);
|
|
1987
|
-
}
|
|
1988
|
-
/**
|
|
1989
|
-
* Calcula o índice real do tab considerando a inversão vertical
|
|
1990
|
-
*/
|
|
1991
|
-
getRealTabIndex(groupDisplayIndex, tabIndexInGroup) {
|
|
1992
|
-
if (!this.tabsData)
|
|
1993
|
-
return 0;
|
|
1994
|
-
const totalGroups = Math.ceil(this.tabsData.length / this.TABS_PER_GROUP);
|
|
1995
|
-
const realGroupIndex = totalGroups - 1 - groupDisplayIndex;
|
|
1996
|
-
return realGroupIndex * this.TABS_PER_GROUP + tabIndexInGroup;
|
|
1997
|
-
}
|
|
1998
|
-
/**
|
|
1999
|
-
* Manipula a seleção de um tab
|
|
2000
|
-
*/
|
|
2001
|
-
onTabSelected(groupDisplayIndex, tabIndexInGroup) {
|
|
2002
|
-
const realIndex = this.getRealTabIndex(groupDisplayIndex, tabIndexInGroup);
|
|
2003
|
-
const tab = this.tabsData[realIndex];
|
|
2004
|
-
if (tab) {
|
|
2005
|
-
this.tabSelected.emit({ tab, index: realIndex });
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Verifica se um tab está selecionado
|
|
2010
|
-
*/
|
|
2011
|
-
isTabSelected(originalIndex) {
|
|
2012
|
-
return this.selectedTab === originalIndex;
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
TableTabsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2016
|
-
TableTabsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableTabsComponent, selector: "lib-table-tabs", inputs: { tabsData: "tabsData", selectedTab: "selectedTab" }, outputs: { tabSelected: "tabSelected" }, ngImport: i0, template: "<div class=\"mx-auto flex flex-col\" *ngIf=\"tabsData && tabsData.length > 0\">\r\n <ng-container *ngFor=\"let groupIndex of getTabGroups(); let i = index\">\r\n <div class=\"mx-auto flex flex-row\">\r\n <ng-container *ngFor=\"let tab of getTabGroup(groupIndex); let j = index\">\r\n <button\r\n class=\"border-2 border-gray-300 bg-gray-200 px-4 py-2 font-medium transition hover:brightness-95\"\r\n [ngClass]=\"\r\n isTabSelected(getRealTabIndex(i, j))\r\n ? 'border-b-0 brightness-110'\r\n : ''\r\n \"\r\n (click)=\"onTabSelected(i, j)\"\r\n >\r\n {{ tab.label }}\r\n <span\r\n *ngIf=\"tab.counter !== undefined\"\r\n class=\"ml-2 text-xs font-bold\"\r\n [ngClass]=\"tab.counterClass\"\r\n >\r\n {{ tab.counter }}\r\n </span>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</div>\r\n\r\n\r\n", dependencies: [{ kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2017
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableTabsComponent, decorators: [{
|
|
2018
|
-
type: Component,
|
|
2019
|
-
args: [{ selector: 'lib-table-tabs', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mx-auto flex flex-col\" *ngIf=\"tabsData && tabsData.length > 0\">\r\n <ng-container *ngFor=\"let groupIndex of getTabGroups(); let i = index\">\r\n <div class=\"mx-auto flex flex-row\">\r\n <ng-container *ngFor=\"let tab of getTabGroup(groupIndex); let j = index\">\r\n <button\r\n class=\"border-2 border-gray-300 bg-gray-200 px-4 py-2 font-medium transition hover:brightness-95\"\r\n [ngClass]=\"\r\n isTabSelected(getRealTabIndex(i, j))\r\n ? 'border-b-0 brightness-110'\r\n : ''\r\n \"\r\n (click)=\"onTabSelected(i, j)\"\r\n >\r\n {{ tab.label }}\r\n <span\r\n *ngIf=\"tab.counter !== undefined\"\r\n class=\"ml-2 text-xs font-bold\"\r\n [ngClass]=\"tab.counterClass\"\r\n >\r\n {{ tab.counter }}\r\n </span>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</div>\r\n\r\n\r\n" }]
|
|
2020
|
-
}], propDecorators: { tabsData: [{
|
|
2021
|
-
type: Input
|
|
2022
|
-
}], selectedTab: [{
|
|
2023
|
-
type: Input
|
|
2024
|
-
}], tabSelected: [{
|
|
2025
|
-
type: Output
|
|
2026
|
-
}] } });
|
|
2027
|
-
|
|
2028
|
-
class TableTooltipComponent {
|
|
2029
|
-
constructor() {
|
|
2030
|
-
this.styles = {};
|
|
2031
|
-
}
|
|
2032
|
-
get showTooltip() {
|
|
2033
|
-
var _a, _b;
|
|
2034
|
-
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.showTooltip) !== null && _b !== void 0 ? _b : false;
|
|
2035
|
-
}
|
|
2036
|
-
get tooltipContent() {
|
|
2037
|
-
var _a, _b;
|
|
2038
|
-
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.tooltipContent) !== null && _b !== void 0 ? _b : '';
|
|
2039
|
-
}
|
|
2040
|
-
get tooltipPosition() {
|
|
2041
|
-
var _a, _b;
|
|
2042
|
-
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.tooltipPosition) !== null && _b !== void 0 ? _b : { x: 0, y: 0 };
|
|
2043
|
-
}
|
|
2044
|
-
get tooltipBgColor() {
|
|
2045
|
-
var _a, _b;
|
|
2046
|
-
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.tooltipBgColor) !== null && _b !== void 0 ? _b : 'bg-gray-800';
|
|
2047
|
-
}
|
|
2048
|
-
get tooltipTextColor() {
|
|
2049
|
-
var _a, _b;
|
|
2050
|
-
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.tooltipTextColor) !== null && _b !== void 0 ? _b : 'text-white';
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
TableTooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2054
|
-
TableTooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableTooltipComponent, selector: "lib-table-tooltip", inputs: { state: "state", styles: "styles" }, ngImport: i0, template: "<div\r\n *ngIf=\"showTooltip\"\r\n class=\"fixed z-50 max-w-md break-words rounded-lg px-3 py-2 text-sm shadow-lg\"\r\n [ngClass]=\"\r\n (tooltipBgColor || 'bg-gray-800') + ' ' + (tooltipTextColor || 'text-white')\r\n \"\r\n [ngStyle]=\"styles\"\r\n [style.left.px]=\"tooltipPosition.x\"\r\n [style.top.px]=\"tooltipPosition.y\"\r\n [style.pointer-events]=\"'none'\"\r\n>\r\n {{ tooltipContent }}\r\n</div>\r\n", dependencies: [{ kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2055
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableTooltipComponent, decorators: [{
|
|
2056
|
-
type: Component,
|
|
2057
|
-
args: [{ selector: 'lib-table-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\r\n *ngIf=\"showTooltip\"\r\n class=\"fixed z-50 max-w-md break-words rounded-lg px-3 py-2 text-sm shadow-lg\"\r\n [ngClass]=\"\r\n (tooltipBgColor || 'bg-gray-800') + ' ' + (tooltipTextColor || 'text-white')\r\n \"\r\n [ngStyle]=\"styles\"\r\n [style.left.px]=\"tooltipPosition.x\"\r\n [style.top.px]=\"tooltipPosition.y\"\r\n [style.pointer-events]=\"'none'\"\r\n>\r\n {{ tooltipContent }}\r\n</div>\r\n" }]
|
|
2058
|
-
}], propDecorators: { state: [{
|
|
2059
|
-
type: Input
|
|
2060
|
-
}], styles: [{
|
|
2061
|
-
type: Input
|
|
2062
|
-
}] } });
|
|
2063
|
-
|
|
2064
|
-
class TableComponent {
|
|
2065
|
-
// CONSTRUCTOR
|
|
2066
|
-
constructor(router, tableService, filterService, tooltipService, paginationService, firestore, el, cdr) {
|
|
2067
|
-
this.router = router;
|
|
2068
|
-
this.tableService = tableService;
|
|
2069
|
-
this.filterService = filterService;
|
|
2070
|
-
this.tooltipService = tooltipService;
|
|
2071
|
-
this.paginationService = paginationService;
|
|
2072
|
-
this.firestore = firestore;
|
|
2073
|
-
this.el = el;
|
|
2074
|
-
this.cdr = cdr;
|
|
2075
|
-
this.arrange = null;
|
|
2076
|
-
this.currentPageNumber = 1;
|
|
2077
|
-
this.currentClientPageIndex = 0;
|
|
2078
|
-
this.isLoading$ = new BehaviorSubject(false);
|
|
2079
|
-
this.items = [];
|
|
2080
|
-
this.filteredItems = [];
|
|
2081
|
-
this.lastDoc = null;
|
|
2082
|
-
this.firstDoc = null;
|
|
2083
|
-
this.sortBy = {
|
|
2084
|
-
field: TABLE_DEFAULTS.SORT_FIELD,
|
|
2085
|
-
order: TABLE_DEFAULTS.SORT_ORDER,
|
|
2086
|
-
};
|
|
2087
|
-
this.columnProperties = [];
|
|
2088
|
-
this.selectSort = new FormControl('');
|
|
2089
|
-
this.currentArrange = '';
|
|
2090
|
-
this.hasNextPage = false;
|
|
2091
|
-
this.dropdownItems = [];
|
|
2092
|
-
this.sortableDropdownItems = [];
|
|
2093
|
-
this.pageSize = TABLE_DEFAULTS.PAGE_SIZE;
|
|
2094
|
-
this.totalItems = 0;
|
|
2095
|
-
this.filterValue = null;
|
|
2096
|
-
this.hasFilterableColumn = false;
|
|
2097
|
-
this.hasSortableColumn = false;
|
|
2098
|
-
this.filterSubject = new Subject();
|
|
2099
|
-
this.debounceTimeMs = TABLE_DEFAULTS.DEBOUNCE_TIME_MS;
|
|
2100
|
-
this.selectedTab = 0;
|
|
2101
|
-
// Controle de loading de imagens
|
|
2102
|
-
this.imageLoadingState = new Map();
|
|
2103
|
-
this.destroy$ = new Subject();
|
|
2104
|
-
this.filtersForm = new FormArray([this.filterService.createFilterGroup()]);
|
|
2105
|
-
this.tooltipState = this.tooltipService.createInitialState();
|
|
2106
|
-
}
|
|
2107
|
-
// FILTER METHODS (delegados ao FilterService)
|
|
2108
|
-
createFilterGroup() {
|
|
2109
|
-
return this.filterService.createFilterGroup();
|
|
2110
|
-
}
|
|
2111
|
-
addFilter(filterData) {
|
|
2112
|
-
this.filterService.addFilter(this.filtersForm, this.data.pagination === true, filterData);
|
|
2113
|
-
}
|
|
2114
|
-
hasActiveDateFilter() {
|
|
2115
|
-
return this.filterService.hasActiveDateFilter(this.filtersForm);
|
|
2116
|
-
}
|
|
2117
|
-
getAvailableFilterOptions() {
|
|
2118
|
-
return this.filterService.getAvailableFilterOptions(this.dropdownItems, this.data.pagination === true, this.filtersForm);
|
|
2119
|
-
}
|
|
2120
|
-
onSelectFilterChange() {
|
|
2121
|
-
var _a;
|
|
2122
|
-
const lastIndex = this.filtersForm.length - 1;
|
|
2123
|
-
const lastFilter = this.filtersForm.at(lastIndex);
|
|
2124
|
-
const selectedFilter = (_a = lastFilter.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
2125
|
-
if (selectedFilter) {
|
|
2126
|
-
if (selectedFilter.arrange === 'filterByDate' &&
|
|
2127
|
-
this.data.pagination === true) {
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2130
|
-
this.addFilter();
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
removeFilter(index) {
|
|
2134
|
-
this.filterService.removeFilter(this.filtersForm, index);
|
|
2135
|
-
}
|
|
2136
|
-
removeAllFilters() {
|
|
2137
|
-
this.filterService.removeAllFilters(this.filtersForm);
|
|
2138
|
-
this.resetFilter();
|
|
2139
|
-
}
|
|
2140
|
-
onDateInput(event, controlName, filterIndex) {
|
|
2141
|
-
const filterGroup = this.filtersForm.at(filterIndex);
|
|
2142
|
-
this.filterService.applyDateMask(event, controlName, filterGroup);
|
|
2143
|
-
}
|
|
2144
|
-
onDateFilterChange() {
|
|
2145
|
-
if (this.data.pagination === false) {
|
|
2146
|
-
this.arrange = this.filterService.buildArrangeFromFilters(this.filtersForm, this.sortBy);
|
|
2147
|
-
this.applyFiltersToDataSource();
|
|
2148
|
-
this.cdr.markForCheck();
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
applyFiltersToDataSource() {
|
|
2152
|
-
if (!this.dataSource)
|
|
2153
|
-
return;
|
|
2154
|
-
let filteredItems = this.filterService.applyClientSideFilters([...this.items], this.filtersForm, this.sortBy);
|
|
2155
|
-
this.dataSource.data = filteredItems;
|
|
2156
|
-
this.filteredItems = filteredItems;
|
|
2157
|
-
this.totalItems = filteredItems.length;
|
|
2158
|
-
this.cdr.markForCheck();
|
|
2159
|
-
}
|
|
2160
|
-
applyClientSideFilters(items) {
|
|
2161
|
-
return this.filterService.applyClientSideFilters(items, this.filtersForm, this.sortBy);
|
|
2162
|
-
}
|
|
2163
|
-
buildArrangeFromFilters() {
|
|
2164
|
-
return this.filterService.buildArrangeFromFilters(this.filtersForm, this.sortBy);
|
|
2165
|
-
}
|
|
2166
|
-
// TOOLTIP METHODS (delegados ao TooltipService)
|
|
2167
|
-
getTooltipStyles() {
|
|
2168
|
-
return this.tooltipService.getTooltipStyles(this.tooltipState);
|
|
2169
|
-
}
|
|
2170
|
-
onCellMouseEnter(event, row, col) {
|
|
2171
|
-
this.tooltipService.handleMouseEnter(event, row, col, (c, r, w) => this.getDisplayValue(c, r, w), (state) => {
|
|
2172
|
-
this.tooltipState = Object.assign(Object.assign({}, this.tooltipState), state);
|
|
2173
|
-
this.cdr.markForCheck();
|
|
2174
|
-
});
|
|
2175
|
-
}
|
|
2176
|
-
onCellMouseLeave() {
|
|
2177
|
-
this.tooltipService.handleMouseLeave((state) => {
|
|
2178
|
-
this.tooltipState = state;
|
|
2179
|
-
this.cdr.markForCheck();
|
|
2180
|
-
});
|
|
2181
|
-
}
|
|
2182
|
-
onCellMouseMove(event) {
|
|
2183
|
-
this.tooltipService.handleMouseMove(event, this.tooltipState.showTooltip, (position) => {
|
|
2184
|
-
this.tooltipState = Object.assign(Object.assign({}, this.tooltipState), { tooltipPosition: position });
|
|
2185
|
-
this.cdr.markForCheck();
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
// TAB METHODS
|
|
2189
|
-
onTabSelected(event) {
|
|
2190
|
-
var _a;
|
|
2191
|
-
if (!((_a = this.data.tabs) === null || _a === void 0 ? void 0 : _a.method))
|
|
2192
|
-
return;
|
|
2193
|
-
this.selectedTab = event.index;
|
|
2194
|
-
this.data.tabs.method(event.tab, event.index);
|
|
2195
|
-
this.cdr.markForCheck();
|
|
2196
|
-
}
|
|
2197
|
-
// UTILITY METHODS (delegados aos utils)
|
|
2198
|
-
getDisplayValue(col, row, withinLimit = false) {
|
|
2199
|
-
return getDisplayValue(col, row, withinLimit);
|
|
2200
|
-
}
|
|
2201
|
-
getNestedValue(obj, path) {
|
|
2202
|
-
return getNestedValue(obj, path);
|
|
2203
|
-
}
|
|
2204
|
-
isString(value) {
|
|
2205
|
-
return isString(value);
|
|
2206
|
-
}
|
|
2207
|
-
trackByProperty(_index, col) {
|
|
2208
|
-
return trackByProperty(_index, col);
|
|
2209
|
-
}
|
|
2210
|
-
// IMAGE LOADING METHODS
|
|
2211
|
-
getImageKey(row, col) {
|
|
2212
|
-
return getImageKey(row, col);
|
|
2213
|
-
}
|
|
2214
|
-
isImageLoading(row, col) {
|
|
2215
|
-
const key = this.getImageKey(row, col);
|
|
2216
|
-
return !this.imageLoadingState.has(key);
|
|
2217
|
-
}
|
|
2218
|
-
onImageLoad(row, col) {
|
|
2219
|
-
const key = this.getImageKey(row, col);
|
|
2220
|
-
this.imageLoadingState.set(key, true);
|
|
2221
|
-
this.cdr.markForCheck();
|
|
2222
|
-
}
|
|
2223
|
-
onImageError(event, row, col, defaultImage) {
|
|
2224
|
-
const key = this.getImageKey(row, col);
|
|
2225
|
-
this.imageLoadingState.set(key, true);
|
|
2226
|
-
const target = event.target;
|
|
2227
|
-
if (target) {
|
|
2228
|
-
if (defaultImage) {
|
|
2229
|
-
target.src = defaultImage;
|
|
2230
|
-
target.onerror = null;
|
|
2231
|
-
}
|
|
2232
|
-
else {
|
|
2233
|
-
target.style.display = 'none';
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
this.cdr.markForCheck();
|
|
2237
|
-
}
|
|
2238
|
-
// LIFECYCLE METHODS
|
|
2239
|
-
ngOnChanges(changes) {
|
|
2240
|
-
if (changes['data']) {
|
|
2241
|
-
setTimeout(() => this.applyCustomColors(), 0);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
ngAfterViewInit() {
|
|
2245
|
-
this.applyCustomColors();
|
|
2246
|
-
}
|
|
2247
|
-
ngOnDestroy() {
|
|
2248
|
-
this.tooltipService.destroy();
|
|
2249
|
-
this.destroy$.next();
|
|
2250
|
-
this.destroy$.complete();
|
|
2251
|
-
}
|
|
2252
|
-
applyCustomColors() {
|
|
2253
|
-
var _a, _b, _c;
|
|
2254
|
-
const hostElement = (_a = this.el) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
2255
|
-
if (!hostElement || !this.data)
|
|
2256
|
-
return;
|
|
2257
|
-
if ((_b = this.data.color) === null || _b === void 0 ? void 0 : _b.bg) {
|
|
2258
|
-
hostElement.style.setProperty('--table-color', this.data.color.bg);
|
|
2259
|
-
hostElement.style.setProperty('--table-header-bg', this.data.color.bg);
|
|
2260
|
-
}
|
|
2261
|
-
if ((_c = this.data.color) === null || _c === void 0 ? void 0 : _c.text) {
|
|
2262
|
-
hostElement.style.setProperty('--table-text-color', this.data.color.text);
|
|
2263
|
-
hostElement.style.setProperty('--table-header-text', this.data.color.text);
|
|
2264
|
-
}
|
|
2265
|
-
setTimeout(() => {
|
|
2266
|
-
const headerCells = hostElement.querySelectorAll('.mat-header-cell, .mat-mdc-header-cell, th.mat-header-cell, th.mat-mdc-header-cell');
|
|
2267
|
-
headerCells.forEach((cell) => {
|
|
2268
|
-
var _a, _b;
|
|
2269
|
-
if ((_a = this.data.color) === null || _a === void 0 ? void 0 : _a.bg) {
|
|
2270
|
-
cell.style.backgroundColor = this.data.color.bg;
|
|
2271
|
-
}
|
|
2272
|
-
if ((_b = this.data.color) === null || _b === void 0 ? void 0 : _b.text) {
|
|
2273
|
-
cell.style.color = this.data.color.text;
|
|
2274
|
-
}
|
|
2275
|
-
});
|
|
2276
|
-
}, 100);
|
|
2277
|
-
}
|
|
2278
|
-
ngOnInit() {
|
|
2279
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2280
|
-
if (!this.data.color) {
|
|
2281
|
-
this.data.color = {
|
|
2282
|
-
bg: TABLE_DEFAULTS.DEFAULT_BG_COLOR,
|
|
2283
|
-
text: TABLE_DEFAULTS.DEFAULT_TEXT_COLOR,
|
|
2284
|
-
};
|
|
2285
|
-
}
|
|
2286
|
-
if (this.data.showSimpleSearch === undefined) {
|
|
2287
|
-
this.data.showSimpleSearch = true;
|
|
2288
|
-
}
|
|
2289
|
-
this.columnProperties = this.data.displayedColumns.map((column) => column.property);
|
|
2290
|
-
this.cdr.markForCheck();
|
|
2291
|
-
if (this.data.actionButton && !this.data.actionButton.condition) {
|
|
2292
|
-
this.data.actionButton.condition = (_row) => true;
|
|
2293
|
-
}
|
|
2294
|
-
// Inicializar dropdownItems usando FilterService
|
|
2295
|
-
const filterConfig = this.filterService.initializeDropdownItems(this.data.displayedColumns);
|
|
2296
|
-
this.dropdownItems = filterConfig.dropdownItems;
|
|
2297
|
-
this.sortableDropdownItems = filterConfig.sortableDropdownItems;
|
|
2298
|
-
this.hasFilterableColumn = filterConfig.hasFilterableColumn;
|
|
2299
|
-
this.hasSortableColumn = filterConfig.hasSortableColumn;
|
|
2300
|
-
if (this.data.filterableOptions) {
|
|
2301
|
-
this.dropdownItems = this.filterService.addFilterableOptions(this.dropdownItems, this.data.filterableOptions);
|
|
2302
|
-
}
|
|
2303
|
-
// Sem paginação
|
|
2304
|
-
if (this.data.pagination === false) {
|
|
2305
|
-
yield this.loadItems();
|
|
2306
|
-
this.cdr.markForCheck();
|
|
2307
|
-
}
|
|
2308
|
-
// Com paginação
|
|
2309
|
-
if (this.data.pagination === true) {
|
|
2310
|
-
if (this.data.sortBy) {
|
|
2311
|
-
this.sortBy = {
|
|
2312
|
-
field: this.data.sortBy.field,
|
|
2313
|
-
order: this.data.sortBy.order,
|
|
2314
|
-
};
|
|
2315
|
-
}
|
|
2316
|
-
this.filterSubject
|
|
2317
|
-
.pipe(debounceTime(this.debounceTimeMs), takeUntil(this.destroy$))
|
|
2318
|
-
.subscribe(() => {
|
|
2319
|
-
this.loadItemsPaginated('reload', true);
|
|
2320
|
-
});
|
|
2321
|
-
this.isLoading$.next(true);
|
|
2322
|
-
this.cdr.markForCheck();
|
|
2323
|
-
yield this.loadItemsPaginated('reload', true);
|
|
2324
|
-
this.sort.active = 'createdAt';
|
|
2325
|
-
this.sort.direction = 'desc';
|
|
2326
|
-
this.dataSource.paginator = this.paginator;
|
|
2327
|
-
this.dataSource.sort = this.sort;
|
|
2328
|
-
this.totalItems = 0;
|
|
2329
|
-
if (this.data.totalRef) {
|
|
2330
|
-
for (const totalRef of this.data.totalRef) {
|
|
2331
|
-
const totalRefDoc = yield totalRef.ref.get();
|
|
2332
|
-
const docData = totalRefDoc.data();
|
|
2333
|
-
if (docData && docData[totalRef.field]) {
|
|
2334
|
-
const fieldValue = docData[totalRef.field];
|
|
2335
|
-
this.totalItems = (this.totalItems +
|
|
2336
|
-
(typeof fieldValue === 'number' ? fieldValue : 0));
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
this.isLoading$.next(false);
|
|
2341
|
-
this.cdr.markForCheck();
|
|
2342
|
-
}
|
|
2343
|
-
});
|
|
2344
|
-
}
|
|
2345
|
-
// DATA LOADING METHODS
|
|
2346
|
-
loadItems() {
|
|
2347
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2348
|
-
this.imageLoadingState.clear();
|
|
2349
|
-
this.items = (yield this.tableService.getItems(this.data.collectionRef));
|
|
2350
|
-
if (this.data.conditions) {
|
|
2351
|
-
this.filterItems();
|
|
2352
|
-
}
|
|
2353
|
-
yield this.loadRelations();
|
|
2354
|
-
yield this.loadQueryLengths();
|
|
2355
|
-
this.totalItems = this.items.length;
|
|
2356
|
-
this.arrange = {
|
|
2357
|
-
filters: [],
|
|
2358
|
-
sortBy: this.data.sortBy || {
|
|
2359
|
-
field: TABLE_DEFAULTS.SORT_FIELD,
|
|
2360
|
-
order: TABLE_DEFAULTS.SORT_ORDER,
|
|
2361
|
-
},
|
|
2362
|
-
};
|
|
2363
|
-
this.sortBy = this.data.sortBy || {
|
|
2364
|
-
field: TABLE_DEFAULTS.SORT_FIELD,
|
|
2365
|
-
order: TABLE_DEFAULTS.SORT_ORDER,
|
|
2366
|
-
};
|
|
2367
|
-
let itemsToDisplay = [...this.items];
|
|
2368
|
-
itemsToDisplay = this.applyClientSideFilters(itemsToDisplay);
|
|
2369
|
-
this.filteredItems = itemsToDisplay;
|
|
2370
|
-
this.dataSource = new MatTableDataSource(itemsToDisplay);
|
|
2371
|
-
this.dataSource.paginator = this.paginator;
|
|
2372
|
-
this.dataSource.sort = this.sort;
|
|
2373
|
-
if (this.data.sortBy) {
|
|
2374
|
-
this.dataSource.sort.active = this.data.sortBy.field;
|
|
2375
|
-
this.dataSource.sort.direction = this.data.sortBy.order;
|
|
2376
|
-
this.dataSource.sort.sortChange.emit();
|
|
2377
|
-
}
|
|
2378
|
-
this.dataSource.filterPredicate = (data, filter) => {
|
|
2379
|
-
const item = data;
|
|
2380
|
-
return this.data.displayedColumns.some((col) => {
|
|
2381
|
-
if (col.filterPredicates) {
|
|
2382
|
-
return col.filterPredicates.some((predicate) => {
|
|
2383
|
-
const propertyValue = item[col.property];
|
|
2384
|
-
if (!propertyValue || typeof propertyValue !== 'object') {
|
|
2385
|
-
return false;
|
|
2386
|
-
}
|
|
2387
|
-
const propertyRecord = propertyValue;
|
|
2388
|
-
const predicateValue = propertyRecord[predicate];
|
|
2389
|
-
if (predicateValue === null || predicateValue === undefined) {
|
|
2390
|
-
return false;
|
|
2391
|
-
}
|
|
2392
|
-
return String(predicateValue)
|
|
2393
|
-
.trim()
|
|
2394
|
-
.toLocaleLowerCase()
|
|
2395
|
-
.includes(filter);
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
if (col.property && col.isFilterable) {
|
|
2399
|
-
const propertyValue = item[col.property];
|
|
2400
|
-
if (propertyValue === null || propertyValue === undefined) {
|
|
2401
|
-
return false;
|
|
2402
|
-
}
|
|
2403
|
-
return String(propertyValue)
|
|
2404
|
-
.trim()
|
|
2405
|
-
.toLocaleLowerCase()
|
|
2406
|
-
.includes(filter);
|
|
2407
|
-
}
|
|
2408
|
-
return false;
|
|
2409
|
-
});
|
|
2410
|
-
};
|
|
2411
|
-
this.filterPredicate = this.dataSource.filterPredicate;
|
|
2412
|
-
this.cdr.markForCheck();
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
loadItemsPaginated(navigation = 'reload', reset = false) {
|
|
2416
|
-
var _a;
|
|
2417
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2418
|
-
this.imageLoadingState.clear();
|
|
2419
|
-
if (reset && ['forward', 'reload'].includes(navigation)) {
|
|
2420
|
-
this.lastDoc = null;
|
|
2421
|
-
this.currentClientPageIndex = 0;
|
|
2422
|
-
}
|
|
2423
|
-
if (reset && ['backward', 'reload'].includes(navigation)) {
|
|
2424
|
-
this.firstDoc = null;
|
|
2425
|
-
this.currentClientPageIndex = 0;
|
|
2426
|
-
}
|
|
2427
|
-
const activeFilters = this.filterService.extractActiveFilters(this.filtersForm);
|
|
2428
|
-
this.arrange = {
|
|
2429
|
-
filters: activeFilters,
|
|
2430
|
-
sortBy: this.sortBy,
|
|
2431
|
-
};
|
|
2432
|
-
const paginated = {
|
|
2433
|
-
batchSize: this.pageSize,
|
|
2434
|
-
collection: this.data.collection,
|
|
2435
|
-
doc: { lastDoc: this.lastDoc, firstDoc: this.firstDoc },
|
|
2436
|
-
navigation,
|
|
2437
|
-
arrange: this.arrange,
|
|
2438
|
-
conditions: this.data.conditions,
|
|
2439
|
-
size: this.totalItems,
|
|
2440
|
-
filterFn: this.data.filterFn,
|
|
2441
|
-
clientPageIndex: this.currentClientPageIndex,
|
|
2442
|
-
};
|
|
2443
|
-
const result = yield this.tableService.getPaginated(paginated);
|
|
2444
|
-
this.items = result.items;
|
|
2445
|
-
yield this.loadRelations();
|
|
2446
|
-
yield this.loadQueryLengths();
|
|
2447
|
-
this.lastDoc = result.lastDoc;
|
|
2448
|
-
this.firstDoc = result.firstDoc;
|
|
2449
|
-
if (result.currentClientPageIndex !== undefined) {
|
|
2450
|
-
this.currentClientPageIndex = result.currentClientPageIndex;
|
|
2451
|
-
}
|
|
2452
|
-
let sum = 0;
|
|
2453
|
-
if (this.data.totalRef) {
|
|
2454
|
-
for (const totalRef of this.data.totalRef) {
|
|
2455
|
-
const totalRefDoc = yield totalRef.ref.get();
|
|
2456
|
-
const docData = totalRefDoc.data();
|
|
2457
|
-
if (docData || result.filterLength) {
|
|
2458
|
-
const fieldValue = docData ? docData[totalRef.field] : undefined;
|
|
2459
|
-
const numericValue = typeof fieldValue === 'number' ? fieldValue : 0;
|
|
2460
|
-
sum = (_a = result.filterLength) !== null && _a !== void 0 ? _a : (sum + numericValue);
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
this.totalItems = sum;
|
|
2464
|
-
}
|
|
2465
|
-
this.hasNextPage = result.hasNextPage;
|
|
2466
|
-
this.dataSource = new MatTableDataSource(this.items);
|
|
2467
|
-
this.filterPredicate = this.dataSource.filterPredicate;
|
|
2468
|
-
this.cdr.markForCheck();
|
|
2469
|
-
});
|
|
2470
|
-
}
|
|
2471
|
-
// PAGINATION METHODS
|
|
2472
|
-
onPageChange(event) {
|
|
2473
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2474
|
-
if (this.data.pagination !== true || !event)
|
|
2475
|
-
return;
|
|
2476
|
-
this.isLoading$.next(true);
|
|
2477
|
-
const currentState = {
|
|
2478
|
-
currentPageNumber: this.currentPageNumber,
|
|
2479
|
-
currentClientPageIndex: this.currentClientPageIndex,
|
|
2480
|
-
pageSize: this.pageSize,
|
|
2481
|
-
totalItems: this.totalItems,
|
|
2482
|
-
hasNextPage: this.hasNextPage,
|
|
2483
|
-
};
|
|
2484
|
-
const navigation = this.paginationService.calculateNavigation(event, currentState);
|
|
2485
|
-
if (!navigation.shouldNavigate) {
|
|
2486
|
-
this.isLoading$.next(false);
|
|
2487
|
-
this.pageEvent = event;
|
|
2488
|
-
return;
|
|
2489
|
-
}
|
|
2490
|
-
// Atualizar estado local
|
|
2491
|
-
this.currentClientPageIndex = navigation.newClientPageIndex;
|
|
2492
|
-
this.currentPageNumber = navigation.newPageNumber;
|
|
2493
|
-
// Atualizar pageSize se mudou
|
|
2494
|
-
if (event.pageSize !== this.pageSize) {
|
|
2495
|
-
this.pageSize = event.pageSize;
|
|
2496
|
-
}
|
|
2497
|
-
// Ajustar pageSize temporariamente para última página se necessário
|
|
2498
|
-
const lastPageIndex = this.paginationService.calculateLastPageIndex(this.totalItems, event.pageSize);
|
|
2499
|
-
let originalPageSize = null;
|
|
2500
|
-
if (event.pageIndex === lastPageIndex &&
|
|
2501
|
-
navigation.direction === 'backward' &&
|
|
2502
|
-
navigation.resetDocs) {
|
|
2503
|
-
const itemsExpectedInLastPage = this.paginationService.calculateLastPageItemCount(this.totalItems, event.pageSize);
|
|
2504
|
-
if (itemsExpectedInLastPage > 0 &&
|
|
2505
|
-
itemsExpectedInLastPage < event.pageSize) {
|
|
2506
|
-
originalPageSize = this.pageSize;
|
|
2507
|
-
this.pageSize = itemsExpectedInLastPage;
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
try {
|
|
2511
|
-
yield this.loadItemsPaginated(navigation.direction, navigation.resetDocs);
|
|
2512
|
-
}
|
|
2513
|
-
catch (error) {
|
|
2514
|
-
console.error('Erro ao carregar itens paginados:', error);
|
|
2515
|
-
}
|
|
2516
|
-
finally {
|
|
2517
|
-
if (originalPageSize !== null) {
|
|
2518
|
-
this.pageSize = originalPageSize;
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
this.pageEvent = event;
|
|
2522
|
-
this.isLoading$.next(false);
|
|
2523
|
-
this.cdr.markForCheck();
|
|
2524
|
-
});
|
|
2525
|
-
}
|
|
2526
|
-
// FILTER/SEARCH METHODS
|
|
2527
|
-
applyFilter(value) {
|
|
2528
|
-
if (this.data.pagination === false) {
|
|
2529
|
-
this.dataSource.filter = String(value).trim().toLowerCase();
|
|
2530
|
-
}
|
|
2531
|
-
if (this.data.pagination === true) {
|
|
2532
|
-
this.filterValue = value;
|
|
2533
|
-
this.filterSubject.next(this.filterValue);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
search(event) {
|
|
2537
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2538
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2539
|
-
if (event) {
|
|
2540
|
-
event.preventDefault();
|
|
2541
|
-
event.stopPropagation();
|
|
2542
|
-
}
|
|
2543
|
-
if (this.selectSort.value) {
|
|
2544
|
-
if (this.selectSort.value.arrange === 'ascending') {
|
|
2545
|
-
this.sortBy = {
|
|
2546
|
-
field: this.selectSort.value.property,
|
|
2547
|
-
order: 'asc',
|
|
2548
|
-
};
|
|
2549
|
-
}
|
|
2550
|
-
if (this.selectSort.value.arrange === 'descending') {
|
|
2551
|
-
this.sortBy = {
|
|
2552
|
-
field: this.selectSort.value.property,
|
|
2553
|
-
order: 'desc',
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
if (this.data.pagination === false) {
|
|
2558
|
-
this.arrange = this.buildArrangeFromFilters();
|
|
2559
|
-
this.applyFiltersToDataSource();
|
|
2560
|
-
this.currentArrange =
|
|
2561
|
-
this.filtersForm.length > 0
|
|
2562
|
-
? ((_c = (_b = (_a = this.filtersForm.at(0).get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.arrange) !== null && _c !== void 0 ? _c : '')
|
|
2563
|
-
: '';
|
|
2564
|
-
this.cdr.markForCheck();
|
|
2565
|
-
}
|
|
2566
|
-
else {
|
|
2567
|
-
yield this.loadItemsPaginated('reload', true);
|
|
2568
|
-
this.currentArrange =
|
|
2569
|
-
this.filtersForm.length > 0
|
|
2570
|
-
? ((_f = (_e = (_d = this.filtersForm.at(0).get('selectFilter')) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.arrange) !== null && _f !== void 0 ? _f : '')
|
|
2571
|
-
: '';
|
|
2572
|
-
this.paginator.firstPage();
|
|
2573
|
-
this.cdr.markForCheck();
|
|
2574
|
-
}
|
|
2575
|
-
});
|
|
2576
|
-
}
|
|
2577
|
-
resetFilter() {
|
|
2578
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2579
|
-
this.dataSource.filter = '';
|
|
2580
|
-
if (this.filterPredicate) {
|
|
2581
|
-
this.dataSource.filterPredicate = this.filterPredicate;
|
|
2582
|
-
}
|
|
2583
|
-
this.filtersForm.clear();
|
|
2584
|
-
this.addFilter();
|
|
2585
|
-
this.selectSort.patchValue('');
|
|
2586
|
-
this.sortBy = {
|
|
2587
|
-
order: this.data.sortBy ? this.data.sortBy.order : 'desc',
|
|
2588
|
-
field: this.data.sortBy ? this.data.sortBy.field : 'createdAt',
|
|
2589
|
-
};
|
|
2590
|
-
if (this.data.pagination === false) {
|
|
2591
|
-
this.arrange = {
|
|
2592
|
-
filters: [],
|
|
2593
|
-
sortBy: this.sortBy,
|
|
2594
|
-
};
|
|
2595
|
-
this.dataSource.data = [...this.items];
|
|
2596
|
-
this.totalItems = this.items.length;
|
|
2597
|
-
this.currentArrange = '';
|
|
2598
|
-
this.cdr.markForCheck();
|
|
2599
|
-
}
|
|
2600
|
-
else {
|
|
2601
|
-
yield this.loadItemsPaginated('reload', true);
|
|
2602
|
-
this.currentArrange = '';
|
|
2603
|
-
this.paginator.firstPage();
|
|
2604
|
-
this.cdr.markForCheck();
|
|
2605
|
-
}
|
|
2606
|
-
});
|
|
2607
|
-
}
|
|
2608
|
-
// NAVIGATION METHODS
|
|
2609
|
-
goToDetails(row) {
|
|
2610
|
-
if (this.data.isNotClickable) {
|
|
2611
|
-
return;
|
|
2612
|
-
}
|
|
2613
|
-
const urlPath = this.data.url || this.data.name;
|
|
2614
|
-
const rowWithId = row;
|
|
2615
|
-
const url = this.router.serializeUrl(this.router.createUrlTree([`/${urlPath}`, rowWithId.id]));
|
|
2616
|
-
window.open(url, '_blank');
|
|
2617
|
-
}
|
|
2618
|
-
// RELATION METHODS
|
|
2619
|
-
getRelation(params) {
|
|
2620
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2621
|
-
try {
|
|
2622
|
-
let snapshot;
|
|
2623
|
-
if (params.id !== '' &&
|
|
2624
|
-
params.id !== undefined &&
|
|
2625
|
-
params.collection !== undefined &&
|
|
2626
|
-
params.collection !== '') {
|
|
2627
|
-
snapshot = yield firstValueFrom(this.firestore.collection(params.collection).doc(params.id).get());
|
|
2628
|
-
}
|
|
2629
|
-
if (snapshot && snapshot.exists) {
|
|
2630
|
-
const data = snapshot.data();
|
|
2631
|
-
const value = data === null || data === void 0 ? void 0 : data[params.newProperty];
|
|
2632
|
-
return typeof value === 'string' ? value : '';
|
|
2633
|
-
}
|
|
2634
|
-
return '';
|
|
2635
|
-
}
|
|
2636
|
-
catch (e) {
|
|
2637
|
-
console.error(e);
|
|
2638
|
-
return '';
|
|
2639
|
-
}
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
loadRelations() {
|
|
2643
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2644
|
-
const relationPromises = this.data.displayedColumns
|
|
2645
|
-
.filter((col) => col.relation)
|
|
2646
|
-
.flatMap((col) => this.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
2647
|
-
var _a;
|
|
2648
|
-
if (col.relation) {
|
|
2649
|
-
const itemRecord = item;
|
|
2650
|
-
itemRecord[col.property] = yield this.getRelation({
|
|
2651
|
-
id: String((_a = itemRecord[col.relation.sourceProperty]) !== null && _a !== void 0 ? _a : ''),
|
|
2652
|
-
collection: col.relation.targetedCollection,
|
|
2653
|
-
newProperty: col.relation.targetedProperty || col.property,
|
|
2654
|
-
});
|
|
2655
|
-
}
|
|
2656
|
-
})));
|
|
2657
|
-
yield Promise.all(relationPromises);
|
|
2658
|
-
});
|
|
2659
|
-
}
|
|
2660
|
-
getQueryLength(params) {
|
|
2661
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2662
|
-
const itemRecord = params.item;
|
|
2663
|
-
const snapshot = yield this.firestore
|
|
2664
|
-
.collection(params.relation.collection)
|
|
2665
|
-
.ref.where(params.relation.property, params.relation.operator, itemRecord[params.relation.value])
|
|
2666
|
-
.get();
|
|
2667
|
-
return snapshot.size;
|
|
2668
|
-
});
|
|
2669
|
-
}
|
|
2670
|
-
loadQueryLengths() {
|
|
2671
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2672
|
-
const lengthPromises = this.data.displayedColumns
|
|
2673
|
-
.filter((col) => col.queryLength)
|
|
2674
|
-
.flatMap((col) => this.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
2675
|
-
if (col.queryLength) {
|
|
2676
|
-
const itemRecord = item;
|
|
2677
|
-
itemRecord[col.property] = yield this.getQueryLength({
|
|
2678
|
-
item: item,
|
|
2679
|
-
relation: col.queryLength,
|
|
2680
|
-
});
|
|
2681
|
-
}
|
|
2682
|
-
})));
|
|
2683
|
-
yield Promise.all(lengthPromises);
|
|
2684
|
-
});
|
|
2685
|
-
}
|
|
2686
|
-
filterItems() {
|
|
2687
|
-
if (this.data.conditions) {
|
|
2688
|
-
this.data.conditions.forEach((cond) => {
|
|
2689
|
-
this.items = this.items.filter((item) => {
|
|
2690
|
-
const operatorFunction = this.tableService.operators[cond.operator];
|
|
2691
|
-
if (operatorFunction) {
|
|
2692
|
-
const itemRecord = item;
|
|
2693
|
-
return operatorFunction(itemRecord[cond.firestoreProperty], cond.dashProperty);
|
|
2694
|
-
}
|
|
2695
|
-
return false;
|
|
2696
|
-
});
|
|
2697
|
-
});
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
// PUBLIC METHODS
|
|
2701
|
-
reloadTable() {
|
|
2702
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2703
|
-
if (this.data.pagination) {
|
|
2704
|
-
yield this.loadItemsPaginated('reload', true);
|
|
2705
|
-
this.paginator.firstPage();
|
|
2706
|
-
this.cdr.markForCheck();
|
|
2707
|
-
}
|
|
2708
|
-
else {
|
|
2709
|
-
yield this.loadItems();
|
|
2710
|
-
}
|
|
2711
|
-
});
|
|
2712
|
-
}
|
|
2713
|
-
updateDisplayedColumns() {
|
|
2714
|
-
if (this.dataSource) {
|
|
2715
|
-
this.dataSource = new MatTableDataSource([]);
|
|
2716
|
-
}
|
|
2717
|
-
this.columnProperties = this.data.displayedColumns.map((column) => column.property);
|
|
2718
|
-
const filterConfig = this.filterService.initializeDropdownItems(this.data.displayedColumns);
|
|
2719
|
-
this.dropdownItems = filterConfig.dropdownItems;
|
|
2720
|
-
this.sortableDropdownItems = filterConfig.sortableDropdownItems;
|
|
2721
|
-
if (this.data.filterableOptions) {
|
|
2722
|
-
this.dropdownItems = this.filterService.addFilterableOptions(this.dropdownItems, this.data.filterableOptions);
|
|
2723
|
-
}
|
|
2724
|
-
this.cdr.markForCheck();
|
|
2725
|
-
}
|
|
2726
|
-
shouldShowActionButton() {
|
|
2727
|
-
var _a, _b;
|
|
2728
|
-
if (!((_a = this.data) === null || _a === void 0 ? void 0 : _a.actionButton)) {
|
|
2729
|
-
return false;
|
|
2730
|
-
}
|
|
2731
|
-
if (!this.data.actionButton.condition) {
|
|
2732
|
-
return true;
|
|
2733
|
-
}
|
|
2734
|
-
try {
|
|
2735
|
-
return (_b = this.data.actionButton.condition(null)) !== null && _b !== void 0 ? _b : true;
|
|
2736
|
-
}
|
|
2737
|
-
catch (_c) {
|
|
2738
|
-
return true;
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
handleDownload() {
|
|
2742
|
-
if (!this.downloadTable)
|
|
2743
|
-
return;
|
|
2744
|
-
if (this.data.pagination === false) {
|
|
2745
|
-
if (this.dataSource && this.dataSource.filteredData) {
|
|
2746
|
-
this.filteredItems = [...this.dataSource.filteredData];
|
|
2747
|
-
}
|
|
2748
|
-
const arrange = this.buildArrangeFromFilters();
|
|
2749
|
-
this.downloadTable(arrange, this.data.conditions || []);
|
|
2750
|
-
}
|
|
2751
|
-
else {
|
|
2752
|
-
if (this.arrange) {
|
|
2753
|
-
this.downloadTable(this.arrange, this.data.conditions || []);
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
TableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, deps: [{ token: i1$2.Router }, { token: TableService }, { token: FilterService }, { token: TooltipService }, { token: PaginationService }, { token: i1.AngularFirestore }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
2759
|
-
TableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableComponent, selector: "lib-table", inputs: { data: "data", downloadTable: "downloadTable" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"data\" class=\"card-body\">\r\n <div class=\"flex flex-col justify-between gap-6\">\r\n <!-- UNIFIED CONTROL PANEL: FILTERS, SORT & ACTIONS -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"\r\n data.pagination === true &&\r\n (dropdownItems.length > 0 ||\r\n sortableDropdownItems.length > 0 ||\r\n data.actionButton)\r\n \"\r\n >\r\n <!-- PANEL HEADER: Title and Custom Action -->\r\n <div\r\n class=\"mb-4 flex flex-col items-start justify-between gap-4 border-b-2 border-gray-200 pb-4 md:flex-row md:items-center\"\r\n >\r\n <!-- Left Side: Title & Main Action Button -->\r\n <div class=\"flex flex-wrap items-center gap-4\">\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\r\n <span class=\"text-lg font-semibold text-gray-700\"\r\n >Filtros e A\u00E7\u00F5es</span\r\n >\r\n </div>\r\n <button\r\n *ngIf=\"data.actionButton && data.actionButton.condition\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\r\n \"\r\n [routerLink]=\"data.actionButton.routerLink\"\r\n (click)=\"\r\n data.actionButton.method ? data.actionButton.method($event) : null\r\n \"\r\n >\r\n <i\r\n *ngIf=\"data.actionButton.icon\"\r\n [class]=\"data.actionButton.icon\"\r\n ></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <!-- SORT FIELD (Integrated with filters) -->\r\n <div class=\"mb-4\" *ngIf=\"sortableDropdownItems.length > 0\">\r\n <div class=\"flex flex-wrap items-center gap-3 p-2\">\r\n <div class=\"min-w-[200px] flex-1\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\r\n <span>Ordenar por</span>\r\n </mat-label>\r\n <mat-select placeholder=\"Selecione...\" [formControl]=\"selectSort\">\r\n <mat-option\r\n *ngFor=\"let item of sortableDropdownItems\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- FILTERS CONTENT (WITH REFINEMENTS) -->\r\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\r\n <div\r\n [formGroup]=\"$any(filterGroup)\"\r\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\r\n class=\"flex flex-wrap items-center gap-3 p-2\"\r\n >\r\n <!-- FILTER TYPE SELECTOR -->\r\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Tipo de filtro</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione o tipo...\"\r\n formControlName=\"selectFilter\"\r\n (selectionChange)=\"onSelectFilterChange()\"\r\n >\r\n <mat-option\r\n *ngFor=\"let item of getAvailableFilterOptions()\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i\r\n [class]=\"item.icon || 'fa fa-filter'\"\r\n class=\"text-sm text-blue-500\"\r\n ></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- TEXT FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-gray-400\"></i>\r\n <span>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Filtrar\"\r\n }}</span>\r\n </mat-label>\r\n <input\r\n (keyup.enter)=\"search($event)\"\r\n formControlName=\"typeFilter\"\r\n matInput\r\n placeholder=\"Digite para filtrar...\"\r\n #input\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DROPDOWN FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value &&\r\n $any(filterGroup)\r\n .get('selectFilter')\r\n ?.value.hasOwnProperty('items')\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Selecione\"\r\n }}</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione...\"\r\n formControlName=\"selectItem\"\r\n multiple\r\n >\r\n <mat-option\r\n *ngFor=\"\r\n let item of $any(filterGroup).get('selectFilter')?.value\r\n .items\r\n \"\r\n [value]=\"item\"\r\n >\r\n {{ item.label }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DATE FILTER -->\r\n <div\r\n class=\"min-w-[340px] flex-auto\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filterByDate'\r\n \"\r\n >\r\n <div\r\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Inicial</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n matInput\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'initialDate', i)\"\r\n formControlName=\"initialDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Final</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'finalDate', i)\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- REMOVE FILTER BUTTON -->\r\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\r\n <button\r\n (click)=\"removeFilter(i)\"\r\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\r\n matTooltip=\"Remover filtro\"\r\n >\r\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- PANEL FOOTER: Add Filter & Action Buttons -->\r\n <div\r\n class=\"-mb-2 flex items-start justify-between gap-4 border-t border-gray-200 pt-4\"\r\n >\r\n <!-- Add Filter Button -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <button\r\n (click)=\"addFilter()\"\r\n class=\"transform rounded-full border-2 border-blue-300 bg-blue-50 px-6 py-2 text-sm font-medium text-blue-600 transition-all duration-300 hover:-translate-y-0.5 hover:border-blue-400 hover:bg-blue-100 hover:shadow-md\"\r\n matTooltip=\"Adicionar novo filtro\"\r\n >\r\n <i class=\"fa fa-plus mr-2\"></i>\r\n Adicionar Filtro\r\n </button>\r\n </div>\r\n\r\n <!-- Right Side: Search, Reset, Export -->\r\n <div\r\n class=\"flex flex-wrap gap-3 self-start sm:self-auto\"\r\n *ngIf=\"\r\n this.hasFilterableColumn === true || this.hasSortableColumn === true\r\n \"\r\n >\r\n <button\r\n (click)=\"search()\"\r\n type=\"button\"\r\n class=\"flex items-center gap-2 rounded-lg bg-green-600 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-green-700\"\r\n matTooltip=\"Aplicar filtros\"\r\n >\r\n <i class=\"fa fa-search\"></i>\r\n Pesquisar\r\n </button>\r\n\r\n <button\r\n (click)=\"resetFilter()\"\r\n class=\"flex items-center gap-2 rounded-lg bg-red-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600\"\r\n matTooltip=\"Limpar filtros\"\r\n >\r\n <i class=\"fas fa-redo-alt\"></i>\r\n Resetar\r\n </button>\r\n\r\n <button\r\n *ngIf=\"data.download !== false && downloadTable\"\r\n class=\"flex items-center gap-2 rounded-lg bg-orange-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-orange-600\"\r\n matTooltipPosition=\"above\"\r\n matTooltip=\"Exportar Tabela\"\r\n [disabled]=\"\r\n this.dataSource && this.dataSource.filteredData.length <= 0\r\n \"\r\n (click)=\"\r\n $any(arrange) && downloadTable !== undefined\r\n ? downloadTable($any(arrange), data.conditions || [])\r\n : null\r\n \"\r\n >\r\n <i class=\"fa fa-download\"></i>\r\n Exportar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- UNIFIED CONTROL PANEL (for non-paginated tables): SEARCH, SORT & FILTERS -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"\r\n data.pagination === false &&\r\n (hasFilterableColumn === true ||\r\n dropdownItems.length > 0 ||\r\n data.actionButton)\r\n \"\r\n >\r\n <!-- PANEL HEADER: Title and Custom Action -->\r\n <div\r\n class=\"mb-4 flex flex-col items-start justify-between gap-4 border-b-2 border-gray-200 pb-4 md:flex-row md:items-center\"\r\n >\r\n <!-- Left Side: Title & Main Action Button -->\r\n <div class=\"flex flex-wrap items-center gap-4\">\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\r\n <span class=\"text-lg font-semibold text-gray-700\"\r\n >Filtros e A\u00E7\u00F5es</span\r\n >\r\n </div>\r\n <button\r\n *ngIf=\"data.actionButton && data.actionButton.condition\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\r\n \"\r\n [routerLink]=\"data.actionButton.routerLink\"\r\n (click)=\"\r\n data.actionButton.method ? data.actionButton.method($event) : null\r\n \"\r\n >\r\n <i\r\n *ngIf=\"data.actionButton.icon\"\r\n [class]=\"data.actionButton.icon\"\r\n ></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <!-- SIMPLE SEARCH -->\r\n <div\r\n class=\"mb-4\"\r\n *ngIf=\"hasFilterableColumn === true && data.showSimpleSearch !== false\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-blue-500\"></i>\r\n Buscar\r\n </mat-label>\r\n <input\r\n matInput\r\n (keyup.enter)=\"search($event)\"\r\n (keyup)=\"applyFilter(filterInput.value)\"\r\n placeholder=\"Digite para filtrar...\"\r\n #filterInput\r\n />\r\n <mat-icon matSuffix class=\"text-gray-500\">search</mat-icon>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- FILTERS PANEL -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <!-- FILTERS CONTENT -->\r\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\r\n <div\r\n [formGroup]=\"$any(filterGroup)\"\r\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\r\n class=\"flex flex-wrap items-center gap-3\"\r\n >\r\n <!-- FILTER TYPE SELECTOR -->\r\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Tipo de filtro</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione o tipo...\"\r\n formControlName=\"selectFilter\"\r\n (selectionChange)=\"onSelectFilterChange()\"\r\n >\r\n <mat-option\r\n *ngFor=\"let item of getAvailableFilterOptions()\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i\r\n [class]=\"item.icon || 'fa fa-filter'\"\r\n class=\"text-sm text-blue-500\"\r\n ></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- TEXT FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filter'\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-gray-400\"></i>\r\n <span>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Filtrar\"\r\n }}</span>\r\n </mat-label>\r\n <input\r\n (keyup.enter)=\"search($event)\"\r\n formControlName=\"typeFilter\"\r\n matInput\r\n placeholder=\"Digite para filtrar...\"\r\n #input\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DROPDOWN FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value &&\r\n $any(filterGroup)\r\n .get('selectFilter')\r\n ?.value.hasOwnProperty('items')\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Selecione\"\r\n }}</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione...\"\r\n formControlName=\"selectItem\"\r\n multiple\r\n >\r\n <mat-option\r\n *ngFor=\"\r\n let item of $any(filterGroup).get('selectFilter')?.value\r\n .items\r\n \"\r\n [value]=\"item\"\r\n >\r\n {{ item.label }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DATE FILTER -->\r\n <div\r\n class=\"min-w-[340px] flex-auto\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filterByDate'\r\n \"\r\n >\r\n <div\r\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Inicial</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n matInput\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'initialDate', i)\"\r\n (blur)=\"onDateFilterChange()\"\r\n formControlName=\"initialDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Final</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'finalDate', i)\"\r\n (blur)=\"onDateFilterChange()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- REMOVE FILTER BUTTON -->\r\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\r\n <button\r\n (click)=\"removeFilter(i)\"\r\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\r\n matTooltip=\"Remover filtro\"\r\n >\r\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- PANEL FOOTER: Add Filter & Actions -->\r\n <div\r\n class=\"-mb-2 flex items-start justify-between gap-4 border-t border-gray-200 pt-4\"\r\n >\r\n <!-- Add Filter Button -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <button\r\n (click)=\"addFilter()\"\r\n class=\"transform rounded-full border-2 border-blue-300 bg-blue-50 px-6 py-2 text-sm font-medium text-blue-600 transition-all duration-300 hover:-translate-y-0.5 hover:border-blue-400 hover:bg-blue-100 hover:shadow-md\"\r\n matTooltip=\"Adicionar novo filtro\"\r\n >\r\n <i class=\"fa fa-plus mr-2\"></i>\r\n Adicionar Filtro\r\n </button>\r\n </div>\r\n\r\n <!-- Action Buttons -->\r\n <div\r\n class=\"flex flex-wrap gap-3 self-start sm:self-auto\"\r\n *ngIf=\"\r\n this.hasFilterableColumn === true ||\r\n this.hasSortableColumn === true\r\n \"\r\n >\r\n <button\r\n (click)=\"search()\"\r\n type=\"button\"\r\n class=\"flex items-center gap-2 rounded-lg bg-green-600 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-green-700\"\r\n matTooltip=\"Aplicar filtros\"\r\n >\r\n <i class=\"fa fa-search\"></i>\r\n Pesquisar\r\n </button>\r\n\r\n <button\r\n (click)=\"resetFilter()\"\r\n class=\"flex items-center gap-2 rounded-lg bg-red-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600\"\r\n matTooltip=\"Limpar filtros\"\r\n >\r\n <i class=\"fas fa-redo-alt\"></i>\r\n Resetar\r\n </button>\r\n\r\n <button\r\n *ngIf=\"data.download !== false && downloadTable\"\r\n class=\"flex items-center gap-2 rounded-lg bg-orange-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-orange-600\"\r\n matTooltipPosition=\"above\"\r\n matTooltip=\"Exportar Tabela\"\r\n [disabled]=\"\r\n this.dataSource && this.dataSource.filteredData.length <= 0\r\n \"\r\n (click)=\"handleDownload()\"\r\n >\r\n <i class=\"fa fa-download\"></i>\r\n Exportar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"flex flex-col\">\r\n <!-- TABS COMPONENT -->\r\n <lib-table-tabs\r\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\r\n [tabsData]=\"data.tabs.tabsData\"\r\n [selectedTab]=\"selectedTab\"\r\n (tabSelected)=\"onTabSelected($event)\"\r\n ></lib-table-tabs>\r\n <div\r\n class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl table-container\"\r\n >\r\n <table\r\n mat-table\r\n [dataSource]=\"dataSource\"\r\n matSort\r\n #sort=\"matSort\"\r\n matSortActive=\"createdAt\"\r\n matSortDirection=\"desc\"\r\n >\r\n <ng-container\r\n *ngFor=\"let col of data.displayedColumns; trackBy: trackByProperty\"\r\n matColumnDef=\"{{ col.property }}\"\r\n >\r\n <ng-container *matHeaderCellDef>\r\n <!-- IF THE COLUMN IS NOT SORTABLE, THEN DON'T SHOW THE SORT BUTTONS -->\r\n <th\r\n *ngIf=\"!col.isSortable || data.pagination === true\"\r\n mat-header-cell\r\n >\r\n {{ col.title }}\r\n </th>\r\n <!-- IF THE COLUMN IS SORTABLE, THEN SHOW THE SORT BUTTONS -->\r\n <th\r\n *ngIf=\"col.isSortable && data.pagination === false\"\r\n mat-header-cell\r\n mat-sort-header\r\n >\r\n {{ col.title }}\r\n </th>\r\n <td\r\n mat-cell\r\n *matCellDef=\"let row\"\r\n (click)=\"col.method ? col.method(row) : null\"\r\n (mouseenter)=\"onCellMouseEnter($event, row, col)\"\r\n (mouseleave)=\"onCellMouseLeave()\"\r\n (mousemove)=\"onCellMouseMove($event)\"\r\n >\r\n <!-- CHECK IF THE COLUMN MUST BE DISPLAYED -->\r\n <span *ngIf=\"!col.image && !col.iconClass && !col.method\">\r\n <ng-container>\r\n <span\r\n *ngIf=\"\r\n col.charLimit &&\r\n row[col.property] &&\r\n row[col.property].length > col.charLimit;\r\n else withinLimit\r\n \"\r\n >\r\n <a\r\n *ngIf=\"col.hasLink === true\"\r\n [href]=\"row[col.property]\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </a>\r\n <a\r\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\r\n [href]=\"col.hasLink\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </a>\r\n <span\r\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </span>\r\n </span>\r\n </ng-container>\r\n <ng-template #withinLimit>\r\n <a\r\n *ngIf=\"col.hasLink === true\"\r\n [href]=\"row[col.property]\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </a>\r\n <a\r\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\r\n [href]=\"col.hasLink\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </a>\r\n <span\r\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </span>\r\n </ng-template>\r\n </span>\r\n <!------------------- IMAGE ------------------>\r\n <!-- Imagem com loading -->\r\n <div\r\n *ngIf=\"\r\n col.image && col.image.path && !col.iconClass && !col.method\r\n \"\r\n class=\"relative inline-block\"\r\n >\r\n <mat-spinner\r\n *ngIf=\"isImageLoading(row, col)\"\r\n [diameter]=\"32\"\r\n class=\"absolute inset-0 m-auto\"\r\n ></mat-spinner>\r\n <img\r\n [src]=\"col.image.path + '/' + row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n [class.opacity-0]=\"isImageLoading(row, col)\"\r\n alt=\"\"\r\n (load)=\"onImageLoad(row, col)\"\r\n (error)=\"onImageError($event, row, col, col.image.default)\"\r\n />\r\n </div>\r\n\r\n <!-- Imagem com URL completa e loading -->\r\n <div\r\n *ngIf=\"\r\n col.image && col.image.url && !col.iconClass && !col.method\r\n \"\r\n class=\"relative inline-block\"\r\n >\r\n <mat-spinner\r\n *ngIf=\"isImageLoading(row, col)\"\r\n [diameter]=\"32\"\r\n class=\"absolute inset-0 m-auto\"\r\n ></mat-spinner>\r\n <img\r\n [src]=\"row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n [class.opacity-0]=\"isImageLoading(row, col)\"\r\n alt=\"\"\r\n (load)=\"onImageLoad(row, col)\"\r\n (error)=\"onImageError($event, row, col, col.image.default)\"\r\n />\r\n </div>\r\n <ng-container *ngIf=\"col.iconClass\">\r\n <button\r\n *ngFor=\"let iconClass of col.iconClass\"\r\n (click)=\"\r\n iconClass.buttonMethod\r\n ? iconClass.buttonMethod(row, $event)\r\n : $event.stopPropagation()\r\n \"\r\n >\r\n <span\r\n [ngClass]=\"iconClass.class\"\r\n *ngIf=\"\r\n iconClass.condition === undefined ||\r\n (iconClass.condition !== undefined &&\r\n $any(iconClass.condition)(row))\r\n \"\r\n >{{ iconClass.text }}</span\r\n >\r\n </button>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"columnProperties\"></tr>\r\n <tr\r\n [ngClass]=\"{\r\n 'example-element-row': data.isNotClickable === true,\r\n 'example-element-row cursor-pointer': !data.isNotClickable,\r\n }\"\r\n mat-row\r\n *matRowDef=\"let row; columns: columnProperties\"\r\n (click)=\"goToDetails(row)\"\r\n ></tr>\r\n\r\n <!-- ROW SHOWN WHEN THERE IS NO MATCHING DATA. -->\r\n <tr class=\"mat-row\" *matNoDataRow>\r\n <td *ngIf=\"!(isLoading$ | async)\" class=\"mat-cell p-4\" colspan=\"4\">\r\n Nenhum resultado encontrado para a busca\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <div class=\"flex justify-center\" *ngIf=\"isLoading$ | async\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n\r\n <div class=\"paginator-container\">\r\n <mat-paginator\r\n #paginator\r\n [pageSizeOptions]=\"[25, 50, 100]\"\r\n [pageSize]=\"pageSize\"\r\n [length]=\"totalItems\"\r\n showFirstLastButtons\r\n aria-label=\"Select page of periodic elements\"\r\n (page)=\"onPageChange($event)\"\r\n [ngClass]=\"{\r\n 'hide-length':\r\n ['filter', 'filterByDate', 'equals'].includes(\r\n this.currentArrange\r\n ) || this.data.filterFn,\r\n 'hide-next-button': !hasNextPage && data.pagination === true,\r\n 'hide-last-button':\r\n (!hasNextPage && data.pagination === true) ||\r\n this.data.filterFn,\r\n }\"\r\n >\r\n </mat-paginator>\r\n <div\r\n *ngIf=\"\r\n !(isLoading$ | async) &&\r\n dataSource?.data &&\r\n dataSource.data.length > 0 &&\r\n data?.filterFn\r\n \"\r\n class=\"page-number-display\"\r\n >\r\n {{ currentPageNumber }}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- TOOLTIP PERSONALIZADO -->\r\n <lib-table-tooltip\r\n [state]=\"tooltipState\"\r\n [styles]=\"getTooltipStyles()\"\r\n ></lib-table-tooltip>\r\n</div>\r\n", styles: ["@charset \"UTF-8\";:host{--table-color: #1976d2;--table-text-color: white;--table-header-bg: #1976d2;--table-header-text: white;--table-scrollbar-bg: #f5f5f5;--table-scrollbar-thumb: var(--table-color)}.table-container::-webkit-scrollbar{width:10px;height:10px;background-color:var(--table-scrollbar-bg, #f5f5f5)}.table-container::-webkit-scrollbar-thumb{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));border-radius:5px}.table-container::-webkit-scrollbar-thumb:hover{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));opacity:.8}.overflow-x-auto::-webkit-scrollbar,.overflow-y-auto::-webkit-scrollbar,.overflow-auto::-webkit-scrollbar{width:10px;height:10px;background-color:var(--table-scrollbar-bg, #f5f5f5)}.overflow-x-auto::-webkit-scrollbar-thumb,.overflow-y-auto::-webkit-scrollbar-thumb,.overflow-auto::-webkit-scrollbar-thumb{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));border-radius:5px}.overflow-x-auto::-webkit-scrollbar-thumb:hover,.overflow-y-auto::-webkit-scrollbar-thumb:hover,.overflow-auto::-webkit-scrollbar-thumb:hover{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));opacity:.8}:host ::ng-deep .mat-table .mat-header-cell,:host ::ng-deep .mat-header-cell,:host ::ng-deep th.mat-header-cell,:host ::ng-deep .mat-mdc-table .mat-mdc-header-cell,:host ::ng-deep .mat-mdc-header-cell,:host ::ng-deep th.mat-mdc-header-cell{background-color:var(--table-header-bg, #1976d2)!important;color:var(--table-header-text, white)!important;font-weight:600}::ng-deep .fa-filter,::ng-deep i.fa-filter{color:var(--table-color, #1976d2)!important}::ng-deep .rounded-xl.border{border-color:var(--table-color, #1976d2)!important}::ng-deep .border-gray-200.rounded-xl{border-color:var(--table-color, #1976d2)!important}::ng-deep .mdc-notched-outline__notch{border-right:none!important}.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix{padding-bottom:0}::ng-deep .mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix{padding-bottom:0}.mat-mdc-text-field-wrapper.mdc-text-field--outlined.mdc-text-field--disabled{background:rgba(0,0,0,.15);background-size:1px 100%!important;background-repeat:repeat-x!important}.mdc-text-field--disabled .mdc-text-field__input{color:#525252}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)){transition:all .2s ease;cursor:pointer}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)):hover:not(:disabled){opacity:.9;transform:scale(1.02)}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)):disabled{opacity:.5;cursor:not-allowed;transform:none}::ng-deep .hide-length .mat-mdc-paginator-range-label{display:none}::ng-deep .hide-next-button .mat-mdc-tooltip-trigger.mat-mdc-paginator-navigation-next.mdc-icon-button.mat-mdc-icon-button.mat-unthemed.mat-mdc-button-base{visibility:hidden}::ng-deep .hide-next-button .mat-mdc-tooltip-trigger.mat-mdc-paginator-navigation-last.mdc-icon-button.mat-mdc-icon-button.mat-unthemed.mat-mdc-button-base.ng-star-inserted{visibility:hidden}::ng-deep .mat-mdc-text-field-wrapper.mdc-text-field.ng-tns-c162-1.mdc-text-field--filled{width:25dvw}::ng-deep .custom-filter .mat-mdc-text-field-wrapper{width:20dvw;max-width:300px}button[matTooltip=\"Adicionar novo filtro\"],button:has(i.fa-plus){display:inline-flex;align-items:center;gap:.5rem;border-radius:9999px;border:2px solid #93c5fd;background-color:#dbeafe;padding:.5rem 1.5rem;font-size:.875rem;font-weight:500;color:#2563eb;transition:all .3s;cursor:pointer;transform:translateY(0)}button[matTooltip=\"Adicionar novo filtro\"]:hover,button:has(i.fa-plus):hover{transform:translateY(-2px);border-color:#60a5fa;background-color:#bfdbfe;box-shadow:0 4px 6px #0000001a}button[matTooltip=\"Aplicar filtros\"],button:has(i.fa-search){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#16a34a;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Aplicar filtros\"]:hover,button:has(i.fa-search):hover{background-color:#15803d}button[matTooltip=\"Aplicar filtros\"]:disabled,button:has(i.fa-search):disabled{opacity:.5;cursor:not-allowed}button[matTooltip=\"Limpar filtros\"],button:has(i.fas.fa-redo-alt){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#ef4444;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Limpar filtros\"]:hover,button:has(i.fas.fa-redo-alt):hover{background-color:#dc2626}button[matTooltip=\"Exportar Tabela\"],button:has(i.fa-download){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#f97316;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Exportar Tabela\"]:hover:not(:disabled),button:has(i.fa-download):hover:not(:disabled){background-color:#ea580c}button[matTooltip=\"Exportar Tabela\"]:disabled,button:has(i.fa-download):disabled{opacity:.5;cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i8.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i8.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i8.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i8.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i8.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i9.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i9.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i9.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i9.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i9.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i9.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i9.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i9.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i9.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i9.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: i9.MatNoDataRow, selector: "ng-template[matNoDataRow]" }, { kind: "component", type: i10.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "directive", type: i11.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i11.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: i12.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i12.MatLabel, selector: "mat-label" }, { kind: "directive", type: i12.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i13.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i14.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i15.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i16.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i17.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i18.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: TableTabsComponent, selector: "lib-table-tabs", inputs: ["tabsData", "selectedTab"], outputs: ["tabSelected"] }, { kind: "component", type: TableTooltipComponent, selector: "lib-table-tooltip", inputs: ["state", "styles"] }, { kind: "pipe", type: i1$1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2760
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, decorators: [{
|
|
2761
|
-
type: Component,
|
|
2762
|
-
args: [{ selector: 'lib-table', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div *ngIf=\"data\" class=\"card-body\">\r\n <div class=\"flex flex-col justify-between gap-6\">\r\n <!-- UNIFIED CONTROL PANEL: FILTERS, SORT & ACTIONS -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"\r\n data.pagination === true &&\r\n (dropdownItems.length > 0 ||\r\n sortableDropdownItems.length > 0 ||\r\n data.actionButton)\r\n \"\r\n >\r\n <!-- PANEL HEADER: Title and Custom Action -->\r\n <div\r\n class=\"mb-4 flex flex-col items-start justify-between gap-4 border-b-2 border-gray-200 pb-4 md:flex-row md:items-center\"\r\n >\r\n <!-- Left Side: Title & Main Action Button -->\r\n <div class=\"flex flex-wrap items-center gap-4\">\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\r\n <span class=\"text-lg font-semibold text-gray-700\"\r\n >Filtros e A\u00E7\u00F5es</span\r\n >\r\n </div>\r\n <button\r\n *ngIf=\"data.actionButton && data.actionButton.condition\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\r\n \"\r\n [routerLink]=\"data.actionButton.routerLink\"\r\n (click)=\"\r\n data.actionButton.method ? data.actionButton.method($event) : null\r\n \"\r\n >\r\n <i\r\n *ngIf=\"data.actionButton.icon\"\r\n [class]=\"data.actionButton.icon\"\r\n ></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <!-- SORT FIELD (Integrated with filters) -->\r\n <div class=\"mb-4\" *ngIf=\"sortableDropdownItems.length > 0\">\r\n <div class=\"flex flex-wrap items-center gap-3 p-2\">\r\n <div class=\"min-w-[200px] flex-1\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\r\n <span>Ordenar por</span>\r\n </mat-label>\r\n <mat-select placeholder=\"Selecione...\" [formControl]=\"selectSort\">\r\n <mat-option\r\n *ngFor=\"let item of sortableDropdownItems\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- FILTERS CONTENT (WITH REFINEMENTS) -->\r\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\r\n <div\r\n [formGroup]=\"$any(filterGroup)\"\r\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\r\n class=\"flex flex-wrap items-center gap-3 p-2\"\r\n >\r\n <!-- FILTER TYPE SELECTOR -->\r\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Tipo de filtro</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione o tipo...\"\r\n formControlName=\"selectFilter\"\r\n (selectionChange)=\"onSelectFilterChange()\"\r\n >\r\n <mat-option\r\n *ngFor=\"let item of getAvailableFilterOptions()\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i\r\n [class]=\"item.icon || 'fa fa-filter'\"\r\n class=\"text-sm text-blue-500\"\r\n ></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- TEXT FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-gray-400\"></i>\r\n <span>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Filtrar\"\r\n }}</span>\r\n </mat-label>\r\n <input\r\n (keyup.enter)=\"search($event)\"\r\n formControlName=\"typeFilter\"\r\n matInput\r\n placeholder=\"Digite para filtrar...\"\r\n #input\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DROPDOWN FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value &&\r\n $any(filterGroup)\r\n .get('selectFilter')\r\n ?.value.hasOwnProperty('items')\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Selecione\"\r\n }}</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione...\"\r\n formControlName=\"selectItem\"\r\n multiple\r\n >\r\n <mat-option\r\n *ngFor=\"\r\n let item of $any(filterGroup).get('selectFilter')?.value\r\n .items\r\n \"\r\n [value]=\"item\"\r\n >\r\n {{ item.label }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DATE FILTER -->\r\n <div\r\n class=\"min-w-[340px] flex-auto\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filterByDate'\r\n \"\r\n >\r\n <div\r\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Inicial</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n matInput\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'initialDate', i)\"\r\n formControlName=\"initialDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Final</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'finalDate', i)\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- REMOVE FILTER BUTTON -->\r\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\r\n <button\r\n (click)=\"removeFilter(i)\"\r\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\r\n matTooltip=\"Remover filtro\"\r\n >\r\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- PANEL FOOTER: Add Filter & Action Buttons -->\r\n <div\r\n class=\"-mb-2 flex items-start justify-between gap-4 border-t border-gray-200 pt-4\"\r\n >\r\n <!-- Add Filter Button -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <button\r\n (click)=\"addFilter()\"\r\n class=\"transform rounded-full border-2 border-blue-300 bg-blue-50 px-6 py-2 text-sm font-medium text-blue-600 transition-all duration-300 hover:-translate-y-0.5 hover:border-blue-400 hover:bg-blue-100 hover:shadow-md\"\r\n matTooltip=\"Adicionar novo filtro\"\r\n >\r\n <i class=\"fa fa-plus mr-2\"></i>\r\n Adicionar Filtro\r\n </button>\r\n </div>\r\n\r\n <!-- Right Side: Search, Reset, Export -->\r\n <div\r\n class=\"flex flex-wrap gap-3 self-start sm:self-auto\"\r\n *ngIf=\"\r\n this.hasFilterableColumn === true || this.hasSortableColumn === true\r\n \"\r\n >\r\n <button\r\n (click)=\"search()\"\r\n type=\"button\"\r\n class=\"flex items-center gap-2 rounded-lg bg-green-600 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-green-700\"\r\n matTooltip=\"Aplicar filtros\"\r\n >\r\n <i class=\"fa fa-search\"></i>\r\n Pesquisar\r\n </button>\r\n\r\n <button\r\n (click)=\"resetFilter()\"\r\n class=\"flex items-center gap-2 rounded-lg bg-red-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600\"\r\n matTooltip=\"Limpar filtros\"\r\n >\r\n <i class=\"fas fa-redo-alt\"></i>\r\n Resetar\r\n </button>\r\n\r\n <button\r\n *ngIf=\"data.download !== false && downloadTable\"\r\n class=\"flex items-center gap-2 rounded-lg bg-orange-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-orange-600\"\r\n matTooltipPosition=\"above\"\r\n matTooltip=\"Exportar Tabela\"\r\n [disabled]=\"\r\n this.dataSource && this.dataSource.filteredData.length <= 0\r\n \"\r\n (click)=\"\r\n $any(arrange) && downloadTable !== undefined\r\n ? downloadTable($any(arrange), data.conditions || [])\r\n : null\r\n \"\r\n >\r\n <i class=\"fa fa-download\"></i>\r\n Exportar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- UNIFIED CONTROL PANEL (for non-paginated tables): SEARCH, SORT & FILTERS -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"\r\n data.pagination === false &&\r\n (hasFilterableColumn === true ||\r\n dropdownItems.length > 0 ||\r\n data.actionButton)\r\n \"\r\n >\r\n <!-- PANEL HEADER: Title and Custom Action -->\r\n <div\r\n class=\"mb-4 flex flex-col items-start justify-between gap-4 border-b-2 border-gray-200 pb-4 md:flex-row md:items-center\"\r\n >\r\n <!-- Left Side: Title & Main Action Button -->\r\n <div class=\"flex flex-wrap items-center gap-4\">\r\n <div class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\r\n <span class=\"text-lg font-semibold text-gray-700\"\r\n >Filtros e A\u00E7\u00F5es</span\r\n >\r\n </div>\r\n <button\r\n *ngIf=\"data.actionButton && data.actionButton.condition\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\r\n \"\r\n [routerLink]=\"data.actionButton.routerLink\"\r\n (click)=\"\r\n data.actionButton.method ? data.actionButton.method($event) : null\r\n \"\r\n >\r\n <i\r\n *ngIf=\"data.actionButton.icon\"\r\n [class]=\"data.actionButton.icon\"\r\n ></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <!-- SIMPLE SEARCH -->\r\n <div\r\n class=\"mb-4\"\r\n *ngIf=\"hasFilterableColumn === true && data.showSimpleSearch !== false\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-blue-500\"></i>\r\n Buscar\r\n </mat-label>\r\n <input\r\n matInput\r\n (keyup.enter)=\"search($event)\"\r\n (keyup)=\"applyFilter(filterInput.value)\"\r\n placeholder=\"Digite para filtrar...\"\r\n #filterInput\r\n />\r\n <mat-icon matSuffix class=\"text-gray-500\">search</mat-icon>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- FILTERS PANEL -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <!-- FILTERS CONTENT -->\r\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\r\n <div\r\n [formGroup]=\"$any(filterGroup)\"\r\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\r\n class=\"flex flex-wrap items-center gap-3\"\r\n >\r\n <!-- FILTER TYPE SELECTOR -->\r\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Tipo de filtro</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione o tipo...\"\r\n formControlName=\"selectFilter\"\r\n (selectionChange)=\"onSelectFilterChange()\"\r\n >\r\n <mat-option\r\n *ngFor=\"let item of getAvailableFilterOptions()\"\r\n [value]=\"item\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <i\r\n [class]=\"item.icon || 'fa fa-filter'\"\r\n class=\"text-sm text-blue-500\"\r\n ></i>\r\n <span>{{ item.title }}</span>\r\n </div>\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- TEXT FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filter'\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-search text-gray-400\"></i>\r\n <span>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Filtrar\"\r\n }}</span>\r\n </mat-label>\r\n <input\r\n (keyup.enter)=\"search($event)\"\r\n formControlName=\"typeFilter\"\r\n matInput\r\n placeholder=\"Digite para filtrar...\"\r\n #input\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DROPDOWN FILTER -->\r\n <div\r\n class=\"min-w-[200px] flex-1\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value &&\r\n $any(filterGroup)\r\n .get('selectFilter')\r\n ?.value.hasOwnProperty('items')\r\n \"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>{{\r\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\r\n \"Selecione\"\r\n }}</mat-label>\r\n <mat-select\r\n placeholder=\"Selecione...\"\r\n formControlName=\"selectItem\"\r\n multiple\r\n >\r\n <mat-option\r\n *ngFor=\"\r\n let item of $any(filterGroup).get('selectFilter')?.value\r\n .items\r\n \"\r\n [value]=\"item\"\r\n >\r\n {{ item.label }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- DATE FILTER -->\r\n <div\r\n class=\"min-w-[340px] flex-auto\"\r\n *ngIf=\"\r\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\r\n 'filterByDate'\r\n \"\r\n >\r\n <div\r\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Inicial</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n matInput\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'initialDate', i)\"\r\n (blur)=\"onDateFilterChange()\"\r\n formControlName=\"initialDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n\r\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\r\n <mat-label class=\"flex items-center gap-2\">\r\n <i class=\"fa fa-calendar text-gray-400\"></i>\r\n <span>Data Final</span>\r\n </mat-label>\r\n <input\r\n type=\"text\"\r\n (keydown.enter)=\"search($event)\"\r\n (input)=\"onDateInput($event, 'finalDate', i)\"\r\n (blur)=\"onDateFilterChange()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n placeholder=\"DD/MM/AAAA\"\r\n maxlength=\"10\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- REMOVE FILTER BUTTON -->\r\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\r\n <button\r\n (click)=\"removeFilter(i)\"\r\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\r\n matTooltip=\"Remover filtro\"\r\n >\r\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- PANEL FOOTER: Add Filter & Actions -->\r\n <div\r\n class=\"-mb-2 flex items-start justify-between gap-4 border-t border-gray-200 pt-4\"\r\n >\r\n <!-- Add Filter Button -->\r\n <div *ngIf=\"dropdownItems.length > 0\">\r\n <button\r\n (click)=\"addFilter()\"\r\n class=\"transform rounded-full border-2 border-blue-300 bg-blue-50 px-6 py-2 text-sm font-medium text-blue-600 transition-all duration-300 hover:-translate-y-0.5 hover:border-blue-400 hover:bg-blue-100 hover:shadow-md\"\r\n matTooltip=\"Adicionar novo filtro\"\r\n >\r\n <i class=\"fa fa-plus mr-2\"></i>\r\n Adicionar Filtro\r\n </button>\r\n </div>\r\n\r\n <!-- Action Buttons -->\r\n <div\r\n class=\"flex flex-wrap gap-3 self-start sm:self-auto\"\r\n *ngIf=\"\r\n this.hasFilterableColumn === true ||\r\n this.hasSortableColumn === true\r\n \"\r\n >\r\n <button\r\n (click)=\"search()\"\r\n type=\"button\"\r\n class=\"flex items-center gap-2 rounded-lg bg-green-600 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-green-700\"\r\n matTooltip=\"Aplicar filtros\"\r\n >\r\n <i class=\"fa fa-search\"></i>\r\n Pesquisar\r\n </button>\r\n\r\n <button\r\n (click)=\"resetFilter()\"\r\n class=\"flex items-center gap-2 rounded-lg bg-red-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600\"\r\n matTooltip=\"Limpar filtros\"\r\n >\r\n <i class=\"fas fa-redo-alt\"></i>\r\n Resetar\r\n </button>\r\n\r\n <button\r\n *ngIf=\"data.download !== false && downloadTable\"\r\n class=\"flex items-center gap-2 rounded-lg bg-orange-500 px-5 py-2 text-sm font-medium text-white transition-colors hover:bg-orange-600\"\r\n matTooltipPosition=\"above\"\r\n matTooltip=\"Exportar Tabela\"\r\n [disabled]=\"\r\n this.dataSource && this.dataSource.filteredData.length <= 0\r\n \"\r\n (click)=\"handleDownload()\"\r\n >\r\n <i class=\"fa fa-download\"></i>\r\n Exportar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"flex flex-col\">\r\n <!-- TABS COMPONENT -->\r\n <lib-table-tabs\r\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\r\n [tabsData]=\"data.tabs.tabsData\"\r\n [selectedTab]=\"selectedTab\"\r\n (tabSelected)=\"onTabSelected($event)\"\r\n ></lib-table-tabs>\r\n <div\r\n class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl table-container\"\r\n >\r\n <table\r\n mat-table\r\n [dataSource]=\"dataSource\"\r\n matSort\r\n #sort=\"matSort\"\r\n matSortActive=\"createdAt\"\r\n matSortDirection=\"desc\"\r\n >\r\n <ng-container\r\n *ngFor=\"let col of data.displayedColumns; trackBy: trackByProperty\"\r\n matColumnDef=\"{{ col.property }}\"\r\n >\r\n <ng-container *matHeaderCellDef>\r\n <!-- IF THE COLUMN IS NOT SORTABLE, THEN DON'T SHOW THE SORT BUTTONS -->\r\n <th\r\n *ngIf=\"!col.isSortable || data.pagination === true\"\r\n mat-header-cell\r\n >\r\n {{ col.title }}\r\n </th>\r\n <!-- IF THE COLUMN IS SORTABLE, THEN SHOW THE SORT BUTTONS -->\r\n <th\r\n *ngIf=\"col.isSortable && data.pagination === false\"\r\n mat-header-cell\r\n mat-sort-header\r\n >\r\n {{ col.title }}\r\n </th>\r\n <td\r\n mat-cell\r\n *matCellDef=\"let row\"\r\n (click)=\"col.method ? col.method(row) : null\"\r\n (mouseenter)=\"onCellMouseEnter($event, row, col)\"\r\n (mouseleave)=\"onCellMouseLeave()\"\r\n (mousemove)=\"onCellMouseMove($event)\"\r\n >\r\n <!-- CHECK IF THE COLUMN MUST BE DISPLAYED -->\r\n <span *ngIf=\"!col.image && !col.iconClass && !col.method\">\r\n <ng-container>\r\n <span\r\n *ngIf=\"\r\n col.charLimit &&\r\n row[col.property] &&\r\n row[col.property].length > col.charLimit;\r\n else withinLimit\r\n \"\r\n >\r\n <a\r\n *ngIf=\"col.hasLink === true\"\r\n [href]=\"row[col.property]\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </a>\r\n <a\r\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\r\n [href]=\"col.hasLink\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </a>\r\n <span\r\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\r\n >\r\n {{ getDisplayValue(col, row) }}\r\n </span>\r\n </span>\r\n </ng-container>\r\n <ng-template #withinLimit>\r\n <a\r\n *ngIf=\"col.hasLink === true\"\r\n [href]=\"row[col.property]\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </a>\r\n <a\r\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\r\n [href]=\"col.hasLink\"\r\n target=\"_blank\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </a>\r\n <span\r\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\r\n >\r\n {{ getDisplayValue(col, row, true) }}\r\n </span>\r\n </ng-template>\r\n </span>\r\n <!------------------- IMAGE ------------------>\r\n <!-- Imagem com loading -->\r\n <div\r\n *ngIf=\"\r\n col.image && col.image.path && !col.iconClass && !col.method\r\n \"\r\n class=\"relative inline-block\"\r\n >\r\n <mat-spinner\r\n *ngIf=\"isImageLoading(row, col)\"\r\n [diameter]=\"32\"\r\n class=\"absolute inset-0 m-auto\"\r\n ></mat-spinner>\r\n <img\r\n [src]=\"col.image.path + '/' + row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n [class.opacity-0]=\"isImageLoading(row, col)\"\r\n alt=\"\"\r\n (load)=\"onImageLoad(row, col)\"\r\n (error)=\"onImageError($event, row, col, col.image.default)\"\r\n />\r\n </div>\r\n\r\n <!-- Imagem com URL completa e loading -->\r\n <div\r\n *ngIf=\"\r\n col.image && col.image.url && !col.iconClass && !col.method\r\n \"\r\n class=\"relative inline-block\"\r\n >\r\n <mat-spinner\r\n *ngIf=\"isImageLoading(row, col)\"\r\n [diameter]=\"32\"\r\n class=\"absolute inset-0 m-auto\"\r\n ></mat-spinner>\r\n <img\r\n [src]=\"row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n [class.opacity-0]=\"isImageLoading(row, col)\"\r\n alt=\"\"\r\n (load)=\"onImageLoad(row, col)\"\r\n (error)=\"onImageError($event, row, col, col.image.default)\"\r\n />\r\n </div>\r\n <ng-container *ngIf=\"col.iconClass\">\r\n <button\r\n *ngFor=\"let iconClass of col.iconClass\"\r\n (click)=\"\r\n iconClass.buttonMethod\r\n ? iconClass.buttonMethod(row, $event)\r\n : $event.stopPropagation()\r\n \"\r\n >\r\n <span\r\n [ngClass]=\"iconClass.class\"\r\n *ngIf=\"\r\n iconClass.condition === undefined ||\r\n (iconClass.condition !== undefined &&\r\n $any(iconClass.condition)(row))\r\n \"\r\n >{{ iconClass.text }}</span\r\n >\r\n </button>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"columnProperties\"></tr>\r\n <tr\r\n [ngClass]=\"{\r\n 'example-element-row': data.isNotClickable === true,\r\n 'example-element-row cursor-pointer': !data.isNotClickable,\r\n }\"\r\n mat-row\r\n *matRowDef=\"let row; columns: columnProperties\"\r\n (click)=\"goToDetails(row)\"\r\n ></tr>\r\n\r\n <!-- ROW SHOWN WHEN THERE IS NO MATCHING DATA. -->\r\n <tr class=\"mat-row\" *matNoDataRow>\r\n <td *ngIf=\"!(isLoading$ | async)\" class=\"mat-cell p-4\" colspan=\"4\">\r\n Nenhum resultado encontrado para a busca\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <div class=\"flex justify-center\" *ngIf=\"isLoading$ | async\">\r\n <mat-spinner></mat-spinner>\r\n </div>\r\n\r\n <div class=\"paginator-container\">\r\n <mat-paginator\r\n #paginator\r\n [pageSizeOptions]=\"[25, 50, 100]\"\r\n [pageSize]=\"pageSize\"\r\n [length]=\"totalItems\"\r\n showFirstLastButtons\r\n aria-label=\"Select page of periodic elements\"\r\n (page)=\"onPageChange($event)\"\r\n [ngClass]=\"{\r\n 'hide-length':\r\n ['filter', 'filterByDate', 'equals'].includes(\r\n this.currentArrange\r\n ) || this.data.filterFn,\r\n 'hide-next-button': !hasNextPage && data.pagination === true,\r\n 'hide-last-button':\r\n (!hasNextPage && data.pagination === true) ||\r\n this.data.filterFn,\r\n }\"\r\n >\r\n </mat-paginator>\r\n <div\r\n *ngIf=\"\r\n !(isLoading$ | async) &&\r\n dataSource?.data &&\r\n dataSource.data.length > 0 &&\r\n data?.filterFn\r\n \"\r\n class=\"page-number-display\"\r\n >\r\n {{ currentPageNumber }}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- TOOLTIP PERSONALIZADO -->\r\n <lib-table-tooltip\r\n [state]=\"tooltipState\"\r\n [styles]=\"getTooltipStyles()\"\r\n ></lib-table-tooltip>\r\n</div>\r\n", styles: ["@charset \"UTF-8\";:host{--table-color: #1976d2;--table-text-color: white;--table-header-bg: #1976d2;--table-header-text: white;--table-scrollbar-bg: #f5f5f5;--table-scrollbar-thumb: var(--table-color)}.table-container::-webkit-scrollbar{width:10px;height:10px;background-color:var(--table-scrollbar-bg, #f5f5f5)}.table-container::-webkit-scrollbar-thumb{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));border-radius:5px}.table-container::-webkit-scrollbar-thumb:hover{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));opacity:.8}.overflow-x-auto::-webkit-scrollbar,.overflow-y-auto::-webkit-scrollbar,.overflow-auto::-webkit-scrollbar{width:10px;height:10px;background-color:var(--table-scrollbar-bg, #f5f5f5)}.overflow-x-auto::-webkit-scrollbar-thumb,.overflow-y-auto::-webkit-scrollbar-thumb,.overflow-auto::-webkit-scrollbar-thumb{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));border-radius:5px}.overflow-x-auto::-webkit-scrollbar-thumb:hover,.overflow-y-auto::-webkit-scrollbar-thumb:hover,.overflow-auto::-webkit-scrollbar-thumb:hover{background-color:var(--table-scrollbar-thumb, var(--table-color, #1976d2));opacity:.8}:host ::ng-deep .mat-table .mat-header-cell,:host ::ng-deep .mat-header-cell,:host ::ng-deep th.mat-header-cell,:host ::ng-deep .mat-mdc-table .mat-mdc-header-cell,:host ::ng-deep .mat-mdc-header-cell,:host ::ng-deep th.mat-mdc-header-cell{background-color:var(--table-header-bg, #1976d2)!important;color:var(--table-header-text, white)!important;font-weight:600}::ng-deep .fa-filter,::ng-deep i.fa-filter{color:var(--table-color, #1976d2)!important}::ng-deep .rounded-xl.border{border-color:var(--table-color, #1976d2)!important}::ng-deep .border-gray-200.rounded-xl{border-color:var(--table-color, #1976d2)!important}::ng-deep .mdc-notched-outline__notch{border-right:none!important}.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix{padding-bottom:0}::ng-deep .mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix{padding-bottom:0}.mat-mdc-text-field-wrapper.mdc-text-field--outlined.mdc-text-field--disabled{background:rgba(0,0,0,.15);background-size:1px 100%!important;background-repeat:repeat-x!important}.mdc-text-field--disabled .mdc-text-field__input{color:#525252}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)){transition:all .2s ease;cursor:pointer}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)):hover:not(:disabled){opacity:.9;transform:scale(1.02)}button:not([matTooltip=\"Adicionar novo filtro\"]):not([matTooltip=\"Aplicar filtros\"]):not([matTooltip=\"Limpar filtros\"]):not([matTooltip=\"Exportar Tabela\"]):not(:has(i.fa-plus)):not(:has(i.fa-search)):not(:has(i.fas.fa-redo-alt)):not(:has(i.fa-download)):disabled{opacity:.5;cursor:not-allowed;transform:none}::ng-deep .hide-length .mat-mdc-paginator-range-label{display:none}::ng-deep .hide-next-button .mat-mdc-tooltip-trigger.mat-mdc-paginator-navigation-next.mdc-icon-button.mat-mdc-icon-button.mat-unthemed.mat-mdc-button-base{visibility:hidden}::ng-deep .hide-next-button .mat-mdc-tooltip-trigger.mat-mdc-paginator-navigation-last.mdc-icon-button.mat-mdc-icon-button.mat-unthemed.mat-mdc-button-base.ng-star-inserted{visibility:hidden}::ng-deep .mat-mdc-text-field-wrapper.mdc-text-field.ng-tns-c162-1.mdc-text-field--filled{width:25dvw}::ng-deep .custom-filter .mat-mdc-text-field-wrapper{width:20dvw;max-width:300px}button[matTooltip=\"Adicionar novo filtro\"],button:has(i.fa-plus){display:inline-flex;align-items:center;gap:.5rem;border-radius:9999px;border:2px solid #93c5fd;background-color:#dbeafe;padding:.5rem 1.5rem;font-size:.875rem;font-weight:500;color:#2563eb;transition:all .3s;cursor:pointer;transform:translateY(0)}button[matTooltip=\"Adicionar novo filtro\"]:hover,button:has(i.fa-plus):hover{transform:translateY(-2px);border-color:#60a5fa;background-color:#bfdbfe;box-shadow:0 4px 6px #0000001a}button[matTooltip=\"Aplicar filtros\"],button:has(i.fa-search){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#16a34a;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Aplicar filtros\"]:hover,button:has(i.fa-search):hover{background-color:#15803d}button[matTooltip=\"Aplicar filtros\"]:disabled,button:has(i.fa-search):disabled{opacity:.5;cursor:not-allowed}button[matTooltip=\"Limpar filtros\"],button:has(i.fas.fa-redo-alt){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#ef4444;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Limpar filtros\"]:hover,button:has(i.fas.fa-redo-alt):hover{background-color:#dc2626}button[matTooltip=\"Exportar Tabela\"],button:has(i.fa-download){display:inline-flex;align-items:center;gap:.5rem;border-radius:.5rem;background-color:#f97316;padding:.5rem 1.25rem;font-size:.875rem;font-weight:500;color:#fff;transition:background-color .2s;cursor:pointer;border:none}button[matTooltip=\"Exportar Tabela\"]:hover:not(:disabled),button:has(i.fa-download):hover:not(:disabled){background-color:#ea580c}button[matTooltip=\"Exportar Tabela\"]:disabled,button:has(i.fa-download):disabled{opacity:.5;cursor:not-allowed}\n"] }]
|
|
2763
|
-
}], ctorParameters: function () { return [{ type: i1$2.Router }, { type: TableService }, { type: FilterService }, { type: TooltipService }, { type: PaginationService }, { type: i1.AngularFirestore }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { data: [{
|
|
2764
|
-
type: Input
|
|
2765
|
-
}], downloadTable: [{
|
|
2766
|
-
type: Input
|
|
2767
|
-
}], paginator: [{
|
|
2768
|
-
type: ViewChild,
|
|
2769
|
-
args: [MatPaginator]
|
|
2770
|
-
}], sort: [{
|
|
2771
|
-
type: ViewChild,
|
|
2772
|
-
args: [MatSort]
|
|
2773
|
-
}] } });
|
|
2774
|
-
|
|
2775
|
-
class NgFirebaseTableKxpModule {
|
|
2776
|
-
}
|
|
2777
|
-
NgFirebaseTableKxpModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2778
|
-
NgFirebaseTableKxpModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, declarations: [NgFirebaseTableKxpComponent,
|
|
2779
|
-
TableComponent,
|
|
2780
|
-
TableTabsComponent,
|
|
2781
|
-
TableTooltipComponent], imports: [CommonModule,
|
|
2782
|
-
ReactiveFormsModule,
|
|
2783
|
-
FormsModule,
|
|
2784
|
-
RouterModule,
|
|
2785
|
-
MatTableModule,
|
|
2786
|
-
MatPaginatorModule,
|
|
2787
|
-
MatSortModule,
|
|
2788
|
-
MatFormFieldModule,
|
|
2789
|
-
MatInputModule,
|
|
2790
|
-
MatSelectModule,
|
|
2791
|
-
MatTooltipModule,
|
|
2792
|
-
MatProgressSpinnerModule,
|
|
2793
|
-
MatIconModule,
|
|
2794
|
-
MatDialogModule], exports: [NgFirebaseTableKxpComponent,
|
|
2795
|
-
TableComponent,
|
|
2796
|
-
TableTabsComponent,
|
|
2797
|
-
TableTooltipComponent] });
|
|
2798
|
-
NgFirebaseTableKxpModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, providers: [TableService, FilterService, TooltipService, PaginationService], imports: [CommonModule,
|
|
2799
|
-
ReactiveFormsModule,
|
|
2800
|
-
FormsModule,
|
|
2801
|
-
RouterModule,
|
|
2802
|
-
MatTableModule,
|
|
2803
|
-
MatPaginatorModule,
|
|
2804
|
-
MatSortModule,
|
|
2805
|
-
MatFormFieldModule,
|
|
2806
|
-
MatInputModule,
|
|
2807
|
-
MatSelectModule,
|
|
2808
|
-
MatTooltipModule,
|
|
2809
|
-
MatProgressSpinnerModule,
|
|
2810
|
-
MatIconModule,
|
|
2811
|
-
MatDialogModule] });
|
|
2812
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, decorators: [{
|
|
2813
|
-
type: NgModule,
|
|
2814
|
-
args: [{
|
|
2815
|
-
declarations: [
|
|
2816
|
-
NgFirebaseTableKxpComponent,
|
|
2817
|
-
TableComponent,
|
|
2818
|
-
TableTabsComponent,
|
|
2819
|
-
TableTooltipComponent,
|
|
2820
|
-
],
|
|
2821
|
-
imports: [
|
|
2822
|
-
CommonModule,
|
|
2823
|
-
ReactiveFormsModule,
|
|
2824
|
-
FormsModule,
|
|
2825
|
-
RouterModule,
|
|
2826
|
-
MatTableModule,
|
|
2827
|
-
MatPaginatorModule,
|
|
2828
|
-
MatSortModule,
|
|
2829
|
-
MatFormFieldModule,
|
|
2830
|
-
MatInputModule,
|
|
2831
|
-
MatSelectModule,
|
|
2832
|
-
MatTooltipModule,
|
|
2833
|
-
MatProgressSpinnerModule,
|
|
2834
|
-
MatIconModule,
|
|
2835
|
-
MatDialogModule,
|
|
2836
|
-
],
|
|
2837
|
-
exports: [
|
|
2838
|
-
NgFirebaseTableKxpComponent,
|
|
2839
|
-
TableComponent,
|
|
2840
|
-
TableTabsComponent,
|
|
2841
|
-
TableTooltipComponent,
|
|
2842
|
-
],
|
|
2843
|
-
providers: [TableService, FilterService, TooltipService, PaginationService],
|
|
2844
|
-
}]
|
|
2845
|
-
}] });
|
|
2846
|
-
|
|
2847
|
-
class NgFirebaseTableKxpService {
|
|
2848
|
-
constructor() { }
|
|
2849
|
-
}
|
|
2850
|
-
NgFirebaseTableKxpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2851
|
-
NgFirebaseTableKxpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, providedIn: 'root' });
|
|
2852
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, decorators: [{
|
|
2853
|
-
type: Injectable,
|
|
2854
|
-
args: [{
|
|
2855
|
-
providedIn: 'root',
|
|
2856
|
-
}]
|
|
2857
|
-
}], ctorParameters: function () { return []; } });
|
|
2858
|
-
|
|
2859
|
-
/*
|
|
2860
|
-
* Public API Surface of ng-firebase-table-kxp
|
|
2861
|
-
*/
|
|
2862
|
-
// Main module
|
|
2863
|
-
|
|
2864
|
-
/**
|
|
2865
|
-
* Generated bundle index. Do not edit.
|
|
2866
|
-
*/
|
|
2867
|
-
|
|
2868
|
-
export { FilterService, NgFirebaseTableKxpComponent, NgFirebaseTableKxpModule, NgFirebaseTableKxpService, PaginationService, TABLE_DEFAULTS, TableComponent, TableService, TableTabsComponent, TableTooltipComponent, TooltipService, formatArrayValue, getDisplayValue, getImageKey, getNestedValue, isString, trackByProperty };
|
|
2869
|
-
//# sourceMappingURL=ng-firebase-table-kxp.mjs.map
|