Skip to content

Commit

Permalink
Fetch submission when needing to update scope
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Aug 28, 2024
1 parent 4cb3b5d commit d3e1d27
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ vireo.controller("SubmissionViewController", function ($controller, $q, $scope,

var deleteFile = function (fieldValue) {
fieldValue.removing = true;
FileUploadService.removeFile($scope.submission, fieldValue).then(function (removed) {
var deleteFilePromise = FileUploadService.removeFile($scope.submission, fieldValue);

deleteFilePromise.then(function (removed) {
delete fieldValue.removing;
});

return deleteFilePromise;
};

var fetchSubmission = function () {
StudentSubmissionRepo.fetchSubmissionById($routeParams.submissionId).then(function (submission) {
angular.extend($scope.submission, submission);
});
}

StudentSubmissionRepo.fetchSubmissionById($routeParams.submissionId).then(function (submission) {
$scope.loaded = true;
$scope.submission = submission;
Expand Down Expand Up @@ -86,6 +96,7 @@ vireo.controller("SubmissionViewController", function ($controller, $q, $scope,
}
$q.all(removePromises).then(function () {
$scope.removingUploads = false;
fetchSubmission();
});
};

Expand All @@ -97,9 +108,13 @@ vireo.controller("SubmissionViewController", function ($controller, $q, $scope,

$scope.archiveManuscript = function () {
$scope.archivingManuscript = true;
FileUploadService.archiveFile($scope.submission, $scope.submission.primaryDocumentFieldValue, true).then(function () {
FileUploadService.archiveFile($scope.submission, $scope.submission.primaryDocumentFieldValue, true).then(function (removeFieldValue) {
$scope.archivingManuscript = false;
$scope.submission.addFieldValue($scope.submission.getPrimaryDocumentFieldProfile().fieldPredicate);
if (removeFieldValue) {
fetchSubmission();
} else {
console.error('Failed to remove field value. Please refresh the page.');
}
});
};

Expand Down Expand Up @@ -171,9 +186,7 @@ vireo.controller("SubmissionViewController", function ($controller, $q, $scope,
CustomActionDefinitionRepo.listen(function(apiRes) {
if(apiRes.meta.status === 'SUCCESS') {
StudentSubmissionRepo.remove($scope.submission);
StudentSubmissionRepo.fetchSubmissionById($routeParams.submissionId).then(function (submission) {
angular.extend($scope.submission, submission);
});
fetchSubmission();
}
});

Expand Down

0 comments on commit d3e1d27

Please sign in to comment.