json-rules-filter 1.0.15 → 1.0.16
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/package.json +1 -1
- package/src/jquery.jsonRulesFilter.js +23 -12
package/package.json
CHANGED
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
// --- DEFAULT CONFIGURATION ---
|
|
22
22
|
const settings = $.extend(true, {
|
|
23
|
-
bsVersion:5,
|
|
23
|
+
bsVersion: 5,
|
|
24
24
|
filters: [
|
|
25
|
-
{ name: "Example", type: "number", data: "example", render: function(data){return data.text /*Callback to render html in options type select*/}}
|
|
25
|
+
{ name: "Example", type: "number", data: "example", render: function (data) { return data.text /*Callback to render html in options type select*/ } }
|
|
26
26
|
],
|
|
27
27
|
language: {
|
|
28
28
|
string: {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
nGreatherThanOrEquals: "Mayor o igual que", nLowerThan: "Menor que", nLowerThanOrEquals: "Menor o igual que"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
title: {text:"Reglas de filtrado",className:"fs-6 fw-semibold"},
|
|
37
|
+
title: { text: "Reglas de filtrado", className: "fs-6 fw-semibold" },
|
|
38
38
|
buttons: {
|
|
39
39
|
reset: { text: "Resetear", className: "fw-semibold link-danger link-offset-2 link-underline link-underline-opacity-0" },
|
|
40
|
-
dropdown: { text: "Añadir regla", className: "btn btn-secondary"},
|
|
40
|
+
dropdown: { text: "Añadir regla", className: "btn btn-secondary" },
|
|
41
41
|
apply: { text: "Aplicar regla", className: "btn btn-primary" },
|
|
42
42
|
},
|
|
43
43
|
onApply: function (filtros, datosFiltrados) { }
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
$contenedor: $contenedor,
|
|
54
54
|
|
|
55
55
|
// ---- Compatibility helper bs5/bs4 ------
|
|
56
|
-
bs: function(classes) {
|
|
56
|
+
bs: function (classes) {
|
|
57
57
|
if (this.settings.bsVersion === 5) return classes;
|
|
58
58
|
|
|
59
59
|
const map = {
|
|
60
|
-
'fs-6':'',
|
|
60
|
+
'fs-6': '',
|
|
61
61
|
'fw-semibold': 'font-weight-bold',
|
|
62
62
|
'fw-bold': 'font-weight-bold',
|
|
63
63
|
'link-danger': 'text-danger',
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
dataField: $el.data("field"), // JSON key path
|
|
101
101
|
dataName: $el.data("name"), // Display name
|
|
102
102
|
// Text of the selected option for labels/summary
|
|
103
|
-
optionFilterText: $el.find("option:selected").map(function(){ return $(this).text(); }).get()
|
|
103
|
+
optionFilterText: $el.find("option:selected").map(function () { return $(this).text(); }).get()
|
|
104
104
|
});
|
|
105
105
|
})
|
|
106
106
|
return rulesAplicated;
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
<div class="py-2" id="container-rules-filters"></div>
|
|
145
145
|
<div class="mt-2">
|
|
146
146
|
<div class="d-flex justify-content-start dropdown">
|
|
147
|
-
<button ${this.settings.bsVersion === 5
|
|
147
|
+
<button ${this.settings.bsVersion === 5 ? `data-bs-popper-config='{"strategy":"fixed"}'` : ''} class="${this.bs(this.settings.buttons.dropdown.className)} dropdown-toggle" type="button" ${toggleAttr}>
|
|
148
148
|
${this.settings.buttons.dropdown.text}
|
|
149
149
|
</button>
|
|
150
150
|
<div class="dropdown-menu p-2 dropdown-rules-columns" style="min-width: 300px;">
|
|
@@ -161,10 +161,21 @@
|
|
|
161
161
|
if (this.settings.bsVersion === 4) {
|
|
162
162
|
//BS4
|
|
163
163
|
$dropdown.dropdown({
|
|
164
|
+
display: 'static',
|
|
164
165
|
popperConfig: {
|
|
165
|
-
positionFixed: true
|
|
166
|
+
positionFixed: true,
|
|
167
|
+
modifiers: {
|
|
168
|
+
preventOverflow: {
|
|
169
|
+
boundariesElement: 'window'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
});
|
|
174
|
+
|
|
175
|
+
$dropdown.on('click', function (e) {
|
|
176
|
+
e.stopPropagation();
|
|
177
|
+
});
|
|
178
|
+
|
|
168
179
|
}
|
|
169
180
|
},
|
|
170
181
|
|
|
@@ -202,7 +213,7 @@
|
|
|
202
213
|
const self = this;
|
|
203
214
|
const $container = this.$contenedor.find("#container-rules-filters");
|
|
204
215
|
|
|
205
|
-
|
|
216
|
+
// Generate unique ID for the new row based on the last element
|
|
206
217
|
let id_select = 0;
|
|
207
218
|
const last_container = $contenedor.find("select[name=select-rule-option]").last();
|
|
208
219
|
if (last_container.length > 0) { id_select = last_container.data("id") + 1; }
|
|
@@ -235,7 +246,7 @@
|
|
|
235
246
|
</div>`;
|
|
236
247
|
|
|
237
248
|
$container.append(row);
|
|
238
|
-
|
|
249
|
+
// Fetch custom render function from settings
|
|
239
250
|
const render = self.settings.filters.find((e) => e.data === dataField).render;
|
|
240
251
|
this.initSelect2(id_select, type, dataField, render);
|
|
241
252
|
},
|
|
@@ -302,7 +313,7 @@
|
|
|
302
313
|
if (valorOriginal === undefined || valorOriginal === null) return false;
|
|
303
314
|
|
|
304
315
|
// Special logic for Multiple Select filters
|
|
305
|
-
if(regla.typeFilter === 'select'){
|
|
316
|
+
if (regla.typeFilter === 'select') {
|
|
306
317
|
const selectedValues = regla.optionFilter; // Array from Select2 multiple
|
|
307
318
|
return selectedValues.includes(valorOriginal.toString());
|
|
308
319
|
}
|