diff --git a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallForm.html b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallForm.html
index 2dea3e03d..66ea8d377 100644
--- a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallForm.html
+++ b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallForm.html
@@ -20,9 +20,9 @@
-
+
diff --git a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js
index 72a8e730f..401b50ebd 100644
--- a/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js
+++ b/app/instructionalSupport/studentSupportCallForm/StudentSupportCallFormCtrl.js
@@ -5,19 +5,17 @@
* # AssignmentCtrl
* Controller of the ipaClientAngularApp
*/
-instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$rootScope', '$window', '$location', '$routeParams', '$uibModal', 'supportStaffFormActionCreators',
- this.StudentSupportCallFormCtrl = function ($scope, $rootScope, $window, $location, $routeParams, $uibModal, supportStaffFormActionCreators) {
+instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$rootScope', '$window', '$location', '$routeParams', '$uibModal', 'studentActions',
+ this.StudentSupportCallFormCtrl = function ($scope, $rootScope, $window, $location, $routeParams, $uibModal, studentActions) {
$window.document.title = "Instructional Support";
$scope.workgroupId = $routeParams.workgroupId;
$scope.year = $routeParams.year;
$scope.termShortCode = $routeParams.termShortCode;
$scope.nextYear = (parseInt($scope.year) + 1).toString().slice(-2);
$scope.view = {};
- $scope.listenersActive = false;
- $rootScope.$on('supportStaffFormStateChanged', function (event, data) {
+ $rootScope.$on('studentStateChanged', function (event, data) {
$scope.view.state = data;
- $scope.listenForSort();
});
$scope.toggleEligibilityConfirmed = function() {
@@ -27,32 +25,32 @@ instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$ro
$scope.view.state.supportCallResponse.eligibilityConfirmed = true;
}
- supportStaffFormActionCreators.updateSupportCallResponse($scope.view.state.supportCallResponse);
+ studentActions.updateSupportCallResponse($scope.view.state.supportCallResponse);
};
$scope.addPreference = function(preference) {
- supportStaffFormActionCreators.addStudentPreference(preference);
+ studentActions.addStudentPreference(preference);
};
$scope.deletePreference = function(preference) {
- supportStaffFormActionCreators.deleteStudentPreference(preference);
+ studentActions.deleteStudentPreference(preference);
};
$scope.updateSupportCallResponse = function() {
- supportStaffFormActionCreators.updateSupportCallResponse($scope.view.state.supportCallResponse);
+ studentActions.updateSupportCallResponse($scope.view.state.supportCallResponse);
};
$scope.submitPreferences = function() {
$scope.view.state.supportCallResponse.submitted = true;
- supportStaffFormActionCreators.submitPreferences($scope.view.state.supportCallResponse, $scope.workgroupId, $scope.year);
+ studentActions.submitPreferences($scope.view.state.supportCallResponse, $scope.workgroupId, $scope.year);
};
$scope.updatePreferencesOrder = function(preferenceIds) {
- supportStaffFormActionCreators.updatePreferencesOrder(preferenceIds, $scope.view.state.userInterface.scheduleId, $scope.termCode);
+ studentActions.updatePreferencesOrder(preferenceIds, $scope.view.state.userInterface.scheduleId, $scope.termCode);
};
$scope.pretendToastMessage = function() {
- supportStaffFormActionCreators.pretendToastMessage();
+ studentActions.pretendToastMessage();
$window.location.href = "/summary/" + $scope.workgroupId + "/" + $scope.year + "?mode=instructionalSupport";
};
@@ -85,31 +83,6 @@ instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$ro
return termCode;
};
- // Activates sortable lists for each sectionGroup, after a short delay to give the view time to render
- $scope.listenForSort = function() {
- if ($scope.listenersActive) {
- return;
- }
- $scope.listenersActive = true;
-
- setTimeout(function() {
- var listenerIds = [];
- var listener = "#sortable";
- listenerIds.push(listener);
-
- listenerIds.forEach( function(listenerId) {
- $(listenerId).sortable({
- placeholder: "sortable-student-preference-placeholder",
- update: function( event, ui ) {
- var preferenceIds = $( listenerId ).sortable( "toArray" );
- $scope.updatePreferencesOrder(preferenceIds, listenerId);
- },
- axis: "y"
- });
- });
- }, 500);
- };
-
$scope.updatePreferencesOrder = function(preferenceIds, listIndentifier) {
var filteredPreferenceIds = [];
@@ -120,7 +93,7 @@ instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$ro
});
var scheduleId = $scope.view.state.misc.scheduleId;
- supportStaffFormActionCreators.updatePreferencesOrder(filteredPreferenceIds, scheduleId, $scope.termCode);
+ studentActions.updatePreferencesOrder(filteredPreferenceIds, scheduleId, $scope.termCode);
};
$scope.getRoleDisplayName = function (roleString) {
@@ -188,13 +161,13 @@ instructionalSupportApp.controller('StudentSupportCallFormCtrl', ['$scope', '$ro
};
}]);
-StudentSupportCallFormCtrl.getPayload = function (authService, supportStaffFormActionCreators, $route, $window) {
+StudentSupportCallFormCtrl.getPayload = function (authService, studentActions, $route, $window) {
authService.validate(localStorage.getItem('JWT'), $route.current.params.workgroupId, $route.current.params.year).then(function () {
// validate params
if ($route.current.params.year.length != 4 || $route.current.params.termShortCode.length != 2) {
$window.location.href = "/summary/" + $route.current.params.workgroupId + "/" + $route.current.params.year + "?mode=instructionalSupport";
} else {
- supportStaffFormActionCreators.getInitialState($route.current.params.workgroupId, $route.current.params.year, $route.current.params.termShortCode);
+ studentActions.getInitialState($route.current.params.workgroupId, $route.current.params.year, $route.current.params.termShortCode);
}
});
};
\ No newline at end of file
diff --git a/app/instructionalSupport/studentSupportCallForm/services/studentSupportActions.js b/app/instructionalSupport/studentSupportCallForm/services/studentSupportActions.js
deleted file mode 100644
index 97e3ae853..000000000
--- a/app/instructionalSupport/studentSupportCallForm/services/studentSupportActions.js
+++ /dev/null
@@ -1,88 +0,0 @@
-instructionalSupportApp.service('supportStaffFormActionCreators', function ($rootScope, $window, supportStaffFormService, supportStaffFormStateService) {
- return {
- getInitialState: function (workgroupId, year, termShortCode) {
- supportStaffFormService.getInitialState(workgroupId, year, termShortCode).then(function (payload) {
- var action = {
- type: INIT_STATE,
- payload: payload,
- year: year
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not load support staff form initial state.", type: "ERROR" });
- });
- },
- addStudentPreference: function (preference) {
- supportStaffFormService.addStudentPreference(preference).then(function (payload) {
- $rootScope.$emit('toast', { message: "Added Preference", type: "SUCCESS" });
- var action = {
- type: ADD_STUDENT_PREFERENCE,
- payload: payload
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not add preference.", type: "ERROR" });
- });
- },
- updateSupportCallResponse: function (supportCallResponse) {
- supportStaffFormService.updateSupportCallResponse(supportCallResponse).then(function (payload) {
- $rootScope.$emit('toast', { message: "Updated preferences", type: "SUCCESS" });
- var action = {
- type: UPDATE_SUPPORT_CALL_RESPONSE,
- payload: payload
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not update preferences.", type: "ERROR" });
- });
- },
- deleteStudentPreference: function (preference) {
- supportStaffFormService.deleteStudentPreference(preference.id).then(function (payload) {
- $rootScope.$emit('toast', { message: "Removed Preference", type: "SUCCESS" });
- var action = {
- type: DELETE_STUDENT_PREFERENCE,
- payload: preference
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not remove preference.", type: "ERROR" });
- });
- },
- submitPreferences: function (supportCallResponse, workgroupId, year) {
- supportStaffFormService.updateSupportCallResponse(supportCallResponse).then(function (payload) {
- $rootScope.$emit('toast', { message: "Updated preferences", type: "SUCCESS" });
- var studentSummaryUrl = "/summary/" + workgroupId + "/" + year + "?mode=instructionalSupport";
- $window.location.href = studentSummaryUrl;
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not update preferences.", type: "ERROR" });
- });
- },
- updatePreferencesOrder: function (preferenceIds, scheduleId, termCode) {
- supportStaffFormService.updatePreferencesOrder(preferenceIds, scheduleId, termCode).then(function (payload) {
- $rootScope.$emit('toast', { message: "Updated preferences", type: "SUCCESS" });
- var action = {
- type: UPDATE_PREFERENCES_ORDER,
- payload: payload
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not update preference order.", type: "ERROR" });
- });
- },
- updatePreference: function (scheduleId, preference) {
- supportStaffFormService.updatePreference(scheduleId, preference).then(function (payload) {
- $rootScope.$emit('toast', { message: "Updated preference comments", type: "SUCCESS" });
- var action = {
- type: UPDATE_PREFERENCE,
- payload: payload
- };
- supportStaffFormStateService.reduce(action);
- }, function (err) {
- $rootScope.$emit('toast', { message: "Could not update preference comments.", type: "ERROR" });
- });
- },
- pretendToastMessage: function () {
- $rootScope.$emit('toast', { message: "Updated preferences", type: "SUCCESS" });
- }
- };
-});
\ No newline at end of file
diff --git a/app/instructionalSupport/studentSupportCallForm/services/studentSupportReducers.js b/app/instructionalSupport/studentSupportCallForm/services/studentSupportReducers.js
deleted file mode 100644
index e6f256310..000000000
--- a/app/instructionalSupport/studentSupportCallForm/services/studentSupportReducers.js
+++ /dev/null
@@ -1,230 +0,0 @@
-instructionalSupportApp.service('supportStaffFormStateService', function ($rootScope, $log, supportStaffFormSelectors) {
- return {
- _state: {},
- _sectionGroupReducers: function (action, sectionGroups) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- sectionGroups = {
- ids: [],
- list: {}
- };
-
- action.payload.sectionGroups.forEach( function(sectionGroup) {
- sectionGroups.ids.push(sectionGroup.id);
- sectionGroups.list[sectionGroup.id] = sectionGroup;
- });
-
- return sectionGroups;
- default:
- return sectionGroups;
- }
- },
- _courseReducers: function (action, courses) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- courses = {
- ids: [],
- list: []
- };
-
- action.payload.courses.forEach( function(course) {
- courses.ids.push(course.id);
- courses.list[course.id] = course;
- });
-
- return courses;
- default:
- return courses;
- }
- },
- _preferenceReducers: function (action, preferences) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- preferences = {
- ids: [],
- list: []
- };
-
- action.payload.studentSupportPreferences.forEach( function(preference) {
- preferences.ids.push(preference.id);
- preferences.list[preference.id] = preference;
- });
-
- return preferences;
- case UPDATE_PREFERENCES_ORDER:
- action.payload;
-
- for (var i = 0; i < action.payload.length; i++) {
- var preferenceId = action.payload[i];
- var priority = i + 1;
- preferences.list[preferenceId].priority = priority;
- }
-
- return preferences;
- case ADD_STUDENT_PREFERENCE:
- var preference = action.payload;
- preferences.ids.push(preference.id);
- preferences.list[preference.id] = preference;
- return preferences;
- case DELETE_STUDENT_PREFERENCE:
- var preference = action.payload;
- var index = preferences.ids.indexOf(preference.id);
- preferences.ids.splice(index, 1);
- var priority = preference.priority;
- preferences.ids.forEach(function(slotPreferenceId) {
- var slotPreference = preferences.list[slotPreferenceId];
- if (slotPreference.priority > priority) {
- slotPreference.priority--;
- }
- });
- return preferences;
- default:
- return preferences;
- }
- },
- _supportAssignmentReducers: function (action, supportAssignments) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- supportAssignments = {
- ids: [],
- list: []
- };
-
- action.payload.supportAssignments.forEach( function(supportAssignment) {
- supportAssignments.ids.push(supportAssignment.id);
- supportAssignments.list[supportAssignment.id] = supportAssignment;
- });
-
- return supportAssignments;
- default:
- return supportAssignments;
- }
- },
- _miscReducers: function (action, misc) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- misc = {};
- misc.scheduleId = action.payload.scheduleId;
- misc.supportStaffId = action.payload.supportStaffId;
- return misc;
- default:
- return misc;
- }
- },
- _supportCallResponseReducers: function (action, supportCallResponse) {
- var scope = this;
-
- switch (action.type) {
- case INIT_STATE:
- supportCallResponse = action.payload.studentSupportCallResponse;
- if (!supportCallResponse) {
- return null;
- }
- supportCallResponse.dueDateDescription = millisecondsToFullDate(supportCallResponse.dueDate);
- return supportCallResponse;
- case UPDATE_SUPPORT_CALL_RESPONSE:
- supportCallResponse = action.payload;
- supportCallResponse.dueDateDescription = millisecondsToFullDate(supportCallResponse.dueDate);
- return supportCallResponse;
- default:
- return supportCallResponse;
- }
- },
- reduce: function (action) {
- var scope = this;
-
- newState = {};
- newState.courses = scope._courseReducers(action, scope._state.courses);
- newState.sectionGroups = scope._sectionGroupReducers(action, scope._state.sectionGroups);
- newState.supportAssignments = scope._supportAssignmentReducers(action, scope._state.supportAssignments);
- newState.misc = scope._miscReducers(action, scope._state.misc);
- newState.preferences = scope._preferenceReducers(action, scope._state.preferences);
- newState.supportCallResponse = scope._supportCallResponseReducers(action, scope._state.supportCallResponse);
-
- scope._state = newState;
-
- // Build new 'page state'
- // This is the 'view friendly' version of the store
- newPageState = {};
- newPageState.supportCallResponse = angular.copy(scope._state.supportCallResponse);
- newPageState.misc = angular.copy(scope._state.misc);
- newPageState.supportAssignments = angular.copy(scope._state.supportAssignments);
-
- newPageState.preferences = supportStaffFormSelectors.generatePreferences(
- scope._state.preferences,
- scope._state.courses,
- scope._state.sectionGroups
- );
-
- newPageState.potentialPreferences = supportStaffFormSelectors.generatePotentialPreferences(
- scope._state.supportAssignments,
- scope._state.courses,
- scope._state.sectionGroups,
- scope._state.preferences,
- scope._state.supportCallResponse
- );
-
- $rootScope.$emit('supportStaffFormStateChanged', newPageState);
- }
- };
-});
-
-millisecondsToFullDate = function(milliseconds) {
- var d = new Date(milliseconds);
- var day = d.getDate();
- var month = d.getMonth() + 1;
- var year = d.getFullYear();
- var formattedDate = year + "-" + month + "-" + day;
- formattedDate = moment(formattedDate, "YYYY-MM-DD").format('LL');
-
- return formattedDate;
-};
-
-// Sort the course Ids by subject Code and then course number
-sortCourseIds = function(courseIds, courses) {
-
- courseIds.sort(function (aId, bId) {
- a = courses[aId];
- b = courses[bId];
- // Use subject codes to sort
- if (a.subjectCode > b.subjectCode) {
- return 1;
- }
-
- if (a.subjectCode < b.subjectCode) {
- return -1;
- }
-
- // Subject codes matched, use course numbers to sort
- if (a.courseNumber > b.courseNumber) {
- return 1;
- }
-
- if (a.courseNumber < b.courseNumber) {
- return -1;
- }
-
- // Course numbers matched, use sequencePattern to sort
- if (a.sequencePattern > b.sequencePattern) {
- return 1;
- }
-
- if (a.sequencePattern < b.sequencePattern) {
- return -1;
- }
-
- return -1;
- });
-
- return courseIds;
-};
\ No newline at end of file
diff --git a/app/instructionalSupport/studentSupportCallForm/services/studentSupportService.js b/app/instructionalSupport/studentSupportCallForm/services/studentSupportService.js
deleted file mode 100644
index 15e9bd41a..000000000
--- a/app/instructionalSupport/studentSupportCallForm/services/studentSupportService.js
+++ /dev/null
@@ -1,77 +0,0 @@
-instructionalSupportApp.factory("supportStaffFormService", this.supportStaffFormService = function($http, $q, $window) {
- return {
- getInitialState: function(workgroupId, year, termShortCode) {
- var deferred = $q.defer();
-
- $http.get(serverRoot + "/api/instructionalSupportStudentFormView/workgroups/" + workgroupId + "/years/" + year + "/termCode/" + termShortCode, { withCredentials: true })
- .success(function(assignmentView) {
- deferred.resolve(assignmentView);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- },
- addStudentPreference: function(preference) {
- var deferred = $q.defer();
- $http.post(serverRoot + "/api/instructionalSupportStudentFormView/sectionGroups/" + preference.sectionGroupId + "/preferenceType/" + preference.appointmentType + "/percentage/" + preference.appointmentPercentage, { withCredentials: true })
- .success(function(assignmentView) {
- deferred.resolve(assignmentView);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- },
- updateSupportCallResponse: function(supportCallResponse) {
- var deferred = $q.defer();
- $http.put(serverRoot + "/api/instructionalSupportStudentFormView/studentSupportCallResponses/" + supportCallResponse.id, supportCallResponse, { withCredentials: true })
- .success(function(assignmentView) {
- deferred.resolve(assignmentView);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- },
- updatePreferencesOrder: function(preferenceIds, scheduleId, termCode) {
- var deferred = $q.defer();
- $http.put(serverRoot + "/api/instructionalSupportStudentFormView/schedules/" + scheduleId + "/terms/" + termCode, preferenceIds, { withCredentials: true })
- .success(function(payload) {
- deferred.resolve(payload);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- },
- updatePreference: function(scheduleId, preference) {
- var deferred = $q.defer();
- $http.put(serverRoot + "/api/instructionalSupportStudentFormView/schedules/" + scheduleId + "/preferences/" + preference.id, preference, { withCredentials: true })
- .success(function(payload) {
- deferred.resolve(payload);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- },
- deleteStudentPreference: function(preferenceId) {
- var deferred = $q.defer();
- $http.delete(serverRoot + "/api/instructionalSupportStudentFormView/studentInstructionalSupportPreferences/" + preferenceId, { withCredentials: true })
- .success(function(payload) {
- deferred.resolve(payload);
- })
- .error(function() {
- deferred.reject();
- });
-
- return deferred.promise;
- }
- };
-});
diff --git a/app/shared/helpers/dates.js b/app/shared/helpers/dates.js
index 2b3c60d26..73e00e88b 100644
--- a/app/shared/helpers/dates.js
+++ b/app/shared/helpers/dates.js
@@ -11,4 +11,18 @@ dateToCalendar = function (date) {
return "";
}
return moment(date).calendar();
+};
+
+millisecondsToDate = function(milliseconds) {
+ if ( !(milliseconds) ) {
+ return "";
+ }
+ var d = new Date(milliseconds);
+ var day = d.getDate();
+ var month = d.getMonth() + 1;
+ var year = d.getFullYear();
+ var formattedDate = year + "-" + month + "-" + day;
+ formattedDate = moment(formattedDate, "YYYY-MM-DD").format('LL');
+
+ return formattedDate;
};
\ No newline at end of file