Skip to content

Commit

Permalink
#1579 WIP: Add a multi selection filter for match criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Oct 21, 2020
1 parent be15f4a commit b3c9cd6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
25 changes: 19 additions & 6 deletions frontend/app/scripts/components/alert/AlertSimilarCaseListCmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
self.CaseResolutionStatus = CaseResolutionStatus;

self.similarityFilters = {
fTitle: undefined,
fMatches: undefined
fTitle: undefined
};

self.matchFilters = {
fMatches: []
};

self.rateFilters = {
Expand Down Expand Up @@ -89,8 +92,11 @@
// Frontend filter methods
this.clearLocalFilters = function() {
self.similarityFilters = {
fTitle: undefined,
fMatches: undefined
fTitle: undefined
};

self.matchFilters = {
fMatches: []
};

self.rateFilters = {
Expand All @@ -101,8 +107,15 @@

this.greaterThan = function(prop){
return function(item){
return !self.rateFilters[prop] || item[prop] >= self.rateFilters[prop];
};
return !self.rateFilters[prop] || item[prop] >= self.rateFilters[prop];
};
};

this.matchFilter = function() {
return function(item){
return !self.matchFilters.fMatches || self.matchFilters.fMatches.length === 0 ||
_.intersection(self.matchFilters.fMatches, item.fMatches).length > 0;
};
};

// Filtering methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
</div>
<div class="case-similarity-match text-bold">
<div>
<select class="form-control input-sm" ng-model="$cmp.similarityFilters.fMatches"
ng-options="item for item in $cmp.matches">
<option value=""></option>
</select>
<multiselect ng-model="$cmp.matchFilters.fMatches" options="$cmp.matches" show-select-all="true" show-unselect-all="true"
classes-btn="'btn-default btn-block btn-sm'"></multiselect>
</div>
</div>
<div class="case-similarity-merge text-bold">
Expand All @@ -103,7 +101,7 @@
</div>

<!-- Table data -->
<div class="case-collection" ng-repeat="item in ($cmp.filteredCases = ($cmp.list.allValues | filter:$cmp.similarityFilters | filter:$cmp.greaterThan('fObservables') | filter:$cmp.greaterThan('fIocs')) | orderBy:$cmp.sortField | limitTo:$cmp.pagination.pageSize:($cmp.pagination.currentPage-1)*$cmp.pagination.pageSize)">
<div class="case-collection" ng-repeat="item in ($cmp.filteredCases = ($cmp.list.allValues | filter:$cmp.similarityFilters | filter:$cmp.matchFilter() | filter:$cmp.greaterThan('fObservables') | filter:$cmp.greaterThan('fIocs')) | orderBy:$cmp.sortField | limitTo:$cmp.pagination.pageSize:($cmp.pagination.currentPage-1)*$cmp.pagination.pageSize)">
<div class="case-item" >
<!-- case tlp -->
<div class="case-tlp bg-tlp-{{item.case.tlp}} clickable" ng-click="$cmp.addFilterValue('tlp', item.case.tlp)"></div>
Expand Down

0 comments on commit b3c9cd6

Please sign in to comment.