Skip to content

Commit

Permalink
WIP #438
Browse files Browse the repository at this point in the history
  • Loading branch information
boogheta committed Mar 7, 2022
1 parent 44511e5 commit 37d663e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hyphe_frontend/app/views/listWebentities.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ <h3 style="padding: 8px">
'background': obj.selected ? 'default-accent-100' : 'default-background-100'
}"
flex
ng-click="dynamicCheck($event, obj)"
>
<md-checkbox ng-model="obj.selected" ng-disabled="!obj.webentity"></md-checkbox>
<md-checkbox ng-model="obj.selected" ng-click="dynamicCheck($event, obj)" ng-disabled="!obj.webentity"></md-checkbox>
<p flex layout="row">
<a
ng-show="obj.webentity.homepage"
Expand Down
34 changes: 34 additions & 0 deletions hyphe_frontend/app/views/listWebentities.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ angular.module('hyphe.listwebentitiesController', [])
})
}

$scope.lastCheckedBox = null
$scope.dynamicCheck = function($event, obj){
console.log(obj.id, $event, $event.shiftKey)
if ($event.target.localName !== "div")
obj.selected = !obj.selected;
if ($event.shiftKey && obj.selected && $scope.lastCheckedBox)
$scope.dynamicWebentities.checkAllBetween(obj.id, $scope.lastCheckedBox)
$scope.lastCheckedBox = obj.selected ? obj.id : null
}

$scope.uncheck = function(weid){
checkedList_remove(weid)
$scope.dynamicWebentities.uncheck(weid)
Expand Down Expand Up @@ -495,6 +505,30 @@ angular.module('hyphe.listwebentitiesController', [])
this.checkOrUncheckAll(false, callback)
}

DynamicWebentities.prototype.checkAllBetween = function(idx1, idx2) {
var first = idx1, last = idx2;
if (first === last || Math.abs(first-last) == 1) return
if (first > last) {
first = idx2
last = idx1
}
console.log("SHOULD CHECK ALL WEs between", first, "and", last);
var first_p = Math.floor(first / this.PAGE_SIZE), last_p = Math.floor(last / this.PAGE_SIZE)
var p
for (p = first_p; p <= last_p; p++) {
if (this.loadedPages[p]) {
this.loadedPages[p].forEach(function(obj){
if (obj.id > first && obj.id < last)
obj.selected = true
})
// } else {
// settings.pagesToLoad.push(p)
}
}
// refacto cascading to account only values between first and last

}

DynamicWebentities.prototype.checkOrUncheckAll = function(checkValue, callback) {
// Strategy: Load each page, check all, and forget
var settings = {pagesToLoad: [], totalPages: 0, token: this.searchToken, callback:callback, checkValue:checkValue}
Expand Down

0 comments on commit 37d663e

Please sign in to comment.