From a2d8a0d1bacc33ddf4e18c477100d57777d38a80 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Jan 2014 03:29:47 +0000 Subject: use typeahead for users filtering git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1558283 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/archiva/i18n/default.properties | 3 ++ .../src/main/webapp/js/archiva/search.js | 7 ++- .../src/main/webapp/js/jquery.ui.widget-1.9.2.js | 0 .../src/main/webapp/js/redback/users.js | 58 +++------------------- 4 files changed, 16 insertions(+), 52 deletions(-) mode change 100755 => 100644 archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/jquery.ui.widget-1.9.2.js diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index d1eda6f41..09c4e26c1 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -702,5 +702,8 @@ welcome.docref=Documentation reference welcome.mainsite=Archiva Web site +version.delete.missing.repoId=You must select a Repository + + 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 a4f89fec8..7e40fce2c 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 @@ -1455,7 +1455,7 @@ define("archiva.search",["jquery","jquery.ui","i18n","jquery.tmpl","select2","kn return; } var dotEnd=request.term.endsWith("."); - // org.apache. requets with org.apache + // org.apache. request with org.apache // org.apa request with org before last dot and filter response with startsWith if (request.term.indexOf(".")>=0){ if (dotEnd){ @@ -1520,12 +1520,15 @@ define("archiva.search",["jquery","jquery.ui","i18n","jquery.tmpl","select2","kn } return false; } - }).data( "autocomplete" )._renderItem = function( ul, item ) { + }) + ._renderItem = function( ul, item ) { + $.log("_renderItem"); return $( "
  • " ) .data( "item.autocomplete", item ) .append( groupId ? "" + item.name.substring(groupId.length+1, item.name.length) + "": "" + item.name + "" ) .appendTo( ul ); }; + } /** diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/jquery.ui.widget-1.9.2.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/jquery.ui.widget-1.9.2.js old mode 100755 new mode 100644 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 ecf804be2..2f13804a6 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","jquery.ui","utils","i18n","jquery.validate","knockout","knockout.simpleGrid","typeahead"], -function(jquery,jqueryui,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { +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 @@ -281,57 +281,15 @@ function(jquery,jqueryui,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { } applyAutocompleteOnHeaderUsers=function(property,usersViewModel){ - - $("#main-content").find("#users-grid-filter-auto-"+property ).autocomplete({ - minLength: 0, - source: function(request, response){ - var founds=[]; - $.log("source:"+request.term+",users:"+usersViewModel.users().length) - $(usersViewModel.users()).each(function(idx,user){ - if(user[property] && user[property]() && user[property]().indexOf(request.term)>=0){ - founds.push(user[property]()); - } - }); - response(unifyArray(founds,true)); - }, - select: function( event, ui ) { - $.log("property:"+property+','+ui.item.value); - var users=[]; - $(usersViewModel.users()).each(function(idx,user){ - if(user[property] && user[property]() && user[property]().indexOf(ui.item.value)>=0){ - users.push(user); - } - }); - $.log("property:"+property+','+ui.item.value+",size:"+users.length); - usersViewModel.users(users); - return false; - } - }); - - /* - olamy: doesn't work???? - var values=[]; + var founds=[]; $(usersViewModel.users()).each(function(idx,user){ - var value=user[property]; - if(value!=null && $.inArray(value, values)<0){ - values.push(value); + if(user[property] && user[property]()){ + founds.push(user[property]()); } }); - var jid = "#users-grid-filter-auto-"+property; - $.log("applyAutocompleteOnHeaderUsers:"+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); - });*/ + $("#main-content").find("#users-grid-filter-auto-"+property ).typeahead({ + local: founds + }); } /** -- cgit v1.2.3