fix bug in Sonia.repository.get method

This commit is contained in:
Sebastian Sdorra
2011-09-25 17:20:40 +02:00
parent 5569882b8a
commit d2c84debc4

View File

@@ -102,28 +102,34 @@ Sonia.repository.get = function(id, callback){
}
}
var repository = null;
var grid = Ext.getCmp('repositoryGrid');
if ( grid ){
var store = grid.getStore();
if (store){
var rec = store.getById(id);
if (rec){
execCallback(rec.data);
repository = rec.data;
}
}
}
Ext.Ajax.request({
url: restUrl + 'repositories/' + id + '.json',
method: 'GET',
scope: this,
success: function(response){
execCallback(Ext.decode(response.responseText));
},
failure: function(result){
main.handleFailure(
result.status
);
}
});
if (repository){
execCallback(repository);
} else {
Ext.Ajax.request({
url: restUrl + 'repositories/' + id + '.json',
method: 'GET',
scope: this,
success: function(response){
execCallback(Ext.decode(response.responseText));
},
failure: function(result){
main.handleFailure(
result.status
);
}
});
}
}