From 187a4579e588b75cfd4218cfe07ca115b86a9bf7 Mon Sep 17 00:00:00 2001 From: Lloyd Wheeler Date: Tue, 28 Nov 2017 11:54:09 -0800 Subject: [PATCH] StudentSupportForm: Move form lock calculations to reducer #1450 --- .../StudentSupportCallFormCtrl.js | 25 +------------------ .../studentPreferences.html | 2 +- .../services/studentReducers.js | 16 ++++++++++-- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js index 401b50ebd..a39d10115 100644 --- a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js +++ b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js @@ -101,33 +101,10 @@ instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$ro }; $scope.termCode = $scope.termShortCodeToTermCode($scope.termShortCode); - - // Form locks when a due date has been set, and has passed - $scope.isFormLocked = function () { - if (!$scope.view.state.supportCallResponse) { - return false; - } - // Validate dueDate - var dueDate = $scope.view.state.supportCallResponse.dueDate; - var submitAfterDueDate = $scope.view.state.supportCallResponse.allowSubmissionAfterDueDate; - - if (dueDate) { - if (submitAfterDueDate == false) { - var date = new Date(); - var currentTime = date.getTime(); - - if (currentTime > dueDate) { - return true; - } - } - } - - return false; - }; $scope.studentSupportCallFormIsValid = function () { // Validate dueDate - if ( $scope.isFormLocked() ) { + if ($scope.view.state.ui.isFormLocked) { $scope.validationError = "The due date for this support call has passed."; return false; } diff --git a/app/instructionalSupport/studentSupportCallForm/directives/studentPreferences/studentPreferences.html b/app/instructionalSupport/studentSupportCallForm/directives/studentPreferences/studentPreferences.html index d17799747..9f318ce1e 100644 --- a/app/instructionalSupport/studentSupportCallForm/directives/studentPreferences/studentPreferences.html +++ b/app/instructionalSupport/studentSupportCallForm/directives/studentPreferences/studentPreferences.html @@ -32,7 +32,7 @@
- dueDate) { + ui.isFormLocked = true; + } + } + } + return ui; case OPEN_PREFERENCE_COMMENT_MODAL: ui.isPreferenceCommentModalOpen = true; return ui;