From 01b2415bfbc8dce47b1f17b8e62c6dd4a11dea83 Mon Sep 17 00:00:00 2001 From: kunw Date: Mon, 11 Jul 2016 16:11:54 +0800 Subject: [PATCH] update for interaction of enter key press when doing searches --- .../js/components/log/list-log.directive.html | 2 +- .../js/components/log/list-log.directive.js | 21 +++++++++++++------ .../list-project-member.directive.html | 2 +- .../list-project-member.directive.js | 9 ++++++++ .../list-replication.directive.html | 4 ++-- .../replication/list-replication.directive.js | 15 ++++++++++++- .../repository/list-repository.directive.html | 2 +- .../repository/list-repository.directive.js | 6 +++++- .../search/search-input.directive.js | 2 +- .../destination.directive.html | 2 +- .../destination.directive.js | 9 ++++++++ .../replication.directive.html | 2 +- .../replication.directive.js | 9 ++++++++ .../components/user/list-user.directive.html | 2 +- .../js/components/user/list-user.directive.js | 8 +++++-- .../js/layout/project/project.controller.js | 9 ++++++++ views/project.htm | 2 +- 17 files changed, 86 insertions(+), 20 deletions(-) diff --git a/static/resources/js/components/log/list-log.directive.html b/static/resources/js/components/log/list-log.directive.html index 912498dd4..8446a66a9 100644 --- a/static/resources/js/components/log/list-log.directive.html +++ b/static/resources/js/components/log/list-log.directive.html @@ -16,7 +16,7 @@
- + diff --git a/static/resources/js/components/log/list-log.directive.js b/static/resources/js/components/log/list-log.directive.js index 5c4868125..06c99c6ba 100644 --- a/static/resources/js/components/log/list-log.directive.js +++ b/static/resources/js/components/log/list-log.directive.js @@ -145,19 +145,28 @@ function listLog() { var directive = { - restrict: 'E', - templateUrl: '/static/resources/js/components/log/list-log.directive.html', - scope: { + 'restrict': 'E', + 'templateUrl': '/static/resources/js/components/log/list-log.directive.html', + 'scope': { 'sectionHeight': '=', 'target': '=', 'publicity': '=' }, - controller: ListLogController, - controllerAs: 'vm', - bindToController: true + 'link': link, + 'controller': ListLogController, + 'controllerAs': 'vm', + 'bindToController': true }; return directive; + + function link(scope, element, attrs, ctrl) { + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.search({'op': ctrl.op, 'username': ctrl.username}); + } + }); + } } })(); \ No newline at end of file diff --git a/static/resources/js/components/project-member/list-project-member.directive.html b/static/resources/js/components/project-member/list-project-member.directive.html index 7e2654168..469022452 100644 --- a/static/resources/js/components/project-member/list-project-member.directive.html +++ b/static/resources/js/components/project-member/list-project-member.directive.html @@ -16,7 +16,7 @@
- + diff --git a/static/resources/js/components/project-member/list-project-member.directive.js b/static/resources/js/components/project-member/list-project-member.directive.js index cdcc28607..efcd9d900 100644 --- a/static/resources/js/components/project-member/list-project-member.directive.js +++ b/static/resources/js/components/project-member/list-project-member.directive.js @@ -106,12 +106,21 @@ 'sectionHeight': '=', 'target': '=' }, + 'link': link, 'controller': ListProjectMemberController, 'controllerAs': 'vm', 'bindToController': true }; return directive; + + function link(scope, element, attrs, ctrl) { + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.retrieve(); + } + }); + } } })(); \ No newline at end of file diff --git a/static/resources/js/components/replication/list-replication.directive.html b/static/resources/js/components/replication/list-replication.directive.html index 2d8eb16f6..428eaef6c 100644 --- a/static/resources/js/components/replication/list-replication.directive.html +++ b/static/resources/js/components/replication/list-replication.directive.html @@ -16,7 +16,7 @@
- + @@ -79,7 +79,7 @@
- + diff --git a/static/resources/js/components/replication/list-replication.directive.js b/static/resources/js/components/replication/list-replication.directive.js index 04411646c..28e8560ea 100644 --- a/static/resources/js/components/replication/list-replication.directive.js +++ b/static/resources/js/components/replication/list-replication.directive.js @@ -143,7 +143,7 @@ $scope.$emit('raiseAlert', alertInfo); vm.searchJobTIP = false; vm.refreshJobTIP = false; - } + }searchReplicationJob function listReplicationJobFailed(data, status) { console.log('Failed to list replication job:' + data); @@ -303,6 +303,19 @@ element.find('#toDatePicker').on('blur', function(){ ctrl.pickUp({'key': 'toDate', 'value': $(this).val()}); }); + + element.find('#txtSearchPolicyInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.searchReplicationPolicy(); + } + }); + + element.find('#txtSearchJobInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.searchReplicationJob(); + } + }); + } } diff --git a/static/resources/js/components/repository/list-repository.directive.html b/static/resources/js/components/repository/list-repository.directive.html index 518d96611..23ad69a99 100644 --- a/static/resources/js/components/repository/list-repository.directive.html +++ b/static/resources/js/components/repository/list-repository.directive.html @@ -2,7 +2,7 @@
- + diff --git a/static/resources/js/components/repository/list-repository.directive.js b/static/resources/js/components/repository/list-repository.directive.js index 0c509777d..7f12a7891 100644 --- a/static/resources/js/components/repository/list-repository.directive.js +++ b/static/resources/js/components/repository/list-repository.directive.js @@ -175,7 +175,11 @@ return directive; function link(scope, element, attr, ctrl) { - + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.retrieve(); + } + }); } } diff --git a/static/resources/js/components/search/search-input.directive.js b/static/resources/js/components/search/search-input.directive.js index 5fd9173d5..cf71be575 100644 --- a/static/resources/js/components/search/search-input.directive.js +++ b/static/resources/js/components/search/search-input.directive.js @@ -57,7 +57,7 @@ .on('keydown', keydownHandler); function keydownHandler(e) { - if(e.keyCode === 13) { + if($(this).is(':focus') && e.keyCode === 13) { ctrl.searchFor($(this).val()); } } diff --git a/static/resources/js/components/system-management/destination.directive.html b/static/resources/js/components/system-management/destination.directive.html index 37774c994..6d47cec4d 100644 --- a/static/resources/js/components/system-management/destination.directive.html +++ b/static/resources/js/components/system-management/destination.directive.html @@ -16,7 +16,7 @@
- + diff --git a/static/resources/js/components/system-management/destination.directive.js b/static/resources/js/components/system-management/destination.directive.js index 071fee268..541c15516 100644 --- a/static/resources/js/components/system-management/destination.directive.js +++ b/static/resources/js/components/system-management/destination.directive.js @@ -108,11 +108,20 @@ 'restrict': 'E', 'templateUrl': '/static/resources/js/components/system-management/destination.directive.html', 'scope': true, + 'link': link, 'controller': DestinationController, 'controllerAs': 'vm', 'bindToController': true }; return directive; + + function link(scope, element, attrs, ctrl) { + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.retrieve(); + } + }); + } } })(); \ No newline at end of file diff --git a/static/resources/js/components/system-management/replication.directive.html b/static/resources/js/components/system-management/replication.directive.html index 90c1bb7ec..01cc5c232 100644 --- a/static/resources/js/components/system-management/replication.directive.html +++ b/static/resources/js/components/system-management/replication.directive.html @@ -16,7 +16,7 @@
- + diff --git a/static/resources/js/components/system-management/replication.directive.js b/static/resources/js/components/system-management/replication.directive.js index 99c453d3f..a66da4e55 100644 --- a/static/resources/js/components/system-management/replication.directive.js +++ b/static/resources/js/components/system-management/replication.directive.js @@ -111,11 +111,20 @@ 'restrict': 'E', 'templateUrl': '/static/resources/js/components/system-management/replication.directive.html', 'scope': true, + 'link': link, 'controller': ReplicationController, 'controllerAs': 'vm', 'bindToController': true }; return directive; + + function link(scope, element, attrs, ctrl) { + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.retrieve(); + } + }); + } } })(); \ No newline at end of file diff --git a/static/resources/js/components/user/list-user.directive.html b/static/resources/js/components/user/list-user.directive.html index f84eedc46..893ad7060 100644 --- a/static/resources/js/components/user/list-user.directive.html +++ b/static/resources/js/components/user/list-user.directive.html @@ -16,7 +16,7 @@
- + diff --git a/static/resources/js/components/user/list-user.directive.js b/static/resources/js/components/user/list-user.directive.js index bbd7c929c..1e9d42ec2 100644 --- a/static/resources/js/components/user/list-user.directive.js +++ b/static/resources/js/components/user/list-user.directive.js @@ -102,8 +102,12 @@ }; return directive; - function link(scope, element, attrs) { - + function link(scope, element, attrs, ctrl) { + element.find('#txtSearchInput').on('keydown', function(e) { + if($(this).is(':focus') && e.keyCode === 13) { + ctrl.retrieve(); + } + }); } } diff --git a/static/resources/js/layout/project/project.controller.js b/static/resources/js/layout/project/project.controller.js index cb497daf5..9a7291eeb 100644 --- a/static/resources/js/layout/project/project.controller.js +++ b/static/resources/js/layout/project/project.controller.js @@ -38,6 +38,8 @@ vm.retrieve(); vm.getProjectRole = getProjectRole; + vm.searchProjectByKeyPress = searchProjectByKeyPress; + //Error message dialog handler for project. $scope.$on('modalTitle', function(e, val) { @@ -116,6 +118,13 @@ console.log('vm.publicity:' + vm.publicity); } + function searchProjectByKeyPress($event) { + var keyCode = $event.which || $event.keyCode; + if(keyCode === 13) { + vm.retrieve(); + } + } + } })(); \ No newline at end of file diff --git a/views/project.htm b/views/project.htm index 25519610a..ac5da5e06 100644 --- a/views/project.htm +++ b/views/project.htm @@ -28,7 +28,7 @@
- +