diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js index b699503737..7c64d482ca 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js @@ -41,6 +41,7 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { formTitleText: 'Repository Form', searchValue: null, + typeFilter: null, initComponent: function(){ @@ -95,9 +96,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { Sonia.repository.Grid.superclass.initComponent.apply(this, arguments); }, - storeLoad: function(store){ + storeLoad: function(){ if (this.searchValue){ - this.searchStore(store); + this.filterStore(); } }, @@ -113,22 +114,31 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { }, search: function(value){ - this.searchValue = value; - var store = this.getStore(); - if ( ! value ){ - store.clearFilter(); - } else { - this.searchStore(store); - } + this.searchValue = value; + this.filterStore(); }, - searchStore: function(store){ - var value = this.searchValue.toLowerCase(); - store.filterBy(function(rec){ - return ! value || - rec.get('name').toLowerCase().indexOf(value) >= 0 || - rec.get('description').toLowerCase().indexOf(value) >= 0; - }); + filter: function(type){ + this.typeFilter = type; + this.filterStore(); + }, + + filterStore: function(){ + var store = this.getStore(); + if ( ! this.searchValue && ! this.typeFilter ){ + store.clearFilter(); + } else { + var search = null; + if ( this.searchValue ){ + search = this.searchValue.toLowerCase(); + } + store.filterBy(function(rec){ + return (! search || + rec.get('name').toLowerCase().indexOf(search) >= 0 || + rec.get('description').toLowerCase().indexOf(search) >= 0) && + (! this.typeFilter || rec.get('type') == this.typeFilter); + }, this); + } }, selectItem: function(item){ diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.panel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.panel.js index d382a2d0d2..ce597cc65e 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.panel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.panel.js @@ -67,9 +67,30 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, { scope: this, handler: this.reload },'-',{ + xtype: 'label', + text: 'Filter: ' + }, ' ', { + xtype: 'combo', + hiddenName : 'type', + typeAhead: true, + triggerAction: 'all', + lazyRender: true, + mode: 'local', + editable: false, + store: repositoryTypeStore, + valueField: 'name', + displayField: 'displayName', + allowBlank: true, + listeners: { + select: { + fn: this.filterByType, + scope: this + } + } + }, ' ',{ xtype: 'label', text: 'Search: ' - }, ' ',{ + }, ' ',{ xtype: 'textfield', enableKeyEvents: true, listeners: { @@ -77,7 +98,7 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, { fn: this.search, scope: this } - } + } }); var config = { @@ -108,6 +129,14 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, { Sonia.repository.Panel.superclass.initComponent.apply(this, arguments); }, + filterByType: function(combo, rec){ + var name = rec.get('name'); + + console.debug(name); + + Ext.getCmp('repositoryGrid').filter(name); + }, + search: function(field){ Ext.getCmp('repositoryGrid').search(field.getValue()); },