@bento-core/facet-filter 1.0.1-ccdihub.21 → 1.0.1-ccdihub.23
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.
|
@@ -112,11 +112,30 @@ const FacetFilterController = props => {
|
|
|
112
112
|
} = updateFacet;
|
|
113
113
|
if (data[apiForFiltering]) {
|
|
114
114
|
if (Array.isArray(data[apiForFiltering])) {
|
|
115
|
+
const validValues = [];
|
|
115
116
|
const updateField = data[apiForFiltering].map(item => {
|
|
116
117
|
const addField = _objectSpread({}, item);
|
|
117
118
|
addField.name = item[field];
|
|
119
|
+
validValues.push(addField.name);
|
|
118
120
|
return addField;
|
|
119
121
|
});
|
|
122
|
+
/**
|
|
123
|
+
* Check if there are orphen filter values and add them to the facet values
|
|
124
|
+
*/
|
|
125
|
+
if (filterState !== undefined) {
|
|
126
|
+
const facetFilter = filterState[facet.datafield];
|
|
127
|
+
if (facetFilter) {
|
|
128
|
+
for (const [key, value] of Object.entries(facetFilter)) {
|
|
129
|
+
if (validValues.indexOf(key) === -1) {
|
|
130
|
+
const tmp = {};
|
|
131
|
+
tmp.group = key;
|
|
132
|
+
tmp.name = key;
|
|
133
|
+
tmp.subjects = 0;
|
|
134
|
+
updateField.push(tmp);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
120
139
|
updateFacet.facetValues = updateField;
|
|
121
140
|
}
|
|
122
141
|
/**
|
package/package.json
CHANGED
|
@@ -97,11 +97,30 @@ const FacetFilterController = (props) => {
|
|
|
97
97
|
} = updateFacet;
|
|
98
98
|
if (data[apiForFiltering]) {
|
|
99
99
|
if (Array.isArray(data[apiForFiltering])) {
|
|
100
|
+
const validValues = [];
|
|
100
101
|
const updateField = data[apiForFiltering].map((item) => {
|
|
101
102
|
const addField = { ...item };
|
|
102
103
|
addField.name = item[field];
|
|
104
|
+
validValues.push(addField.name);
|
|
103
105
|
return addField;
|
|
104
106
|
});
|
|
107
|
+
/**
|
|
108
|
+
* Check if there are orphen filter values and add them to the facet values
|
|
109
|
+
*/
|
|
110
|
+
if (filterState !== undefined) {
|
|
111
|
+
const facetFilter = filterState[facet.datafield];
|
|
112
|
+
if (facetFilter) {
|
|
113
|
+
for (const [key, value] of Object.entries(facetFilter)) {
|
|
114
|
+
if (validValues.indexOf(key) === -1) {
|
|
115
|
+
const tmp = {};
|
|
116
|
+
tmp.group = key;
|
|
117
|
+
tmp.name = key;
|
|
118
|
+
tmp.subjects = 0;
|
|
119
|
+
updateField.push(tmp);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
105
124
|
updateFacet.facetValues = updateField;
|
|
106
125
|
}
|
|
107
126
|
/**
|