From 2ab42c23caa0e56ff82acde9c40e0e2604daa0e7 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 25 Nov 2013 05:12:42 +0000 Subject: [PATCH] cleanup a bit git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1545152 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 7 +-- .../src/main/webapp/js/archiva/search.js | 8 +--- .../src/main/webapp/js/redback/users.js | 43 +++++++++++++++---- .../js/templates/redback/user-edit.html | 2 +- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js index cd665cb35..fa60b2b68 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js @@ -880,17 +880,18 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa }; drawQuickSearchAutocomplete=function(selector){ - - $( selector ? selector : "#quick-search-autocomplete" ).typeahead( + var box = $( selector ? selector : "#quick-search-autocomplete" ); + box.typeahead( { name: 'quick-search-result', remote: 'restServices/archivaServices/searchService/quickSearch?queryString=%QUERY', valueKey: 'artifactId', + maxParallelRequests:1, limit: 50 } ); - $( selector ? selector : "#quick-search-autocomplete" ).bind('typeahead:selected', function(obj, datum, name) { + box.bind('typeahead:selected', function(obj, datum, name) { window.sammyArchivaApplication.setLocation("#quicksearch~" + datum.artifactId); }); }; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js index 1f2d17b01..aa92cc07e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js @@ -1419,6 +1419,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","select2","knockout","kno if (selectedRepo){ url+="?repositoryId="+encodeURIComponent(selectedRepo); } + $( "#main-content").find("#browse-autocomplete" ).autocomplete({ minLength: 2, source: function(request, response){ @@ -2017,12 +2018,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","select2","knockout","kno }); var box = $( "#main-content").find("#search-filter-auto-"+property ); - box.typeahead( - { - local: values, - maxParallelRequests:2 - } - ); + box.typeahead( { local: values } ); box.bind('typeahead:selected', function(obj, datum, name) { var artifacts=[]; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js index 18c9dafb0..89157bdb1 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -define("redback.users",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid"], -function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { +define("redback.users",["jquery","utils","i18n","jquery.validate","knockout","knockout.simpleGrid","typeahead"], +function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { /** * view model used for users grid @@ -47,11 +47,15 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { filter: true } ], - pageSize: 10 + pageSize: 10, + gridUpdateCallBack: function(){ + $.log("gridUpdateCallBack users result"); + applyAutocompleteOnHeaders(self); + } }); clearFilters=function(){ self.users(self.originalUsers()); - applyAutocompleteOnHeaders(self); + }; filterLocked=function(){ var founds=[]; @@ -61,7 +65,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } }); self.users(founds); - applyAutocompleteOnHeaders(self); } filterNonLocked=function(){ var founds=[]; @@ -71,7 +74,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } }); self.users(founds); - applyAutocompleteOnHeaders(self); } filterPasswordChangeRequired=function(){ @@ -82,7 +84,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } }); self.users(founds); - applyAutocompleteOnHeaders(self); } filterPasswordChangeNotRequired=function(){ var founds=[]; @@ -92,7 +93,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } }); self.users(founds); - applyAutocompleteOnHeaders(self); } @@ -281,6 +281,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } applyAutocompleteOnHeader=function(property,usersViewModel){ + $("#main-content").find("#users-grid-filter-auto-"+property ).autocomplete({ minLength: 0, source: function(request, response){ @@ -306,6 +307,31 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { return false; } }); + + /* + olamy: doesn't work???? + var values=[]; + $(usersViewModel.users()).each(function(idx,user){ + var value=user[property]; + if(value!=null && $.inArray(value, values)<0){ + values.push(value); + } + }); + var jid = "#users-grid-filter-auto-"+property; + $.log("applyAutocompleteOnHeader:"+values.length+" for " + jid); + + var box = $("#main-content").find(jid); + + box.typeahead( { local: values } ); + box.bind('typeahead:selected', function(obj, datum, name) { + var users=[]; + $(usersViewModel.users()).each(function(idx,user){ + if(user[property] && user[property]() && user[property]().indexOf(datum.value)>=0){ + users.push(user); + } + }); + usersViewModel.users(users); + });*/ } /** @@ -341,7 +367,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) { } }) mainContent.find("#users-view-tabs-content #users-view").addClass("active"); - applyAutocompleteOnHeaders(usersViewModel); mainContent.find("#usersTable").find('.dropdown-toggle').dropdown(); } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html index 06fafec9f..371e47c05 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html @@ -193,7 +193,7 @@ {{each(i, columnDefinition) columns}} {{if columnDefinition.filter }} - {{/if}} -- 2.39.5