ng-firebase-table-kxp 1.0.11 → 1.0.13
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/README.md +602 -602
- package/esm2020/lib/components/table/table.component.mjs +1092 -1020
- package/esm2020/lib/ng-firebase-table-kxp.component.mjs +11 -11
- package/esm2020/lib/ng-firebase-table-kxp.module.mjs +80 -80
- package/esm2020/lib/ng-firebase-table-kxp.service.mjs +14 -14
- package/esm2020/lib/services/table.service.mjs +1112 -1112
- package/esm2020/lib/types/Table.mjs +2 -2
- package/esm2020/ng-firebase-table-kxp.mjs +4 -4
- package/esm2020/public-api.mjs +15 -15
- package/fesm2015/ng-firebase-table-kxp.mjs +2282 -2208
- package/fesm2015/ng-firebase-table-kxp.mjs.map +1 -1
- package/fesm2020/ng-firebase-table-kxp.mjs +2250 -2178
- package/fesm2020/ng-firebase-table-kxp.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/components/table/table.component.d.ts +120 -118
- package/lib/ng-firebase-table-kxp.component.d.ts +5 -5
- package/lib/ng-firebase-table-kxp.module.d.ts +22 -22
- package/lib/ng-firebase-table-kxp.service.d.ts +6 -6
- package/lib/services/table.service.d.ts +74 -74
- package/lib/types/Table.d.ts +139 -139
- package/package.json +1 -1
- package/public-api.d.ts +6 -6
|
@@ -36,2226 +36,2300 @@ import * as i1 from '@angular/fire/compat/firestore';
|
|
|
36
36
|
import * as i3 from 'ngx-toastr';
|
|
37
37
|
import * as i12 from '@angular/material/core';
|
|
38
38
|
|
|
39
|
-
class NgFirebaseTableKxpComponent {
|
|
40
|
-
}
|
|
41
|
-
NgFirebaseTableKxpComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
42
|
-
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 });
|
|
43
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, decorators: [{
|
|
44
|
-
type: Component,
|
|
45
|
-
args: [{ selector: 'lib-ng-firebase-table-kxp', template: ` <p>ng-firebase-table-kxp works!</p> ` }]
|
|
39
|
+
class NgFirebaseTableKxpComponent {
|
|
40
|
+
}
|
|
41
|
+
NgFirebaseTableKxpComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
42
|
+
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 });
|
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpComponent, decorators: [{
|
|
44
|
+
type: Component,
|
|
45
|
+
args: [{ selector: 'lib-ng-firebase-table-kxp', template: ` <p>ng-firebase-table-kxp works!</p> ` }]
|
|
46
46
|
}] });
|
|
47
47
|
|
|
48
|
-
class TableService {
|
|
49
|
-
constructor(ngFire, dialog, toastr) {
|
|
50
|
-
this.ngFire = ngFire;
|
|
51
|
-
this.dialog = dialog;
|
|
52
|
-
this.toastr = toastr;
|
|
53
|
-
this.operators = {
|
|
54
|
-
'==': (a, b) => a === b,
|
|
55
|
-
'!=': (a, b) => a !== b,
|
|
56
|
-
'>': (a, b) => a > b,
|
|
57
|
-
'<': (a, b) => a < b,
|
|
58
|
-
'>=': (a, b) => a >= b,
|
|
59
|
-
'<=': (a, b) => a <= b,
|
|
60
|
-
in: (a, b) => Array.isArray(b) && b.includes(a),
|
|
61
|
-
'not-in': (a, b) => Array.isArray(b) && !b.includes(a),
|
|
62
|
-
'array-contains': (a, b) => Array.isArray(a) && a.includes(b),
|
|
63
|
-
'array-contains-any': (a, b) => Array.isArray(a) &&
|
|
64
|
-
Array.isArray(b) &&
|
|
65
|
-
b.some((item) => a.includes(item)),
|
|
66
|
-
includes: (a, b) => a.includes(b), // Para strings ou arrays
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
getItems(collection) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
try {
|
|
72
|
-
const querySnapshot = yield collection.get();
|
|
73
|
-
return querySnapshot.docs.map((doc) => {
|
|
74
|
-
return Object.assign(Object.assign({}, doc.data()), { id: doc.id });
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.warn('Collection não encontrada:', error);
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
executeQuery(params) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (params.filterFn) {
|
|
86
|
-
// Lógica com filtro no cliente (filterFn)
|
|
87
|
-
const BATCH_FETCH_SIZE = params.batchSize;
|
|
88
|
-
const GOAL_SIZE = params.batchSize + 1;
|
|
89
|
-
if (params.navigation === 'forward' || params.navigation === 'reload') {
|
|
90
|
-
if (params.navigation === 'reload' && params.doc) {
|
|
91
|
-
params.doc.lastDoc = null;
|
|
92
|
-
}
|
|
93
|
-
let lastDocCursor = params.doc ? params.doc.lastDoc : null;
|
|
94
|
-
let pageResults = [];
|
|
95
|
-
let allFetchedDocs = [];
|
|
96
|
-
let hasMoreDocsInDb = true;
|
|
97
|
-
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
98
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
99
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
100
|
-
if (lastDocCursor) {
|
|
101
|
-
query = query.startAfter(lastDocCursor);
|
|
102
|
-
}
|
|
103
|
-
query = query.limit(BATCH_FETCH_SIZE);
|
|
104
|
-
const snapshot = yield query.get();
|
|
105
|
-
if (snapshot.empty) {
|
|
106
|
-
hasMoreDocsInDb = false;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
lastDocCursor = snapshot.docs[snapshot.docs.length - 1];
|
|
110
|
-
allFetchedDocs.push(...snapshot.docs);
|
|
111
|
-
const batchUsers = snapshot.docs
|
|
112
|
-
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
113
|
-
.filter(params.filterFn);
|
|
114
|
-
pageResults.push(...batchUsers);
|
|
115
|
-
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
116
|
-
hasMoreDocsInDb = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const hasNextPage = pageResults.length > params.batchSize;
|
|
120
|
-
const finalItems = pageResults.slice(0, params.batchSize);
|
|
121
|
-
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
122
|
-
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
123
|
-
return {
|
|
124
|
-
items: finalItems,
|
|
125
|
-
filterLength: null,
|
|
126
|
-
firstDoc: firstDocOfPage,
|
|
127
|
-
lastDoc: lastDocOfPage,
|
|
128
|
-
hasNextPage: hasNextPage,
|
|
129
|
-
hasPreviousPage: !!(params.doc && params.doc.lastDoc) &&
|
|
130
|
-
params.navigation !== 'reload',
|
|
131
|
-
currentClientPageIndex: undefined,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
// Lógica para trás (backward)
|
|
135
|
-
else if (params.navigation === 'backward') {
|
|
136
|
-
if (!params.doc || !params.doc.firstDoc) {
|
|
137
|
-
return {
|
|
138
|
-
items: [],
|
|
139
|
-
filterLength: null,
|
|
140
|
-
firstDoc: null,
|
|
141
|
-
lastDoc: null,
|
|
142
|
-
hasNextPage: true,
|
|
143
|
-
hasPreviousPage: false,
|
|
144
|
-
currentClientPageIndex: undefined,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
let pageResults = [];
|
|
148
|
-
let allFetchedDocs = [];
|
|
149
|
-
let hasMoreDocsInDb = true;
|
|
150
|
-
let boundaryDoc = params.doc.firstDoc;
|
|
151
|
-
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
152
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
153
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
154
|
-
query = query.endBefore(boundaryDoc);
|
|
155
|
-
query = query.limitToLast(BATCH_FETCH_SIZE);
|
|
156
|
-
const snapshot = yield query.get();
|
|
157
|
-
if (snapshot.empty) {
|
|
158
|
-
hasMoreDocsInDb = false;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
boundaryDoc = snapshot.docs[0];
|
|
162
|
-
allFetchedDocs = [...snapshot.docs, ...allFetchedDocs];
|
|
163
|
-
const batchUsers = snapshot.docs
|
|
164
|
-
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
165
|
-
.filter(params.filterFn);
|
|
166
|
-
pageResults = [...batchUsers, ...pageResults];
|
|
167
|
-
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
168
|
-
hasMoreDocsInDb = false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const finalItems = pageResults.slice(0, params.batchSize);
|
|
172
|
-
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
173
|
-
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
174
|
-
return {
|
|
175
|
-
items: finalItems,
|
|
176
|
-
filterLength: null,
|
|
177
|
-
firstDoc: firstDocOfPage,
|
|
178
|
-
lastDoc: lastDocOfPage,
|
|
179
|
-
hasNextPage: true,
|
|
180
|
-
currentClientPageIndex: undefined,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
let items = [];
|
|
186
|
-
let docs = [];
|
|
187
|
-
let hasNextPage = false;
|
|
188
|
-
let filterLength = null;
|
|
189
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
190
|
-
if (params.conditions) {
|
|
191
|
-
params.conditions.forEach((c) => {
|
|
192
|
-
if (c.operator === '!=') {
|
|
193
|
-
query = query.orderBy(c.firestoreProperty);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
198
|
-
if (params.navigation === 'reload') {
|
|
199
|
-
query = query.limit(params.batchSize + 1);
|
|
200
|
-
if (params.doc && params.doc.firstDoc) {
|
|
201
|
-
query = query.startAt(params.doc.firstDoc);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (params.navigation === 'forward') {
|
|
205
|
-
query = query.limit(params.batchSize + 1);
|
|
206
|
-
if (params.doc && params.doc.lastDoc) {
|
|
207
|
-
query = query.startAfter(params.doc.lastDoc);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
// backward
|
|
212
|
-
query = query.limitToLast(params.batchSize + 1);
|
|
213
|
-
if (params.doc && params.doc.firstDoc) {
|
|
214
|
-
query = query.endBefore(params.doc.firstDoc);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const itemCol = yield query.get();
|
|
218
|
-
itemCol.docs.forEach((doc) => docs.push(doc));
|
|
219
|
-
const itemPromises = docs.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
const itemData = item.data();
|
|
221
|
-
items.push(Object.assign({ id: item.id }, itemData));
|
|
222
|
-
}));
|
|
223
|
-
let lastDoc = docs[docs.length - 1] || null;
|
|
224
|
-
let firstDoc = docs[0];
|
|
225
|
-
if ((items.length > params.batchSize && params.navigation === 'forward') ||
|
|
226
|
-
(params.navigation === 'reload' && items.length > params.batchSize)) {
|
|
227
|
-
lastDoc = docs[docs.length - 2] || null;
|
|
228
|
-
items.pop();
|
|
229
|
-
hasNextPage = true;
|
|
230
|
-
}
|
|
231
|
-
if (items.length > params.batchSize && params.navigation === 'backward') {
|
|
232
|
-
firstDoc = docs[1];
|
|
233
|
-
items.shift();
|
|
234
|
-
hasNextPage = true;
|
|
235
|
-
}
|
|
236
|
-
yield Promise.all(itemPromises);
|
|
237
|
-
return {
|
|
238
|
-
items,
|
|
239
|
-
filterLength,
|
|
240
|
-
lastDoc,
|
|
241
|
-
firstDoc,
|
|
242
|
-
hasNextPage,
|
|
243
|
-
currentClientPageIndex: undefined,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
// Fallback para garantir que sempre retornamos algo
|
|
247
|
-
return {
|
|
248
|
-
items: [],
|
|
249
|
-
filterLength: null,
|
|
250
|
-
firstDoc: null,
|
|
251
|
-
lastDoc: null,
|
|
252
|
-
hasNextPage: false,
|
|
253
|
-
currentClientPageIndex: undefined,
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
applyFilters(query, arrange, conditions) {
|
|
258
|
-
if (conditions) {
|
|
259
|
-
conditions.map((cond) => {
|
|
260
|
-
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
let hasFilterSpecificOrderBy = false;
|
|
264
|
-
let appliedOrderByField = null;
|
|
265
|
-
const equalsFilters = arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
266
|
-
const otherFilters = arrange.filters.filter((f) => f.arrange !== 'equals');
|
|
267
|
-
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
268
|
-
const prop = current.filter.property;
|
|
269
|
-
if (!acc[prop]) {
|
|
270
|
-
acc[prop] = [];
|
|
271
|
-
}
|
|
272
|
-
acc[prop].push(current.filter.filtering);
|
|
273
|
-
return acc;
|
|
274
|
-
}, {});
|
|
275
|
-
for (const prop in equalsGroupedByProperty) {
|
|
276
|
-
const values = equalsGroupedByProperty[prop];
|
|
277
|
-
if (values.length > 0) {
|
|
278
|
-
query = query.where(prop, 'in', values);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
otherFilters.forEach((filterItem) => {
|
|
282
|
-
var _a, _b;
|
|
283
|
-
// Aplicar filtragem por busca
|
|
284
|
-
if (((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
285
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property) !== '' &&
|
|
286
|
-
filterItem.arrange === 'filter') {
|
|
287
|
-
query = query
|
|
288
|
-
.where(filterItem.filter.property, '>=', filterItem.filter.filtering.trim().toUpperCase())
|
|
289
|
-
.where(filterItem.filter.property, '<=', filterItem.filter.filtering.trim().toUpperCase() + '\uf8ff');
|
|
290
|
-
if (!hasFilterSpecificOrderBy) {
|
|
291
|
-
query = query.orderBy(filterItem.filter.property);
|
|
292
|
-
hasFilterSpecificOrderBy = true;
|
|
293
|
-
appliedOrderByField = filterItem.filter.property;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
// Aplicar filtro do tipo "filterByDate"
|
|
297
|
-
if (filterItem.dateFilter && filterItem.arrange === 'filterByDate') {
|
|
298
|
-
query = query
|
|
299
|
-
.where(arrange.sortBy.field, '>=', filterItem.dateFilter.initial)
|
|
300
|
-
.where(arrange.sortBy.field, '<=', filterItem.dateFilter.final);
|
|
301
|
-
if (!hasFilterSpecificOrderBy) {
|
|
302
|
-
query = query.orderBy(arrange.sortBy.field);
|
|
303
|
-
hasFilterSpecificOrderBy = true;
|
|
304
|
-
appliedOrderByField = arrange.sortBy.field;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
// Aplicar sortBy
|
|
309
|
-
if (arrange.sortBy && arrange.sortBy.field && arrange.sortBy.order) {
|
|
310
|
-
if (appliedOrderByField !== arrange.sortBy.field) {
|
|
311
|
-
query = query.orderBy(arrange.sortBy.field, arrange.sortBy.order);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return query;
|
|
315
|
-
}
|
|
316
|
-
getIdFilter(params) {
|
|
317
|
-
var _a, _b, _c;
|
|
318
|
-
if (!((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters))
|
|
319
|
-
return null;
|
|
320
|
-
const idFilter = params.arrange.filters.find((f) => {
|
|
321
|
-
var _a, _b;
|
|
322
|
-
return f.arrange === 'filter' &&
|
|
323
|
-
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) === 'id' &&
|
|
324
|
-
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.filtering);
|
|
325
|
-
});
|
|
326
|
-
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;
|
|
327
|
-
}
|
|
328
|
-
getDocumentById(collection, docId) {
|
|
329
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
-
try {
|
|
331
|
-
const docRef = this.ngFire.collection(collection).doc(docId);
|
|
332
|
-
const docSnapshot = yield docRef.get().toPromise();
|
|
333
|
-
if (docSnapshot && docSnapshot.exists) {
|
|
334
|
-
return Object.assign({ id: docSnapshot.id }, docSnapshot.data());
|
|
335
|
-
}
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
console.warn('Erro ao buscar documento por ID:', error);
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
searchByIdPartial(params, searchTerm) {
|
|
345
|
-
var _a, _b, _c, _d;
|
|
346
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
-
const exactMatch = yield this.getDocumentById(params.collection, searchTerm);
|
|
348
|
-
if (exactMatch) {
|
|
349
|
-
if (params.conditions) {
|
|
350
|
-
const operators = this.operators;
|
|
351
|
-
const passesConditions = params.conditions.every((cond) => {
|
|
352
|
-
const operatorFn = operators[cond.operator];
|
|
353
|
-
return operatorFn
|
|
354
|
-
? operatorFn(exactMatch[cond.firestoreProperty], cond.dashProperty)
|
|
355
|
-
: false;
|
|
356
|
-
});
|
|
357
|
-
if (!passesConditions) {
|
|
358
|
-
return {
|
|
359
|
-
items: [],
|
|
360
|
-
filterLength: 0,
|
|
361
|
-
firstDoc: null,
|
|
362
|
-
lastDoc: null,
|
|
363
|
-
hasNextPage: false,
|
|
364
|
-
hasPreviousPage: false,
|
|
365
|
-
currentClientPageIndex: 0,
|
|
366
|
-
totalPages: 0,
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (params.filterFn && !params.filterFn(exactMatch)) {
|
|
371
|
-
return {
|
|
372
|
-
items: [],
|
|
373
|
-
filterLength: 0,
|
|
374
|
-
firstDoc: null,
|
|
375
|
-
lastDoc: null,
|
|
376
|
-
hasNextPage: false,
|
|
377
|
-
hasPreviousPage: false,
|
|
378
|
-
currentClientPageIndex: 0,
|
|
379
|
-
totalPages: 0,
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
items: [exactMatch],
|
|
384
|
-
filterLength: 1,
|
|
385
|
-
firstDoc: null,
|
|
386
|
-
lastDoc: null,
|
|
387
|
-
hasNextPage: false,
|
|
388
|
-
hasPreviousPage: false,
|
|
389
|
-
currentClientPageIndex: 0,
|
|
390
|
-
totalPages: 1,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
const searchTermLower = searchTerm.toLowerCase();
|
|
394
|
-
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'); }) }) });
|
|
395
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
396
|
-
// Aplicar conditions
|
|
397
|
-
if (params.conditions) {
|
|
398
|
-
params.conditions.forEach((cond) => {
|
|
399
|
-
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
// Aplicar sortBy
|
|
403
|
-
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)) {
|
|
404
|
-
query = query.orderBy(params.arrange.sortBy.field, params.arrange.sortBy.order);
|
|
405
|
-
}
|
|
406
|
-
const snapshot = yield query.get();
|
|
407
|
-
let items = snapshot.docs
|
|
408
|
-
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
409
|
-
.filter((item) => item.id.toLowerCase().includes(searchTermLower));
|
|
410
|
-
// Separar equals filters e outros filtros
|
|
411
|
-
const equalsFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
412
|
-
const otherFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => {
|
|
413
|
-
var _a;
|
|
414
|
-
return f.arrange !== 'equals' &&
|
|
415
|
-
(f.arrange !== 'filter' || ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) !== 'id');
|
|
416
|
-
});
|
|
417
|
-
// Aplicar equals filters com lógica OR dentro de cada propriedade
|
|
418
|
-
if (equalsFilters.length > 0) {
|
|
419
|
-
// Agrupar por propriedade para aplicar OR
|
|
420
|
-
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
421
|
-
const prop = f.filter.property;
|
|
422
|
-
if (!acc[prop]) {
|
|
423
|
-
acc[prop] = [];
|
|
424
|
-
}
|
|
425
|
-
acc[prop].push(f.filter.filtering);
|
|
426
|
-
return acc;
|
|
427
|
-
}, {});
|
|
428
|
-
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
429
|
-
items = items.filter((item) => {
|
|
430
|
-
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
431
|
-
return values.includes(item[prop]);
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
// Aplicar outros filtros
|
|
436
|
-
otherFilters.forEach((filterItem) => {
|
|
437
|
-
var _a, _b;
|
|
438
|
-
if (filterItem.arrange === 'filter' &&
|
|
439
|
-
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
440
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
441
|
-
const filterValue = String(filterItem.filter.filtering)
|
|
442
|
-
.trim()
|
|
443
|
-
.toLowerCase();
|
|
444
|
-
items = items.filter((item) => {
|
|
445
|
-
const itemValue = String(item[filterItem.filter.property]).toLowerCase();
|
|
446
|
-
return itemValue.includes(filterValue);
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
// Aplicar filterFn se existir
|
|
451
|
-
if (params.filterFn) {
|
|
452
|
-
items = items.filter(params.filterFn);
|
|
453
|
-
}
|
|
454
|
-
// Paginação
|
|
455
|
-
const pageSize = params.batchSize;
|
|
456
|
-
let currentClientPageIndex = 0;
|
|
457
|
-
if (params.navigation === 'reload') {
|
|
458
|
-
currentClientPageIndex = 0;
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
// Usar o índice passado pelo componente sem incrementar/decrementar
|
|
462
|
-
currentClientPageIndex = params.clientPageIndex || 0;
|
|
463
|
-
}
|
|
464
|
-
const startIndex = currentClientPageIndex * pageSize;
|
|
465
|
-
const endIndex = startIndex + pageSize;
|
|
466
|
-
const paginatedItems = items.slice(startIndex, endIndex);
|
|
467
|
-
const totalPages = Math.ceil(items.length / pageSize);
|
|
468
|
-
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
469
|
-
const hasPreviousPage = currentClientPageIndex > 0;
|
|
470
|
-
return {
|
|
471
|
-
items: paginatedItems,
|
|
472
|
-
filterLength: items.length,
|
|
473
|
-
firstDoc: null,
|
|
474
|
-
lastDoc: null,
|
|
475
|
-
hasNextPage,
|
|
476
|
-
hasPreviousPage,
|
|
477
|
-
currentClientPageIndex,
|
|
478
|
-
totalPages,
|
|
479
|
-
};
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
shouldUseClientSideFallback(params) {
|
|
483
|
-
var _a, _b, _c;
|
|
484
|
-
const hasConditions = params.conditions && params.conditions.length > 0;
|
|
485
|
-
const hasArrangeFilters = ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters) && params.arrange.filters.length > 0;
|
|
486
|
-
const hasSortBy = (_c = (_b = params.arrange) === null || _b === void 0 ? void 0 : _b.sortBy) === null || _c === void 0 ? void 0 : _c.field;
|
|
487
|
-
if (params.filterFn) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
if (hasArrangeFilters) {
|
|
491
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
492
|
-
if (equalsFilters.length > 0) {
|
|
493
|
-
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
494
|
-
if (propertiesSet.size > 1) {
|
|
495
|
-
return true;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
if (hasConditions && hasArrangeFilters && hasSortBy) {
|
|
500
|
-
return true;
|
|
501
|
-
}
|
|
502
|
-
if (hasConditions && hasArrangeFilters) {
|
|
503
|
-
return true;
|
|
504
|
-
}
|
|
505
|
-
if (hasArrangeFilters && params.arrange.filters.length > 1 && hasSortBy) {
|
|
506
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
507
|
-
if (equalsFilters.length > 0) {
|
|
508
|
-
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
509
|
-
if (propertiesSet.size === 1 &&
|
|
510
|
-
equalsFilters.length === params.arrange.filters.length) {
|
|
511
|
-
return false;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return true;
|
|
515
|
-
}
|
|
516
|
-
return false;
|
|
517
|
-
}
|
|
518
|
-
getPaginated(params) {
|
|
519
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
-
const idFilterValue = this.getIdFilter(params);
|
|
521
|
-
if (idFilterValue) {
|
|
522
|
-
const result = yield this.searchByIdPartial(params, idFilterValue);
|
|
523
|
-
return result;
|
|
524
|
-
}
|
|
525
|
-
// Detectar preventivamente se deve usar fallback
|
|
526
|
-
if (this.shouldUseClientSideFallback(params)) {
|
|
527
|
-
yield this.trackMissingIndexPreventive(params.collection, params.arrange, params.conditions);
|
|
528
|
-
const result = yield this.executeClientSideQuery(params);
|
|
529
|
-
console.log('📊 [TABLE] Resultados paginados via fallback client-side:', {
|
|
530
|
-
totalItems: result.filterLength,
|
|
531
|
-
returnedItems: result.items.length,
|
|
532
|
-
hasNextPage: result.hasNextPage,
|
|
533
|
-
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
534
|
-
});
|
|
535
|
-
return result;
|
|
536
|
-
}
|
|
537
|
-
try {
|
|
538
|
-
const result = yield this.executeQuery(params);
|
|
539
|
-
console.log('📊 [TABLE] Resultados paginados via Firestore:', {
|
|
540
|
-
totalItems: result.filterLength || 'N/A',
|
|
541
|
-
returnedItems: result.items.length,
|
|
542
|
-
hasNextPage: result.hasNextPage,
|
|
543
|
-
});
|
|
544
|
-
return result;
|
|
545
|
-
}
|
|
546
|
-
catch (error) {
|
|
547
|
-
if (error && error.code === 'failed-precondition') {
|
|
548
|
-
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
549
|
-
const result = yield this.executeClientSideQuery(params);
|
|
550
|
-
console.log('📊 [TABLE] Resultados paginados via fallback (erro de index):', {
|
|
551
|
-
totalItems: result.filterLength,
|
|
552
|
-
returnedItems: result.items.length,
|
|
553
|
-
hasNextPage: result.hasNextPage,
|
|
554
|
-
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
555
|
-
});
|
|
556
|
-
return result;
|
|
557
|
-
}
|
|
558
|
-
else if (error && error.code === 'invalid-argument') {
|
|
559
|
-
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
560
|
-
const result = yield this.executeClientSideQuery(params);
|
|
561
|
-
console.log('📊 [TABLE] Resultados paginados via fallback (argumento inválido):', {
|
|
562
|
-
totalItems: result.filterLength,
|
|
563
|
-
returnedItems: result.items.length,
|
|
564
|
-
hasNextPage: result.hasNextPage,
|
|
565
|
-
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
566
|
-
});
|
|
567
|
-
return result;
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
throw error;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
executeClientSideQuery(params) {
|
|
576
|
-
var _a, _b, _c;
|
|
577
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
-
// Otimizar usando pelo menos uma cláusula .where() quando possível
|
|
579
|
-
let query = this.ngFire.collection(params.collection).ref;
|
|
580
|
-
let appliedCondition = null;
|
|
581
|
-
let hasAppliedWhereClause = false;
|
|
582
|
-
// Primeiro, tenta aplicar condições simples
|
|
583
|
-
if (params.conditions && params.conditions.length > 0) {
|
|
584
|
-
const simpleCondition = params.conditions.find((cond) => ['==', '>', '<', '>=', '<=', 'in', 'array-contains'].includes(cond.operator));
|
|
585
|
-
if (simpleCondition) {
|
|
586
|
-
query = query.where(simpleCondition.firestoreProperty, simpleCondition.operator, simpleCondition.dashProperty);
|
|
587
|
-
appliedCondition = simpleCondition;
|
|
588
|
-
hasAppliedWhereClause = true;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
// Se não há condições disponíveis, tenta aplicar filtros do arrange
|
|
592
|
-
let appliedFirestoreFilter = null;
|
|
593
|
-
if (!hasAppliedWhereClause && ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters)) {
|
|
594
|
-
// Agrupar equals filters por propriedade
|
|
595
|
-
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
596
|
-
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
597
|
-
const prop = current.filter.property;
|
|
598
|
-
if (!acc[prop]) {
|
|
599
|
-
acc[prop] = [];
|
|
600
|
-
}
|
|
601
|
-
acc[prop].push(current.filter.filtering);
|
|
602
|
-
return acc;
|
|
603
|
-
}, {});
|
|
604
|
-
// Se há apenas UMA propriedade com múltiplos valores, aplicar no Firestore com 'in'
|
|
605
|
-
const properties = Object.keys(equalsGroupedByProperty);
|
|
606
|
-
if (properties.length === 1 && equalsFilters.length > 0) {
|
|
607
|
-
const prop = properties[0];
|
|
608
|
-
const values = equalsGroupedByProperty[prop];
|
|
609
|
-
query = query.where(prop, 'in', values);
|
|
610
|
-
hasAppliedWhereClause = true;
|
|
611
|
-
// Marcar TODOS os equals filters dessa propriedade como aplicados
|
|
612
|
-
appliedFirestoreFilter = 'all-equals';
|
|
613
|
-
}
|
|
614
|
-
else if (properties.length === 0) {
|
|
615
|
-
const otherFilter = params.arrange.filters.find((f) => {
|
|
616
|
-
var _a, _b, _c, _d;
|
|
617
|
-
return (f.arrange === 'filter' &&
|
|
618
|
-
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
619
|
-
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
620
|
-
(f.arrange === 'filterByDate' &&
|
|
621
|
-
((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
622
|
-
((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
623
|
-
});
|
|
624
|
-
if (otherFilter) {
|
|
625
|
-
if (otherFilter.arrange === 'filter' && otherFilter.filter) {
|
|
626
|
-
const filterValue = otherFilter.filter.filtering
|
|
627
|
-
.trim()
|
|
628
|
-
.toUpperCase();
|
|
629
|
-
query = query
|
|
630
|
-
.where(otherFilter.filter.property, '>=', filterValue)
|
|
631
|
-
.where(otherFilter.filter.property, '<=', filterValue + '\uf8ff');
|
|
632
|
-
hasAppliedWhereClause = true;
|
|
633
|
-
appliedFirestoreFilter = otherFilter;
|
|
634
|
-
}
|
|
635
|
-
else if (otherFilter.arrange === 'filterByDate' &&
|
|
636
|
-
otherFilter.dateFilter &&
|
|
637
|
-
((_b = params.arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field)) {
|
|
638
|
-
query = query
|
|
639
|
-
.where(params.arrange.sortBy.field, '>=', otherFilter.dateFilter.initial)
|
|
640
|
-
.where(params.arrange.sortBy.field, '<=', otherFilter.dateFilter.final);
|
|
641
|
-
hasAppliedWhereClause = true;
|
|
642
|
-
appliedFirestoreFilter = otherFilter;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
const allDocsSnapshot = yield query.get();
|
|
648
|
-
let items = allDocsSnapshot.docs.map((doc) => (Object.assign({ id: doc.id }, doc.data())));
|
|
649
|
-
// Aplicar condições restantes
|
|
650
|
-
if (params.conditions) {
|
|
651
|
-
const remainingConditions = params.conditions.filter((cond) => cond !== appliedCondition);
|
|
652
|
-
if (remainingConditions.length > 0) {
|
|
653
|
-
const operators = this.operators;
|
|
654
|
-
items = items.filter((item) => {
|
|
655
|
-
return remainingConditions.every((cond) => {
|
|
656
|
-
const operatorFn = operators[cond.operator];
|
|
657
|
-
return operatorFn
|
|
658
|
-
? operatorFn(item[cond.firestoreProperty], cond.dashProperty)
|
|
659
|
-
: false;
|
|
660
|
-
});
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
const { filters, sortBy } = params.arrange;
|
|
665
|
-
// Track which filter was already applied in Firestore to avoid double filtering
|
|
666
|
-
if (hasAppliedWhereClause && !appliedCondition && ((_c = params.arrange) === null || _c === void 0 ? void 0 : _c.filters)) {
|
|
667
|
-
const equalsFilter = params.arrange.filters.find((f) => { var _a; return f.arrange === 'equals' && ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering); });
|
|
668
|
-
if (equalsFilter) {
|
|
669
|
-
appliedFirestoreFilter = equalsFilter;
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
appliedFirestoreFilter = params.arrange.filters.find((f) => {
|
|
673
|
-
var _a, _b, _c, _d;
|
|
674
|
-
return (f.arrange === 'filter' &&
|
|
675
|
-
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
676
|
-
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
677
|
-
(f.arrange === 'filterByDate' &&
|
|
678
|
-
((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
679
|
-
((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
const equalsFilters = filters.filter((f) => f.arrange === 'equals');
|
|
684
|
-
const otherFilters = filters.filter((f) => f.arrange !== 'equals');
|
|
685
|
-
// Aplicar equals filters no client-side apenas se não foram aplicados no Firestore
|
|
686
|
-
if (appliedFirestoreFilter !== 'all-equals' && equalsFilters.length > 0) {
|
|
687
|
-
// Agrupar por propriedade para aplicar OR dentro de cada propriedade
|
|
688
|
-
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
689
|
-
const prop = f.filter.property;
|
|
690
|
-
if (!acc[prop]) {
|
|
691
|
-
acc[prop] = [];
|
|
692
|
-
}
|
|
693
|
-
acc[prop].push(f.filter.filtering);
|
|
694
|
-
return acc;
|
|
695
|
-
}, {});
|
|
696
|
-
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
697
|
-
// (AND entre propriedades, OR dentro de cada propriedade)
|
|
698
|
-
items = items.filter((item) => {
|
|
699
|
-
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
700
|
-
return values.includes(item[prop]);
|
|
701
|
-
});
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
otherFilters.forEach((filterItem) => {
|
|
705
|
-
var _a, _b, _c, _d;
|
|
706
|
-
if (appliedFirestoreFilter === filterItem) {
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
if (filterItem.arrange === 'filter' &&
|
|
710
|
-
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
711
|
-
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
712
|
-
const filterValue = String(filterItem.filter.filtering)
|
|
713
|
-
.trim()
|
|
714
|
-
.toLowerCase();
|
|
715
|
-
items = items.filter((item) => {
|
|
716
|
-
const itemValue = String(item[filterItem.filter.property]).toLowerCase();
|
|
717
|
-
return itemValue.includes(filterValue);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
if (filterItem.arrange === 'filterByDate' &&
|
|
721
|
-
((_c = filterItem.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
722
|
-
((_d = filterItem.dateFilter) === null || _d === void 0 ? void 0 : _d.final) &&
|
|
723
|
-
sortBy.field) {
|
|
724
|
-
items = items.filter((item) => {
|
|
725
|
-
try {
|
|
726
|
-
const fieldValue = item[sortBy.field];
|
|
727
|
-
if (!fieldValue) {
|
|
728
|
-
return false;
|
|
729
|
-
}
|
|
730
|
-
let itemDate;
|
|
731
|
-
if (typeof fieldValue.toDate === 'function') {
|
|
732
|
-
itemDate = fieldValue.toDate();
|
|
733
|
-
}
|
|
734
|
-
else if (fieldValue instanceof Date) {
|
|
735
|
-
itemDate = fieldValue;
|
|
736
|
-
}
|
|
737
|
-
else if (typeof fieldValue === 'string') {
|
|
738
|
-
itemDate = new Date(fieldValue);
|
|
739
|
-
if (isNaN(itemDate.getTime())) {
|
|
740
|
-
return false;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
else if (typeof fieldValue === 'number') {
|
|
744
|
-
itemDate = new Date(fieldValue);
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
return false;
|
|
748
|
-
}
|
|
749
|
-
return (itemDate >= filterItem.dateFilter.initial &&
|
|
750
|
-
itemDate <= filterItem.dateFilter.final);
|
|
751
|
-
}
|
|
752
|
-
catch (error) {
|
|
753
|
-
console.warn('Erro ao processar filtro de data para o item:', item.id, error);
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
// Aplicar filterFn se existir
|
|
760
|
-
if (params.filterFn) {
|
|
761
|
-
items = items.filter(params.filterFn);
|
|
762
|
-
}
|
|
763
|
-
if (sortBy && sortBy.field && sortBy.order) {
|
|
764
|
-
items.sort((a, b) => {
|
|
765
|
-
const valA = a[sortBy.field];
|
|
766
|
-
const valB = b[sortBy.field];
|
|
767
|
-
if (valA < valB) {
|
|
768
|
-
return sortBy.order === 'asc' ? -1 : 1;
|
|
769
|
-
}
|
|
770
|
-
if (valA > valB) {
|
|
771
|
-
return sortBy.order === 'asc' ? 1 : -1;
|
|
772
|
-
}
|
|
773
|
-
return 0;
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
// Implementação adequada da paginação
|
|
777
|
-
let currentClientPageIndex = 0;
|
|
778
|
-
// Determinar a página atual baseada na navegação
|
|
779
|
-
if (params.navigation === 'reload') {
|
|
780
|
-
currentClientPageIndex = 0;
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
currentClientPageIndex = params.clientPageIndex || 0;
|
|
784
|
-
}
|
|
785
|
-
const pageSize = params.batchSize;
|
|
786
|
-
const startIndex = currentClientPageIndex * pageSize;
|
|
787
|
-
const endIndex = startIndex + pageSize;
|
|
788
|
-
const paginatedItems = items.slice(startIndex, endIndex);
|
|
789
|
-
const totalPages = Math.ceil(items.length / pageSize);
|
|
790
|
-
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
791
|
-
const hasPreviousPage = currentClientPageIndex > 0;
|
|
792
|
-
return {
|
|
793
|
-
items: paginatedItems,
|
|
794
|
-
filterLength: items.length,
|
|
795
|
-
lastDoc: null,
|
|
796
|
-
firstDoc: null,
|
|
797
|
-
hasNextPage: hasNextPage,
|
|
798
|
-
hasPreviousPage: hasPreviousPage,
|
|
799
|
-
currentClientPageIndex: currentClientPageIndex,
|
|
800
|
-
totalPages: totalPages,
|
|
801
|
-
};
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
getItemsData(collection, arrange, conditions = undefined) {
|
|
805
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
806
|
-
try {
|
|
807
|
-
let query = this.ngFire.collection(collection).ref;
|
|
808
|
-
query = this.applyFilters(query, arrange, conditions);
|
|
809
|
-
const snapshot = yield query.get();
|
|
810
|
-
return yield Promise.all(snapshot.docs.map((doc) => __awaiter(this, void 0, void 0, function* () {
|
|
811
|
-
const data = doc.data();
|
|
812
|
-
const id = doc.id;
|
|
813
|
-
return Object.assign({ id }, data);
|
|
814
|
-
})));
|
|
815
|
-
}
|
|
816
|
-
catch (e) {
|
|
817
|
-
throw e;
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
deleteIndex(id, col) {
|
|
822
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
823
|
-
try {
|
|
824
|
-
const batch = this.ngFire.firestore.batch();
|
|
825
|
-
const docRef = this.ngFire.collection(col).doc(id);
|
|
826
|
-
const docSnapshot = (yield firstValueFrom(docRef.get()));
|
|
827
|
-
const doc = docSnapshot.data();
|
|
828
|
-
batch.delete(docRef.ref);
|
|
829
|
-
if (doc && typeof doc.index === 'number') {
|
|
830
|
-
yield this.reindex(doc.index, col, batch);
|
|
831
|
-
}
|
|
832
|
-
yield batch.commit();
|
|
833
|
-
this.toastr.success('Item excluído com sucesso!');
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
catch (e) {
|
|
837
|
-
const error = e;
|
|
838
|
-
console.error('Erro ao deletar item:', error);
|
|
839
|
-
this.toastr.error('Erro ao deletar item.');
|
|
840
|
-
return false;
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
reindex(index, col, batch) {
|
|
845
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
846
|
-
try {
|
|
847
|
-
const snapshot = (yield firstValueFrom(this.ngFire.collection(col).get()));
|
|
848
|
-
const docs = snapshot.docs;
|
|
849
|
-
for (let doc of docs) {
|
|
850
|
-
const data = doc.data();
|
|
851
|
-
if (data && typeof data.index === 'number' && data.index > index) {
|
|
852
|
-
data.index--;
|
|
853
|
-
const docRef = this.ngFire.collection(col).doc(doc.id).ref;
|
|
854
|
-
batch.update(docRef, data);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
catch (error) {
|
|
859
|
-
console.error('Erro ao reindexar:', error);
|
|
860
|
-
}
|
|
861
|
-
return;
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
dateFormatValidator() {
|
|
865
|
-
return (control) => {
|
|
866
|
-
if (!control.value) {
|
|
867
|
-
return null;
|
|
868
|
-
}
|
|
869
|
-
const dateStr = control.value.trim();
|
|
870
|
-
const datePattern = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
871
|
-
if (!datePattern.test(dateStr)) {
|
|
872
|
-
return { invalidFormat: true };
|
|
873
|
-
}
|
|
874
|
-
const parts = dateStr.split('/');
|
|
875
|
-
const day = parts[0].padStart(2, '0');
|
|
876
|
-
const month = parts[1].padStart(2, '0');
|
|
877
|
-
const year = parts[2];
|
|
878
|
-
const normalizedDate = `${day}/${month}/${year}`;
|
|
879
|
-
const date = moment(normalizedDate, 'DD/MM/YYYY', true);
|
|
880
|
-
if (!date.isValid()) {
|
|
881
|
-
return { invalidDate: true };
|
|
882
|
-
}
|
|
883
|
-
return null;
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
updateIndex(index, id, col) {
|
|
887
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
888
|
-
yield this.ngFire.collection(col).doc(id).update({ index });
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Extrai o link de criação de índice da mensagem de erro do Firestore
|
|
893
|
-
*/
|
|
894
|
-
extractIndexLink(error) {
|
|
895
|
-
if (!error || !error.message)
|
|
896
|
-
return null;
|
|
897
|
-
const linkMatch = error.message.match(/(https:\/\/console\.firebase\.google\.com\/[^\s]+)/);
|
|
898
|
-
return linkMatch ? linkMatch[1] : null;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Rastreia índices ausentes ao usar fallback preventivo
|
|
902
|
-
*/
|
|
903
|
-
trackMissingIndexPreventive(collection, arrange, conditions = undefined) {
|
|
904
|
-
var _a;
|
|
905
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
906
|
-
try {
|
|
907
|
-
const querySignature = this.generateQuerySignature(collection, arrange, conditions);
|
|
908
|
-
const docId = `${collection}_${querySignature}`;
|
|
909
|
-
const indexLink = this.generateIndexLink(collection, arrange, conditions);
|
|
910
|
-
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
911
|
-
const trackingData = {
|
|
912
|
-
collection,
|
|
913
|
-
indexLink,
|
|
914
|
-
indexInstructions,
|
|
915
|
-
arrange: {
|
|
916
|
-
sortBy: arrange.sortBy,
|
|
917
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
918
|
-
var _a, _b;
|
|
919
|
-
return ({
|
|
920
|
-
arrange: f.arrange,
|
|
921
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
922
|
-
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
923
|
-
});
|
|
924
|
-
})) || [],
|
|
925
|
-
},
|
|
926
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
927
|
-
property: c.firestoreProperty,
|
|
928
|
-
operator: c.operator,
|
|
929
|
-
}))) || [],
|
|
930
|
-
errorMessage: `Fallback preventivo usado para a collection ${collection}. A query exigiria índice composto.`,
|
|
931
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
932
|
-
};
|
|
933
|
-
console.log('📄 [INDEX LINK] Dados que serão salvos no documento:', {
|
|
934
|
-
docId,
|
|
935
|
-
collection: trackingData.collection,
|
|
936
|
-
indexLink: trackingData.indexLink,
|
|
937
|
-
arrange: trackingData.arrange,
|
|
938
|
-
conditions: trackingData.conditions,
|
|
939
|
-
errorMessage: trackingData.errorMessage,
|
|
940
|
-
});
|
|
941
|
-
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
942
|
-
const doc = yield docRef.get().toPromise();
|
|
943
|
-
if (doc && doc.exists) {
|
|
944
|
-
yield docRef.update({
|
|
945
|
-
count: firebase.firestore.FieldValue.increment(1),
|
|
946
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
947
|
-
lastError: trackingData.errorMessage,
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
catch (trackingError) {
|
|
955
|
-
console.warn('Falha ao rastrear fallback preventivo:', trackingError);
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* Gera uma assinatura única para uma query
|
|
961
|
-
*/
|
|
962
|
-
generateQuerySignature(collection, arrange, conditions = undefined) {
|
|
963
|
-
var _a;
|
|
964
|
-
const signature = {
|
|
965
|
-
collection,
|
|
966
|
-
sortBy: arrange.sortBy,
|
|
967
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
968
|
-
var _a;
|
|
969
|
-
return ({
|
|
970
|
-
arrange: f.arrange,
|
|
971
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
972
|
-
});
|
|
973
|
-
})) || [],
|
|
974
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
975
|
-
property: c.firestoreProperty,
|
|
976
|
-
operator: c.operator,
|
|
977
|
-
}))) || [],
|
|
978
|
-
};
|
|
979
|
-
return btoa(JSON.stringify(signature))
|
|
980
|
-
.replace(/[^a-zA-Z0-9]/g, '')
|
|
981
|
-
.substring(0, 20);
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Gera instruções claras para criar o índice manualmente
|
|
985
|
-
*/
|
|
986
|
-
generateIndexInstructions(collection, arrange, conditions = undefined) {
|
|
987
|
-
var _a;
|
|
988
|
-
const instructions = {
|
|
989
|
-
summary: '',
|
|
990
|
-
collection: collection,
|
|
991
|
-
fields: [],
|
|
992
|
-
queryExample: '',
|
|
993
|
-
stepByStep: [],
|
|
994
|
-
notes: [],
|
|
995
|
-
};
|
|
996
|
-
const fields = [];
|
|
997
|
-
if (conditions && conditions.length > 0) {
|
|
998
|
-
conditions.forEach((condition) => {
|
|
999
|
-
if (condition.firestoreProperty) {
|
|
1000
|
-
fields.push({
|
|
1001
|
-
field: condition.firestoreProperty,
|
|
1002
|
-
order: 'Ascending',
|
|
1003
|
-
type: 'WHERE clause',
|
|
1004
|
-
operator: condition.operator,
|
|
1005
|
-
description: `Filtrar por ${condition.firestoreProperty} usando operador ${condition.operator}`,
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
if (arrange.filters && arrange.filters.length > 0) {
|
|
1011
|
-
arrange.filters.forEach((filter) => {
|
|
1012
|
-
var _a;
|
|
1013
|
-
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1014
|
-
fields.push({
|
|
1015
|
-
field: filter.filter.property,
|
|
1016
|
-
order: 'Ascending',
|
|
1017
|
-
type: 'WHERE clause (filter)',
|
|
1018
|
-
operator: filter.arrange === 'filter' ? 'CONTAINS' : 'RANGE',
|
|
1019
|
-
description: `Filtrar por ${filter.filter.property} usando filtro ${filter.arrange}`,
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1025
|
-
fields.push({
|
|
1026
|
-
field: arrange.sortBy.field,
|
|
1027
|
-
order: arrange.sortBy.order === 'desc' ? 'Descending' : 'Ascending',
|
|
1028
|
-
type: 'ORDER BY clause',
|
|
1029
|
-
operator: 'N/A',
|
|
1030
|
-
description: `Ordenar resultados por ${arrange.sortBy.field} em ordem ${arrange.sortBy.order}`,
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
instructions.fields = fields;
|
|
1034
|
-
const fieldNames = fields.map((f) => f.field).join(' + ');
|
|
1035
|
-
instructions.summary = `Criar índice composto para ${collection}: ${fieldNames}`;
|
|
1036
|
-
let queryExample = `db.collection('${collection}')`;
|
|
1037
|
-
fields.forEach((field, index) => {
|
|
1038
|
-
if (field.type.includes('WHERE')) {
|
|
1039
|
-
if (field.operator === '==') {
|
|
1040
|
-
queryExample += `\n .where('${field.field}', '==', 'value')`;
|
|
1041
|
-
}
|
|
1042
|
-
else if (field.operator === 'CONTAINS') {
|
|
1043
|
-
queryExample += `\n .where('${field.field}', '>=', 'searchText')`;
|
|
1044
|
-
}
|
|
1045
|
-
else {
|
|
1046
|
-
queryExample += `\n .where('${field.field}', '${field.operator}', 'value')`;
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
const orderByField = fields.find((f) => f.type.includes('ORDER BY'));
|
|
1051
|
-
if (orderByField) {
|
|
1052
|
-
queryExample += `\n .orderBy('${orderByField.field}', '${orderByField.order.toLowerCase()}')`;
|
|
1053
|
-
}
|
|
1054
|
-
instructions.queryExample = queryExample;
|
|
1055
|
-
instructions.stepByStep = [
|
|
1056
|
-
'1. Ir para Firebase Console → Firestore → Indexes',
|
|
1057
|
-
'2. Clicar em "Create Index"',
|
|
1058
|
-
`3. Definir Collection ID: ${collection}`,
|
|
1059
|
-
'4. Configurar campos nesta ORDEM EXATA:',
|
|
1060
|
-
...fields.map((field, index) => ` ${index + 1}. Campo: ${field.field}, Order: ${field.order}, Array: No`),
|
|
1061
|
-
'5. Definir Query scopes: Collection',
|
|
1062
|
-
'6. Clicar em "Create" e aguardar conclusão',
|
|
1063
|
-
];
|
|
1064
|
-
instructions.notes = [
|
|
1065
|
-
'⚠️ A ordem dos campos é CRÍTICA - deve corresponder exatamente à ordem da query',
|
|
1066
|
-
'⚠️ As cláusulas WHERE devem vir ANTES do campo ORDER BY',
|
|
1067
|
-
'⚠️ Este índice só funcionará para queries com esta combinação EXATA de campos',
|
|
1068
|
-
'⚠️ A criação do índice pode levar vários minutos',
|
|
1069
|
-
];
|
|
1070
|
-
return instructions;
|
|
1071
|
-
}
|
|
1072
|
-
/**
|
|
1073
|
-
* Gera um link de índice baseado na estrutura da query
|
|
1074
|
-
*/
|
|
1075
|
-
generateIndexLink(collection, arrange, conditions = undefined) {
|
|
1076
|
-
var _a;
|
|
1077
|
-
try {
|
|
1078
|
-
const indexFields = [];
|
|
1079
|
-
if (conditions && conditions.length > 0) {
|
|
1080
|
-
conditions.forEach((condition) => {
|
|
1081
|
-
if (condition.firestoreProperty) {
|
|
1082
|
-
indexFields.push(condition.firestoreProperty);
|
|
1083
|
-
}
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
if (arrange.filters && arrange.filters.length > 0) {
|
|
1087
|
-
arrange.filters.forEach((filter) => {
|
|
1088
|
-
var _a;
|
|
1089
|
-
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1090
|
-
indexFields.push(filter.filter.property);
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1095
|
-
indexFields.push(arrange.sortBy.field);
|
|
1096
|
-
}
|
|
1097
|
-
if (indexFields.length > 1) {
|
|
1098
|
-
const baseUrl = 'https://console.firebase.google.com/project/toppayy-dev/firestore/indexes';
|
|
1099
|
-
const queryParams = new URLSearchParams({
|
|
1100
|
-
create_composite: `collection=${collection}&fields=${indexFields.join(',')}`,
|
|
1101
|
-
});
|
|
1102
|
-
const finalLink = `${baseUrl}?${queryParams.toString()}`;
|
|
1103
|
-
return finalLink;
|
|
1104
|
-
}
|
|
1105
|
-
return null;
|
|
1106
|
-
}
|
|
1107
|
-
catch (error) {
|
|
1108
|
-
console.warn('Falha ao gerar link de índice:', error);
|
|
1109
|
-
return null;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
trackMissingIndex(error, collection, arrange, conditions = undefined) {
|
|
1113
|
-
var _a;
|
|
1114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1115
|
-
try {
|
|
1116
|
-
const indexLink = this.extractIndexLink(error);
|
|
1117
|
-
if (!indexLink)
|
|
1118
|
-
return;
|
|
1119
|
-
const linkHash = btoa(indexLink)
|
|
1120
|
-
.replace(/[^a-zA-Z0-9]/g, '')
|
|
1121
|
-
.substring(0, 20);
|
|
1122
|
-
const docId = `${collection}_${linkHash}`;
|
|
1123
|
-
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
1124
|
-
const trackingData = {
|
|
1125
|
-
collection,
|
|
1126
|
-
indexLink,
|
|
1127
|
-
indexInstructions,
|
|
1128
|
-
arrange: {
|
|
1129
|
-
sortBy: arrange.sortBy,
|
|
1130
|
-
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
1131
|
-
var _a, _b;
|
|
1132
|
-
return ({
|
|
1133
|
-
arrange: f.arrange,
|
|
1134
|
-
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
1135
|
-
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
1136
|
-
});
|
|
1137
|
-
})) || [],
|
|
1138
|
-
},
|
|
1139
|
-
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
1140
|
-
property: c.firestoreProperty,
|
|
1141
|
-
operator: c.operator,
|
|
1142
|
-
}))) || [],
|
|
1143
|
-
errorMessage: error.message,
|
|
1144
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1145
|
-
};
|
|
1146
|
-
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
1147
|
-
const doc = yield docRef.get().toPromise();
|
|
1148
|
-
if (doc && doc.exists) {
|
|
1149
|
-
yield docRef.update({
|
|
1150
|
-
count: firebase.firestore.FieldValue.increment(1),
|
|
1151
|
-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1152
|
-
lastError: error.message,
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
catch (trackingError) {
|
|
1160
|
-
console.warn('Falha ao rastrear índice ausente:', trackingError);
|
|
1161
|
-
}
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
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 });
|
|
1166
|
-
TableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, providedIn: 'root' });
|
|
1167
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, decorators: [{
|
|
1168
|
-
type: Injectable,
|
|
1169
|
-
args: [{
|
|
1170
|
-
providedIn: 'root',
|
|
1171
|
-
}]
|
|
1172
|
-
}], ctorParameters: function () {
|
|
1173
|
-
return [{ type: i1.AngularFirestore, decorators: [{
|
|
1174
|
-
type: Optional
|
|
1175
|
-
}] }, { type: i2.MatDialog, decorators: [{
|
|
1176
|
-
type: Optional
|
|
1177
|
-
}] }, { type: i3.ToastrService, decorators: [{
|
|
1178
|
-
type: Optional
|
|
1179
|
-
}] }];
|
|
48
|
+
class TableService {
|
|
49
|
+
constructor(ngFire, dialog, toastr) {
|
|
50
|
+
this.ngFire = ngFire;
|
|
51
|
+
this.dialog = dialog;
|
|
52
|
+
this.toastr = toastr;
|
|
53
|
+
this.operators = {
|
|
54
|
+
'==': (a, b) => a === b,
|
|
55
|
+
'!=': (a, b) => a !== b,
|
|
56
|
+
'>': (a, b) => a > b,
|
|
57
|
+
'<': (a, b) => a < b,
|
|
58
|
+
'>=': (a, b) => a >= b,
|
|
59
|
+
'<=': (a, b) => a <= b,
|
|
60
|
+
in: (a, b) => Array.isArray(b) && b.includes(a),
|
|
61
|
+
'not-in': (a, b) => Array.isArray(b) && !b.includes(a),
|
|
62
|
+
'array-contains': (a, b) => Array.isArray(a) && a.includes(b),
|
|
63
|
+
'array-contains-any': (a, b) => Array.isArray(a) &&
|
|
64
|
+
Array.isArray(b) &&
|
|
65
|
+
b.some((item) => a.includes(item)),
|
|
66
|
+
includes: (a, b) => a.includes(b), // Para strings ou arrays
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
getItems(collection) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
try {
|
|
72
|
+
const querySnapshot = yield collection.get();
|
|
73
|
+
return querySnapshot.docs.map((doc) => {
|
|
74
|
+
return Object.assign(Object.assign({}, doc.data()), { id: doc.id });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.warn('Collection não encontrada:', error);
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
executeQuery(params) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (params.filterFn) {
|
|
86
|
+
// Lógica com filtro no cliente (filterFn)
|
|
87
|
+
const BATCH_FETCH_SIZE = params.batchSize;
|
|
88
|
+
const GOAL_SIZE = params.batchSize + 1;
|
|
89
|
+
if (params.navigation === 'forward' || params.navigation === 'reload') {
|
|
90
|
+
if (params.navigation === 'reload' && params.doc) {
|
|
91
|
+
params.doc.lastDoc = null;
|
|
92
|
+
}
|
|
93
|
+
let lastDocCursor = params.doc ? params.doc.lastDoc : null;
|
|
94
|
+
let pageResults = [];
|
|
95
|
+
let allFetchedDocs = [];
|
|
96
|
+
let hasMoreDocsInDb = true;
|
|
97
|
+
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
98
|
+
let query = this.ngFire.collection(params.collection).ref;
|
|
99
|
+
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
100
|
+
if (lastDocCursor) {
|
|
101
|
+
query = query.startAfter(lastDocCursor);
|
|
102
|
+
}
|
|
103
|
+
query = query.limit(BATCH_FETCH_SIZE);
|
|
104
|
+
const snapshot = yield query.get();
|
|
105
|
+
if (snapshot.empty) {
|
|
106
|
+
hasMoreDocsInDb = false;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
lastDocCursor = snapshot.docs[snapshot.docs.length - 1];
|
|
110
|
+
allFetchedDocs.push(...snapshot.docs);
|
|
111
|
+
const batchUsers = snapshot.docs
|
|
112
|
+
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
113
|
+
.filter(params.filterFn);
|
|
114
|
+
pageResults.push(...batchUsers);
|
|
115
|
+
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
116
|
+
hasMoreDocsInDb = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const hasNextPage = pageResults.length > params.batchSize;
|
|
120
|
+
const finalItems = pageResults.slice(0, params.batchSize);
|
|
121
|
+
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
122
|
+
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
123
|
+
return {
|
|
124
|
+
items: finalItems,
|
|
125
|
+
filterLength: null,
|
|
126
|
+
firstDoc: firstDocOfPage,
|
|
127
|
+
lastDoc: lastDocOfPage,
|
|
128
|
+
hasNextPage: hasNextPage,
|
|
129
|
+
hasPreviousPage: !!(params.doc && params.doc.lastDoc) &&
|
|
130
|
+
params.navigation !== 'reload',
|
|
131
|
+
currentClientPageIndex: undefined,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// Lógica para trás (backward)
|
|
135
|
+
else if (params.navigation === 'backward') {
|
|
136
|
+
if (!params.doc || !params.doc.firstDoc) {
|
|
137
|
+
return {
|
|
138
|
+
items: [],
|
|
139
|
+
filterLength: null,
|
|
140
|
+
firstDoc: null,
|
|
141
|
+
lastDoc: null,
|
|
142
|
+
hasNextPage: true,
|
|
143
|
+
hasPreviousPage: false,
|
|
144
|
+
currentClientPageIndex: undefined,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
let pageResults = [];
|
|
148
|
+
let allFetchedDocs = [];
|
|
149
|
+
let hasMoreDocsInDb = true;
|
|
150
|
+
let boundaryDoc = params.doc.firstDoc;
|
|
151
|
+
while (pageResults.length < GOAL_SIZE && hasMoreDocsInDb) {
|
|
152
|
+
let query = this.ngFire.collection(params.collection).ref;
|
|
153
|
+
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
154
|
+
query = query.endBefore(boundaryDoc);
|
|
155
|
+
query = query.limitToLast(BATCH_FETCH_SIZE);
|
|
156
|
+
const snapshot = yield query.get();
|
|
157
|
+
if (snapshot.empty) {
|
|
158
|
+
hasMoreDocsInDb = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
boundaryDoc = snapshot.docs[0];
|
|
162
|
+
allFetchedDocs = [...snapshot.docs, ...allFetchedDocs];
|
|
163
|
+
const batchUsers = snapshot.docs
|
|
164
|
+
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
165
|
+
.filter(params.filterFn);
|
|
166
|
+
pageResults = [...batchUsers, ...pageResults];
|
|
167
|
+
if (snapshot.size < BATCH_FETCH_SIZE) {
|
|
168
|
+
hasMoreDocsInDb = false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const finalItems = pageResults.slice(0, params.batchSize);
|
|
172
|
+
const firstDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[0]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
173
|
+
const lastDocOfPage = allFetchedDocs.find((doc) => { var _a; return doc.id === ((_a = finalItems[finalItems.length - 1]) === null || _a === void 0 ? void 0 : _a.id); }) || null;
|
|
174
|
+
return {
|
|
175
|
+
items: finalItems,
|
|
176
|
+
filterLength: null,
|
|
177
|
+
firstDoc: firstDocOfPage,
|
|
178
|
+
lastDoc: lastDocOfPage,
|
|
179
|
+
hasNextPage: true,
|
|
180
|
+
currentClientPageIndex: undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
let items = [];
|
|
186
|
+
let docs = [];
|
|
187
|
+
let hasNextPage = false;
|
|
188
|
+
let filterLength = null;
|
|
189
|
+
let query = this.ngFire.collection(params.collection).ref;
|
|
190
|
+
if (params.conditions) {
|
|
191
|
+
params.conditions.forEach((c) => {
|
|
192
|
+
if (c.operator === '!=') {
|
|
193
|
+
query = query.orderBy(c.firestoreProperty);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
query = this.applyFilters(query, params.arrange, params.conditions);
|
|
198
|
+
if (params.navigation === 'reload') {
|
|
199
|
+
query = query.limit(params.batchSize + 1);
|
|
200
|
+
if (params.doc && params.doc.firstDoc) {
|
|
201
|
+
query = query.startAt(params.doc.firstDoc);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (params.navigation === 'forward') {
|
|
205
|
+
query = query.limit(params.batchSize + 1);
|
|
206
|
+
if (params.doc && params.doc.lastDoc) {
|
|
207
|
+
query = query.startAfter(params.doc.lastDoc);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// backward
|
|
212
|
+
query = query.limitToLast(params.batchSize + 1);
|
|
213
|
+
if (params.doc && params.doc.firstDoc) {
|
|
214
|
+
query = query.endBefore(params.doc.firstDoc);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const itemCol = yield query.get();
|
|
218
|
+
itemCol.docs.forEach((doc) => docs.push(doc));
|
|
219
|
+
const itemPromises = docs.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
const itemData = item.data();
|
|
221
|
+
items.push(Object.assign({ id: item.id }, itemData));
|
|
222
|
+
}));
|
|
223
|
+
let lastDoc = docs[docs.length - 1] || null;
|
|
224
|
+
let firstDoc = docs[0];
|
|
225
|
+
if ((items.length > params.batchSize && params.navigation === 'forward') ||
|
|
226
|
+
(params.navigation === 'reload' && items.length > params.batchSize)) {
|
|
227
|
+
lastDoc = docs[docs.length - 2] || null;
|
|
228
|
+
items.pop();
|
|
229
|
+
hasNextPage = true;
|
|
230
|
+
}
|
|
231
|
+
if (items.length > params.batchSize && params.navigation === 'backward') {
|
|
232
|
+
firstDoc = docs[1];
|
|
233
|
+
items.shift();
|
|
234
|
+
hasNextPage = true;
|
|
235
|
+
}
|
|
236
|
+
yield Promise.all(itemPromises);
|
|
237
|
+
return {
|
|
238
|
+
items,
|
|
239
|
+
filterLength,
|
|
240
|
+
lastDoc,
|
|
241
|
+
firstDoc,
|
|
242
|
+
hasNextPage,
|
|
243
|
+
currentClientPageIndex: undefined,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
// Fallback para garantir que sempre retornamos algo
|
|
247
|
+
return {
|
|
248
|
+
items: [],
|
|
249
|
+
filterLength: null,
|
|
250
|
+
firstDoc: null,
|
|
251
|
+
lastDoc: null,
|
|
252
|
+
hasNextPage: false,
|
|
253
|
+
currentClientPageIndex: undefined,
|
|
254
|
+
};
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
applyFilters(query, arrange, conditions) {
|
|
258
|
+
if (conditions) {
|
|
259
|
+
conditions.map((cond) => {
|
|
260
|
+
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
let hasFilterSpecificOrderBy = false;
|
|
264
|
+
let appliedOrderByField = null;
|
|
265
|
+
const equalsFilters = arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
266
|
+
const otherFilters = arrange.filters.filter((f) => f.arrange !== 'equals');
|
|
267
|
+
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
268
|
+
const prop = current.filter.property;
|
|
269
|
+
if (!acc[prop]) {
|
|
270
|
+
acc[prop] = [];
|
|
271
|
+
}
|
|
272
|
+
acc[prop].push(current.filter.filtering);
|
|
273
|
+
return acc;
|
|
274
|
+
}, {});
|
|
275
|
+
for (const prop in equalsGroupedByProperty) {
|
|
276
|
+
const values = equalsGroupedByProperty[prop];
|
|
277
|
+
if (values.length > 0) {
|
|
278
|
+
query = query.where(prop, 'in', values);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
otherFilters.forEach((filterItem) => {
|
|
282
|
+
var _a, _b;
|
|
283
|
+
// Aplicar filtragem por busca
|
|
284
|
+
if (((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
285
|
+
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property) !== '' &&
|
|
286
|
+
filterItem.arrange === 'filter') {
|
|
287
|
+
query = query
|
|
288
|
+
.where(filterItem.filter.property, '>=', filterItem.filter.filtering.trim().toUpperCase())
|
|
289
|
+
.where(filterItem.filter.property, '<=', filterItem.filter.filtering.trim().toUpperCase() + '\uf8ff');
|
|
290
|
+
if (!hasFilterSpecificOrderBy) {
|
|
291
|
+
query = query.orderBy(filterItem.filter.property);
|
|
292
|
+
hasFilterSpecificOrderBy = true;
|
|
293
|
+
appliedOrderByField = filterItem.filter.property;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// Aplicar filtro do tipo "filterByDate"
|
|
297
|
+
if (filterItem.dateFilter && filterItem.arrange === 'filterByDate') {
|
|
298
|
+
query = query
|
|
299
|
+
.where(arrange.sortBy.field, '>=', filterItem.dateFilter.initial)
|
|
300
|
+
.where(arrange.sortBy.field, '<=', filterItem.dateFilter.final);
|
|
301
|
+
if (!hasFilterSpecificOrderBy) {
|
|
302
|
+
query = query.orderBy(arrange.sortBy.field);
|
|
303
|
+
hasFilterSpecificOrderBy = true;
|
|
304
|
+
appliedOrderByField = arrange.sortBy.field;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
// Aplicar sortBy
|
|
309
|
+
if (arrange.sortBy && arrange.sortBy.field && arrange.sortBy.order) {
|
|
310
|
+
if (appliedOrderByField !== arrange.sortBy.field) {
|
|
311
|
+
query = query.orderBy(arrange.sortBy.field, arrange.sortBy.order);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return query;
|
|
315
|
+
}
|
|
316
|
+
getIdFilter(params) {
|
|
317
|
+
var _a, _b, _c;
|
|
318
|
+
if (!((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters))
|
|
319
|
+
return null;
|
|
320
|
+
const idFilter = params.arrange.filters.find((f) => {
|
|
321
|
+
var _a, _b;
|
|
322
|
+
return f.arrange === 'filter' &&
|
|
323
|
+
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) === 'id' &&
|
|
324
|
+
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.filtering);
|
|
325
|
+
});
|
|
326
|
+
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;
|
|
327
|
+
}
|
|
328
|
+
getDocumentById(collection, docId) {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
try {
|
|
331
|
+
const docRef = this.ngFire.collection(collection).doc(docId);
|
|
332
|
+
const docSnapshot = yield docRef.get().toPromise();
|
|
333
|
+
if (docSnapshot && docSnapshot.exists) {
|
|
334
|
+
return Object.assign({ id: docSnapshot.id }, docSnapshot.data());
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
console.warn('Erro ao buscar documento por ID:', error);
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
searchByIdPartial(params, searchTerm) {
|
|
345
|
+
var _a, _b, _c, _d;
|
|
346
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
+
const exactMatch = yield this.getDocumentById(params.collection, searchTerm);
|
|
348
|
+
if (exactMatch) {
|
|
349
|
+
if (params.conditions) {
|
|
350
|
+
const operators = this.operators;
|
|
351
|
+
const passesConditions = params.conditions.every((cond) => {
|
|
352
|
+
const operatorFn = operators[cond.operator];
|
|
353
|
+
return operatorFn
|
|
354
|
+
? operatorFn(exactMatch[cond.firestoreProperty], cond.dashProperty)
|
|
355
|
+
: false;
|
|
356
|
+
});
|
|
357
|
+
if (!passesConditions) {
|
|
358
|
+
return {
|
|
359
|
+
items: [],
|
|
360
|
+
filterLength: 0,
|
|
361
|
+
firstDoc: null,
|
|
362
|
+
lastDoc: null,
|
|
363
|
+
hasNextPage: false,
|
|
364
|
+
hasPreviousPage: false,
|
|
365
|
+
currentClientPageIndex: 0,
|
|
366
|
+
totalPages: 0,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (params.filterFn && !params.filterFn(exactMatch)) {
|
|
371
|
+
return {
|
|
372
|
+
items: [],
|
|
373
|
+
filterLength: 0,
|
|
374
|
+
firstDoc: null,
|
|
375
|
+
lastDoc: null,
|
|
376
|
+
hasNextPage: false,
|
|
377
|
+
hasPreviousPage: false,
|
|
378
|
+
currentClientPageIndex: 0,
|
|
379
|
+
totalPages: 0,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
items: [exactMatch],
|
|
384
|
+
filterLength: 1,
|
|
385
|
+
firstDoc: null,
|
|
386
|
+
lastDoc: null,
|
|
387
|
+
hasNextPage: false,
|
|
388
|
+
hasPreviousPage: false,
|
|
389
|
+
currentClientPageIndex: 0,
|
|
390
|
+
totalPages: 1,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const searchTermLower = searchTerm.toLowerCase();
|
|
394
|
+
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'); }) }) });
|
|
395
|
+
let query = this.ngFire.collection(params.collection).ref;
|
|
396
|
+
// Aplicar conditions
|
|
397
|
+
if (params.conditions) {
|
|
398
|
+
params.conditions.forEach((cond) => {
|
|
399
|
+
query = query.where(cond.firestoreProperty, cond.operator, cond.dashProperty);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
// Aplicar sortBy
|
|
403
|
+
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)) {
|
|
404
|
+
query = query.orderBy(params.arrange.sortBy.field, params.arrange.sortBy.order);
|
|
405
|
+
}
|
|
406
|
+
const snapshot = yield query.get();
|
|
407
|
+
let items = snapshot.docs
|
|
408
|
+
.map((doc) => (Object.assign({ id: doc.id }, doc.data())))
|
|
409
|
+
.filter((item) => item.id.toLowerCase().includes(searchTermLower));
|
|
410
|
+
// Separar equals filters e outros filtros
|
|
411
|
+
const equalsFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
412
|
+
const otherFilters = paramsWithoutIdFilter.arrange.filters.filter((f) => {
|
|
413
|
+
var _a;
|
|
414
|
+
return f.arrange !== 'equals' &&
|
|
415
|
+
(f.arrange !== 'filter' || ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) !== 'id');
|
|
416
|
+
});
|
|
417
|
+
// Aplicar equals filters com lógica OR dentro de cada propriedade
|
|
418
|
+
if (equalsFilters.length > 0) {
|
|
419
|
+
// Agrupar por propriedade para aplicar OR
|
|
420
|
+
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
421
|
+
const prop = f.filter.property;
|
|
422
|
+
if (!acc[prop]) {
|
|
423
|
+
acc[prop] = [];
|
|
424
|
+
}
|
|
425
|
+
acc[prop].push(f.filter.filtering);
|
|
426
|
+
return acc;
|
|
427
|
+
}, {});
|
|
428
|
+
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
429
|
+
items = items.filter((item) => {
|
|
430
|
+
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
431
|
+
return values.includes(item[prop]);
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
// Aplicar outros filtros
|
|
436
|
+
otherFilters.forEach((filterItem) => {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
if (filterItem.arrange === 'filter' &&
|
|
439
|
+
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
440
|
+
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
441
|
+
const filterValue = String(filterItem.filter.filtering)
|
|
442
|
+
.trim()
|
|
443
|
+
.toLowerCase();
|
|
444
|
+
items = items.filter((item) => {
|
|
445
|
+
const itemValue = String(item[filterItem.filter.property]).toLowerCase();
|
|
446
|
+
return itemValue.includes(filterValue);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
// Aplicar filterFn se existir
|
|
451
|
+
if (params.filterFn) {
|
|
452
|
+
items = items.filter(params.filterFn);
|
|
453
|
+
}
|
|
454
|
+
// Paginação
|
|
455
|
+
const pageSize = params.batchSize;
|
|
456
|
+
let currentClientPageIndex = 0;
|
|
457
|
+
if (params.navigation === 'reload') {
|
|
458
|
+
currentClientPageIndex = 0;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
// Usar o índice passado pelo componente sem incrementar/decrementar
|
|
462
|
+
currentClientPageIndex = params.clientPageIndex || 0;
|
|
463
|
+
}
|
|
464
|
+
const startIndex = currentClientPageIndex * pageSize;
|
|
465
|
+
const endIndex = startIndex + pageSize;
|
|
466
|
+
const paginatedItems = items.slice(startIndex, endIndex);
|
|
467
|
+
const totalPages = Math.ceil(items.length / pageSize);
|
|
468
|
+
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
469
|
+
const hasPreviousPage = currentClientPageIndex > 0;
|
|
470
|
+
return {
|
|
471
|
+
items: paginatedItems,
|
|
472
|
+
filterLength: items.length,
|
|
473
|
+
firstDoc: null,
|
|
474
|
+
lastDoc: null,
|
|
475
|
+
hasNextPage,
|
|
476
|
+
hasPreviousPage,
|
|
477
|
+
currentClientPageIndex,
|
|
478
|
+
totalPages,
|
|
479
|
+
};
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
shouldUseClientSideFallback(params) {
|
|
483
|
+
var _a, _b, _c;
|
|
484
|
+
const hasConditions = params.conditions && params.conditions.length > 0;
|
|
485
|
+
const hasArrangeFilters = ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters) && params.arrange.filters.length > 0;
|
|
486
|
+
const hasSortBy = (_c = (_b = params.arrange) === null || _b === void 0 ? void 0 : _b.sortBy) === null || _c === void 0 ? void 0 : _c.field;
|
|
487
|
+
if (params.filterFn) {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
if (hasArrangeFilters) {
|
|
491
|
+
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
492
|
+
if (equalsFilters.length > 0) {
|
|
493
|
+
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
494
|
+
if (propertiesSet.size > 1) {
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (hasConditions && hasArrangeFilters && hasSortBy) {
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
502
|
+
if (hasConditions && hasArrangeFilters) {
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
if (hasArrangeFilters && params.arrange.filters.length > 1 && hasSortBy) {
|
|
506
|
+
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
507
|
+
if (equalsFilters.length > 0) {
|
|
508
|
+
const propertiesSet = new Set(equalsFilters.map((f) => f.filter.property));
|
|
509
|
+
if (propertiesSet.size === 1 &&
|
|
510
|
+
equalsFilters.length === params.arrange.filters.length) {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
getPaginated(params) {
|
|
519
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
+
const idFilterValue = this.getIdFilter(params);
|
|
521
|
+
if (idFilterValue) {
|
|
522
|
+
const result = yield this.searchByIdPartial(params, idFilterValue);
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
525
|
+
// Detectar preventivamente se deve usar fallback
|
|
526
|
+
if (this.shouldUseClientSideFallback(params)) {
|
|
527
|
+
yield this.trackMissingIndexPreventive(params.collection, params.arrange, params.conditions);
|
|
528
|
+
const result = yield this.executeClientSideQuery(params);
|
|
529
|
+
console.log('📊 [TABLE] Resultados paginados via fallback client-side:', {
|
|
530
|
+
totalItems: result.filterLength,
|
|
531
|
+
returnedItems: result.items.length,
|
|
532
|
+
hasNextPage: result.hasNextPage,
|
|
533
|
+
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
534
|
+
});
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
const result = yield this.executeQuery(params);
|
|
539
|
+
console.log('📊 [TABLE] Resultados paginados via Firestore:', {
|
|
540
|
+
totalItems: result.filterLength || 'N/A',
|
|
541
|
+
returnedItems: result.items.length,
|
|
542
|
+
hasNextPage: result.hasNextPage,
|
|
543
|
+
});
|
|
544
|
+
return result;
|
|
545
|
+
}
|
|
546
|
+
catch (error) {
|
|
547
|
+
if (error && error.code === 'failed-precondition') {
|
|
548
|
+
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
549
|
+
const result = yield this.executeClientSideQuery(params);
|
|
550
|
+
console.log('📊 [TABLE] Resultados paginados via fallback (erro de index):', {
|
|
551
|
+
totalItems: result.filterLength,
|
|
552
|
+
returnedItems: result.items.length,
|
|
553
|
+
hasNextPage: result.hasNextPage,
|
|
554
|
+
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
555
|
+
});
|
|
556
|
+
return result;
|
|
557
|
+
}
|
|
558
|
+
else if (error && error.code === 'invalid-argument') {
|
|
559
|
+
yield this.trackMissingIndex(error, params.collection, params.arrange, params.conditions);
|
|
560
|
+
const result = yield this.executeClientSideQuery(params);
|
|
561
|
+
console.log('📊 [TABLE] Resultados paginados via fallback (argumento inválido):', {
|
|
562
|
+
totalItems: result.filterLength,
|
|
563
|
+
returnedItems: result.items.length,
|
|
564
|
+
hasNextPage: result.hasNextPage,
|
|
565
|
+
currentPage: (result.currentClientPageIndex || 0) + 1,
|
|
566
|
+
});
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
executeClientSideQuery(params) {
|
|
576
|
+
var _a, _b, _c;
|
|
577
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
+
// Otimizar usando pelo menos uma cláusula .where() quando possível
|
|
579
|
+
let query = this.ngFire.collection(params.collection).ref;
|
|
580
|
+
let appliedCondition = null;
|
|
581
|
+
let hasAppliedWhereClause = false;
|
|
582
|
+
// Primeiro, tenta aplicar condições simples
|
|
583
|
+
if (params.conditions && params.conditions.length > 0) {
|
|
584
|
+
const simpleCondition = params.conditions.find((cond) => ['==', '>', '<', '>=', '<=', 'in', 'array-contains'].includes(cond.operator));
|
|
585
|
+
if (simpleCondition) {
|
|
586
|
+
query = query.where(simpleCondition.firestoreProperty, simpleCondition.operator, simpleCondition.dashProperty);
|
|
587
|
+
appliedCondition = simpleCondition;
|
|
588
|
+
hasAppliedWhereClause = true;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// Se não há condições disponíveis, tenta aplicar filtros do arrange
|
|
592
|
+
let appliedFirestoreFilter = null;
|
|
593
|
+
if (!hasAppliedWhereClause && ((_a = params.arrange) === null || _a === void 0 ? void 0 : _a.filters)) {
|
|
594
|
+
// Agrupar equals filters por propriedade
|
|
595
|
+
const equalsFilters = params.arrange.filters.filter((f) => f.arrange === 'equals' && f.filter);
|
|
596
|
+
const equalsGroupedByProperty = equalsFilters.reduce((acc, current) => {
|
|
597
|
+
const prop = current.filter.property;
|
|
598
|
+
if (!acc[prop]) {
|
|
599
|
+
acc[prop] = [];
|
|
600
|
+
}
|
|
601
|
+
acc[prop].push(current.filter.filtering);
|
|
602
|
+
return acc;
|
|
603
|
+
}, {});
|
|
604
|
+
// Se há apenas UMA propriedade com múltiplos valores, aplicar no Firestore com 'in'
|
|
605
|
+
const properties = Object.keys(equalsGroupedByProperty);
|
|
606
|
+
if (properties.length === 1 && equalsFilters.length > 0) {
|
|
607
|
+
const prop = properties[0];
|
|
608
|
+
const values = equalsGroupedByProperty[prop];
|
|
609
|
+
query = query.where(prop, 'in', values);
|
|
610
|
+
hasAppliedWhereClause = true;
|
|
611
|
+
// Marcar TODOS os equals filters dessa propriedade como aplicados
|
|
612
|
+
appliedFirestoreFilter = 'all-equals';
|
|
613
|
+
}
|
|
614
|
+
else if (properties.length === 0) {
|
|
615
|
+
const otherFilter = params.arrange.filters.find((f) => {
|
|
616
|
+
var _a, _b, _c, _d;
|
|
617
|
+
return (f.arrange === 'filter' &&
|
|
618
|
+
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
619
|
+
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
620
|
+
(f.arrange === 'filterByDate' &&
|
|
621
|
+
((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
622
|
+
((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
623
|
+
});
|
|
624
|
+
if (otherFilter) {
|
|
625
|
+
if (otherFilter.arrange === 'filter' && otherFilter.filter) {
|
|
626
|
+
const filterValue = otherFilter.filter.filtering
|
|
627
|
+
.trim()
|
|
628
|
+
.toUpperCase();
|
|
629
|
+
query = query
|
|
630
|
+
.where(otherFilter.filter.property, '>=', filterValue)
|
|
631
|
+
.where(otherFilter.filter.property, '<=', filterValue + '\uf8ff');
|
|
632
|
+
hasAppliedWhereClause = true;
|
|
633
|
+
appliedFirestoreFilter = otherFilter;
|
|
634
|
+
}
|
|
635
|
+
else if (otherFilter.arrange === 'filterByDate' &&
|
|
636
|
+
otherFilter.dateFilter &&
|
|
637
|
+
((_b = params.arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field)) {
|
|
638
|
+
query = query
|
|
639
|
+
.where(params.arrange.sortBy.field, '>=', otherFilter.dateFilter.initial)
|
|
640
|
+
.where(params.arrange.sortBy.field, '<=', otherFilter.dateFilter.final);
|
|
641
|
+
hasAppliedWhereClause = true;
|
|
642
|
+
appliedFirestoreFilter = otherFilter;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const allDocsSnapshot = yield query.get();
|
|
648
|
+
let items = allDocsSnapshot.docs.map((doc) => (Object.assign({ id: doc.id }, doc.data())));
|
|
649
|
+
// Aplicar condições restantes
|
|
650
|
+
if (params.conditions) {
|
|
651
|
+
const remainingConditions = params.conditions.filter((cond) => cond !== appliedCondition);
|
|
652
|
+
if (remainingConditions.length > 0) {
|
|
653
|
+
const operators = this.operators;
|
|
654
|
+
items = items.filter((item) => {
|
|
655
|
+
return remainingConditions.every((cond) => {
|
|
656
|
+
const operatorFn = operators[cond.operator];
|
|
657
|
+
return operatorFn
|
|
658
|
+
? operatorFn(item[cond.firestoreProperty], cond.dashProperty)
|
|
659
|
+
: false;
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
const { filters, sortBy } = params.arrange;
|
|
665
|
+
// Track which filter was already applied in Firestore to avoid double filtering
|
|
666
|
+
if (hasAppliedWhereClause && !appliedCondition && ((_c = params.arrange) === null || _c === void 0 ? void 0 : _c.filters)) {
|
|
667
|
+
const equalsFilter = params.arrange.filters.find((f) => { var _a; return f.arrange === 'equals' && ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering); });
|
|
668
|
+
if (equalsFilter) {
|
|
669
|
+
appliedFirestoreFilter = equalsFilter;
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
appliedFirestoreFilter = params.arrange.filters.find((f) => {
|
|
673
|
+
var _a, _b, _c, _d;
|
|
674
|
+
return (f.arrange === 'filter' &&
|
|
675
|
+
((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
676
|
+
((_b = f.filter) === null || _b === void 0 ? void 0 : _b.property)) ||
|
|
677
|
+
(f.arrange === 'filterByDate' &&
|
|
678
|
+
((_c = f.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
679
|
+
((_d = f.dateFilter) === null || _d === void 0 ? void 0 : _d.final));
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const equalsFilters = filters.filter((f) => f.arrange === 'equals');
|
|
684
|
+
const otherFilters = filters.filter((f) => f.arrange !== 'equals');
|
|
685
|
+
// Aplicar equals filters no client-side apenas se não foram aplicados no Firestore
|
|
686
|
+
if (appliedFirestoreFilter !== 'all-equals' && equalsFilters.length > 0) {
|
|
687
|
+
// Agrupar por propriedade para aplicar OR dentro de cada propriedade
|
|
688
|
+
const groupedByProperty = equalsFilters.reduce((acc, f) => {
|
|
689
|
+
const prop = f.filter.property;
|
|
690
|
+
if (!acc[prop]) {
|
|
691
|
+
acc[prop] = [];
|
|
692
|
+
}
|
|
693
|
+
acc[prop].push(f.filter.filtering);
|
|
694
|
+
return acc;
|
|
695
|
+
}, {});
|
|
696
|
+
// Filtrar: item deve ter pelo menos um valor de CADA propriedade
|
|
697
|
+
// (AND entre propriedades, OR dentro de cada propriedade)
|
|
698
|
+
items = items.filter((item) => {
|
|
699
|
+
return Object.entries(groupedByProperty).every(([prop, values]) => {
|
|
700
|
+
return values.includes(item[prop]);
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
otherFilters.forEach((filterItem) => {
|
|
705
|
+
var _a, _b, _c, _d;
|
|
706
|
+
if (appliedFirestoreFilter === filterItem) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (filterItem.arrange === 'filter' &&
|
|
710
|
+
((_a = filterItem.filter) === null || _a === void 0 ? void 0 : _a.filtering) &&
|
|
711
|
+
((_b = filterItem.filter) === null || _b === void 0 ? void 0 : _b.property)) {
|
|
712
|
+
const filterValue = String(filterItem.filter.filtering)
|
|
713
|
+
.trim()
|
|
714
|
+
.toLowerCase();
|
|
715
|
+
items = items.filter((item) => {
|
|
716
|
+
const itemValue = String(item[filterItem.filter.property]).toLowerCase();
|
|
717
|
+
return itemValue.includes(filterValue);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
if (filterItem.arrange === 'filterByDate' &&
|
|
721
|
+
((_c = filterItem.dateFilter) === null || _c === void 0 ? void 0 : _c.initial) &&
|
|
722
|
+
((_d = filterItem.dateFilter) === null || _d === void 0 ? void 0 : _d.final) &&
|
|
723
|
+
sortBy.field) {
|
|
724
|
+
items = items.filter((item) => {
|
|
725
|
+
try {
|
|
726
|
+
const fieldValue = item[sortBy.field];
|
|
727
|
+
if (!fieldValue) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
let itemDate;
|
|
731
|
+
if (typeof fieldValue.toDate === 'function') {
|
|
732
|
+
itemDate = fieldValue.toDate();
|
|
733
|
+
}
|
|
734
|
+
else if (fieldValue instanceof Date) {
|
|
735
|
+
itemDate = fieldValue;
|
|
736
|
+
}
|
|
737
|
+
else if (typeof fieldValue === 'string') {
|
|
738
|
+
itemDate = new Date(fieldValue);
|
|
739
|
+
if (isNaN(itemDate.getTime())) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
else if (typeof fieldValue === 'number') {
|
|
744
|
+
itemDate = new Date(fieldValue);
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
return (itemDate >= filterItem.dateFilter.initial &&
|
|
750
|
+
itemDate <= filterItem.dateFilter.final);
|
|
751
|
+
}
|
|
752
|
+
catch (error) {
|
|
753
|
+
console.warn('Erro ao processar filtro de data para o item:', item.id, error);
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
// Aplicar filterFn se existir
|
|
760
|
+
if (params.filterFn) {
|
|
761
|
+
items = items.filter(params.filterFn);
|
|
762
|
+
}
|
|
763
|
+
if (sortBy && sortBy.field && sortBy.order) {
|
|
764
|
+
items.sort((a, b) => {
|
|
765
|
+
const valA = a[sortBy.field];
|
|
766
|
+
const valB = b[sortBy.field];
|
|
767
|
+
if (valA < valB) {
|
|
768
|
+
return sortBy.order === 'asc' ? -1 : 1;
|
|
769
|
+
}
|
|
770
|
+
if (valA > valB) {
|
|
771
|
+
return sortBy.order === 'asc' ? 1 : -1;
|
|
772
|
+
}
|
|
773
|
+
return 0;
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
// Implementação adequada da paginação
|
|
777
|
+
let currentClientPageIndex = 0;
|
|
778
|
+
// Determinar a página atual baseada na navegação
|
|
779
|
+
if (params.navigation === 'reload') {
|
|
780
|
+
currentClientPageIndex = 0;
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
currentClientPageIndex = params.clientPageIndex || 0;
|
|
784
|
+
}
|
|
785
|
+
const pageSize = params.batchSize;
|
|
786
|
+
const startIndex = currentClientPageIndex * pageSize;
|
|
787
|
+
const endIndex = startIndex + pageSize;
|
|
788
|
+
const paginatedItems = items.slice(startIndex, endIndex);
|
|
789
|
+
const totalPages = Math.ceil(items.length / pageSize);
|
|
790
|
+
const hasNextPage = currentClientPageIndex < totalPages - 1;
|
|
791
|
+
const hasPreviousPage = currentClientPageIndex > 0;
|
|
792
|
+
return {
|
|
793
|
+
items: paginatedItems,
|
|
794
|
+
filterLength: items.length,
|
|
795
|
+
lastDoc: null,
|
|
796
|
+
firstDoc: null,
|
|
797
|
+
hasNextPage: hasNextPage,
|
|
798
|
+
hasPreviousPage: hasPreviousPage,
|
|
799
|
+
currentClientPageIndex: currentClientPageIndex,
|
|
800
|
+
totalPages: totalPages,
|
|
801
|
+
};
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
getItemsData(collection, arrange, conditions = undefined) {
|
|
805
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
806
|
+
try {
|
|
807
|
+
let query = this.ngFire.collection(collection).ref;
|
|
808
|
+
query = this.applyFilters(query, arrange, conditions);
|
|
809
|
+
const snapshot = yield query.get();
|
|
810
|
+
return yield Promise.all(snapshot.docs.map((doc) => __awaiter(this, void 0, void 0, function* () {
|
|
811
|
+
const data = doc.data();
|
|
812
|
+
const id = doc.id;
|
|
813
|
+
return Object.assign({ id }, data);
|
|
814
|
+
})));
|
|
815
|
+
}
|
|
816
|
+
catch (e) {
|
|
817
|
+
throw e;
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
deleteIndex(id, col) {
|
|
822
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
823
|
+
try {
|
|
824
|
+
const batch = this.ngFire.firestore.batch();
|
|
825
|
+
const docRef = this.ngFire.collection(col).doc(id);
|
|
826
|
+
const docSnapshot = (yield firstValueFrom(docRef.get()));
|
|
827
|
+
const doc = docSnapshot.data();
|
|
828
|
+
batch.delete(docRef.ref);
|
|
829
|
+
if (doc && typeof doc.index === 'number') {
|
|
830
|
+
yield this.reindex(doc.index, col, batch);
|
|
831
|
+
}
|
|
832
|
+
yield batch.commit();
|
|
833
|
+
this.toastr.success('Item excluído com sucesso!');
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
catch (e) {
|
|
837
|
+
const error = e;
|
|
838
|
+
console.error('Erro ao deletar item:', error);
|
|
839
|
+
this.toastr.error('Erro ao deletar item.');
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
reindex(index, col, batch) {
|
|
845
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
846
|
+
try {
|
|
847
|
+
const snapshot = (yield firstValueFrom(this.ngFire.collection(col).get()));
|
|
848
|
+
const docs = snapshot.docs;
|
|
849
|
+
for (let doc of docs) {
|
|
850
|
+
const data = doc.data();
|
|
851
|
+
if (data && typeof data.index === 'number' && data.index > index) {
|
|
852
|
+
data.index--;
|
|
853
|
+
const docRef = this.ngFire.collection(col).doc(doc.id).ref;
|
|
854
|
+
batch.update(docRef, data);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
catch (error) {
|
|
859
|
+
console.error('Erro ao reindexar:', error);
|
|
860
|
+
}
|
|
861
|
+
return;
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
dateFormatValidator() {
|
|
865
|
+
return (control) => {
|
|
866
|
+
if (!control.value) {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
const dateStr = control.value.trim();
|
|
870
|
+
const datePattern = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
871
|
+
if (!datePattern.test(dateStr)) {
|
|
872
|
+
return { invalidFormat: true };
|
|
873
|
+
}
|
|
874
|
+
const parts = dateStr.split('/');
|
|
875
|
+
const day = parts[0].padStart(2, '0');
|
|
876
|
+
const month = parts[1].padStart(2, '0');
|
|
877
|
+
const year = parts[2];
|
|
878
|
+
const normalizedDate = `${day}/${month}/${year}`;
|
|
879
|
+
const date = moment(normalizedDate, 'DD/MM/YYYY', true);
|
|
880
|
+
if (!date.isValid()) {
|
|
881
|
+
return { invalidDate: true };
|
|
882
|
+
}
|
|
883
|
+
return null;
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
updateIndex(index, id, col) {
|
|
887
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
888
|
+
yield this.ngFire.collection(col).doc(id).update({ index });
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Extrai o link de criação de índice da mensagem de erro do Firestore
|
|
893
|
+
*/
|
|
894
|
+
extractIndexLink(error) {
|
|
895
|
+
if (!error || !error.message)
|
|
896
|
+
return null;
|
|
897
|
+
const linkMatch = error.message.match(/(https:\/\/console\.firebase\.google\.com\/[^\s]+)/);
|
|
898
|
+
return linkMatch ? linkMatch[1] : null;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Rastreia índices ausentes ao usar fallback preventivo
|
|
902
|
+
*/
|
|
903
|
+
trackMissingIndexPreventive(collection, arrange, conditions = undefined) {
|
|
904
|
+
var _a;
|
|
905
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
906
|
+
try {
|
|
907
|
+
const querySignature = this.generateQuerySignature(collection, arrange, conditions);
|
|
908
|
+
const docId = `${collection}_${querySignature}`;
|
|
909
|
+
const indexLink = this.generateIndexLink(collection, arrange, conditions);
|
|
910
|
+
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
911
|
+
const trackingData = {
|
|
912
|
+
collection,
|
|
913
|
+
indexLink,
|
|
914
|
+
indexInstructions,
|
|
915
|
+
arrange: {
|
|
916
|
+
sortBy: arrange.sortBy,
|
|
917
|
+
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
918
|
+
var _a, _b;
|
|
919
|
+
return ({
|
|
920
|
+
arrange: f.arrange,
|
|
921
|
+
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
922
|
+
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
923
|
+
});
|
|
924
|
+
})) || [],
|
|
925
|
+
},
|
|
926
|
+
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
927
|
+
property: c.firestoreProperty,
|
|
928
|
+
operator: c.operator,
|
|
929
|
+
}))) || [],
|
|
930
|
+
errorMessage: `Fallback preventivo usado para a collection ${collection}. A query exigiria índice composto.`,
|
|
931
|
+
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
932
|
+
};
|
|
933
|
+
console.log('📄 [INDEX LINK] Dados que serão salvos no documento:', {
|
|
934
|
+
docId,
|
|
935
|
+
collection: trackingData.collection,
|
|
936
|
+
indexLink: trackingData.indexLink,
|
|
937
|
+
arrange: trackingData.arrange,
|
|
938
|
+
conditions: trackingData.conditions,
|
|
939
|
+
errorMessage: trackingData.errorMessage,
|
|
940
|
+
});
|
|
941
|
+
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
942
|
+
const doc = yield docRef.get().toPromise();
|
|
943
|
+
if (doc && doc.exists) {
|
|
944
|
+
yield docRef.update({
|
|
945
|
+
count: firebase.firestore.FieldValue.increment(1),
|
|
946
|
+
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
947
|
+
lastError: trackingData.errorMessage,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
catch (trackingError) {
|
|
955
|
+
console.warn('Falha ao rastrear fallback preventivo:', trackingError);
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Gera uma assinatura única para uma query
|
|
961
|
+
*/
|
|
962
|
+
generateQuerySignature(collection, arrange, conditions = undefined) {
|
|
963
|
+
var _a;
|
|
964
|
+
const signature = {
|
|
965
|
+
collection,
|
|
966
|
+
sortBy: arrange.sortBy,
|
|
967
|
+
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
968
|
+
var _a;
|
|
969
|
+
return ({
|
|
970
|
+
arrange: f.arrange,
|
|
971
|
+
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
972
|
+
});
|
|
973
|
+
})) || [],
|
|
974
|
+
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
975
|
+
property: c.firestoreProperty,
|
|
976
|
+
operator: c.operator,
|
|
977
|
+
}))) || [],
|
|
978
|
+
};
|
|
979
|
+
return btoa(JSON.stringify(signature))
|
|
980
|
+
.replace(/[^a-zA-Z0-9]/g, '')
|
|
981
|
+
.substring(0, 20);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Gera instruções claras para criar o índice manualmente
|
|
985
|
+
*/
|
|
986
|
+
generateIndexInstructions(collection, arrange, conditions = undefined) {
|
|
987
|
+
var _a;
|
|
988
|
+
const instructions = {
|
|
989
|
+
summary: '',
|
|
990
|
+
collection: collection,
|
|
991
|
+
fields: [],
|
|
992
|
+
queryExample: '',
|
|
993
|
+
stepByStep: [],
|
|
994
|
+
notes: [],
|
|
995
|
+
};
|
|
996
|
+
const fields = [];
|
|
997
|
+
if (conditions && conditions.length > 0) {
|
|
998
|
+
conditions.forEach((condition) => {
|
|
999
|
+
if (condition.firestoreProperty) {
|
|
1000
|
+
fields.push({
|
|
1001
|
+
field: condition.firestoreProperty,
|
|
1002
|
+
order: 'Ascending',
|
|
1003
|
+
type: 'WHERE clause',
|
|
1004
|
+
operator: condition.operator,
|
|
1005
|
+
description: `Filtrar por ${condition.firestoreProperty} usando operador ${condition.operator}`,
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
if (arrange.filters && arrange.filters.length > 0) {
|
|
1011
|
+
arrange.filters.forEach((filter) => {
|
|
1012
|
+
var _a;
|
|
1013
|
+
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1014
|
+
fields.push({
|
|
1015
|
+
field: filter.filter.property,
|
|
1016
|
+
order: 'Ascending',
|
|
1017
|
+
type: 'WHERE clause (filter)',
|
|
1018
|
+
operator: filter.arrange === 'filter' ? 'CONTAINS' : 'RANGE',
|
|
1019
|
+
description: `Filtrar por ${filter.filter.property} usando filtro ${filter.arrange}`,
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1025
|
+
fields.push({
|
|
1026
|
+
field: arrange.sortBy.field,
|
|
1027
|
+
order: arrange.sortBy.order === 'desc' ? 'Descending' : 'Ascending',
|
|
1028
|
+
type: 'ORDER BY clause',
|
|
1029
|
+
operator: 'N/A',
|
|
1030
|
+
description: `Ordenar resultados por ${arrange.sortBy.field} em ordem ${arrange.sortBy.order}`,
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
instructions.fields = fields;
|
|
1034
|
+
const fieldNames = fields.map((f) => f.field).join(' + ');
|
|
1035
|
+
instructions.summary = `Criar índice composto para ${collection}: ${fieldNames}`;
|
|
1036
|
+
let queryExample = `db.collection('${collection}')`;
|
|
1037
|
+
fields.forEach((field, index) => {
|
|
1038
|
+
if (field.type.includes('WHERE')) {
|
|
1039
|
+
if (field.operator === '==') {
|
|
1040
|
+
queryExample += `\n .where('${field.field}', '==', 'value')`;
|
|
1041
|
+
}
|
|
1042
|
+
else if (field.operator === 'CONTAINS') {
|
|
1043
|
+
queryExample += `\n .where('${field.field}', '>=', 'searchText')`;
|
|
1044
|
+
}
|
|
1045
|
+
else {
|
|
1046
|
+
queryExample += `\n .where('${field.field}', '${field.operator}', 'value')`;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
const orderByField = fields.find((f) => f.type.includes('ORDER BY'));
|
|
1051
|
+
if (orderByField) {
|
|
1052
|
+
queryExample += `\n .orderBy('${orderByField.field}', '${orderByField.order.toLowerCase()}')`;
|
|
1053
|
+
}
|
|
1054
|
+
instructions.queryExample = queryExample;
|
|
1055
|
+
instructions.stepByStep = [
|
|
1056
|
+
'1. Ir para Firebase Console → Firestore → Indexes',
|
|
1057
|
+
'2. Clicar em "Create Index"',
|
|
1058
|
+
`3. Definir Collection ID: ${collection}`,
|
|
1059
|
+
'4. Configurar campos nesta ORDEM EXATA:',
|
|
1060
|
+
...fields.map((field, index) => ` ${index + 1}. Campo: ${field.field}, Order: ${field.order}, Array: No`),
|
|
1061
|
+
'5. Definir Query scopes: Collection',
|
|
1062
|
+
'6. Clicar em "Create" e aguardar conclusão',
|
|
1063
|
+
];
|
|
1064
|
+
instructions.notes = [
|
|
1065
|
+
'⚠️ A ordem dos campos é CRÍTICA - deve corresponder exatamente à ordem da query',
|
|
1066
|
+
'⚠️ As cláusulas WHERE devem vir ANTES do campo ORDER BY',
|
|
1067
|
+
'⚠️ Este índice só funcionará para queries com esta combinação EXATA de campos',
|
|
1068
|
+
'⚠️ A criação do índice pode levar vários minutos',
|
|
1069
|
+
];
|
|
1070
|
+
return instructions;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Gera um link de índice baseado na estrutura da query
|
|
1074
|
+
*/
|
|
1075
|
+
generateIndexLink(collection, arrange, conditions = undefined) {
|
|
1076
|
+
var _a;
|
|
1077
|
+
try {
|
|
1078
|
+
const indexFields = [];
|
|
1079
|
+
if (conditions && conditions.length > 0) {
|
|
1080
|
+
conditions.forEach((condition) => {
|
|
1081
|
+
if (condition.firestoreProperty) {
|
|
1082
|
+
indexFields.push(condition.firestoreProperty);
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
if (arrange.filters && arrange.filters.length > 0) {
|
|
1087
|
+
arrange.filters.forEach((filter) => {
|
|
1088
|
+
var _a;
|
|
1089
|
+
if ((_a = filter.filter) === null || _a === void 0 ? void 0 : _a.property) {
|
|
1090
|
+
indexFields.push(filter.filter.property);
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
if ((_a = arrange.sortBy) === null || _a === void 0 ? void 0 : _a.field) {
|
|
1095
|
+
indexFields.push(arrange.sortBy.field);
|
|
1096
|
+
}
|
|
1097
|
+
if (indexFields.length > 1) {
|
|
1098
|
+
const baseUrl = 'https://console.firebase.google.com/project/toppayy-dev/firestore/indexes';
|
|
1099
|
+
const queryParams = new URLSearchParams({
|
|
1100
|
+
create_composite: `collection=${collection}&fields=${indexFields.join(',')}`,
|
|
1101
|
+
});
|
|
1102
|
+
const finalLink = `${baseUrl}?${queryParams.toString()}`;
|
|
1103
|
+
return finalLink;
|
|
1104
|
+
}
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
catch (error) {
|
|
1108
|
+
console.warn('Falha ao gerar link de índice:', error);
|
|
1109
|
+
return null;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
trackMissingIndex(error, collection, arrange, conditions = undefined) {
|
|
1113
|
+
var _a;
|
|
1114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1115
|
+
try {
|
|
1116
|
+
const indexLink = this.extractIndexLink(error);
|
|
1117
|
+
if (!indexLink)
|
|
1118
|
+
return;
|
|
1119
|
+
const linkHash = btoa(indexLink)
|
|
1120
|
+
.replace(/[^a-zA-Z0-9]/g, '')
|
|
1121
|
+
.substring(0, 20);
|
|
1122
|
+
const docId = `${collection}_${linkHash}`;
|
|
1123
|
+
const indexInstructions = this.generateIndexInstructions(collection, arrange, conditions);
|
|
1124
|
+
const trackingData = {
|
|
1125
|
+
collection,
|
|
1126
|
+
indexLink,
|
|
1127
|
+
indexInstructions,
|
|
1128
|
+
arrange: {
|
|
1129
|
+
sortBy: arrange.sortBy,
|
|
1130
|
+
filters: ((_a = arrange.filters) === null || _a === void 0 ? void 0 : _a.map((f) => {
|
|
1131
|
+
var _a, _b;
|
|
1132
|
+
return ({
|
|
1133
|
+
arrange: f.arrange,
|
|
1134
|
+
property: ((_a = f.filter) === null || _a === void 0 ? void 0 : _a.property) || null,
|
|
1135
|
+
dateField: f.arrange === 'filterByDate' ? (_b = arrange.sortBy) === null || _b === void 0 ? void 0 : _b.field : null,
|
|
1136
|
+
});
|
|
1137
|
+
})) || [],
|
|
1138
|
+
},
|
|
1139
|
+
conditions: (conditions === null || conditions === void 0 ? void 0 : conditions.map((c) => ({
|
|
1140
|
+
property: c.firestoreProperty,
|
|
1141
|
+
operator: c.operator,
|
|
1142
|
+
}))) || [],
|
|
1143
|
+
errorMessage: error.message,
|
|
1144
|
+
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1145
|
+
};
|
|
1146
|
+
const docRef = this.ngFire.collection('missingIndexes').doc(docId);
|
|
1147
|
+
const doc = yield docRef.get().toPromise();
|
|
1148
|
+
if (doc && doc.exists) {
|
|
1149
|
+
yield docRef.update({
|
|
1150
|
+
count: firebase.firestore.FieldValue.increment(1),
|
|
1151
|
+
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
|
1152
|
+
lastError: error.message,
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
else {
|
|
1156
|
+
yield docRef.set(Object.assign(Object.assign({}, trackingData), { count: 1, createdAt: firebase.firestore.FieldValue.serverTimestamp() }));
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
catch (trackingError) {
|
|
1160
|
+
console.warn('Falha ao rastrear índice ausente:', trackingError);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
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 });
|
|
1166
|
+
TableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, providedIn: 'root' });
|
|
1167
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableService, decorators: [{
|
|
1168
|
+
type: Injectable,
|
|
1169
|
+
args: [{
|
|
1170
|
+
providedIn: 'root',
|
|
1171
|
+
}]
|
|
1172
|
+
}], ctorParameters: function () {
|
|
1173
|
+
return [{ type: i1.AngularFirestore, decorators: [{
|
|
1174
|
+
type: Optional
|
|
1175
|
+
}] }, { type: i2.MatDialog, decorators: [{
|
|
1176
|
+
type: Optional
|
|
1177
|
+
}] }, { type: i3.ToastrService, decorators: [{
|
|
1178
|
+
type: Optional
|
|
1179
|
+
}] }];
|
|
1180
1180
|
} });
|
|
1181
1181
|
|
|
1182
|
-
class TableComponent {
|
|
1183
|
-
// CONSTRUCTOR
|
|
1184
|
-
constructor(router, tableService, firestore) {
|
|
1185
|
-
this.router = router;
|
|
1186
|
-
this.tableService = tableService;
|
|
1187
|
-
this.firestore = firestore;
|
|
1188
|
-
this.arrange = null;
|
|
1189
|
-
this.currentPageNumber = 1;
|
|
1190
|
-
this.currentClientPageIndex = 0;
|
|
1191
|
-
this.items = [];
|
|
1192
|
-
this.filteredItems = []; // Dados filtrados para modo não paginado (público para acesso externo)
|
|
1193
|
-
this.isLoading = false;
|
|
1194
|
-
this.lastDoc = null;
|
|
1195
|
-
this.firstDoc = null;
|
|
1196
|
-
this.sortBy = {
|
|
1197
|
-
field: 'createdAt',
|
|
1198
|
-
order: 'desc',
|
|
1199
|
-
};
|
|
1200
|
-
this.columnProperties = [];
|
|
1201
|
-
this.selectSort = new FormControl('');
|
|
1202
|
-
this.currentArrange = '';
|
|
1203
|
-
this.hasNextPage = false;
|
|
1204
|
-
this.dropdownItems = [];
|
|
1205
|
-
this.sortableDropdownItems = [];
|
|
1206
|
-
this.pageSize = 25;
|
|
1207
|
-
this.totalItems = 0;
|
|
1208
|
-
this.filterValue = null;
|
|
1209
|
-
this.hasFilterableColumn = false;
|
|
1210
|
-
this.hasSortableColumn = false;
|
|
1211
|
-
this.filterSubject = new Subject();
|
|
1212
|
-
this.debounceTimeMs = 500;
|
|
1213
|
-
this.selectedTab = 0;
|
|
1214
|
-
// Propriedades para controle do tooltip
|
|
1215
|
-
this.hoveredCell = null;
|
|
1216
|
-
this.showTooltip = false;
|
|
1217
|
-
this.tooltipContent = '';
|
|
1218
|
-
this.tooltipPosition = { x: 0, y: 0 };
|
|
1219
|
-
this.filtersForm = new FormArray([this.createFilterGroup()]);
|
|
1220
|
-
}
|
|
1221
|
-
createFilterGroup() {
|
|
1222
|
-
return new FormGroup({
|
|
1223
|
-
selectFilter: new FormControl(''),
|
|
1224
|
-
typeFilter: new FormControl(''),
|
|
1225
|
-
selectItem: new FormControl(''),
|
|
1226
|
-
initialDate: new FormControl('',
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
this.filtersForm.
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
this.
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
.
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
this.
|
|
1421
|
-
}
|
|
1422
|
-
this.
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
if (
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
if (
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
if (
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
this.
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
this.
|
|
2063
|
-
this.
|
|
2064
|
-
this.
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
if (
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
if (
|
|
2119
|
-
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
this.
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
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 }], 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, Custom Action, and Global Actions -->\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\r\n <!-- Right Side: Search, Reset, Export -->\r\n <div\r\n class=\"flex flex-wrap gap-3\"\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\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 rounded-lg border border-gray-200 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 *ngFor=\"let item of dropdownItems\" [value]=\"item\">\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()\"\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 matInput\r\n (keyup.enter)=\"search()\"\r\n formControlName=\"initialDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 (keyup.enter)=\"search()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 & Sort -->\r\n <div\r\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\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 <!-- Sort Dropdown -->\r\n <div\r\n class=\"w-full sm:w-auto sm:min-w-[250px]\"\r\n *ngIf=\"sortableDropdownItems.length > 0\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Ordenar por</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 <!-- SIMPLE SEARCH (for non-paginated tables) -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"data.pagination === false && hasFilterableColumn === true\"\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()\"\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 <button\r\n *ngIf=\"data.actionButton\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' float-right 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 *ngIf=\"data.actionButton.icon\" [class]=\"data.actionButton.icon\"></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n\r\n <!-- FILTERS PANEL (for non-paginated tables) -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"data.pagination === false && dropdownItems.length > 0\"\r\n >\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 rounded-lg border border-gray-200 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 *ngFor=\"let item of dropdownItems\" [value]=\"item\">\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()\"\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 matInput\r\n (keyup.enter)=\"search()\"\r\n (blur)=\"onDateFilterChange()\"\r\n formControlName=\"initialDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 (keyup.enter)=\"search()\"\r\n (blur)=\"onDateFilterChange()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\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 class=\"flex flex-wrap gap-3\">\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 Aplicar\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\r\n <div class=\"flex flex-col\">\r\n <div\r\n class=\"mx-auto flex flex-col\"\r\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\r\n >\r\n <!-- Calcular quantos grupos de 6 tabs existem -->\r\n <ng-container\r\n *ngFor=\"\r\n let groupIndex of getTabGroups(data.tabs.tabsData);\r\n let i = index\r\n \"\r\n >\r\n <div class=\"mx-auto flex flex-row\">\r\n <ng-container\r\n *ngFor=\"\r\n let tab of getTabGroup(data.tabs.tabsData, groupIndex);\r\n let j = index\r\n \"\r\n >\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)=\"onTableSelected(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 <div class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl\">\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\"\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 [ngClass]=\"\r\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\r\n (data.color?.text ? ' ' + $any(data.color).text : '')\r\n \"\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 [ngClass]=\"\r\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\r\n (data.color?.text ? ' ' + $any(data.color).text : '')\r\n \"\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 <img\r\n *ngIf=\"\r\n col.image && col.image.path && !col.iconClass && !col.method\r\n \"\r\n [src]=\"col.image.path + '/' + row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n alt=\"Imagem\"\r\n />\r\n <img\r\n *ngIf=\"\r\n col.image && col.image.url && !col.iconClass && !col.method\r\n \"\r\n [src]=\"row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n alt=\"Imagem\"\r\n />\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\" 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\">\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) || this.data.filterFn\r\n }\"\r\n >\r\n </mat-paginator>\r\n <div\r\n *ngIf=\"\r\n !isLoading &&\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 <div\r\n *ngIf=\"showTooltip\"\r\n class=\"fixed z-50 max-w-md break-words rounded-lg bg-gray-800 px-3 py-2 text-sm text-white shadow-lg\"\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</div>\r\n", styles: ["::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}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i6.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i6.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i6.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i6.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i6.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i6.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i6.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i6.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i6.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i6.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: i6.MatNoDataRow, selector: "ng-template[matNoDataRow]" }, { kind: "component", type: i7.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "directive", type: i8.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i8.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: i9.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i9.MatLabel, selector: "mat-label" }, { kind: "directive", type: i9.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i10.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: i11.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i12.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i13.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i14.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i15.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i16.NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "showTemplate", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime", "leadZero", "triggerOnMaskChange", "apm", "inputTransformFn", "outputTransformFn", "keepCharacterPositions"], outputs: ["maskFilled"], exportAs: ["mask", "ngxMask"] }] });
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
args: [{ selector: 'lib-table', 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, Custom Action, and Global Actions -->\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\r\n <!-- Right Side: Search, Reset, Export -->\r\n <div\r\n class=\"flex flex-wrap gap-3\"\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\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 rounded-lg border border-gray-200 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 *ngFor=\"let item of dropdownItems\" [value]=\"item\">\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()\"\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 matInput\r\n (keyup.enter)=\"search()\"\r\n formControlName=\"initialDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 (keyup.enter)=\"search()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 & Sort -->\r\n <div\r\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\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 <!-- Sort Dropdown -->\r\n <div\r\n class=\"w-full sm:w-auto sm:min-w-[250px]\"\r\n *ngIf=\"sortableDropdownItems.length > 0\"\r\n >\r\n <mat-form-field appearance=\"outline\" class=\"w-full\">\r\n <mat-label>Ordenar por</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 <!-- SIMPLE SEARCH (for non-paginated tables) -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"data.pagination === false && hasFilterableColumn === true\"\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()\"\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 <button\r\n *ngIf=\"data.actionButton\"\r\n [ngClass]=\"\r\n (data.actionButton.colorClass || 'bg-blue-500') +\r\n ' float-right 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 *ngIf=\"data.actionButton.icon\" [class]=\"data.actionButton.icon\"></i>\r\n {{ data.actionButton.label }}\r\n </button>\r\n </div>\r\n\r\n <!-- FILTERS PANEL (for non-paginated tables) -->\r\n <div\r\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\r\n *ngIf=\"data.pagination === false && dropdownItems.length > 0\"\r\n >\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 rounded-lg border border-gray-200 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 *ngFor=\"let item of dropdownItems\" [value]=\"item\">\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()\"\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 matInput\r\n (keyup.enter)=\"search()\"\r\n (blur)=\"onDateFilterChange()\"\r\n formControlName=\"initialDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 (keyup.enter)=\"search()\"\r\n (blur)=\"onDateFilterChange()\"\r\n matInput\r\n formControlName=\"finalDate\"\r\n [dropSpecialCharacters]=\"false\"\r\n mask=\"d0/M0/0000\"\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 flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\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 class=\"flex flex-wrap gap-3\">\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 Aplicar\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\r\n <div class=\"flex flex-col\">\r\n <div\r\n class=\"mx-auto flex flex-col\"\r\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\r\n >\r\n <!-- Calcular quantos grupos de 6 tabs existem -->\r\n <ng-container\r\n *ngFor=\"\r\n let groupIndex of getTabGroups(data.tabs.tabsData);\r\n let i = index\r\n \"\r\n >\r\n <div class=\"mx-auto flex flex-row\">\r\n <ng-container\r\n *ngFor=\"\r\n let tab of getTabGroup(data.tabs.tabsData, groupIndex);\r\n let j = index\r\n \"\r\n >\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)=\"onTableSelected(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 <div class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl\">\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\"\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 [ngClass]=\"\r\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\r\n (data.color?.text ? ' ' + $any(data.color).text : '')\r\n \"\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 [ngClass]=\"\r\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\r\n (data.color?.text ? ' ' + $any(data.color).text : '')\r\n \"\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 <img\r\n *ngIf=\"\r\n col.image && col.image.path && !col.iconClass && !col.method\r\n \"\r\n [src]=\"col.image.path + '/' + row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n alt=\"Imagem\"\r\n />\r\n <img\r\n *ngIf=\"\r\n col.image && col.image.url && !col.iconClass && !col.method\r\n \"\r\n [src]=\"row[col.property]\"\r\n [ngClass]=\"col.image.class\"\r\n alt=\"Imagem\"\r\n />\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\" 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\">\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) || this.data.filterFn\r\n }\"\r\n >\r\n </mat-paginator>\r\n <div\r\n *ngIf=\"\r\n !isLoading &&\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 <div\r\n *ngIf=\"showTooltip\"\r\n class=\"fixed z-50 max-w-md break-words rounded-lg bg-gray-800 px-3 py-2 text-sm text-white shadow-lg\"\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</div>\r\n", styles: ["::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}\n"] }]
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
1182
|
+
class TableComponent {
|
|
1183
|
+
// CONSTRUCTOR
|
|
1184
|
+
constructor(router, tableService, firestore) {
|
|
1185
|
+
this.router = router;
|
|
1186
|
+
this.tableService = tableService;
|
|
1187
|
+
this.firestore = firestore;
|
|
1188
|
+
this.arrange = null;
|
|
1189
|
+
this.currentPageNumber = 1;
|
|
1190
|
+
this.currentClientPageIndex = 0;
|
|
1191
|
+
this.items = [];
|
|
1192
|
+
this.filteredItems = []; // Dados filtrados para modo não paginado (público para acesso externo)
|
|
1193
|
+
this.isLoading = false;
|
|
1194
|
+
this.lastDoc = null;
|
|
1195
|
+
this.firstDoc = null;
|
|
1196
|
+
this.sortBy = {
|
|
1197
|
+
field: 'createdAt',
|
|
1198
|
+
order: 'desc',
|
|
1199
|
+
};
|
|
1200
|
+
this.columnProperties = [];
|
|
1201
|
+
this.selectSort = new FormControl('');
|
|
1202
|
+
this.currentArrange = '';
|
|
1203
|
+
this.hasNextPage = false;
|
|
1204
|
+
this.dropdownItems = [];
|
|
1205
|
+
this.sortableDropdownItems = [];
|
|
1206
|
+
this.pageSize = 25;
|
|
1207
|
+
this.totalItems = 0;
|
|
1208
|
+
this.filterValue = null;
|
|
1209
|
+
this.hasFilterableColumn = false;
|
|
1210
|
+
this.hasSortableColumn = false;
|
|
1211
|
+
this.filterSubject = new Subject();
|
|
1212
|
+
this.debounceTimeMs = 500;
|
|
1213
|
+
this.selectedTab = 0;
|
|
1214
|
+
// Propriedades para controle do tooltip
|
|
1215
|
+
this.hoveredCell = null;
|
|
1216
|
+
this.showTooltip = false;
|
|
1217
|
+
this.tooltipContent = '';
|
|
1218
|
+
this.tooltipPosition = { x: 0, y: 0 };
|
|
1219
|
+
this.filtersForm = new FormArray([this.createFilterGroup()]);
|
|
1220
|
+
}
|
|
1221
|
+
createFilterGroup() {
|
|
1222
|
+
return new FormGroup({
|
|
1223
|
+
selectFilter: new FormControl(''),
|
|
1224
|
+
typeFilter: new FormControl(''),
|
|
1225
|
+
selectItem: new FormControl(''),
|
|
1226
|
+
initialDate: new FormControl('', [
|
|
1227
|
+
this.tableService.dateFormatValidator(),
|
|
1228
|
+
]),
|
|
1229
|
+
finalDate: new FormControl('', [this.tableService.dateFormatValidator()]),
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
addFilter(filterData) {
|
|
1233
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1234
|
+
if (this.data.pagination === true &&
|
|
1235
|
+
this.hasActiveDateFilter() &&
|
|
1236
|
+
((_a = filterData === null || filterData === void 0 ? void 0 : filterData.selectFilter) === null || _a === void 0 ? void 0 : _a.arrange) === 'filterByDate') {
|
|
1237
|
+
// Não permitir adicionar novo filtro de data quando já existe um ativo
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
const newFilterGroup = this.createFilterGroup();
|
|
1241
|
+
if (filterData) {
|
|
1242
|
+
if (filterData.selectFilter) {
|
|
1243
|
+
(_b = newFilterGroup.get('selectFilter')) === null || _b === void 0 ? void 0 : _b.setValue(filterData.selectFilter);
|
|
1244
|
+
}
|
|
1245
|
+
if (filterData.typeFilter) {
|
|
1246
|
+
(_c = newFilterGroup.get('typeFilter')) === null || _c === void 0 ? void 0 : _c.setValue(filterData.typeFilter);
|
|
1247
|
+
}
|
|
1248
|
+
if (filterData.selectItem) {
|
|
1249
|
+
(_d = newFilterGroup.get('selectItem')) === null || _d === void 0 ? void 0 : _d.setValue(filterData.selectItem);
|
|
1250
|
+
}
|
|
1251
|
+
if (filterData.initialDate) {
|
|
1252
|
+
(_e = newFilterGroup.get('initialDate')) === null || _e === void 0 ? void 0 : _e.setValue(filterData.initialDate);
|
|
1253
|
+
}
|
|
1254
|
+
if (filterData.finalDate) {
|
|
1255
|
+
(_f = newFilterGroup.get('finalDate')) === null || _f === void 0 ? void 0 : _f.setValue(filterData.finalDate);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
this.filtersForm.push(newFilterGroup);
|
|
1259
|
+
}
|
|
1260
|
+
hasActiveDateFilter() {
|
|
1261
|
+
return this.filtersForm.controls.some((control) => {
|
|
1262
|
+
var _a;
|
|
1263
|
+
const group = control;
|
|
1264
|
+
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1265
|
+
return (selectedFilter === null || selectedFilter === void 0 ? void 0 : selectedFilter.arrange) === 'filterByDate';
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
getAvailableFilterOptions() {
|
|
1269
|
+
if (this.data.pagination === true && this.hasActiveDateFilter()) {
|
|
1270
|
+
return this.dropdownItems.filter((item) => item.arrange !== 'filterByDate');
|
|
1271
|
+
}
|
|
1272
|
+
return this.dropdownItems;
|
|
1273
|
+
}
|
|
1274
|
+
onSelectFilterChange() {
|
|
1275
|
+
var _a;
|
|
1276
|
+
const lastIndex = this.filtersForm.length - 1;
|
|
1277
|
+
const lastFilter = this.filtersForm.at(lastIndex);
|
|
1278
|
+
const selectedFilter = (_a = lastFilter.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1279
|
+
if (selectedFilter) {
|
|
1280
|
+
if (selectedFilter.arrange === 'filterByDate' &&
|
|
1281
|
+
this.data.pagination === true) {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
this.addFilter();
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
removeFilter(index) {
|
|
1288
|
+
this.filtersForm.removeAt(index);
|
|
1289
|
+
if (this.filtersForm.length === 0) {
|
|
1290
|
+
this.addFilter();
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
removeAllFilters() {
|
|
1294
|
+
this.filtersForm.clear();
|
|
1295
|
+
this.addFilter();
|
|
1296
|
+
this.resetFilter();
|
|
1297
|
+
}
|
|
1298
|
+
// METHODS
|
|
1299
|
+
ngOnInit() {
|
|
1300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1301
|
+
if (!this.data.color)
|
|
1302
|
+
this.data.color = { bg: 'bg-primary', text: 'text-black' };
|
|
1303
|
+
this.columnProperties = this.data.displayedColumns.map((column) => {
|
|
1304
|
+
return column.property;
|
|
1305
|
+
});
|
|
1306
|
+
if (this.data.actionButton && !this.data.actionButton.condition) {
|
|
1307
|
+
this.data.actionButton.condition = (_row) => true;
|
|
1308
|
+
}
|
|
1309
|
+
this.data.displayedColumns.forEach((col) => {
|
|
1310
|
+
if (col.isFilterable) {
|
|
1311
|
+
if (this.hasFilterableColumn === false)
|
|
1312
|
+
this.hasFilterableColumn = true;
|
|
1313
|
+
this.dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filter', title: col.title }));
|
|
1314
|
+
}
|
|
1315
|
+
if (col.isSortable) {
|
|
1316
|
+
if (this.hasSortableColumn === false)
|
|
1317
|
+
this.hasSortableColumn = true;
|
|
1318
|
+
this.sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'ascending', title: col.title + ': crescente' }));
|
|
1319
|
+
this.sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'descending', title: col.title + ': decrescente' }));
|
|
1320
|
+
}
|
|
1321
|
+
if (col.isFilterableByDate) {
|
|
1322
|
+
this.dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filterByDate', title: col.title + ': filtro por data' }));
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
if (this.data.filterableOptions &&
|
|
1326
|
+
Array.isArray(this.data.filterableOptions) &&
|
|
1327
|
+
this.data.filterableOptions.length > 0) {
|
|
1328
|
+
this.data.filterableOptions.forEach((option) => this.dropdownItems.push(Object.assign(Object.assign({}, option), { arrange: 'equals' })));
|
|
1329
|
+
}
|
|
1330
|
+
// Sem paginação
|
|
1331
|
+
if (this.data.pagination === false) {
|
|
1332
|
+
yield this.loadItems();
|
|
1333
|
+
}
|
|
1334
|
+
// Com paginação
|
|
1335
|
+
if (this.data.pagination === true) {
|
|
1336
|
+
if (this.data.sortBy)
|
|
1337
|
+
this.sortBy = {
|
|
1338
|
+
field: this.data.sortBy.field,
|
|
1339
|
+
order: this.data.sortBy.order,
|
|
1340
|
+
};
|
|
1341
|
+
this.filterSubject
|
|
1342
|
+
.pipe(debounceTime(this.debounceTimeMs))
|
|
1343
|
+
.subscribe(() => {
|
|
1344
|
+
this.loadItemsPaginated('reload', true);
|
|
1345
|
+
});
|
|
1346
|
+
this.isLoading = true;
|
|
1347
|
+
yield this.loadItemsPaginated('reload', true);
|
|
1348
|
+
this.sort.active = 'createdAt';
|
|
1349
|
+
this.sort.direction = 'desc';
|
|
1350
|
+
this.dataSource.paginator = this.paginator;
|
|
1351
|
+
this.dataSource.sort = this.sort;
|
|
1352
|
+
this.totalItems = 0;
|
|
1353
|
+
if (this.data.totalRef) {
|
|
1354
|
+
for (const totalRef of this.data.totalRef) {
|
|
1355
|
+
const totalRefDoc = yield totalRef.ref.get();
|
|
1356
|
+
const docData = totalRefDoc.data();
|
|
1357
|
+
if (docData && docData[totalRef.field])
|
|
1358
|
+
this.totalItems = (this.totalItems +
|
|
1359
|
+
docData[totalRef.field]);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
this.isLoading = false;
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
getDisplayValue(col, row, withinLimit = false) {
|
|
1367
|
+
let value;
|
|
1368
|
+
if (col.calculateValue) {
|
|
1369
|
+
value = col.calculateValue(row);
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
value = this.getNestedValue(row, col.property);
|
|
1373
|
+
}
|
|
1374
|
+
if (Array.isArray(value) && col.arrayField) {
|
|
1375
|
+
value = this.formatArrayValue(value, col.arrayField);
|
|
1376
|
+
}
|
|
1377
|
+
if (col.queryLength && row[col.property]) {
|
|
1378
|
+
value = row[col.property];
|
|
1379
|
+
}
|
|
1380
|
+
value = col.pipe ? col.pipe.transform(value) : value;
|
|
1381
|
+
if (value === null || value === undefined) {
|
|
1382
|
+
value = '';
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
value = String(value);
|
|
1386
|
+
}
|
|
1387
|
+
if (typeof value !== 'string') {
|
|
1388
|
+
value = '';
|
|
1389
|
+
}
|
|
1390
|
+
if (withinLimit || !col.charLimit) {
|
|
1391
|
+
return value;
|
|
1392
|
+
}
|
|
1393
|
+
return value.substring(0, col.charLimit) + '...';
|
|
1394
|
+
}
|
|
1395
|
+
getNestedValue(obj, path) {
|
|
1396
|
+
if (!path)
|
|
1397
|
+
return undefined;
|
|
1398
|
+
const properties = path.split('.');
|
|
1399
|
+
return properties.reduce((acc, currentPart) => acc && acc[currentPart], obj);
|
|
1400
|
+
}
|
|
1401
|
+
formatArrayValue(array, field) {
|
|
1402
|
+
if (!Array.isArray(array) || array.length === 0) {
|
|
1403
|
+
return '';
|
|
1404
|
+
}
|
|
1405
|
+
const values = array
|
|
1406
|
+
.map((item) => {
|
|
1407
|
+
if (typeof item === 'object' && item !== null) {
|
|
1408
|
+
return item[field] || '';
|
|
1409
|
+
}
|
|
1410
|
+
return String(item);
|
|
1411
|
+
})
|
|
1412
|
+
.filter((value) => value !== '' && value !== null && value !== undefined);
|
|
1413
|
+
return values.join(', ');
|
|
1414
|
+
}
|
|
1415
|
+
// Métodos sem paginação
|
|
1416
|
+
loadItems() {
|
|
1417
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1418
|
+
this.items = yield this.tableService.getItems(this.data.collectionRef);
|
|
1419
|
+
if (this.data.conditions) {
|
|
1420
|
+
this.filterItems();
|
|
1421
|
+
}
|
|
1422
|
+
yield this.loadRelations();
|
|
1423
|
+
yield this.loadQueryLengths();
|
|
1424
|
+
this.totalItems = this.items.length;
|
|
1425
|
+
// Inicializar arrange para tabelas não paginadas
|
|
1426
|
+
this.arrange = {
|
|
1427
|
+
filters: [],
|
|
1428
|
+
sortBy: this.data.sortBy || {
|
|
1429
|
+
field: 'createdAt',
|
|
1430
|
+
order: 'desc',
|
|
1431
|
+
},
|
|
1432
|
+
};
|
|
1433
|
+
this.sortBy = this.data.sortBy || {
|
|
1434
|
+
field: 'createdAt',
|
|
1435
|
+
order: 'desc',
|
|
1436
|
+
};
|
|
1437
|
+
// Aplicar filtros client-side se existirem
|
|
1438
|
+
let itemsToDisplay = [...this.items];
|
|
1439
|
+
itemsToDisplay = this.applyClientSideFilters(itemsToDisplay);
|
|
1440
|
+
this.filteredItems = itemsToDisplay; // Armazenar dados filtrados
|
|
1441
|
+
this.dataSource = new MatTableDataSource(itemsToDisplay);
|
|
1442
|
+
this.dataSource.paginator = this.paginator;
|
|
1443
|
+
this.dataSource.sort = this.sort;
|
|
1444
|
+
if (this.data.sortBy) {
|
|
1445
|
+
this.dataSource.sort.active = this.data.sortBy.field;
|
|
1446
|
+
this.dataSource.sort.direction = this.data.sortBy.order;
|
|
1447
|
+
this.dataSource.sort.sortChange.emit();
|
|
1448
|
+
}
|
|
1449
|
+
this.dataSource.filterPredicate = (data, filter) => {
|
|
1450
|
+
return this.data.displayedColumns.some((col) => {
|
|
1451
|
+
if (col.filterPredicates) {
|
|
1452
|
+
return col.filterPredicates.some((predicate) => {
|
|
1453
|
+
const propertyValue = data[col.property];
|
|
1454
|
+
if (!propertyValue || typeof propertyValue !== 'object') {
|
|
1455
|
+
return false;
|
|
1456
|
+
}
|
|
1457
|
+
const predicateValue = propertyValue[predicate];
|
|
1458
|
+
if (predicateValue === null || predicateValue === undefined) {
|
|
1459
|
+
return false;
|
|
1460
|
+
}
|
|
1461
|
+
return String(predicateValue)
|
|
1462
|
+
.trim()
|
|
1463
|
+
.toLocaleLowerCase()
|
|
1464
|
+
.includes(filter);
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
if (col.property && col.isFilterable) {
|
|
1468
|
+
const propertyValue = data[col.property];
|
|
1469
|
+
if (propertyValue === null || propertyValue === undefined) {
|
|
1470
|
+
return false;
|
|
1471
|
+
}
|
|
1472
|
+
return String(propertyValue)
|
|
1473
|
+
.trim()
|
|
1474
|
+
.toLocaleLowerCase()
|
|
1475
|
+
.includes(filter);
|
|
1476
|
+
}
|
|
1477
|
+
return false;
|
|
1478
|
+
});
|
|
1479
|
+
};
|
|
1480
|
+
this.filterPredicate = this.dataSource.filterPredicate;
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
// Aplicar filtros client-side (filtros por data)
|
|
1484
|
+
applyClientSideFilters(items) {
|
|
1485
|
+
let filteredItems = [...items];
|
|
1486
|
+
// Agrupar filtros de data por propriedade
|
|
1487
|
+
const dateFiltersByProperty = {};
|
|
1488
|
+
const otherFilters = [];
|
|
1489
|
+
this.filtersForm.controls.forEach((control) => {
|
|
1490
|
+
var _a, _b, _c;
|
|
1491
|
+
const group = control;
|
|
1492
|
+
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1493
|
+
if (!selectedFilter)
|
|
1494
|
+
return;
|
|
1495
|
+
const arrange = selectedFilter.arrange;
|
|
1496
|
+
if (arrange === 'filterByDate') {
|
|
1497
|
+
const initial = (_b = group.get('initialDate')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1498
|
+
const final = (_c = group.get('finalDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1499
|
+
// Só aplicar filtro se ambas as datas estiverem preenchidas
|
|
1500
|
+
if (initial && final && initial.trim() && final.trim()) {
|
|
1501
|
+
try {
|
|
1502
|
+
// Validar formato da data (DD/MM/AAAA)
|
|
1503
|
+
const datePattern = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
1504
|
+
if (!datePattern.test(initial) || !datePattern.test(final)) {
|
|
1505
|
+
return; // Ignorar se formato inválido
|
|
1506
|
+
}
|
|
1507
|
+
const [dayI, monthI, yearI] = initial.split('/');
|
|
1508
|
+
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1509
|
+
const [dayF, monthF, yearF] = final.split('/');
|
|
1510
|
+
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1511
|
+
finalDate.setHours(23, 59, 59);
|
|
1512
|
+
// Validar se as datas são válidas
|
|
1513
|
+
if (isNaN(initialDate.getTime()) || isNaN(finalDate.getTime())) {
|
|
1514
|
+
return; // Ignorar se datas inválidas
|
|
1515
|
+
}
|
|
1516
|
+
// Usar o campo da coluna ou o sortBy.field como padrão
|
|
1517
|
+
const dateField = selectedFilter.property || this.sortBy.field;
|
|
1518
|
+
if (!dateFiltersByProperty[dateField]) {
|
|
1519
|
+
dateFiltersByProperty[dateField] = [];
|
|
1520
|
+
}
|
|
1521
|
+
dateFiltersByProperty[dateField].push({
|
|
1522
|
+
initial: initialDate,
|
|
1523
|
+
final: finalDate,
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
catch (error) {
|
|
1527
|
+
console.warn('Erro ao processar datas do filtro:', error);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
otherFilters.push({ group, selectedFilter, arrange });
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
Object.keys(dateFiltersByProperty).forEach((dateField) => {
|
|
1536
|
+
const intervals = dateFiltersByProperty[dateField];
|
|
1537
|
+
filteredItems = filteredItems.filter((item) => {
|
|
1538
|
+
try {
|
|
1539
|
+
const fieldValue = item[dateField];
|
|
1540
|
+
if (!fieldValue) {
|
|
1541
|
+
return false;
|
|
1542
|
+
}
|
|
1543
|
+
let itemDate;
|
|
1544
|
+
if (typeof fieldValue.toDate === 'function') {
|
|
1545
|
+
itemDate = fieldValue.toDate();
|
|
1546
|
+
}
|
|
1547
|
+
else if (fieldValue instanceof Date) {
|
|
1548
|
+
itemDate = fieldValue;
|
|
1549
|
+
}
|
|
1550
|
+
else if (typeof fieldValue === 'string') {
|
|
1551
|
+
itemDate = new Date(fieldValue);
|
|
1552
|
+
if (isNaN(itemDate.getTime())) {
|
|
1553
|
+
return false;
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
else if (typeof fieldValue === 'number') {
|
|
1557
|
+
itemDate = new Date(fieldValue);
|
|
1558
|
+
}
|
|
1559
|
+
else {
|
|
1560
|
+
return false;
|
|
1561
|
+
}
|
|
1562
|
+
return intervals.some((interval) => itemDate >= interval.initial && itemDate <= interval.final);
|
|
1563
|
+
}
|
|
1564
|
+
catch (error) {
|
|
1565
|
+
console.warn('Erro ao processar filtro de data para o item:', item.id, error);
|
|
1566
|
+
return false;
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
});
|
|
1570
|
+
otherFilters.forEach(({ group, selectedFilter, arrange }) => {
|
|
1571
|
+
var _a, _b;
|
|
1572
|
+
if (arrange === 'filter') {
|
|
1573
|
+
const filterValue = (_a = group.get('typeFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1574
|
+
if (filterValue && filterValue.trim()) {
|
|
1575
|
+
const property = selectedFilter.property;
|
|
1576
|
+
filteredItems = filteredItems.filter((item) => {
|
|
1577
|
+
const value = String(item[property] || '')
|
|
1578
|
+
.trim()
|
|
1579
|
+
.toLocaleLowerCase();
|
|
1580
|
+
return value.includes(filterValue.trim().toLocaleLowerCase());
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
else if (selectedFilter.hasOwnProperty('items') &&
|
|
1585
|
+
arrange === 'equals') {
|
|
1586
|
+
const selectedItems = (_b = group.get('selectItem')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1587
|
+
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1588
|
+
const values = selectedItems.map((item) => item.value);
|
|
1589
|
+
filteredItems = filteredItems.filter((item) => {
|
|
1590
|
+
return selectedItems.some((selectedItem) => {
|
|
1591
|
+
const itemValue = item[selectedItem.property];
|
|
1592
|
+
return itemValue === selectedItem.value;
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
return filteredItems;
|
|
1599
|
+
}
|
|
1600
|
+
// Handler para mudanças de data no filtro
|
|
1601
|
+
onDateFilterChange() {
|
|
1602
|
+
if (this.data.pagination === false) {
|
|
1603
|
+
// Atualizar arrange com os filtros ativos
|
|
1604
|
+
this.arrange = this.buildArrangeFromFilters();
|
|
1605
|
+
// Aplicar filtros (ou remover se campos estiverem vazios)
|
|
1606
|
+
this.applyFiltersToDataSource();
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
// Aplicar filtros ao dataSource quando não há paginação
|
|
1610
|
+
applyFiltersToDataSource() {
|
|
1611
|
+
if (!this.dataSource)
|
|
1612
|
+
return;
|
|
1613
|
+
let filteredItems = this.applyClientSideFilters([...this.items]);
|
|
1614
|
+
this.dataSource.data = filteredItems;
|
|
1615
|
+
// Atualizar filteredItems com os dados filtrados (será atualizado novamente no handleDownload com filteredData)
|
|
1616
|
+
this.filteredItems = filteredItems;
|
|
1617
|
+
this.totalItems = filteredItems.length;
|
|
1618
|
+
}
|
|
1619
|
+
// Métodos com paginação
|
|
1620
|
+
loadItemsPaginated(navigation = 'reload', reset = false) {
|
|
1621
|
+
var _a;
|
|
1622
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1623
|
+
if (reset && ['forward', 'reload'].includes(navigation)) {
|
|
1624
|
+
this.lastDoc = null;
|
|
1625
|
+
this.currentClientPageIndex = 0;
|
|
1626
|
+
}
|
|
1627
|
+
if (reset && ['backward', 'reload'].includes(navigation)) {
|
|
1628
|
+
this.firstDoc = null;
|
|
1629
|
+
this.currentClientPageIndex = 0;
|
|
1630
|
+
}
|
|
1631
|
+
const activeFilters = this.filtersForm.controls
|
|
1632
|
+
.flatMap((control) => {
|
|
1633
|
+
var _a, _b, _c, _d, _e;
|
|
1634
|
+
const group = control;
|
|
1635
|
+
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1636
|
+
if (!selectedFilter)
|
|
1637
|
+
return [];
|
|
1638
|
+
const arrange = selectedFilter.arrange;
|
|
1639
|
+
if (arrange === 'filter') {
|
|
1640
|
+
const filterValue = (_b = group.get('typeFilter')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1641
|
+
if (!filterValue)
|
|
1642
|
+
return [];
|
|
1643
|
+
return {
|
|
1644
|
+
arrange,
|
|
1645
|
+
filter: {
|
|
1646
|
+
property: selectedFilter.property,
|
|
1647
|
+
filtering: filterValue,
|
|
1648
|
+
},
|
|
1649
|
+
dateFilter: undefined,
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
if (arrange === 'filterByDate') {
|
|
1653
|
+
const initial = (_c = group.get('initialDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1654
|
+
const final = (_d = group.get('finalDate')) === null || _d === void 0 ? void 0 : _d.value;
|
|
1655
|
+
if (initial && final) {
|
|
1656
|
+
const [dayI, monthI, yearI] = initial.split('/');
|
|
1657
|
+
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1658
|
+
const [dayF, monthF, yearF] = final.split('/');
|
|
1659
|
+
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1660
|
+
finalDate.setHours(23, 59, 59);
|
|
1661
|
+
return {
|
|
1662
|
+
arrange,
|
|
1663
|
+
filter: undefined,
|
|
1664
|
+
dateFilter: {
|
|
1665
|
+
initial: initialDate,
|
|
1666
|
+
final: finalDate,
|
|
1667
|
+
},
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
return [];
|
|
1671
|
+
}
|
|
1672
|
+
if (selectedFilter.hasOwnProperty('items') && arrange === 'equals') {
|
|
1673
|
+
const selectedItems = (_e = group.get('selectItem')) === null || _e === void 0 ? void 0 : _e.value;
|
|
1674
|
+
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1675
|
+
return selectedItems.map((item) => ({
|
|
1676
|
+
arrange,
|
|
1677
|
+
filter: {
|
|
1678
|
+
property: item.property,
|
|
1679
|
+
filtering: item.value,
|
|
1680
|
+
},
|
|
1681
|
+
dateFilter: undefined,
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
return [];
|
|
1686
|
+
})
|
|
1687
|
+
.filter((f) => { var _a; return f && (((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) !== undefined || f.dateFilter); });
|
|
1688
|
+
this.arrange = {
|
|
1689
|
+
filters: activeFilters,
|
|
1690
|
+
sortBy: this.sortBy,
|
|
1691
|
+
};
|
|
1692
|
+
const paginated = {
|
|
1693
|
+
batchSize: this.pageSize,
|
|
1694
|
+
collection: this.data.collection,
|
|
1695
|
+
doc: { lastDoc: this.lastDoc, firstDoc: this.firstDoc },
|
|
1696
|
+
navigation,
|
|
1697
|
+
arrange: this.arrange,
|
|
1698
|
+
conditions: this.data.conditions,
|
|
1699
|
+
size: this.totalItems,
|
|
1700
|
+
filterFn: this.data.filterFn,
|
|
1701
|
+
clientPageIndex: this.currentClientPageIndex,
|
|
1702
|
+
};
|
|
1703
|
+
const result = yield this.tableService.getPaginated(paginated);
|
|
1704
|
+
this.items = result.items;
|
|
1705
|
+
yield this.loadRelations();
|
|
1706
|
+
yield this.loadQueryLengths();
|
|
1707
|
+
this.lastDoc = result.lastDoc;
|
|
1708
|
+
this.firstDoc = result.firstDoc;
|
|
1709
|
+
// Atualizar currentClientPageIndex se retornado pelo fallback
|
|
1710
|
+
if (result.currentClientPageIndex !== undefined) {
|
|
1711
|
+
this.currentClientPageIndex = result.currentClientPageIndex;
|
|
1712
|
+
}
|
|
1713
|
+
let sum = 0;
|
|
1714
|
+
if (this.data.totalRef) {
|
|
1715
|
+
for (const totalRef of this.data.totalRef) {
|
|
1716
|
+
const totalRefDoc = yield totalRef.ref.get();
|
|
1717
|
+
const docData = totalRefDoc.data();
|
|
1718
|
+
if (docData || result.filterLength) {
|
|
1719
|
+
sum =
|
|
1720
|
+
(_a = result.filterLength) !== null && _a !== void 0 ? _a : (sum + (docData ? docData[totalRef.field] : 0));
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
this.totalItems = sum;
|
|
1724
|
+
}
|
|
1725
|
+
this.hasNextPage = result.hasNextPage;
|
|
1726
|
+
this.dataSource = new MatTableDataSource(this.items);
|
|
1727
|
+
this.filterPredicate = this.dataSource.filterPredicate;
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
onPageChange(event) {
|
|
1731
|
+
var _a;
|
|
1732
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1733
|
+
if (this.data.pagination === true && event) {
|
|
1734
|
+
this.isLoading = true;
|
|
1735
|
+
const previousPageIndex = (_a = event.previousPageIndex) !== null && _a !== void 0 ? _a : 0;
|
|
1736
|
+
const pageIndex = event.pageIndex;
|
|
1737
|
+
const currentComponentPageSize = this.pageSize;
|
|
1738
|
+
const eventPageSize = event.pageSize;
|
|
1739
|
+
const totalItems = this.totalItems;
|
|
1740
|
+
let navigationDirection;
|
|
1741
|
+
let resetDocs = false;
|
|
1742
|
+
let originalPageSize = null;
|
|
1743
|
+
const lastPageIndex = Math.max(0, Math.ceil(totalItems / eventPageSize) - 1);
|
|
1744
|
+
// Atualizar currentClientPageIndex sempre para o fallback
|
|
1745
|
+
this.currentClientPageIndex = pageIndex;
|
|
1746
|
+
if (previousPageIndex !== undefined && pageIndex > previousPageIndex) {
|
|
1747
|
+
this.currentPageNumber++;
|
|
1748
|
+
}
|
|
1749
|
+
else if (previousPageIndex !== undefined &&
|
|
1750
|
+
pageIndex < previousPageIndex) {
|
|
1751
|
+
this.currentPageNumber = Math.max(1, this.currentPageNumber - 1);
|
|
1752
|
+
}
|
|
1753
|
+
if (eventPageSize !== currentComponentPageSize) {
|
|
1754
|
+
console.log('Alterou a quantidade de elementos exibidos por página');
|
|
1755
|
+
this.pageSize = eventPageSize;
|
|
1756
|
+
navigationDirection = 'forward';
|
|
1757
|
+
resetDocs = true;
|
|
1758
|
+
this.currentClientPageIndex = 0;
|
|
1759
|
+
}
|
|
1760
|
+
else if (pageIndex === 0 &&
|
|
1761
|
+
previousPageIndex !== undefined &&
|
|
1762
|
+
pageIndex < previousPageIndex) {
|
|
1763
|
+
console.log('Pulou para a primeira página');
|
|
1764
|
+
navigationDirection = 'forward';
|
|
1765
|
+
this.currentPageNumber = 1;
|
|
1766
|
+
this.currentClientPageIndex = 0;
|
|
1767
|
+
resetDocs = true;
|
|
1768
|
+
}
|
|
1769
|
+
else if (pageIndex === lastPageIndex &&
|
|
1770
|
+
previousPageIndex !== undefined &&
|
|
1771
|
+
pageIndex > previousPageIndex &&
|
|
1772
|
+
pageIndex - previousPageIndex > 1) {
|
|
1773
|
+
console.log('Pulou para a ultima página');
|
|
1774
|
+
navigationDirection = 'backward';
|
|
1775
|
+
resetDocs = true;
|
|
1776
|
+
const itemsExpectedInLastPage = totalItems - lastPageIndex * eventPageSize;
|
|
1777
|
+
if (itemsExpectedInLastPage > 0 &&
|
|
1778
|
+
itemsExpectedInLastPage < eventPageSize) {
|
|
1779
|
+
originalPageSize = this.pageSize;
|
|
1780
|
+
this.pageSize = itemsExpectedInLastPage;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
else if (previousPageIndex !== undefined &&
|
|
1784
|
+
pageIndex > previousPageIndex) {
|
|
1785
|
+
console.log('Procedendo');
|
|
1786
|
+
navigationDirection = 'forward';
|
|
1787
|
+
resetDocs = false;
|
|
1788
|
+
}
|
|
1789
|
+
else if (previousPageIndex !== undefined &&
|
|
1790
|
+
pageIndex < previousPageIndex) {
|
|
1791
|
+
console.log('Retrocedendo.');
|
|
1792
|
+
navigationDirection = 'backward';
|
|
1793
|
+
resetDocs = false;
|
|
1794
|
+
}
|
|
1795
|
+
else if (previousPageIndex !== undefined &&
|
|
1796
|
+
pageIndex === previousPageIndex) {
|
|
1797
|
+
console.log('Recarregando.');
|
|
1798
|
+
navigationDirection = 'reload';
|
|
1799
|
+
resetDocs = false;
|
|
1800
|
+
}
|
|
1801
|
+
else if (previousPageIndex === undefined && pageIndex === 0) {
|
|
1802
|
+
console.log('Evento inicial do paginador para pág 0. ngOnInit carregou.');
|
|
1803
|
+
this.isLoading = false;
|
|
1804
|
+
if (event)
|
|
1805
|
+
this.pageEvent = event;
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
else {
|
|
1809
|
+
console.warn('INESPERADO! Condição de navegação não tratada:', event);
|
|
1810
|
+
this.isLoading = false;
|
|
1811
|
+
if (event)
|
|
1812
|
+
this.pageEvent = event;
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
if (navigationDirection) {
|
|
1816
|
+
try {
|
|
1817
|
+
yield this.loadItemsPaginated(navigationDirection, resetDocs);
|
|
1818
|
+
}
|
|
1819
|
+
catch (error) {
|
|
1820
|
+
console.error('Erro ao carregar itens paginados:', error);
|
|
1821
|
+
}
|
|
1822
|
+
finally {
|
|
1823
|
+
if (originalPageSize !== null) {
|
|
1824
|
+
this.pageSize = originalPageSize;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
if (event)
|
|
1829
|
+
this.pageEvent = event;
|
|
1830
|
+
this.isLoading = false;
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
// Outros métodos
|
|
1835
|
+
applyFilter(value) {
|
|
1836
|
+
// Sem paginação
|
|
1837
|
+
if (this.data.pagination === false) {
|
|
1838
|
+
this.dataSource.filter = String(value).trim().toLowerCase();
|
|
1839
|
+
}
|
|
1840
|
+
// Com paginação
|
|
1841
|
+
if (this.data.pagination === true) {
|
|
1842
|
+
this.filterValue = value;
|
|
1843
|
+
this.filterSubject.next(this.filterValue);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
goToDetails(row) {
|
|
1847
|
+
if (this.data.isNotClickable) {
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
const urlPath = this.data.url || this.data.name;
|
|
1851
|
+
const url = this.router.serializeUrl(this.router.createUrlTree([`/${urlPath}`, row.id]));
|
|
1852
|
+
window.open(url, '_blank');
|
|
1853
|
+
}
|
|
1854
|
+
getRelation(params) {
|
|
1855
|
+
var _a;
|
|
1856
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1857
|
+
try {
|
|
1858
|
+
let snapshot;
|
|
1859
|
+
if (params.id !== '' &&
|
|
1860
|
+
params.id !== undefined &&
|
|
1861
|
+
params.collection !== undefined &&
|
|
1862
|
+
params.collection !== '') {
|
|
1863
|
+
snapshot = yield firstValueFrom(this.firestore.collection(params.collection).doc(params.id).get());
|
|
1864
|
+
}
|
|
1865
|
+
if (snapshot && snapshot.exists) {
|
|
1866
|
+
const data = snapshot.data();
|
|
1867
|
+
return (_a = data === null || data === void 0 ? void 0 : data[params.newProperty]) !== null && _a !== void 0 ? _a : '';
|
|
1868
|
+
}
|
|
1869
|
+
return '';
|
|
1870
|
+
}
|
|
1871
|
+
catch (e) {
|
|
1872
|
+
console.log(e);
|
|
1873
|
+
return '';
|
|
1874
|
+
}
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
loadRelations() {
|
|
1878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1879
|
+
const relationPromises = this.data.displayedColumns
|
|
1880
|
+
.filter((col) => col.relation)
|
|
1881
|
+
.flatMap((col) => this.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
1882
|
+
if (col.relation) {
|
|
1883
|
+
item[col.property] = yield this.getRelation({
|
|
1884
|
+
id: item[col.relation.property],
|
|
1885
|
+
collection: col.relation.collection,
|
|
1886
|
+
newProperty: col.relation.newProperty,
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
})));
|
|
1890
|
+
yield Promise.all(relationPromises);
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
getQueryLength(params) {
|
|
1894
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1895
|
+
const snapshot = yield this.firestore
|
|
1896
|
+
.collection(params.relation.collection)
|
|
1897
|
+
.ref.where(params.relation.property, params.relation.operator, params.item[params.relation.value])
|
|
1898
|
+
.get();
|
|
1899
|
+
return snapshot.size;
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
loadQueryLengths() {
|
|
1903
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1904
|
+
const lengthPromises = this.data.displayedColumns
|
|
1905
|
+
.filter((col) => col.queryLength)
|
|
1906
|
+
.flatMap((col) => this.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
1907
|
+
if (col.queryLength) {
|
|
1908
|
+
item[col.property] = yield this.getQueryLength({
|
|
1909
|
+
item: item,
|
|
1910
|
+
relation: col.queryLength,
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
})));
|
|
1914
|
+
yield Promise.all(lengthPromises);
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
filterItems() {
|
|
1918
|
+
if (this.data.conditions) {
|
|
1919
|
+
this.data.conditions.forEach((cond) => {
|
|
1920
|
+
this.items = this.items.filter((item) => {
|
|
1921
|
+
const operatorFunction = this.tableService.operators[cond.operator];
|
|
1922
|
+
if (operatorFunction) {
|
|
1923
|
+
return operatorFunction(item[cond.firestoreProperty], cond.dashProperty);
|
|
1924
|
+
}
|
|
1925
|
+
return false;
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
buildArrangeFromFilters() {
|
|
1931
|
+
const activeFilters = this.filtersForm.controls
|
|
1932
|
+
.flatMap((control) => {
|
|
1933
|
+
var _a, _b, _c, _d, _e;
|
|
1934
|
+
const group = control;
|
|
1935
|
+
const selectedFilter = (_a = group.get('selectFilter')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1936
|
+
if (!selectedFilter)
|
|
1937
|
+
return [];
|
|
1938
|
+
const arrange = selectedFilter.arrange;
|
|
1939
|
+
if (arrange === 'filter') {
|
|
1940
|
+
const filterValue = (_b = group.get('typeFilter')) === null || _b === void 0 ? void 0 : _b.value;
|
|
1941
|
+
if (!filterValue)
|
|
1942
|
+
return [];
|
|
1943
|
+
return {
|
|
1944
|
+
arrange,
|
|
1945
|
+
filter: {
|
|
1946
|
+
property: selectedFilter.property,
|
|
1947
|
+
filtering: filterValue,
|
|
1948
|
+
},
|
|
1949
|
+
dateFilter: undefined,
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
if (arrange === 'filterByDate') {
|
|
1953
|
+
const initial = (_c = group.get('initialDate')) === null || _c === void 0 ? void 0 : _c.value;
|
|
1954
|
+
const final = (_d = group.get('finalDate')) === null || _d === void 0 ? void 0 : _d.value;
|
|
1955
|
+
if (initial && final) {
|
|
1956
|
+
try {
|
|
1957
|
+
const [dayI, monthI, yearI] = initial.split('/');
|
|
1958
|
+
const initialDate = new Date(`${monthI}/${dayI}/${yearI}`);
|
|
1959
|
+
const [dayF, monthF, yearF] = final.split('/');
|
|
1960
|
+
const finalDate = new Date(`${monthF}/${dayF}/${yearF}`);
|
|
1961
|
+
finalDate.setHours(23, 59, 59);
|
|
1962
|
+
return {
|
|
1963
|
+
arrange,
|
|
1964
|
+
filter: undefined,
|
|
1965
|
+
dateFilter: {
|
|
1966
|
+
initial: initialDate,
|
|
1967
|
+
final: finalDate,
|
|
1968
|
+
},
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
catch (error) {
|
|
1972
|
+
return [];
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
return [];
|
|
1976
|
+
}
|
|
1977
|
+
if (selectedFilter.hasOwnProperty('items') && arrange === 'equals') {
|
|
1978
|
+
const selectedItems = (_e = group.get('selectItem')) === null || _e === void 0 ? void 0 : _e.value;
|
|
1979
|
+
if (Array.isArray(selectedItems) && selectedItems.length > 0) {
|
|
1980
|
+
return selectedItems.map((item) => ({
|
|
1981
|
+
arrange,
|
|
1982
|
+
filter: {
|
|
1983
|
+
property: item.property,
|
|
1984
|
+
filtering: item.value,
|
|
1985
|
+
},
|
|
1986
|
+
dateFilter: undefined,
|
|
1987
|
+
}));
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
return [];
|
|
1991
|
+
})
|
|
1992
|
+
.filter((f) => { var _a; return f && (((_a = f.filter) === null || _a === void 0 ? void 0 : _a.filtering) !== undefined || f.dateFilter); });
|
|
1993
|
+
return {
|
|
1994
|
+
filters: activeFilters,
|
|
1995
|
+
sortBy: this.sortBy,
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
// Filtro de data
|
|
1999
|
+
search(event) {
|
|
2000
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2001
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2002
|
+
// Prevenir comportamento padrão do formulário ao pressionar Enter
|
|
2003
|
+
if (event) {
|
|
2004
|
+
event.preventDefault();
|
|
2005
|
+
event.stopPropagation();
|
|
2006
|
+
}
|
|
2007
|
+
if (this.selectSort.value) {
|
|
2008
|
+
if (this.selectSort.value.arrange === 'ascending') {
|
|
2009
|
+
this.sortBy = {
|
|
2010
|
+
field: this.selectSort.value.property,
|
|
2011
|
+
order: 'asc',
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
if (this.selectSort.value.arrange === 'descending') {
|
|
2015
|
+
this.sortBy = {
|
|
2016
|
+
field: this.selectSort.value.property,
|
|
2017
|
+
order: 'desc',
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
// Sem paginação: aplicar filtros client-side
|
|
2022
|
+
if (this.data.pagination === false) {
|
|
2023
|
+
// Atualizar arrange com os filtros ativos
|
|
2024
|
+
this.arrange = this.buildArrangeFromFilters();
|
|
2025
|
+
this.applyFiltersToDataSource();
|
|
2026
|
+
this.currentArrange =
|
|
2027
|
+
this.filtersForm.length > 0
|
|
2028
|
+
? (_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 : ''
|
|
2029
|
+
: '';
|
|
2030
|
+
}
|
|
2031
|
+
else {
|
|
2032
|
+
// Com paginação: comportamento original
|
|
2033
|
+
yield this.loadItemsPaginated('reload', true);
|
|
2034
|
+
this.currentArrange =
|
|
2035
|
+
this.filtersForm.length > 0
|
|
2036
|
+
? (_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 : ''
|
|
2037
|
+
: '';
|
|
2038
|
+
this.paginator.firstPage();
|
|
2039
|
+
}
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
resetFilter() {
|
|
2043
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2044
|
+
this.dataSource.filter = '';
|
|
2045
|
+
if (this.filterPredicate) {
|
|
2046
|
+
this.dataSource.filterPredicate = this.filterPredicate;
|
|
2047
|
+
}
|
|
2048
|
+
this.filtersForm.clear();
|
|
2049
|
+
this.addFilter();
|
|
2050
|
+
this.selectSort.patchValue('');
|
|
2051
|
+
this.sortBy = {
|
|
2052
|
+
order: this.data.sortBy ? this.data.sortBy.order : 'desc',
|
|
2053
|
+
field: this.data.sortBy ? this.data.sortBy.field : 'createdAt',
|
|
2054
|
+
};
|
|
2055
|
+
// Sem paginação: recarregar itens originais
|
|
2056
|
+
if (this.data.pagination === false) {
|
|
2057
|
+
// Resetar arrange para valores padrão
|
|
2058
|
+
this.arrange = {
|
|
2059
|
+
filters: [],
|
|
2060
|
+
sortBy: this.sortBy,
|
|
2061
|
+
};
|
|
2062
|
+
this.dataSource.data = [...this.items];
|
|
2063
|
+
this.totalItems = this.items.length;
|
|
2064
|
+
this.currentArrange = '';
|
|
2065
|
+
}
|
|
2066
|
+
else {
|
|
2067
|
+
// Com paginação: comportamento original
|
|
2068
|
+
yield this.loadItemsPaginated('reload', true);
|
|
2069
|
+
this.currentArrange = '';
|
|
2070
|
+
this.paginator.firstPage();
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
// Método público para recarregar a tabela
|
|
2075
|
+
reloadTable() {
|
|
2076
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2077
|
+
if (this.data.pagination) {
|
|
2078
|
+
yield this.loadItemsPaginated('reload', true);
|
|
2079
|
+
this.paginator.firstPage();
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
yield this.loadItems();
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
updateDisplayedColumns() {
|
|
2087
|
+
if (this.dataSource) {
|
|
2088
|
+
this.dataSource = new MatTableDataSource([]);
|
|
2089
|
+
}
|
|
2090
|
+
this.columnProperties = this.data.displayedColumns.map((column) => {
|
|
2091
|
+
return column.property;
|
|
2092
|
+
});
|
|
2093
|
+
this.dropdownItems = [];
|
|
2094
|
+
this.sortableDropdownItems = [];
|
|
2095
|
+
this.data.displayedColumns.forEach((col) => {
|
|
2096
|
+
if (col.isFilterable) {
|
|
2097
|
+
this.dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filter', title: col.title }));
|
|
2098
|
+
}
|
|
2099
|
+
if (col.isSortable) {
|
|
2100
|
+
this.sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'ascending', title: col.title + ': crescente' }));
|
|
2101
|
+
this.sortableDropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'descending', title: col.title + ': decrescente' }));
|
|
2102
|
+
}
|
|
2103
|
+
if (col.isFilterableByDate) {
|
|
2104
|
+
this.dropdownItems.push(Object.assign(Object.assign({}, col), { arrange: 'filterByDate', title: col.title + ': filtro por data' }));
|
|
2105
|
+
}
|
|
2106
|
+
});
|
|
2107
|
+
if (this.data.filterableOptions &&
|
|
2108
|
+
Array.isArray(this.data.filterableOptions)) {
|
|
2109
|
+
this.data.filterableOptions.forEach((option) => this.dropdownItems.push(Object.assign(Object.assign({}, option), { arrange: 'equals' })));
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
isString(value) {
|
|
2113
|
+
return typeof value === 'string';
|
|
2114
|
+
}
|
|
2115
|
+
// Métodos para controle do tooltip
|
|
2116
|
+
onCellMouseEnter(event, row, col) {
|
|
2117
|
+
// Só mostrar tooltip se a coluna tiver charLimit definido
|
|
2118
|
+
if (!col.charLimit) {
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
const fullValue = this.getDisplayValue(col, row, true);
|
|
2122
|
+
// Só mostrar tooltip se o valor completo for maior que o limite
|
|
2123
|
+
if (fullValue.length <= col.charLimit) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
this.hoveredCell = { row, col };
|
|
2127
|
+
this.tooltipContent = fullValue;
|
|
2128
|
+
// Definir posição do tooltip
|
|
2129
|
+
this.tooltipPosition = {
|
|
2130
|
+
x: event.clientX + 10,
|
|
2131
|
+
y: event.clientY - 10,
|
|
2132
|
+
};
|
|
2133
|
+
// Timeout para mostrar o tooltip
|
|
2134
|
+
this.tooltipTimeout = setTimeout(() => {
|
|
2135
|
+
if (this.hoveredCell &&
|
|
2136
|
+
this.hoveredCell.row === row &&
|
|
2137
|
+
this.hoveredCell.col === col) {
|
|
2138
|
+
this.showTooltip = true;
|
|
2139
|
+
}
|
|
2140
|
+
}, 500);
|
|
2141
|
+
}
|
|
2142
|
+
onCellMouseLeave() {
|
|
2143
|
+
if (this.tooltipTimeout) {
|
|
2144
|
+
clearTimeout(this.tooltipTimeout);
|
|
2145
|
+
this.tooltipTimeout = null;
|
|
2146
|
+
}
|
|
2147
|
+
this.showTooltip = false;
|
|
2148
|
+
this.hoveredCell = null;
|
|
2149
|
+
this.tooltipContent = '';
|
|
2150
|
+
}
|
|
2151
|
+
onCellMouseMove(event) {
|
|
2152
|
+
if (this.showTooltip) {
|
|
2153
|
+
this.tooltipPosition = {
|
|
2154
|
+
x: event.clientX + 10,
|
|
2155
|
+
y: event.clientY - 10,
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
// Métodos para inversão vertical dos tabs
|
|
2160
|
+
getTabGroups(tabs) {
|
|
2161
|
+
if (!tabs || tabs.length === 0)
|
|
2162
|
+
return [];
|
|
2163
|
+
const totalGroups = Math.ceil(tabs.length / 6);
|
|
2164
|
+
const groups = [];
|
|
2165
|
+
// Criar array de índices invertidos (último grupo primeiro)
|
|
2166
|
+
for (let i = totalGroups - 1; i >= 0; i--) {
|
|
2167
|
+
groups.push(i);
|
|
2168
|
+
}
|
|
2169
|
+
return groups;
|
|
2170
|
+
}
|
|
2171
|
+
getTabGroup(tabs, groupIndex) {
|
|
2172
|
+
if (!tabs || tabs.length === 0)
|
|
2173
|
+
return [];
|
|
2174
|
+
const startIndex = groupIndex * 6;
|
|
2175
|
+
const endIndex = Math.min(startIndex + 6, tabs.length);
|
|
2176
|
+
return tabs.slice(startIndex, endIndex);
|
|
2177
|
+
}
|
|
2178
|
+
getRealTabIndex(groupIndex, tabIndexInGroup) {
|
|
2179
|
+
var _a;
|
|
2180
|
+
if (!((_a = this.data.tabs) === null || _a === void 0 ? void 0 : _a.tabsData))
|
|
2181
|
+
return 0;
|
|
2182
|
+
const totalGroups = Math.ceil(this.data.tabs.tabsData.length / 6);
|
|
2183
|
+
const realGroupIndex = totalGroups - 1 - groupIndex;
|
|
2184
|
+
return realGroupIndex * 6 + tabIndexInGroup;
|
|
2185
|
+
}
|
|
2186
|
+
onTableSelected(i, j) {
|
|
2187
|
+
var _a;
|
|
2188
|
+
if (!((_a = this.data.tabs) === null || _a === void 0 ? void 0 : _a.tabsData) || !this.data.tabs.method)
|
|
2189
|
+
return;
|
|
2190
|
+
this.selectedTab = this.getRealTabIndex(i, j);
|
|
2191
|
+
const tab = this.data.tabs.tabsData[this.selectedTab];
|
|
2192
|
+
if (tab) {
|
|
2193
|
+
this.data.tabs.method(tab, this.selectedTab);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
isTabSelected(originalIndex) {
|
|
2197
|
+
return this.selectedTab === originalIndex;
|
|
2198
|
+
}
|
|
2199
|
+
shouldShowActionButton() {
|
|
2200
|
+
var _a, _b;
|
|
2201
|
+
if (!((_a = this.data) === null || _a === void 0 ? void 0 : _a.actionButton)) {
|
|
2202
|
+
return false;
|
|
2203
|
+
}
|
|
2204
|
+
if (!this.data.actionButton.condition) {
|
|
2205
|
+
return true;
|
|
2206
|
+
}
|
|
2207
|
+
try {
|
|
2208
|
+
return (_b = this.data.actionButton.condition(null)) !== null && _b !== void 0 ? _b : true;
|
|
2209
|
+
}
|
|
2210
|
+
catch (_c) {
|
|
2211
|
+
return true;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
// Método para lidar com download (diferente para paginado e não paginado)
|
|
2215
|
+
handleDownload() {
|
|
2216
|
+
if (!this.downloadTable)
|
|
2217
|
+
return;
|
|
2218
|
+
// Se não há paginação, usar dados filtrados do dataSource
|
|
2219
|
+
if (this.data.pagination === false) {
|
|
2220
|
+
// Atualizar filteredItems com os dados filtrados do dataSource
|
|
2221
|
+
// (que já inclui filtro de texto aplicado via filterPredicate)
|
|
2222
|
+
if (this.dataSource && this.dataSource.filteredData) {
|
|
2223
|
+
this.filteredItems = [...this.dataSource.filteredData];
|
|
2224
|
+
}
|
|
2225
|
+
// Construir arrange com os filtros ativos (se houver)
|
|
2226
|
+
const arrange = this.buildArrangeFromFilters();
|
|
2227
|
+
this.downloadTable(arrange, this.data.conditions || []);
|
|
2228
|
+
}
|
|
2229
|
+
else {
|
|
2230
|
+
// Modo paginado: usar arrange existente (comportamento original)
|
|
2231
|
+
if (this.arrange) {
|
|
2232
|
+
this.downloadTable(this.arrange, this.data.conditions || []);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
TableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, deps: [{ token: i1$1.Router }, { token: TableService }, { token: i1.AngularFirestore }], target: i0.ɵɵFactoryTarget.Component });
|
|
2238
|
+
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 }], ngImport: i0, template: "<div *ngIf=\"data\" class=\"card-body\">\n <div class=\"flex flex-col justify-between gap-6\">\n <!-- UNIFIED CONTROL PANEL: FILTERS, SORT & ACTIONS -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"\n data.pagination === true &&\n (dropdownItems.length > 0 ||\n sortableDropdownItems.length > 0 ||\n data.actionButton)\n \"\n >\n <!-- PANEL HEADER: Title, Custom Action, and Global Actions -->\n <div\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\"\n >\n <!-- Left Side: Title & Main Action Button -->\n <div class=\"flex flex-wrap items-center gap-4\">\n <div class=\"flex items-center gap-2\">\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\n <span class=\"text-lg font-semibold text-gray-700\"\n >Filtros e A\u00E7\u00F5es</span\n >\n </div>\n <button\n *ngIf=\"data.actionButton && data.actionButton.condition\"\n [ngClass]=\"\n (data.actionButton.colorClass || 'bg-blue-500') +\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\n \"\n [routerLink]=\"data.actionButton.routerLink\"\n (click)=\"\n data.actionButton.method ? data.actionButton.method($event) : null\n \"\n >\n <i\n *ngIf=\"data.actionButton.icon\"\n [class]=\"data.actionButton.icon\"\n ></i>\n {{ data.actionButton.label }}\n </button>\n </div>\n\n <!-- Right Side: Search, Reset, Export -->\n <div\n class=\"flex flex-wrap gap-3\"\n *ngIf=\"\n this.hasFilterableColumn === true || this.hasSortableColumn === true\n \"\n >\n <button\n (click)=\"search()\"\n type=\"button\"\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\"\n matTooltip=\"Aplicar filtros\"\n >\n <i class=\"fa fa-search\"></i>\n Pesquisar\n </button>\n\n <button\n (click)=\"resetFilter()\"\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\"\n matTooltip=\"Limpar filtros\"\n >\n <i class=\"fas fa-redo-alt\"></i>\n Resetar\n </button>\n\n <button\n *ngIf=\"data.download !== false && downloadTable\"\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\"\n matTooltipPosition=\"above\"\n matTooltip=\"Exportar Tabela\"\n [disabled]=\"\n this.dataSource && this.dataSource.filteredData.length <= 0\n \"\n (click)=\"\n $any(arrange) && downloadTable !== undefined\n ? downloadTable($any(arrange), data.conditions || [])\n : null\n \"\n >\n <i class=\"fa fa-download\"></i>\n Exportar\n </button>\n </div>\n </div>\n\n <!-- FILTERS CONTENT (WITH REFINEMENTS) -->\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\n <div\n [formGroup]=\"$any(filterGroup)\"\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\n class=\"flex flex-wrap items-center gap-3 rounded-lg border border-gray-200 p-2\"\n >\n <!-- FILTER TYPE SELECTOR -->\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Tipo de filtro</mat-label>\n <mat-select\n placeholder=\"Selecione o tipo...\"\n formControlName=\"selectFilter\"\n (selectionChange)=\"onSelectFilterChange()\"\n >\n <mat-option *ngFor=\"let item of getAvailableFilterOptions()\" [value]=\"item\">\n <div class=\"flex items-center gap-2\">\n <i\n [class]=\"item.icon || 'fa fa-filter'\"\n class=\"text-sm text-blue-500\"\n ></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- TEXT FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-gray-400\"></i>\n <span>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Filtrar\"\n }}</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n formControlName=\"typeFilter\"\n matInput\n placeholder=\"Digite para filtrar...\"\n #input\n />\n </mat-form-field>\n </div>\n\n <!-- DROPDOWN FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value &&\n $any(filterGroup)\n .get('selectFilter')\n ?.value.hasOwnProperty('items')\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Selecione\"\n }}</mat-label>\n <mat-select\n placeholder=\"Selecione...\"\n formControlName=\"selectItem\"\n multiple\n >\n <mat-option\n *ngFor=\"\n let item of $any(filterGroup).get('selectFilter')?.value\n .items\n \"\n [value]=\"item\"\n >\n {{ item.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- DATE FILTER -->\n <div\n class=\"min-w-[340px] flex-auto\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\n 'filterByDate'\n \"\n >\n <div\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\n >\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Inicial</span>\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n formControlName=\"initialDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Final</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n matInput\n formControlName=\"finalDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <!-- REMOVE FILTER BUTTON -->\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\n <button\n (click)=\"removeFilter(i)\"\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\n matTooltip=\"Remover filtro\"\n >\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\n </button>\n </div>\n </div>\n </div>\n\n <!-- PANEL FOOTER: Add Filter & Sort -->\n <div\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\n >\n <!-- Add Filter Button -->\n <div *ngIf=\"dropdownItems.length > 0\">\n <button\n (click)=\"addFilter()\"\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\"\n matTooltip=\"Adicionar novo filtro\"\n >\n <i class=\"fa fa-plus mr-2\"></i>\n Adicionar Filtro\n </button>\n </div>\n\n <!-- Sort Dropdown -->\n <div\n class=\"w-full sm:w-auto sm:min-w-[250px]\"\n *ngIf=\"sortableDropdownItems.length > 0\"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Ordenar por</mat-label>\n <mat-select placeholder=\"Selecione...\" [formControl]=\"selectSort\">\n <mat-option\n *ngFor=\"let item of sortableDropdownItems\"\n [value]=\"item\"\n >\n <div class=\"flex items-center gap-2\">\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n </div>\n </div>\n\n <!-- SIMPLE SEARCH (for non-paginated tables) -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"data.pagination === false && hasFilterableColumn === true\"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-blue-500\"></i>\n Buscar\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n (keyup)=\"applyFilter(filterInput.value)\"\n placeholder=\"Digite para filtrar...\"\n #filterInput\n />\n <mat-icon matSuffix class=\"text-gray-500\">search</mat-icon>\n </mat-form-field>\n <button\n *ngIf=\"data.actionButton\"\n [ngClass]=\"\n (data.actionButton.colorClass || 'bg-blue-500') +\n ' float-right flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\n \"\n [routerLink]=\"data.actionButton.routerLink\"\n (click)=\"\n data.actionButton.method ? data.actionButton.method($event) : null\n \"\n >\n <i *ngIf=\"data.actionButton.icon\" [class]=\"data.actionButton.icon\"></i>\n {{ data.actionButton.label }}\n </button>\n </div>\n\n <!-- FILTERS PANEL (for non-paginated tables) -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"data.pagination === false && dropdownItems.length > 0\"\n >\n <!-- FILTERS CONTENT -->\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\n <div\n [formGroup]=\"$any(filterGroup)\"\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\n class=\"flex flex-wrap items-center gap-3 rounded-lg border border-gray-200 p-2\"\n >\n <!-- FILTER TYPE SELECTOR -->\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Tipo de filtro</mat-label>\n <mat-select\n placeholder=\"Selecione o tipo...\"\n formControlName=\"selectFilter\"\n (selectionChange)=\"onSelectFilterChange()\"\n >\n <mat-option *ngFor=\"let item of getAvailableFilterOptions()\" [value]=\"item\">\n <div class=\"flex items-center gap-2\">\n <i\n [class]=\"item.icon || 'fa fa-filter'\"\n class=\"text-sm text-blue-500\"\n ></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- TEXT FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-gray-400\"></i>\n <span>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Filtrar\"\n }}</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n formControlName=\"typeFilter\"\n matInput\n placeholder=\"Digite para filtrar...\"\n #input\n />\n </mat-form-field>\n </div>\n\n <!-- DROPDOWN FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value &&\n $any(filterGroup)\n .get('selectFilter')\n ?.value.hasOwnProperty('items')\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Selecione\"\n }}</mat-label>\n <mat-select\n placeholder=\"Selecione...\"\n formControlName=\"selectItem\"\n multiple\n >\n <mat-option\n *ngFor=\"\n let item of $any(filterGroup).get('selectFilter')?.value\n .items\n \"\n [value]=\"item\"\n >\n {{ item.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- DATE FILTER -->\n <div\n class=\"min-w-[340px] flex-auto\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\n 'filterByDate'\n \"\n >\n <div\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\n >\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Inicial</span>\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n (blur)=\"onDateFilterChange()\"\n formControlName=\"initialDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Final</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n (blur)=\"onDateFilterChange()\"\n matInput\n formControlName=\"finalDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <!-- REMOVE FILTER BUTTON -->\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\n <button\n (click)=\"removeFilter(i)\"\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\n matTooltip=\"Remover filtro\"\n >\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\n </button>\n </div>\n </div>\n </div>\n\n <!-- PANEL FOOTER: Add Filter & Actions -->\n <div\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\n >\n <!-- Add Filter Button -->\n <div *ngIf=\"dropdownItems.length > 0\">\n <button\n (click)=\"addFilter()\"\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\"\n matTooltip=\"Adicionar novo filtro\"\n >\n <i class=\"fa fa-plus mr-2\"></i>\n Adicionar Filtro\n </button>\n </div>\n\n <!-- Action Buttons -->\n <div class=\"flex flex-wrap gap-3\">\n <button\n (click)=\"search()\"\n type=\"button\"\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\"\n matTooltip=\"Aplicar filtros\"\n >\n <i class=\"fa fa-search\"></i>\n Aplicar\n </button>\n\n <button\n (click)=\"resetFilter()\"\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\"\n matTooltip=\"Limpar filtros\"\n >\n <i class=\"fas fa-redo-alt\"></i>\n Resetar\n </button>\n\n <button\n *ngIf=\"data.download !== false && downloadTable\"\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\"\n matTooltipPosition=\"above\"\n matTooltip=\"Exportar Tabela\"\n [disabled]=\"\n this.dataSource && this.dataSource.filteredData.length <= 0\n \"\n (click)=\"handleDownload()\"\n >\n <i class=\"fa fa-download\"></i>\n Exportar\n </button>\n </div>\n </div>\n </div>\n\n <div class=\"flex flex-col\">\n <div\n class=\"mx-auto flex flex-col\"\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\n >\n <!-- Calcular quantos grupos de 6 tabs existem -->\n <ng-container\n *ngFor=\"\n let groupIndex of getTabGroups(data.tabs.tabsData);\n let i = index\n \"\n >\n <div class=\"mx-auto flex flex-row\">\n <ng-container\n *ngFor=\"\n let tab of getTabGroup(data.tabs.tabsData, groupIndex);\n let j = index\n \"\n >\n <button\n class=\"border-2 border-gray-300 bg-gray-200 px-4 py-2 font-medium transition hover:brightness-95\"\n [ngClass]=\"\n isTabSelected(getRealTabIndex(i, j))\n ? 'border-b-0 brightness-110'\n : ''\n \"\n (click)=\"onTableSelected(i, j)\"\n >\n {{ tab.label }}\n <span\n *ngIf=\"tab.counter !== undefined\"\n class=\"ml-2 text-xs font-bold\"\n [ngClass]=\"tab.counterClass\"\n >\n {{ tab.counter }}\n </span>\n </button>\n </ng-container>\n </div>\n </ng-container>\n </div>\n <div class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl\">\n <table\n mat-table\n [dataSource]=\"dataSource\"\n matSort\n #sort=\"matSort\"\n matSortActive=\"createdAt\"\n matSortDirection=\"desc\"\n >\n <ng-container\n *ngFor=\"let col of data.displayedColumns\"\n matColumnDef=\"{{ col.property }}\"\n >\n <ng-container *matHeaderCellDef>\n <!-- IF THE COLUMN IS NOT SORTABLE, THEN DON'T SHOW THE SORT BUTTONS -->\n <th\n *ngIf=\"!col.isSortable || data.pagination === true\"\n mat-header-cell\n [ngClass]=\"\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\n (data.color?.text ? ' ' + $any(data.color).text : '')\n \"\n >\n {{ col.title }}\n </th>\n <!-- IF THE COLUMN IS SORTABLE, THEN SHOW THE SORT BUTTONS -->\n <th\n *ngIf=\"col.isSortable && data.pagination === false\"\n mat-header-cell\n mat-sort-header\n [ngClass]=\"\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\n (data.color?.text ? ' ' + $any(data.color).text : '')\n \"\n >\n {{ col.title }}\n </th>\n <td\n mat-cell\n *matCellDef=\"let row\"\n (click)=\"col.method ? col.method(row) : null\"\n (mouseenter)=\"onCellMouseEnter($event, row, col)\"\n (mouseleave)=\"onCellMouseLeave()\"\n (mousemove)=\"onCellMouseMove($event)\"\n >\n <!-- CHECK IF THE COLUMN MUST BE DISPLAYED -->\n <span *ngIf=\"!col.image && !col.iconClass && !col.method\">\n <ng-container>\n <span\n *ngIf=\"\n col.charLimit &&\n row[col.property] &&\n row[col.property].length > col.charLimit;\n else withinLimit\n \"\n >\n <a\n *ngIf=\"col.hasLink === true\"\n [href]=\"row[col.property]\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row) }}\n </a>\n <a\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\n [href]=\"col.hasLink\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row) }}\n </a>\n <span\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\n >\n {{ getDisplayValue(col, row) }}\n </span>\n </span>\n </ng-container>\n <ng-template #withinLimit>\n <a\n *ngIf=\"col.hasLink === true\"\n [href]=\"row[col.property]\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row, true) }}\n </a>\n <a\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\n [href]=\"col.hasLink\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row, true) }}\n </a>\n <span\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\n >\n {{ getDisplayValue(col, row, true) }}\n </span>\n </ng-template>\n </span>\n <!------------------- IMAGE ------------------>\n <img\n *ngIf=\"\n col.image && col.image.path && !col.iconClass && !col.method\n \"\n [src]=\"col.image.path + '/' + row[col.property]\"\n [ngClass]=\"col.image.class\"\n alt=\"Imagem\"\n />\n <img\n *ngIf=\"\n col.image && col.image.url && !col.iconClass && !col.method\n \"\n [src]=\"row[col.property]\"\n [ngClass]=\"col.image.class\"\n alt=\"Imagem\"\n />\n <ng-container *ngIf=\"col.iconClass\">\n <button\n *ngFor=\"let iconClass of col.iconClass\"\n (click)=\"\n iconClass.buttonMethod\n ? iconClass.buttonMethod(row, $event)\n : $event.stopPropagation()\n \"\n >\n <span\n [ngClass]=\"iconClass.class\"\n *ngIf=\"\n iconClass.condition === undefined ||\n (iconClass.condition !== undefined &&\n $any(iconClass.condition)(row))\n \"\n >{{ iconClass.text }}</span\n >\n </button>\n </ng-container>\n </td>\n </ng-container>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnProperties\"></tr>\n <tr\n [ngClass]=\"{\n 'example-element-row': data.isNotClickable === true,\n 'example-element-row cursor-pointer': !data.isNotClickable\n }\"\n mat-row\n *matRowDef=\"let row; columns: columnProperties\"\n (click)=\"goToDetails(row)\"\n ></tr>\n\n <!-- ROW SHOWN WHEN THERE IS NO MATCHING DATA. -->\n <tr class=\"mat-row\" *matNoDataRow>\n <td *ngIf=\"!isLoading\" class=\"mat-cell p-4\" colspan=\"4\">\n Nenhum resultado encontrado para a busca\n </td>\n </tr>\n </table>\n\n <div class=\"flex justify-center\" *ngIf=\"isLoading\">\n <mat-spinner></mat-spinner>\n </div>\n\n <div class=\"paginator-container\">\n <mat-paginator\n #paginator\n [pageSizeOptions]=\"[25, 50, 100]\"\n [pageSize]=\"pageSize\"\n [length]=\"totalItems\"\n showFirstLastButtons\n aria-label=\"Select page of periodic elements\"\n (page)=\"onPageChange($event)\"\n [ngClass]=\"{\n 'hide-length':\n ['filter', 'filterByDate', 'equals'].includes(\n this.currentArrange\n ) || this.data.filterFn,\n 'hide-next-button': !hasNextPage && data.pagination === true,\n 'hide-last-button':\n (!hasNextPage && data.pagination === true) || this.data.filterFn\n }\"\n >\n </mat-paginator>\n <div\n *ngIf=\"\n !isLoading &&\n dataSource?.data &&\n dataSource.data.length > 0 &&\n data?.filterFn\n \"\n class=\"page-number-display\"\n >\n {{ currentPageNumber }}\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- TOOLTIP PERSONALIZADO -->\n <div\n *ngIf=\"showTooltip\"\n class=\"fixed z-50 max-w-md break-words rounded-lg bg-gray-800 px-3 py-2 text-sm text-white shadow-lg\"\n [style.left.px]=\"tooltipPosition.x\"\n [style.top.px]=\"tooltipPosition.y\"\n [style.pointer-events]=\"'none'\"\n >\n {{ tooltipContent }}\n </div>\n</div>\n", styles: ["::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}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.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: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i6.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i6.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i6.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i6.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i6.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i6.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i6.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i6.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i6.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i6.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: i6.MatNoDataRow, selector: "ng-template[matNoDataRow]" }, { kind: "component", type: i7.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "directive", type: i8.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i8.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: i9.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i9.MatLabel, selector: "mat-label" }, { kind: "directive", type: i9.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i10.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: i11.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i12.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i13.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i14.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i15.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i16.NgxMaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "showTemplate", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime", "leadZero", "triggerOnMaskChange", "apm", "inputTransformFn", "outputTransformFn", "keepCharacterPositions"], outputs: ["maskFilled"], exportAs: ["mask", "ngxMask"] }] });
|
|
2239
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, decorators: [{
|
|
2240
|
+
type: Component,
|
|
2241
|
+
args: [{ selector: 'lib-table', template: "<div *ngIf=\"data\" class=\"card-body\">\n <div class=\"flex flex-col justify-between gap-6\">\n <!-- UNIFIED CONTROL PANEL: FILTERS, SORT & ACTIONS -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"\n data.pagination === true &&\n (dropdownItems.length > 0 ||\n sortableDropdownItems.length > 0 ||\n data.actionButton)\n \"\n >\n <!-- PANEL HEADER: Title, Custom Action, and Global Actions -->\n <div\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\"\n >\n <!-- Left Side: Title & Main Action Button -->\n <div class=\"flex flex-wrap items-center gap-4\">\n <div class=\"flex items-center gap-2\">\n <i class=\"fa fa-filter text-xl text-blue-500\"></i>\n <span class=\"text-lg font-semibold text-gray-700\"\n >Filtros e A\u00E7\u00F5es</span\n >\n </div>\n <button\n *ngIf=\"data.actionButton && data.actionButton.condition\"\n [ngClass]=\"\n (data.actionButton.colorClass || 'bg-blue-500') +\n ' flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\n \"\n [routerLink]=\"data.actionButton.routerLink\"\n (click)=\"\n data.actionButton.method ? data.actionButton.method($event) : null\n \"\n >\n <i\n *ngIf=\"data.actionButton.icon\"\n [class]=\"data.actionButton.icon\"\n ></i>\n {{ data.actionButton.label }}\n </button>\n </div>\n\n <!-- Right Side: Search, Reset, Export -->\n <div\n class=\"flex flex-wrap gap-3\"\n *ngIf=\"\n this.hasFilterableColumn === true || this.hasSortableColumn === true\n \"\n >\n <button\n (click)=\"search()\"\n type=\"button\"\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\"\n matTooltip=\"Aplicar filtros\"\n >\n <i class=\"fa fa-search\"></i>\n Pesquisar\n </button>\n\n <button\n (click)=\"resetFilter()\"\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\"\n matTooltip=\"Limpar filtros\"\n >\n <i class=\"fas fa-redo-alt\"></i>\n Resetar\n </button>\n\n <button\n *ngIf=\"data.download !== false && downloadTable\"\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\"\n matTooltipPosition=\"above\"\n matTooltip=\"Exportar Tabela\"\n [disabled]=\"\n this.dataSource && this.dataSource.filteredData.length <= 0\n \"\n (click)=\"\n $any(arrange) && downloadTable !== undefined\n ? downloadTable($any(arrange), data.conditions || [])\n : null\n \"\n >\n <i class=\"fa fa-download\"></i>\n Exportar\n </button>\n </div>\n </div>\n\n <!-- FILTERS CONTENT (WITH REFINEMENTS) -->\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\n <div\n [formGroup]=\"$any(filterGroup)\"\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\n class=\"flex flex-wrap items-center gap-3 rounded-lg border border-gray-200 p-2\"\n >\n <!-- FILTER TYPE SELECTOR -->\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Tipo de filtro</mat-label>\n <mat-select\n placeholder=\"Selecione o tipo...\"\n formControlName=\"selectFilter\"\n (selectionChange)=\"onSelectFilterChange()\"\n >\n <mat-option *ngFor=\"let item of getAvailableFilterOptions()\" [value]=\"item\">\n <div class=\"flex items-center gap-2\">\n <i\n [class]=\"item.icon || 'fa fa-filter'\"\n class=\"text-sm text-blue-500\"\n ></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- TEXT FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-gray-400\"></i>\n <span>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Filtrar\"\n }}</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n formControlName=\"typeFilter\"\n matInput\n placeholder=\"Digite para filtrar...\"\n #input\n />\n </mat-form-field>\n </div>\n\n <!-- DROPDOWN FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value &&\n $any(filterGroup)\n .get('selectFilter')\n ?.value.hasOwnProperty('items')\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Selecione\"\n }}</mat-label>\n <mat-select\n placeholder=\"Selecione...\"\n formControlName=\"selectItem\"\n multiple\n >\n <mat-option\n *ngFor=\"\n let item of $any(filterGroup).get('selectFilter')?.value\n .items\n \"\n [value]=\"item\"\n >\n {{ item.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- DATE FILTER -->\n <div\n class=\"min-w-[340px] flex-auto\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\n 'filterByDate'\n \"\n >\n <div\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\n >\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Inicial</span>\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n formControlName=\"initialDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Final</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n matInput\n formControlName=\"finalDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <!-- REMOVE FILTER BUTTON -->\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\n <button\n (click)=\"removeFilter(i)\"\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\n matTooltip=\"Remover filtro\"\n >\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\n </button>\n </div>\n </div>\n </div>\n\n <!-- PANEL FOOTER: Add Filter & Sort -->\n <div\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\n >\n <!-- Add Filter Button -->\n <div *ngIf=\"dropdownItems.length > 0\">\n <button\n (click)=\"addFilter()\"\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\"\n matTooltip=\"Adicionar novo filtro\"\n >\n <i class=\"fa fa-plus mr-2\"></i>\n Adicionar Filtro\n </button>\n </div>\n\n <!-- Sort Dropdown -->\n <div\n class=\"w-full sm:w-auto sm:min-w-[250px]\"\n *ngIf=\"sortableDropdownItems.length > 0\"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Ordenar por</mat-label>\n <mat-select placeholder=\"Selecione...\" [formControl]=\"selectSort\">\n <mat-option\n *ngFor=\"let item of sortableDropdownItems\"\n [value]=\"item\"\n >\n <div class=\"flex items-center gap-2\">\n <i class=\"fa fa-sort-alpha-down text-cyan-600\"></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n </div>\n </div>\n\n <!-- SIMPLE SEARCH (for non-paginated tables) -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"data.pagination === false && hasFilterableColumn === true\"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-blue-500\"></i>\n Buscar\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n (keyup)=\"applyFilter(filterInput.value)\"\n placeholder=\"Digite para filtrar...\"\n #filterInput\n />\n <mat-icon matSuffix class=\"text-gray-500\">search</mat-icon>\n </mat-form-field>\n <button\n *ngIf=\"data.actionButton\"\n [ngClass]=\"\n (data.actionButton.colorClass || 'bg-blue-500') +\n ' float-right flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white hover:opacity-70'\n \"\n [routerLink]=\"data.actionButton.routerLink\"\n (click)=\"\n data.actionButton.method ? data.actionButton.method($event) : null\n \"\n >\n <i *ngIf=\"data.actionButton.icon\" [class]=\"data.actionButton.icon\"></i>\n {{ data.actionButton.label }}\n </button>\n </div>\n\n <!-- FILTERS PANEL (for non-paginated tables) -->\n <div\n class=\"rounded-xl border border-gray-200 bg-white p-4 shadow-lg\"\n *ngIf=\"data.pagination === false && dropdownItems.length > 0\"\n >\n <!-- FILTERS CONTENT -->\n <div class=\"mb-4 space-y-3\" *ngIf=\"filtersForm.controls.length > 0\">\n <div\n [formGroup]=\"$any(filterGroup)\"\n *ngFor=\"let filterGroup of filtersForm.controls; let i = index\"\n class=\"flex flex-wrap items-center gap-3 rounded-lg border border-gray-200 p-2\"\n >\n <!-- FILTER TYPE SELECTOR -->\n <div class=\"min-w-[200px] flex-1\" *ngIf=\"dropdownItems.length > 0\">\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>Tipo de filtro</mat-label>\n <mat-select\n placeholder=\"Selecione o tipo...\"\n formControlName=\"selectFilter\"\n (selectionChange)=\"onSelectFilterChange()\"\n >\n <mat-option *ngFor=\"let item of getAvailableFilterOptions()\" [value]=\"item\">\n <div class=\"flex items-center gap-2\">\n <i\n [class]=\"item.icon || 'fa fa-filter'\"\n class=\"text-sm text-blue-500\"\n ></i>\n <span>{{ item.title }}</span>\n </div>\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- TEXT FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange === 'filter'\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-search text-gray-400\"></i>\n <span>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Filtrar\"\n }}</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n formControlName=\"typeFilter\"\n matInput\n placeholder=\"Digite para filtrar...\"\n #input\n />\n </mat-form-field>\n </div>\n\n <!-- DROPDOWN FILTER -->\n <div\n class=\"min-w-[200px] flex-1\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value &&\n $any(filterGroup)\n .get('selectFilter')\n ?.value.hasOwnProperty('items')\n \"\n >\n <mat-form-field appearance=\"outline\" class=\"w-full\">\n <mat-label>{{\n $any(filterGroup).get(\"selectFilter\")?.value?.title ||\n \"Selecione\"\n }}</mat-label>\n <mat-select\n placeholder=\"Selecione...\"\n formControlName=\"selectItem\"\n multiple\n >\n <mat-option\n *ngFor=\"\n let item of $any(filterGroup).get('selectFilter')?.value\n .items\n \"\n [value]=\"item\"\n >\n {{ item.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <!-- DATE FILTER -->\n <div\n class=\"min-w-[340px] flex-auto\"\n *ngIf=\"\n $any(filterGroup).get('selectFilter')?.value?.arrange ===\n 'filterByDate'\n \"\n >\n <div\n class=\"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center\"\n >\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Inicial</span>\n </mat-label>\n <input\n matInput\n (keyup.enter)=\"search($event)\"\n (blur)=\"onDateFilterChange()\"\n formControlName=\"initialDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n\n <mat-form-field appearance=\"outline\" class=\"flex-1\">\n <mat-label class=\"flex items-center gap-2\">\n <i class=\"fa fa-calendar text-gray-400\"></i>\n <span>Data Final</span>\n </mat-label>\n <input\n (keyup.enter)=\"search($event)\"\n (blur)=\"onDateFilterChange()\"\n matInput\n formControlName=\"finalDate\"\n [dropSpecialCharacters]=\"false\"\n mask=\"d0/M0/0000\"\n placeholder=\"DD/MM/AAAA\"\n maxlength=\"10\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <!-- REMOVE FILTER BUTTON -->\n <div *ngIf=\"filtersForm.length > 1\" class=\"ml-auto flex-shrink-0\">\n <button\n (click)=\"removeFilter(i)\"\n class=\"flex h-10 w-10 items-center justify-center rounded-full transition-colors duration-300 hover:bg-red-100\"\n matTooltip=\"Remover filtro\"\n >\n <i class=\"fa fa-trash text-red-500 hover:text-red-600\"></i>\n </button>\n </div>\n </div>\n </div>\n\n <!-- PANEL FOOTER: Add Filter & Actions -->\n <div\n class=\"-mb-2 flex flex-col items-center justify-between gap-4 border-t border-gray-200 pt-4 sm:flex-row\"\n >\n <!-- Add Filter Button -->\n <div *ngIf=\"dropdownItems.length > 0\">\n <button\n (click)=\"addFilter()\"\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\"\n matTooltip=\"Adicionar novo filtro\"\n >\n <i class=\"fa fa-plus mr-2\"></i>\n Adicionar Filtro\n </button>\n </div>\n\n <!-- Action Buttons -->\n <div class=\"flex flex-wrap gap-3\">\n <button\n (click)=\"search()\"\n type=\"button\"\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\"\n matTooltip=\"Aplicar filtros\"\n >\n <i class=\"fa fa-search\"></i>\n Aplicar\n </button>\n\n <button\n (click)=\"resetFilter()\"\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\"\n matTooltip=\"Limpar filtros\"\n >\n <i class=\"fas fa-redo-alt\"></i>\n Resetar\n </button>\n\n <button\n *ngIf=\"data.download !== false && downloadTable\"\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\"\n matTooltipPosition=\"above\"\n matTooltip=\"Exportar Tabela\"\n [disabled]=\"\n this.dataSource && this.dataSource.filteredData.length <= 0\n \"\n (click)=\"handleDownload()\"\n >\n <i class=\"fa fa-download\"></i>\n Exportar\n </button>\n </div>\n </div>\n </div>\n\n <div class=\"flex flex-col\">\n <div\n class=\"mx-auto flex flex-col\"\n *ngIf=\"data.tabs && data.tabs.tabsData && data.tabs.tabsData.length > 0\"\n >\n <!-- Calcular quantos grupos de 6 tabs existem -->\n <ng-container\n *ngFor=\"\n let groupIndex of getTabGroups(data.tabs.tabsData);\n let i = index\n \"\n >\n <div class=\"mx-auto flex flex-row\">\n <ng-container\n *ngFor=\"\n let tab of getTabGroup(data.tabs.tabsData, groupIndex);\n let j = index\n \"\n >\n <button\n class=\"border-2 border-gray-300 bg-gray-200 px-4 py-2 font-medium transition hover:brightness-95\"\n [ngClass]=\"\n isTabSelected(getRealTabIndex(i, j))\n ? 'border-b-0 brightness-110'\n : ''\n \"\n (click)=\"onTableSelected(i, j)\"\n >\n {{ tab.label }}\n <span\n *ngIf=\"tab.counter !== undefined\"\n class=\"ml-2 text-xs font-bold\"\n [ngClass]=\"tab.counterClass\"\n >\n {{ tab.counter }}\n </span>\n </button>\n </ng-container>\n </div>\n </ng-container>\n </div>\n <div class=\"mat-elevation-z8 w-full overflow-x-auto rounded-xl\">\n <table\n mat-table\n [dataSource]=\"dataSource\"\n matSort\n #sort=\"matSort\"\n matSortActive=\"createdAt\"\n matSortDirection=\"desc\"\n >\n <ng-container\n *ngFor=\"let col of data.displayedColumns\"\n matColumnDef=\"{{ col.property }}\"\n >\n <ng-container *matHeaderCellDef>\n <!-- IF THE COLUMN IS NOT SORTABLE, THEN DON'T SHOW THE SORT BUTTONS -->\n <th\n *ngIf=\"!col.isSortable || data.pagination === true\"\n mat-header-cell\n [ngClass]=\"\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\n (data.color?.text ? ' ' + $any(data.color).text : '')\n \"\n >\n {{ col.title }}\n </th>\n <!-- IF THE COLUMN IS SORTABLE, THEN SHOW THE SORT BUTTONS -->\n <th\n *ngIf=\"col.isSortable && data.pagination === false\"\n mat-header-cell\n mat-sort-header\n [ngClass]=\"\n (data.color?.bg ? ' ' + $any(data.color).bg : '') +\n (data.color?.text ? ' ' + $any(data.color).text : '')\n \"\n >\n {{ col.title }}\n </th>\n <td\n mat-cell\n *matCellDef=\"let row\"\n (click)=\"col.method ? col.method(row) : null\"\n (mouseenter)=\"onCellMouseEnter($event, row, col)\"\n (mouseleave)=\"onCellMouseLeave()\"\n (mousemove)=\"onCellMouseMove($event)\"\n >\n <!-- CHECK IF THE COLUMN MUST BE DISPLAYED -->\n <span *ngIf=\"!col.image && !col.iconClass && !col.method\">\n <ng-container>\n <span\n *ngIf=\"\n col.charLimit &&\n row[col.property] &&\n row[col.property].length > col.charLimit;\n else withinLimit\n \"\n >\n <a\n *ngIf=\"col.hasLink === true\"\n [href]=\"row[col.property]\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row) }}\n </a>\n <a\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\n [href]=\"col.hasLink\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row) }}\n </a>\n <span\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\n >\n {{ getDisplayValue(col, row) }}\n </span>\n </span>\n </ng-container>\n <ng-template #withinLimit>\n <a\n *ngIf=\"col.hasLink === true\"\n [href]=\"row[col.property]\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row, true) }}\n </a>\n <a\n *ngIf=\"col.hasLink && isString(col.hasLink)\"\n [href]=\"col.hasLink\"\n target=\"_blank\"\n >\n {{ getDisplayValue(col, row, true) }}\n </a>\n <span\n *ngIf=\"col.hasLink !== true && !isString(col.hasLink)\"\n >\n {{ getDisplayValue(col, row, true) }}\n </span>\n </ng-template>\n </span>\n <!------------------- IMAGE ------------------>\n <img\n *ngIf=\"\n col.image && col.image.path && !col.iconClass && !col.method\n \"\n [src]=\"col.image.path + '/' + row[col.property]\"\n [ngClass]=\"col.image.class\"\n alt=\"Imagem\"\n />\n <img\n *ngIf=\"\n col.image && col.image.url && !col.iconClass && !col.method\n \"\n [src]=\"row[col.property]\"\n [ngClass]=\"col.image.class\"\n alt=\"Imagem\"\n />\n <ng-container *ngIf=\"col.iconClass\">\n <button\n *ngFor=\"let iconClass of col.iconClass\"\n (click)=\"\n iconClass.buttonMethod\n ? iconClass.buttonMethod(row, $event)\n : $event.stopPropagation()\n \"\n >\n <span\n [ngClass]=\"iconClass.class\"\n *ngIf=\"\n iconClass.condition === undefined ||\n (iconClass.condition !== undefined &&\n $any(iconClass.condition)(row))\n \"\n >{{ iconClass.text }}</span\n >\n </button>\n </ng-container>\n </td>\n </ng-container>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnProperties\"></tr>\n <tr\n [ngClass]=\"{\n 'example-element-row': data.isNotClickable === true,\n 'example-element-row cursor-pointer': !data.isNotClickable\n }\"\n mat-row\n *matRowDef=\"let row; columns: columnProperties\"\n (click)=\"goToDetails(row)\"\n ></tr>\n\n <!-- ROW SHOWN WHEN THERE IS NO MATCHING DATA. -->\n <tr class=\"mat-row\" *matNoDataRow>\n <td *ngIf=\"!isLoading\" class=\"mat-cell p-4\" colspan=\"4\">\n Nenhum resultado encontrado para a busca\n </td>\n </tr>\n </table>\n\n <div class=\"flex justify-center\" *ngIf=\"isLoading\">\n <mat-spinner></mat-spinner>\n </div>\n\n <div class=\"paginator-container\">\n <mat-paginator\n #paginator\n [pageSizeOptions]=\"[25, 50, 100]\"\n [pageSize]=\"pageSize\"\n [length]=\"totalItems\"\n showFirstLastButtons\n aria-label=\"Select page of periodic elements\"\n (page)=\"onPageChange($event)\"\n [ngClass]=\"{\n 'hide-length':\n ['filter', 'filterByDate', 'equals'].includes(\n this.currentArrange\n ) || this.data.filterFn,\n 'hide-next-button': !hasNextPage && data.pagination === true,\n 'hide-last-button':\n (!hasNextPage && data.pagination === true) || this.data.filterFn\n }\"\n >\n </mat-paginator>\n <div\n *ngIf=\"\n !isLoading &&\n dataSource?.data &&\n dataSource.data.length > 0 &&\n data?.filterFn\n \"\n class=\"page-number-display\"\n >\n {{ currentPageNumber }}\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- TOOLTIP PERSONALIZADO -->\n <div\n *ngIf=\"showTooltip\"\n class=\"fixed z-50 max-w-md break-words rounded-lg bg-gray-800 px-3 py-2 text-sm text-white shadow-lg\"\n [style.left.px]=\"tooltipPosition.x\"\n [style.top.px]=\"tooltipPosition.y\"\n [style.pointer-events]=\"'none'\"\n >\n {{ tooltipContent }}\n </div>\n</div>\n", styles: ["::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}\n"] }]
|
|
2242
|
+
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: TableService }, { type: i1.AngularFirestore }]; }, propDecorators: { data: [{
|
|
2243
|
+
type: Input
|
|
2244
|
+
}], downloadTable: [{
|
|
2245
|
+
type: Input
|
|
2246
|
+
}], paginator: [{
|
|
2247
|
+
type: ViewChild,
|
|
2248
|
+
args: [MatPaginator]
|
|
2249
|
+
}], sort: [{
|
|
2250
|
+
type: ViewChild,
|
|
2251
|
+
args: [MatSort]
|
|
2178
2252
|
}] } });
|
|
2179
2253
|
|
|
2180
|
-
class NgFirebaseTableKxpModule {
|
|
2181
|
-
}
|
|
2182
|
-
NgFirebaseTableKxpModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2183
|
-
NgFirebaseTableKxpModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, declarations: [NgFirebaseTableKxpComponent, TableComponent], imports: [CommonModule,
|
|
2184
|
-
ReactiveFormsModule,
|
|
2185
|
-
FormsModule,
|
|
2186
|
-
RouterModule,
|
|
2187
|
-
MatTableModule,
|
|
2188
|
-
MatPaginatorModule,
|
|
2189
|
-
MatSortModule,
|
|
2190
|
-
MatFormFieldModule,
|
|
2191
|
-
MatInputModule,
|
|
2192
|
-
MatSelectModule,
|
|
2193
|
-
MatTooltipModule,
|
|
2194
|
-
MatProgressSpinnerModule,
|
|
2195
|
-
MatIconModule,
|
|
2196
|
-
MatDialogModule,
|
|
2197
|
-
NgxMaskDirective,
|
|
2198
|
-
NgxMaskPipe], exports: [NgFirebaseTableKxpComponent, TableComponent] });
|
|
2199
|
-
NgFirebaseTableKxpModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, providers: [provideNgxMask()], imports: [CommonModule,
|
|
2200
|
-
ReactiveFormsModule,
|
|
2201
|
-
FormsModule,
|
|
2202
|
-
RouterModule,
|
|
2203
|
-
MatTableModule,
|
|
2204
|
-
MatPaginatorModule,
|
|
2205
|
-
MatSortModule,
|
|
2206
|
-
MatFormFieldModule,
|
|
2207
|
-
MatInputModule,
|
|
2208
|
-
MatSelectModule,
|
|
2209
|
-
MatTooltipModule,
|
|
2210
|
-
MatProgressSpinnerModule,
|
|
2211
|
-
MatIconModule,
|
|
2212
|
-
MatDialogModule] });
|
|
2213
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, decorators: [{
|
|
2214
|
-
type: NgModule,
|
|
2215
|
-
args: [{
|
|
2216
|
-
declarations: [NgFirebaseTableKxpComponent, TableComponent],
|
|
2217
|
-
imports: [
|
|
2218
|
-
CommonModule,
|
|
2219
|
-
ReactiveFormsModule,
|
|
2220
|
-
FormsModule,
|
|
2221
|
-
RouterModule,
|
|
2222
|
-
MatTableModule,
|
|
2223
|
-
MatPaginatorModule,
|
|
2224
|
-
MatSortModule,
|
|
2225
|
-
MatFormFieldModule,
|
|
2226
|
-
MatInputModule,
|
|
2227
|
-
MatSelectModule,
|
|
2228
|
-
MatTooltipModule,
|
|
2229
|
-
MatProgressSpinnerModule,
|
|
2230
|
-
MatIconModule,
|
|
2231
|
-
MatDialogModule,
|
|
2232
|
-
NgxMaskDirective,
|
|
2233
|
-
NgxMaskPipe,
|
|
2234
|
-
],
|
|
2235
|
-
exports: [NgFirebaseTableKxpComponent, TableComponent],
|
|
2236
|
-
providers: [provideNgxMask()],
|
|
2237
|
-
}]
|
|
2254
|
+
class NgFirebaseTableKxpModule {
|
|
2255
|
+
}
|
|
2256
|
+
NgFirebaseTableKxpModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2257
|
+
NgFirebaseTableKxpModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, declarations: [NgFirebaseTableKxpComponent, TableComponent], imports: [CommonModule,
|
|
2258
|
+
ReactiveFormsModule,
|
|
2259
|
+
FormsModule,
|
|
2260
|
+
RouterModule,
|
|
2261
|
+
MatTableModule,
|
|
2262
|
+
MatPaginatorModule,
|
|
2263
|
+
MatSortModule,
|
|
2264
|
+
MatFormFieldModule,
|
|
2265
|
+
MatInputModule,
|
|
2266
|
+
MatSelectModule,
|
|
2267
|
+
MatTooltipModule,
|
|
2268
|
+
MatProgressSpinnerModule,
|
|
2269
|
+
MatIconModule,
|
|
2270
|
+
MatDialogModule,
|
|
2271
|
+
NgxMaskDirective,
|
|
2272
|
+
NgxMaskPipe], exports: [NgFirebaseTableKxpComponent, TableComponent] });
|
|
2273
|
+
NgFirebaseTableKxpModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, providers: [provideNgxMask()], imports: [CommonModule,
|
|
2274
|
+
ReactiveFormsModule,
|
|
2275
|
+
FormsModule,
|
|
2276
|
+
RouterModule,
|
|
2277
|
+
MatTableModule,
|
|
2278
|
+
MatPaginatorModule,
|
|
2279
|
+
MatSortModule,
|
|
2280
|
+
MatFormFieldModule,
|
|
2281
|
+
MatInputModule,
|
|
2282
|
+
MatSelectModule,
|
|
2283
|
+
MatTooltipModule,
|
|
2284
|
+
MatProgressSpinnerModule,
|
|
2285
|
+
MatIconModule,
|
|
2286
|
+
MatDialogModule] });
|
|
2287
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpModule, decorators: [{
|
|
2288
|
+
type: NgModule,
|
|
2289
|
+
args: [{
|
|
2290
|
+
declarations: [NgFirebaseTableKxpComponent, TableComponent],
|
|
2291
|
+
imports: [
|
|
2292
|
+
CommonModule,
|
|
2293
|
+
ReactiveFormsModule,
|
|
2294
|
+
FormsModule,
|
|
2295
|
+
RouterModule,
|
|
2296
|
+
MatTableModule,
|
|
2297
|
+
MatPaginatorModule,
|
|
2298
|
+
MatSortModule,
|
|
2299
|
+
MatFormFieldModule,
|
|
2300
|
+
MatInputModule,
|
|
2301
|
+
MatSelectModule,
|
|
2302
|
+
MatTooltipModule,
|
|
2303
|
+
MatProgressSpinnerModule,
|
|
2304
|
+
MatIconModule,
|
|
2305
|
+
MatDialogModule,
|
|
2306
|
+
NgxMaskDirective,
|
|
2307
|
+
NgxMaskPipe,
|
|
2308
|
+
],
|
|
2309
|
+
exports: [NgFirebaseTableKxpComponent, TableComponent],
|
|
2310
|
+
providers: [provideNgxMask()],
|
|
2311
|
+
}]
|
|
2238
2312
|
}] });
|
|
2239
2313
|
|
|
2240
|
-
class NgFirebaseTableKxpService {
|
|
2241
|
-
constructor() { }
|
|
2242
|
-
}
|
|
2243
|
-
NgFirebaseTableKxpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2244
|
-
NgFirebaseTableKxpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, providedIn: 'root' });
|
|
2245
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, decorators: [{
|
|
2246
|
-
type: Injectable,
|
|
2247
|
-
args: [{
|
|
2248
|
-
providedIn: 'root',
|
|
2249
|
-
}]
|
|
2314
|
+
class NgFirebaseTableKxpService {
|
|
2315
|
+
constructor() { }
|
|
2316
|
+
}
|
|
2317
|
+
NgFirebaseTableKxpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2318
|
+
NgFirebaseTableKxpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, providedIn: 'root' });
|
|
2319
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NgFirebaseTableKxpService, decorators: [{
|
|
2320
|
+
type: Injectable,
|
|
2321
|
+
args: [{
|
|
2322
|
+
providedIn: 'root',
|
|
2323
|
+
}]
|
|
2250
2324
|
}], ctorParameters: function () { return []; } });
|
|
2251
2325
|
|
|
2252
|
-
/*
|
|
2253
|
-
* Public API Surface of ng-firebase-table-kxp
|
|
2254
|
-
*/
|
|
2326
|
+
/*
|
|
2327
|
+
* Public API Surface of ng-firebase-table-kxp
|
|
2328
|
+
*/
|
|
2255
2329
|
// Main module
|
|
2256
2330
|
|
|
2257
|
-
/**
|
|
2258
|
-
* Generated bundle index. Do not edit.
|
|
2331
|
+
/**
|
|
2332
|
+
* Generated bundle index. Do not edit.
|
|
2259
2333
|
*/
|
|
2260
2334
|
|
|
2261
2335
|
export { NgFirebaseTableKxpComponent, NgFirebaseTableKxpModule, NgFirebaseTableKxpService, TableComponent, TableService };
|