Planned decom date not to be set if after retirement date of the app, or is app is already removed.
#CTCTOWALTZ-1845
@@ -88,6 +88,8 @@ function controller($q,
}
vm.onTabChange();
})
+ .then(() => serviceBroker.loadViewData(CORE_API.ApplicationStore.getById, [vm.parentEntityRef.id])
+ .then(r => vm.application = r.data))
};
const recalcTabs = function () {
@@ -210,7 +212,26 @@ function controller($q,
.finally(reloadDecommData);
};
+ vm.checkPlannedDecomDateIsValid = (decomDate) => {
+
+ const appDate = new Date(vm.application.plannedRetirementDate);
+
+ const sameDate = appDate.getFullYear() === decomDate.getFullYear()
+ && appDate.getMonth() === decomDate.getMonth()
+ && appDate.getDate() === decomDate.getDate();
+
+ return appDate > decomDate || sameDate;
+ };
+
vm.onSaveDecommissionDate = (dateChange) => {
+
+ if (vm.application.entityLifecycleStatus === 'REMOVED'){
+ notification.error("Decommission date cannot be set. This application is no longer active");
+ return;
+ }
+
+ if (_.isNull(vm.application.plannedRetirementDate) || vm.checkPlannedDecomDateIsValid(dateChange.newVal)){
+
dateChange.newVal = getDateAsUtc(dateChange.newVal);
serviceBroker
@@ -223,6 +244,11 @@ function controller($q,
})
.catch(e => displayError(notification, "Could not save decommission date", e))
.finally(reloadDecommData);
+
+ } else {
+ const appDate = new Date(vm.application.plannedRetirementDate).toDateString();
+ notification.error("Decommission date cannot be later than the planned retirement date of the application: " + appDate);
+ }
};
vm.onRemoveDecommission = () => {
