Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue 53] Add submission list filter by graduation semester similar to Vireo 3 #87

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FieldValueController {
@GetMapping("/predicate/{value}")
@PreAuthorize("hasRole('STUDENT')")
public ApiResponse getFieldValuesByPredicateValue(@PathVariable String value) {
return new ApiResponse(SUCCESS, fieldValueRepo.getAllValuesByFieldPredicateValue("submission_type"));
return new ApiResponse(SUCCESS, fieldValueRepo.getAllValuesByFieldPredicateValue(value));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle

update(true);

const withoutActiveFilter = function(value) {
return $scope.activeFilters.namedSearchFilters.filter((nsf) => nsf.filterValues.indexOf(value) >= 0).length == 0;
};

var assignableUsers = UserRepo.getAssignableUsers(0, 0);
var savedFilters = SavedFilterRepo.getAll();
var emailTemplates = EmailTemplateRepo.getAll();
Expand All @@ -217,6 +221,15 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle
var packagers = PackagerRepo.getAll();
var controlledVocabularies = ControlledVocabularyRepo.getAll();
var submissionTypeList = FieldValueRepo.findValuesByPredicateValue('submission_type');
var graduationSemesters = FieldValueRepo.findValuesByPredicateValue('dc.date.issued', function (a, b) {
const [monthA, yearA] = a.split(' ');
const [monthB, yearB] = b.split(' ');

const dateA = new Date(`${monthA} 1, ${yearA}`);
const dateB = new Date(`${monthB} 1, ${yearB}`);

return dateB - dateA;
});

var addBatchCommentEmail = function (message) {
batchCommentEmail.adding = true;
Expand Down Expand Up @@ -625,6 +638,8 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle
"embargos": embargos,
"submissionTypeList": submissionTypeList,
"assignableUsers": assignableUsers,
"graduationSemesters": graduationSemesters,
"withoutActiveFilter": withoutActiveFilter,
"defaultLimit": 3,
"getTypeAheadByPredicateName": getTypeAheadByPredicateName,
"datepickerOptions": datepickerOptions
Expand All @@ -646,6 +661,8 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle
"submissionStatuses": submissionStatuses,
"newStatus": submissionStatuses[0],
"assignableUsers": assignableUsers,
"graduationSemesters": graduationSemesters,
"withoutActiveFilter": withoutActiveFilter,
"batchAssignTo": batchAssignTo,
"batchPublish": batchPublish,
"resetBatchCommentEmailModal": resetBatchCommentEmailModal,
Expand Down
6 changes: 5 additions & 1 deletion src/main/webapp/app/repo/fieldValueRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vireo.repo("FieldValueRepo", function FieldValueRepo(FieldValue, WsApi) {

var fieldValueRepo = this;

fieldValueRepo.findValuesByPredicateValue = function(value) {
fieldValueRepo.findValuesByPredicateValue = function(value, sort) {
var fieldValues = [];

// FieldValue exists on the API Mapping but is under the Submission controller, which is not correct and so manually define the entire mapping inline here.
Expand All @@ -20,6 +20,10 @@ vireo.repo("FieldValueRepo", function FieldValueRepo(FieldValue, WsApi) {
for (var i in values) {
fieldValues.push(values[i]);
}

if (sort) {
fieldValues = fieldValues.sort(sort);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
<form ng-submit="box.addDateFilter(column)">
<div class="input-group">
<span class="input-group-addon" ng-click="date=true">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input
type="text"
class="form-control"
uib-datepicker-popup="MMMM yyyy"
datepicker-options="box.datepickerOptions"
ng-model="box[column.title.split(' ').join('')].d1"
ng-click="date=true"
is-open="date"
ng-required="!fieldProfile.optional"
show-button-bar="false"
readonly
/>
</div>
<input type="submit" value="Add Filter" class="btn btn-default btn-block add-date-filter-btn" ng-disabled="!box[column.title.split(' ').join('')].d1" />
<form ng-init="box.graduationSemestersLimit=box.defaultLimit;" name="{{'box.'+(column.title.split(' ').join(''))+'Form'}}">
<ul class="sidebox-list">
<li
class="filter"
ng-repeat="semester in semesters = box.graduationSemesters | filter:box.withoutActiveFilter | limitTo:box.graduationSemestersLimit"
ng-click="box[column.title.split(' ').join('')]=semester;box.addExactMatchFilter(column, semester);">{{semester}}</li>
<li class="more-less" ng-click="box.graduationSemestersLimit=semesters.length" ng-if="box.graduationSemestersLimit<=box.defaultLimit && semesters.length>box.defaultLimit">more...</li>
<li class="more-less" ng-click="box.graduationSemestersLimit=box.defaultLimit" ng-if="box.graduationSemestersLimit>box.defaultLimit">less...</li>
</ul>
</form>
Loading