update for advanced-search options.

This commit is contained in:
kunw 2016-07-04 19:09:19 +08:00
parent ed08eb1c16
commit ae3bfba3c8
5 changed files with 37 additions and 16 deletions

View File

@ -46,7 +46,7 @@
<div class="col-xs-2 col-md-2"> <div class="col-xs-2 col-md-2">
<form> <form>
<div class="form-group" style="margin-top: 40%;"> <div class="form-group" style="margin-top: 40%;">
<button type="button" class="btn btn-primary" ng-click="vm.search({op: vm.op})">// 'search' | tr //</button> <button type="button" class="btn btn-primary" ng-click="vm.doSearch({op: vm.op})">// 'search' | tr //</button>
</div> </div>
</form> </form>
</div> </div>

View File

@ -16,6 +16,8 @@
vm.opAll = true; vm.opAll = true;
vm.doSearch = doSearch;
$scope.$watch('vm.op', function(current) { $scope.$watch('vm.op', function(current) {
if(current && vm.op[0] === 'all') { if(current && vm.op[0] === 'all') {
vm.opCreate = true; vm.opCreate = true;
@ -23,7 +25,6 @@
vm.opPush = true; vm.opPush = true;
vm.opDelete = true; vm.opDelete = true;
vm.opOthers = true; vm.opOthers = true;
vm.others = "";
} }
}, true); }, true);
@ -38,13 +39,14 @@
vm.toDate = current; vm.toDate = current;
} }
}); });
vm.opCreate = true; vm.opCreate = true;
vm.opPull = true; vm.opPull = true;
vm.opPush = true; vm.opPush = true;
vm.opDelete = true; vm.opDelete = true;
vm.opOthers = true; vm.opOthers = true;
vm.others = ""; vm.others = '';
vm.op = []; vm.op = [];
vm.op.push('all'); vm.op.push('all');
@ -56,26 +58,25 @@
vm.opDelete = vm.opAll; vm.opDelete = vm.opAll;
vm.opOthers = vm.opAll; vm.opOthers = vm.opAll;
}else { }else {
vm.op = [];
vm.opAll = false; vm.opAll = false;
} }
vm.op = [];
if(vm.opCreate) { if(vm.opCreate) {
vm.op.push('create'); vm.op.push('create');
} }
if(vm.opPull) { if(vm.opPull) {
vm.op.push('pull'); vm.op.push('pull');
} }
if(vm.opPush) { if(vm.opPush) {
vm.op.push('push'); vm.op.push('push');
} }
if(vm.opDelete) { if(vm.opDelete) {
vm.op.push('delete'); vm.op.push('delete');
}
if(vm.opOthers && $.trim(vm.others) !== '') {
vm.op.push($.trim(vm.others));
} }
if(vm.opOthers && vm.others !== "") {
vm.op.push(vm.others);
}
} }
vm.pickUp = pickUp; vm.pickUp = pickUp;
@ -100,6 +101,13 @@
vm.others = ''; vm.others = '';
vm.isOpen = false; vm.isOpen = false;
} }
function doSearch (e){
if(vm.opOthers && $.trim(vm.others) !== '') {
e.op.push(vm.others);
}
vm.search(e);
}
} }
function advancedSearch() { function advancedSearch() {
@ -109,6 +117,7 @@
'scope': { 'scope': {
'isOpen': '=', 'isOpen': '=',
'op': '=', 'op': '=',
'opOthers': '=',
'others': '=', 'others': '=',
'fromDate': '=', 'fromDate': '=',
'toDate': '=', 'toDate': '=',

View File

@ -11,7 +11,7 @@
</span> </span>
</div> </div>
</div> </div>
<advanced-search ng-show="vm.isOpen" is-open="vm.isOpen" op="vm.op" others="vm.others" search='vm.search({op: vm.op, username: vm.username})' from-date="vm.fromDate" to-date="vm.toDate"></advanced-search> <advanced-search ng-show="vm.isOpen" is-open="vm.isOpen" op="vm.op" others="vm.others" search='vm.search({op: vm.op, username: vm.username})' from-date="vm.fromDate" to-date="vm.toDate" op-others="vm.opOthers"></advanced-search>
<div class="pane"> <div class="pane">
<div class="sub-pane"> <div class="sub-pane">
<div class="table-head-container"> <div class="table-head-container">

View File

@ -24,7 +24,8 @@
vm.username = ""; vm.username = "";
vm.op = []; vm.op = [];
vm.opOthers = true;
vm.search = search; vm.search = search;
vm.showAdvancedSearch = showAdvancedSearch; vm.showAdvancedSearch = showAdvancedSearch;
@ -52,9 +53,18 @@
function search(e) { function search(e) {
if(e.op[0] === 'all') { if(e.op[0] === 'all') {
vm.queryParams.keywords = ''; if(vm.opOthers && $.trim(vm.others) !== '') {
e.op = [];
e.op.push(vm.others);
vm.queryParams.keywords = e.op.join('/');
}else{
vm.queryParams.keywords = '';
}
}else { }else {
vm.queryParams.keywords = e.op.join('/') ; if(vm.opOthers && $.trim(vm.others) !== '') {
e.op.push(vm.others);
}
vm.queryParams.keywords = e.op.join('/');
} }
vm.queryParams.username = e.username; vm.queryParams.username = e.username;
@ -92,6 +102,7 @@
vm.fromDate = ''; vm.fromDate = '';
vm.toDate = ''; vm.toDate = '';
vm.others = ''; vm.others = '';
vm.opOthers = true;
vm.isOpen = false; vm.isOpen = false;
} }
function listLogFailed(response){ function listLogFailed(response){

View File

@ -36,6 +36,7 @@
$scope.$on('$locationChangeSuccess', function() { $scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.filterInput = '';
vm.retrieve(); vm.retrieve();
}); });