mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 02:06:18 +01:00
added repository type filter
This commit is contained in:
@@ -41,6 +41,7 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
formTitleText: 'Repository Form',
|
formTitleText: 'Repository Form',
|
||||||
|
|
||||||
searchValue: null,
|
searchValue: null,
|
||||||
|
typeFilter: null,
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
|
|
||||||
@@ -95,9 +96,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
|
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
storeLoad: function(store){
|
storeLoad: function(){
|
||||||
if (this.searchValue){
|
if (this.searchValue){
|
||||||
this.searchStore(store);
|
this.filterStore();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -114,21 +115,30 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
|
|
||||||
search: function(value){
|
search: function(value){
|
||||||
this.searchValue = value;
|
this.searchValue = value;
|
||||||
var store = this.getStore();
|
this.filterStore();
|
||||||
if ( ! value ){
|
|
||||||
store.clearFilter();
|
|
||||||
} else {
|
|
||||||
this.searchStore(store);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
searchStore: function(store){
|
filter: function(type){
|
||||||
var value = this.searchValue.toLowerCase();
|
this.typeFilter = type;
|
||||||
store.filterBy(function(rec){
|
this.filterStore();
|
||||||
return ! value ||
|
},
|
||||||
rec.get('name').toLowerCase().indexOf(value) >= 0 ||
|
|
||||||
rec.get('description').toLowerCase().indexOf(value) >= 0;
|
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){
|
selectItem: function(item){
|
||||||
|
|||||||
@@ -67,9 +67,30 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
scope: this,
|
scope: this,
|
||||||
handler: this.reload
|
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',
|
xtype: 'label',
|
||||||
text: 'Search: '
|
text: 'Search: '
|
||||||
}, ' ',{
|
}, ' ',{
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
enableKeyEvents: true,
|
enableKeyEvents: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
@@ -108,6 +129,14 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
Sonia.repository.Panel.superclass.initComponent.apply(this, arguments);
|
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){
|
search: function(field){
|
||||||
Ext.getCmp('repositoryGrid').search(field.getValue());
|
Ext.getCmp('repositoryGrid').search(field.getValue());
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user