|
| 1 | +/* eslint-disable max-len */ |
1 | 2 | /* eslint-disable arrow-body-style */
|
2 | 3 | /* eslint-disable react/destructuring-assignment */
|
3 | 4 | import _ from 'lodash';
|
@@ -218,7 +219,7 @@ const transformDonutData = (data) => {
|
218 | 219 | transformedData.projectCountByFiscalYearSorted = data.projectCountByFiscalYear.sort((a, b) => ((a.subjects < b.subjects) ? 1 : -1));
|
219 | 220 |
|
220 | 221 | for (let i = 0; i < transformedData.publicationCountByYearSorted.length; i += 1) {
|
221 |
| - // eslint-disable-next-line max-len |
| 222 | + // eslint-disable-next-line max-len |
222 | 223 | transformedData.publicationCountByYearSorted[i].group = new Date(parseInt(transformedData.publicationCountByYearSorted[i].group, 10)).getFullYear();
|
223 | 224 | }
|
224 | 225 |
|
@@ -1258,28 +1259,71 @@ const reducers = {
|
1258 | 1259 | };
|
1259 | 1260 | },
|
1260 | 1261 | TOGGLE_CHECKBOX_WITH_API: (state, item) => {
|
| 1262 | + const newAllFilters = { |
| 1263 | + award_amounts: [], docs: [], fiscal_years: [], programs: [], |
| 1264 | + }; |
| 1265 | + |
| 1266 | + let validCheckBoxOptions = []; |
| 1267 | + |
| 1268 | + if (item.allFilters.award_amounts.length !== 0) { |
| 1269 | + validCheckBoxOptions = item.data.searchProjects.filterProjectCountByAwardAmount.map((opt) => opt.group); |
| 1270 | + item.allFilters.award_amounts.forEach((amount) => { |
| 1271 | + if (validCheckBoxOptions.indexOf(amount) > -1) { |
| 1272 | + newAllFilters.award_amounts.push(amount); |
| 1273 | + } |
| 1274 | + }); |
| 1275 | + } |
| 1276 | + |
| 1277 | + if (item.allFilters.docs.length !== 0) { |
| 1278 | + validCheckBoxOptions = item.data.searchProjects.filterProjectCountByDOC.map((opt) => opt.group); |
| 1279 | + item.allFilters.docs.forEach((doc) => { |
| 1280 | + if (validCheckBoxOptions.indexOf(doc) > -1) { |
| 1281 | + newAllFilters.docs.push(doc); |
| 1282 | + } |
| 1283 | + }); |
| 1284 | + } |
| 1285 | + |
| 1286 | + if (item.allFilters.fiscal_years.length !== 0) { |
| 1287 | + validCheckBoxOptions = item.data.searchProjects.filterProjectCountByFiscalYear.map((opt) => opt.group); |
| 1288 | + item.allFilters.fiscal_years.forEach((fyear) => { |
| 1289 | + if (validCheckBoxOptions.indexOf(fyear) > -1) { |
| 1290 | + newAllFilters.fiscal_years.push(fyear); |
| 1291 | + } |
| 1292 | + }); |
| 1293 | + } |
| 1294 | + |
| 1295 | + if (item.allFilters.programs.length !== 0) { |
| 1296 | + validCheckBoxOptions = item.data.searchProjects.filterProjectCountByProgram.map((opt) => opt.group); |
| 1297 | + item.allFilters.programs.forEach((program) => { |
| 1298 | + if (validCheckBoxOptions.indexOf(program) > -1) { |
| 1299 | + newAllFilters.programs.push(program); |
| 1300 | + } |
| 1301 | + }); |
| 1302 | + } |
| 1303 | + |
1261 | 1304 | let updatedCheckboxData1 = updateFilteredAPIDataIntoCheckBoxData(
|
1262 | 1305 | item.data.searchProjects, facetSearchData,
|
1263 | 1306 | );
|
1264 | 1307 | const rangeData = updatedCheckboxData1.filter((sideBar) => sideBar.slider === true);
|
1265 | 1308 | updatedCheckboxData1 = updatedCheckboxData1.filter((sideBar) => sideBar.slider !== true);
|
1266 |
| - let checkboxData1 = setSelectedFilterValues(updatedCheckboxData1, item.allFilters); |
| 1309 | + let checkboxData1 = setSelectedFilterValues(updatedCheckboxData1, newAllFilters); |
1267 | 1310 | updatedCheckboxData1 = updatedCheckboxData1.concat(rangeData);
|
1268 | 1311 | checkboxData1 = checkboxData1.concat(rangeData);
|
1269 | 1312 | checkboxData1.forEach((cbd, idx) => {
|
1270 | 1313 | checkboxData1[idx].tooltips = updatedCheckboxData1[idx].tooltips;
|
1271 | 1314 | });
|
1272 | 1315 | fetchDataForDashboardTab(
|
1273 | 1316 | tabIndex[0].title,
|
1274 |
| - item.allFilters, |
| 1317 | + newAllFilters, |
1275 | 1318 | );
|
| 1319 | + |
1276 | 1320 | return {
|
1277 | 1321 | ...state,
|
1278 | 1322 | setSideBarLoading: false,
|
1279 |
| - allActiveFilters: item.allFilters, |
| 1323 | + allActiveFilters: newAllFilters, |
1280 | 1324 | checkbox: {
|
1281 | 1325 | data: checkboxData1,
|
1282 |
| - variables: item.allFilters, |
| 1326 | + variables: newAllFilters, |
1283 | 1327 | },
|
1284 | 1328 | stats: getFilteredStat(item.data.searchProjects, statsCount),
|
1285 | 1329 | widgets: getWidgetsInitData(item.data.searchProjects, widgetsData),
|
|
0 commit comments