@visns-studio/visns-components 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/components/crm/visns-table-filter.jsx +125 -119
- package/package.json +1 -1
|
@@ -1,124 +1,130 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
function TableFilter(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
4
|
+
const { filters, setFilters, setSettings } = props;
|
|
5
|
+
|
|
6
|
+
const filterTable = (e) => {
|
|
7
|
+
const { id, value, url } = e.target.dataset;
|
|
8
|
+
|
|
9
|
+
console.info("a", url);
|
|
10
|
+
|
|
11
|
+
if (props.hasOwnProperty("setSettings") === true) {
|
|
12
|
+
console.info("b");
|
|
13
|
+
if (url && url !== "") {
|
|
14
|
+
console.info("c");
|
|
15
|
+
window.open(url);
|
|
16
|
+
} else {
|
|
17
|
+
console.info("d");
|
|
18
|
+
setSettings((prevState) => {
|
|
19
|
+
if (prevState.ajaxSetting) {
|
|
20
|
+
let _where = [];
|
|
21
|
+
|
|
22
|
+
prevState.ajaxSetting.where.forEach((a) => {
|
|
23
|
+
if (a.id === id) {
|
|
24
|
+
let _push = true;
|
|
25
|
+
|
|
26
|
+
_where.forEach((b) => {
|
|
27
|
+
if (b.id === id) {
|
|
28
|
+
_push = false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (_push === true) {
|
|
33
|
+
_where.push({
|
|
34
|
+
id: id,
|
|
35
|
+
value: value,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
_where.push(a);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
let _push = true;
|
|
44
|
+
|
|
45
|
+
_where.forEach((a) => {
|
|
46
|
+
if (a.id === id) {
|
|
47
|
+
_push = false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (_push === true) {
|
|
52
|
+
_where.push({
|
|
53
|
+
id: id,
|
|
54
|
+
value: value,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
...prevState,
|
|
60
|
+
ajaxSetting: {
|
|
61
|
+
...prevState.ajaxSetting,
|
|
62
|
+
where: _where,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
let w = prevState.where;
|
|
67
|
+
|
|
68
|
+
prevState.where.forEach((a, b) => {
|
|
69
|
+
if (id === a.id) {
|
|
70
|
+
w[b].value = value;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return { ...prevState, where: w };
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let tempFilters = filters;
|
|
81
|
+
|
|
82
|
+
filters.map((item, index) => {
|
|
83
|
+
if (
|
|
84
|
+
e.target.dataset.hasOwnProperty("value") &&
|
|
85
|
+
parseInt(value) >= 0
|
|
86
|
+
) {
|
|
87
|
+
if (parseInt(value) === parseInt(item.value)) {
|
|
88
|
+
tempFilters[index].class = "subactive";
|
|
89
|
+
tempFilters[index].show = true;
|
|
90
|
+
} else {
|
|
91
|
+
tempFilters[index].class = "";
|
|
92
|
+
tempFilters[index].show = false;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
if (id === item.id) {
|
|
96
|
+
tempFilters[index].class = "subactive";
|
|
97
|
+
tempFilters[index].show = true;
|
|
98
|
+
} else {
|
|
99
|
+
tempFilters[index].class = "";
|
|
100
|
+
tempFilters[index].show = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
setFilters(tempFilters);
|
|
106
|
+
setFilters((prevState) => [...prevState]);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<ul>
|
|
111
|
+
{filters.map((item, key) => (
|
|
112
|
+
<li key={"table-filter-" + key}>
|
|
113
|
+
<a
|
|
114
|
+
data-id={item.id}
|
|
115
|
+
data-value={
|
|
116
|
+
item.hasOwnProperty("value") ? item.value : ""
|
|
117
|
+
}
|
|
118
|
+
data-url={item.url || ""}
|
|
119
|
+
onClick={filterTable}
|
|
120
|
+
className={item.class}
|
|
121
|
+
>
|
|
122
|
+
{item.label}
|
|
123
|
+
</a>
|
|
124
|
+
</li>
|
|
125
|
+
))}
|
|
126
|
+
</ul>
|
|
127
|
+
);
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
export default TableFilter;
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-dom": ">=18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"name": "@visns-studio/visns-components",
|
|
35
|
-
"version": "1.0.
|
|
35
|
+
"version": "1.0.13",
|
|
36
36
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
37
37
|
"main": "index.js",
|
|
38
38
|
"devDependencies": {},
|