Skip to content

Commit

Permalink
loading lazy sources and updating combo title
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed May 24, 2011
1 parent 47637fe commit 11770a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/static/externals/gxp
Submodule gxp updated from 838735 to d99035
25 changes: 23 additions & 2 deletions app/static/script/app/GeoExplorer.js
Expand Up @@ -1059,6 +1059,16 @@ var GeoExplorer = Ext.extend(gxp.Viewer, {
};

source = this.layerSources[initialSourceId];
if (source.store.getCount() == 0) {
// assuming a lazy source
source.store.on("load", function() {
var index = sources.find("id", initialSourceId);
var rec = sources.getAt(index);
rec.set("title", source.title);
sourceComboBox.onSelect(rec, index);
});
source.store.load();
}
source.store.filterBy(function(r) {
return !!source.getProjection(r);
}, this);
Expand Down Expand Up @@ -1092,8 +1102,19 @@ var GeoExplorer = Ext.extend(gxp.Viewer, {
value: initialSourceId,
listeners: {
select: function(combo, record, index) {
var source = this.layerSources[record.get("id")];
var id = record.get("id");
var source = this.layerSources[id];
var store = source.store;
if (store.getCount() == 0) {
// assuming a lazy source
source.store.on("load", function() {
var index = sources.find("id", id);
var rec = sources.getAt(index);
rec.set("title", source.title);
sourceComboBox.onSelect(rec, index);
});
store.load();
}
store.filterBy(function(r) {
return !!source.getProjection(r);
}, this);
Expand Down Expand Up @@ -1139,7 +1160,7 @@ var GeoExplorer = Ext.extend(gxp.Viewer, {
// add to combo and select
var record = new sources.recordType({
id: id,
title: this.layerSources[id].title || "Untitled" // TODO: titles
title: this.layerSources[id].title || id // TODO: titles
});
sources.insert(0, [record]);
sourceComboBox.onSelect(record, 0);
Expand Down

0 comments on commit 11770a9

Please sign in to comment.