-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created new Abstract Paged Controller and isolated Table Directive Sc…
…ope. WIP
- Loading branch information
Showing
6 changed files
with
140 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
app.controller('AbstractPagedController', function ($controller, $scope, FeatureProposal, FeatureProposalRepo, IdeaRepo, ServiceRepo) { | ||
|
||
angular.extend(this, $controller('AbstractController', { | ||
$scope: $scope | ||
})); | ||
|
||
if ($scope.filters) { | ||
|
||
$scope.filter = $scope.filters[0]; | ||
|
||
$scope.activeFilters = $scope.repo.getPageSettings().filters; | ||
|
||
$scope.selectFilter = function (filter) { | ||
$scope.filter = filter; | ||
}; | ||
|
||
$scope.removeFilter = function (prop, v) { | ||
$scope.activeFilters[prop].splice($scope.activeFilters[prop].indexOf(v), 1); | ||
if ($scope.activeFilters[prop].length === 0) { | ||
delete $scope.activeFilters[prop]; | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
}; | ||
|
||
$scope.applyFilter = function (filter) { | ||
if ($scope.activeFilters[filter.property]) { | ||
$scope.activeFilters[filter.property].push(filter.value); | ||
} else { | ||
$scope.activeFilters[filter.property] = [filter.value]; | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
delete $scope.filter.value; | ||
}; | ||
|
||
$scope.lookupGloss = function (prop) { | ||
for (var i in $scope.filters) { | ||
var filter = angular.copy($scope.filters[i]); | ||
if (filter.property === prop) { | ||
return filter.gloss; | ||
} | ||
} | ||
}; | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,89 @@ | ||
app.directive('weaverTable', function ($controller) { | ||
return { | ||
templateUrl: 'views/directives/tableControls.html', | ||
restrict: 'E', | ||
replace: false, | ||
transclude: { | ||
table: 'weaverTableElement', | ||
controls: 'weaverTableControls', | ||
modals: 'weaverTableModals' | ||
}, | ||
scope: false, | ||
link: function ($scope, element, attr) { | ||
|
||
if($scope.filters) { | ||
|
||
$scope.filter = $scope.filters[0]; | ||
return { | ||
templateUrl: 'views/directives/tableControls.html', | ||
restrict: 'E', | ||
replace: false, | ||
transclude: { | ||
table: 'weaverTableElement', | ||
controls: 'weaverTableControls', | ||
modals: 'weaverTableModals' | ||
}, | ||
scope: { | ||
defaultSorting: "=", | ||
repo: "=" | ||
}, | ||
link: function ($scope, element, attr) { | ||
var activeSort; | ||
|
||
if ($scope.defaultSorting === undefined) { | ||
activeSort = $scope.repo.getPageSettings().sort = [ | ||
{ | ||
property: 'service.name', | ||
direction: 'ASC' | ||
}, { | ||
property: 'lastModified', | ||
direction: 'DESC' | ||
} | ||
]; | ||
} else { | ||
activeSort = $scope.repo.getPageSettings().sort = [$scope.defaultSorting]; | ||
|
||
} | ||
|
||
$scope.activeFilters = $scope.repo.getPageSettings().filters; | ||
|
||
$scope.selectFilter = function(filter) { | ||
$scope.filter = filter; | ||
}; | ||
|
||
$scope.removeFilter = function (prop, v) { | ||
$scope.activeFilters[prop].splice($scope.activeFilters[prop].indexOf(v), 1); | ||
if($scope.activeFilters[prop].length === 0) { | ||
delete $scope.activeFilters[prop]; | ||
$scope.unsorted = function (prop) { | ||
for (var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if (sort.property === prop) { | ||
return false; | ||
} | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
return true; | ||
}; | ||
|
||
$scope.applyFilter = function(filter) { | ||
if($scope.activeFilters[filter.property]) { | ||
$scope.activeFilters[filter.property].push(filter.value); | ||
} else { | ||
$scope.activeFilters[filter.property] = [filter.value]; | ||
|
||
$scope.asc = function (prop) { | ||
for (var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if (sort.property === prop && sort.direction === 'ASC') { | ||
return true; | ||
} | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
delete $scope.filter.value; | ||
return false; | ||
}; | ||
|
||
$scope.lookupGloss = function(prop) { | ||
for(var i in $scope.filters) { | ||
var filter = angular.copy($scope.filters[i]); | ||
if(filter.property === prop) { | ||
return filter.gloss; | ||
$scope.desc = function (prop) { | ||
for (var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if (sort.property === prop && sort.direction === 'DESC') { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
} | ||
|
||
var activeSort = $scope.repo.getPageSettings().sort = [{ | ||
property: 'service.name', | ||
direction: 'ASC' | ||
}, { | ||
property: 'lastModified', | ||
direction: 'DESC' | ||
}]; | ||
|
||
$scope.unsorted = function(prop) { | ||
for(var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if(sort.property === prop) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
|
||
$scope.asc = function(prop) { | ||
for(var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if(sort.property === prop && sort.direction === 'ASC') { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
$scope.desc = function(prop) { | ||
for(var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if(sort.property === prop && sort.direction === 'DESC') { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
$scope.toggleSort = function(prop) { | ||
var asc = true; | ||
for(var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if(sort.property === prop) { | ||
if(sort.direction === 'ASC') { | ||
sort.direction = 'DESC'; | ||
} else { | ||
activeSort.splice(i, 1); | ||
$scope.toggleSort = function (prop) { | ||
var asc = true; | ||
for (var i in activeSort) { | ||
var sort = activeSort[i]; | ||
if (sort.property === prop) { | ||
if (sort.direction === 'ASC') { | ||
sort.direction = 'DESC'; | ||
} else { | ||
activeSort.splice(i, 1); | ||
} | ||
asc = false; | ||
break; | ||
} | ||
asc = false; | ||
break; | ||
} | ||
} | ||
if(asc) { | ||
activeSort.push({ | ||
property: prop, | ||
direction: 'ASC' | ||
}); | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
}; | ||
if (asc) { | ||
activeSort.push({ | ||
property: prop, | ||
direction: 'ASC' | ||
}); | ||
} | ||
$scope.repo.getTableParams().reload(); | ||
}; | ||
|
||
} | ||
}; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters