Skip to content

Commit af9140d

Browse files
committed
check year when loading settings
1 parent e01dd5f commit af9140d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/workloadSummaryReport/directives/workloadDownloadModal/workloadDownloadModal.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ let workloadDownloadModal = function (WorkloadSummaryActions) {
1818
scope.showSnapshotWarning = false;
1919

2020
scope.$watch('userWorkgroupSnapshots', function (userWorkgroupsSnapshots) {
21-
if (localStorage.getItem("workloadSnapshotDownloadSelections")) {
22-
scope.departmentSnapshots = JSON.parse(localStorage.getItem("workloadSnapshotDownloadSelections"));
23-
scope.isSortedByRecentActivity = JSON.parse(localStorage.getItem("workloadSnapshotDownloadSorted"));
21+
const workloadSnapshotDownloadSettings = JSON.parse(localStorage.getItem('workloadSnapshotDownloadSettings'));
22+
23+
if (
24+
workloadSnapshotDownloadSettings?.year === scope.year &&
25+
workloadSnapshotDownloadSettings?.snapshots.length === Object.keys(userWorkgroupsSnapshots ?? {}).length
26+
) {
27+
scope.departmentSnapshots = workloadSnapshotDownloadSettings.snapshots;
28+
scope.isSortedByRecentActivity = workloadSnapshotDownloadSettings.isSorted;
2429
} else if (userWorkgroupsSnapshots) {
2530
scope.departmentSnapshots = scope.getScenarioOptions(userWorkgroupsSnapshots);
2631
scope.showSnapshotWarning = scope.isAnyWorkgroupMissingSnapshots(userWorkgroupsSnapshots);
@@ -105,8 +110,12 @@ let workloadDownloadModal = function (WorkloadSummaryActions) {
105110
scope.close = function () {
106111
scope.status = null;
107112
WorkloadSummaryActions.toggleDownloadModal();
108-
localStorage.setItem("workloadSnapshotDownloadSelections", JSON.stringify(scope.departmentSnapshots));
109-
localStorage.setItem("workloadSnapshotDownloadSorted", JSON.stringify(scope.isSortedByRecentActivity));
113+
localStorage.setItem('workloadSnapshotDownloadSettings', JSON.stringify({
114+
snapshots: scope.departmentSnapshots,
115+
year: scope.year,
116+
isSorted: scope.isSortedByRecentActivity
117+
})
118+
);
110119
};
111120

112121
scope.submit = function () {

0 commit comments

Comments
 (0)