@elite.framework/ng.ui.core 1.0.90 → 1.0.93
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/fesm2022/elite.framework-ng.ui.core-datepicker.mjs +2 -0
- package/fesm2022/elite.framework-ng.ui.core-datepicker.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.ui.core-generic-crud-table.mjs +1 -1
- package/fesm2022/elite.framework-ng.ui.core-generic-crud-table.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.ui.core-generic-search-advanced.mjs +75 -20
- package/fesm2022/elite.framework-ng.ui.core-generic-search-advanced.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.ui.core.mjs +2 -0
- package/fesm2022/elite.framework-ng.ui.core.mjs.map +1 -1
- package/generic-search-advanced/index.d.ts +3 -1
- package/package.json +16 -16
|
@@ -1152,6 +1152,15 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1152
1152
|
this.initializeDefaultConditions();
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
|
+
initializeConditionsWithFieldConfigs(conditions, groupIndex) {
|
|
1156
|
+
return conditions.map((condition, conditionIndex) => ({
|
|
1157
|
+
...condition,
|
|
1158
|
+
operatorsForField: this.getOperatorsForField(condition.field),
|
|
1159
|
+
valueFieldConfig: condition.field ?
|
|
1160
|
+
this.generateValueFieldConfig(condition, groupIndex, conditionIndex) :
|
|
1161
|
+
null
|
|
1162
|
+
}));
|
|
1163
|
+
}
|
|
1155
1164
|
getLogicalOperatorText(operator) {
|
|
1156
1165
|
const operatorMap = {
|
|
1157
1166
|
'and': this.translate.instant('and'),
|
|
@@ -1166,7 +1175,7 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1166
1175
|
const defaultConditions = [];
|
|
1167
1176
|
for (let i = 0; i < defaultFields.length; i++) {
|
|
1168
1177
|
const field = defaultFields[i];
|
|
1169
|
-
defaultConditions.push(this.createDefaultCondition(field, 0, i));
|
|
1178
|
+
defaultConditions.push(this.createDefaultCondition(field, 0, i, field.props?.operator));
|
|
1170
1179
|
}
|
|
1171
1180
|
this.groups = [{
|
|
1172
1181
|
logicalOperator: 'and',
|
|
@@ -1187,17 +1196,17 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1187
1196
|
}
|
|
1188
1197
|
isSupportedFieldType(fieldType) {
|
|
1189
1198
|
// Only include field types that make sense for filtering
|
|
1190
|
-
const supportedTypes = ['input', 'number', 'datepicker', 'select', 'checkbox', 'generic-selector', 'switch', 'radio', 'textarea'];
|
|
1199
|
+
const supportedTypes = ['input', 'number', 'datepicker', 'custom-datepicker', 'select', 'checkbox', 'generic-selector', 'switch', 'radio', 'textarea'];
|
|
1191
1200
|
return supportedTypes.includes(fieldType);
|
|
1192
1201
|
}
|
|
1193
1202
|
getFieldLabel(key) {
|
|
1194
1203
|
const f = this.props['fields']?.find((x) => x.key === key);
|
|
1195
1204
|
return f ? f.label : '';
|
|
1196
1205
|
}
|
|
1197
|
-
createDefaultCondition(field, groupIndex, conditionIndex) {
|
|
1206
|
+
createDefaultCondition(field, groupIndex, conditionIndex, operator) {
|
|
1198
1207
|
const defaultCondition = {
|
|
1199
1208
|
field: field.key,
|
|
1200
|
-
operator: this.getDefaultOperator(field.type),
|
|
1209
|
+
operator: operator ? operator : this.getDefaultOperator(field.type),
|
|
1201
1210
|
value: this.getDefaultValue(field.type),
|
|
1202
1211
|
valueFieldConfig: null,
|
|
1203
1212
|
operatorsForField: this.getOperatorsForField(field),
|
|
@@ -1206,15 +1215,6 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1206
1215
|
defaultCondition.valueFieldConfig = this.generateValueFieldConfig(defaultCondition, groupIndex, conditionIndex);
|
|
1207
1216
|
return defaultCondition;
|
|
1208
1217
|
}
|
|
1209
|
-
initializeConditionsWithFieldConfigs(conditions, groupIndex) {
|
|
1210
|
-
return conditions.map((condition, conditionIndex) => ({
|
|
1211
|
-
...condition,
|
|
1212
|
-
operatorsForField: this.getOperatorsForField(condition.field),
|
|
1213
|
-
valueFieldConfig: condition.field ?
|
|
1214
|
-
this.generateValueFieldConfig(condition, groupIndex, conditionIndex) :
|
|
1215
|
-
null
|
|
1216
|
-
}));
|
|
1217
|
-
}
|
|
1218
1218
|
// Field type and operator methods that use QueryBuilderService logic
|
|
1219
1219
|
getFieldType(fieldKey) {
|
|
1220
1220
|
const field = this.props['fields'].find((f) => f.key === fieldKey);
|
|
@@ -1313,9 +1313,33 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1313
1313
|
});
|
|
1314
1314
|
this.updateValue();
|
|
1315
1315
|
}
|
|
1316
|
+
// removeGroup(groupIndex: number) {
|
|
1317
|
+
// this.groups.splice(groupIndex, 1);
|
|
1318
|
+
// this.updateValue();
|
|
1319
|
+
// }
|
|
1316
1320
|
removeGroup(groupIndex) {
|
|
1317
|
-
this.groups
|
|
1318
|
-
|
|
1321
|
+
if (this.groups[groupIndex]) {
|
|
1322
|
+
// Get all field keys for this group before deleting
|
|
1323
|
+
const fieldKeysToRemove = [];
|
|
1324
|
+
// Collect all condition field keys in this group
|
|
1325
|
+
if (this.groups[groupIndex].conditions) {
|
|
1326
|
+
for (let c = 0; c < this.groups[groupIndex].conditions.length; c++) {
|
|
1327
|
+
const fieldKey = this.getConditionValueKey(groupIndex, c);
|
|
1328
|
+
fieldKeysToRemove.push(fieldKey);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
// Remove the group
|
|
1332
|
+
this.groups.splice(groupIndex, 1);
|
|
1333
|
+
// Remove all associated fields from model
|
|
1334
|
+
this.removeMultipleFromModel(fieldKeysToRemove);
|
|
1335
|
+
this.updateValue();
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
// Remove multiple fields from formly model
|
|
1339
|
+
removeMultipleFromModel(fieldKeys) {
|
|
1340
|
+
fieldKeys.forEach(fieldKey => {
|
|
1341
|
+
this.removeFromModel(fieldKey);
|
|
1342
|
+
});
|
|
1319
1343
|
}
|
|
1320
1344
|
// Condition Management
|
|
1321
1345
|
addCondition(groupIndex = 0) {
|
|
@@ -1353,14 +1377,35 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1353
1377
|
}
|
|
1354
1378
|
removeCondition(groupIndex, conditionIndex) {
|
|
1355
1379
|
if (this.groups[groupIndex]) {
|
|
1356
|
-
|
|
1380
|
+
// Get the field key before deleting so we can remove from model
|
|
1381
|
+
const fieldKey = this.getConditionValueKey(groupIndex, conditionIndex);
|
|
1382
|
+
// Using delete operator (sets to undefined, then we filter)
|
|
1383
|
+
delete this.groups[groupIndex].conditions[conditionIndex];
|
|
1384
|
+
// Remove the undefined entries from conditions array
|
|
1385
|
+
this.groups[groupIndex].conditions = this.groups[groupIndex].conditions.filter((condition) => condition !== undefined);
|
|
1357
1386
|
// Remove empty groups
|
|
1358
1387
|
if (this.groups[groupIndex].conditions.length === 0 && this.groups.length > 1) {
|
|
1359
|
-
this.
|
|
1388
|
+
delete this.groups[groupIndex];
|
|
1389
|
+
// Remove undefined groups from array
|
|
1390
|
+
this.groups = this.groups.filter(group => group !== undefined);
|
|
1360
1391
|
}
|
|
1392
|
+
// Remove from formly model
|
|
1393
|
+
this.removeFromModel(fieldKey);
|
|
1361
1394
|
this.updateValue();
|
|
1362
1395
|
}
|
|
1363
1396
|
}
|
|
1397
|
+
// Remove the field from formly model
|
|
1398
|
+
removeFromModel(fieldKey) {
|
|
1399
|
+
if (this.model && this.model.hasOwnProperty(fieldKey)) {
|
|
1400
|
+
delete this.model[fieldKey];
|
|
1401
|
+
}
|
|
1402
|
+
// Also update the form control to ensure sync
|
|
1403
|
+
if (this.formControl.value && this.formControl.value.hasOwnProperty(fieldKey)) {
|
|
1404
|
+
const updatedValue = { ...this.formControl.value };
|
|
1405
|
+
delete updatedValue[fieldKey];
|
|
1406
|
+
this.formControl.setValue(updatedValue);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1364
1409
|
// Value Management
|
|
1365
1410
|
updateValue() {
|
|
1366
1411
|
// Sync condition values from form model with safe access
|
|
@@ -1369,9 +1414,13 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1369
1414
|
for (let c = 0; c < group.conditions.length; c++) {
|
|
1370
1415
|
const condition = group.conditions[c];
|
|
1371
1416
|
const fieldKey = this.getConditionValueKey(g, c);
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1417
|
+
try {
|
|
1418
|
+
const modelValue = this.model?.[fieldKey];
|
|
1419
|
+
if (modelValue !== undefined) {
|
|
1420
|
+
condition.value = modelValue;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
catch (error) {
|
|
1375
1424
|
}
|
|
1376
1425
|
}
|
|
1377
1426
|
}
|
|
@@ -1398,6 +1447,12 @@ class QueryBuilderComponent extends FieldType {
|
|
|
1398
1447
|
}
|
|
1399
1448
|
clearAll() {
|
|
1400
1449
|
this.groups = [];
|
|
1450
|
+
// Completely reset the form and model
|
|
1451
|
+
this.form.reset();
|
|
1452
|
+
// Manually set model to empty object
|
|
1453
|
+
Object.keys(this.model).forEach(key => {
|
|
1454
|
+
delete this.model[key];
|
|
1455
|
+
});
|
|
1401
1456
|
this.addGroup();
|
|
1402
1457
|
}
|
|
1403
1458
|
// Helper methods
|