From 11770a97093a6bce18d39fef33c9844344cd0928 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 24 May 2011 16:15:44 +0200 Subject: [PATCH] loading lazy sources and updating combo title --- app/static/externals/gxp | 2 +- app/static/script/app/GeoExplorer.js | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/static/externals/gxp b/app/static/externals/gxp index 838735c..d990358 160000 --- a/app/static/externals/gxp +++ b/app/static/externals/gxp @@ -1 +1 @@ -Subproject commit 838735cfb1090450998031f0af585a484875271d +Subproject commit d99035813aff380e7bd3b437d788086fa4ca7fac diff --git a/app/static/script/app/GeoExplorer.js b/app/static/script/app/GeoExplorer.js index 04f4f06..529e221 100644 --- a/app/static/script/app/GeoExplorer.js +++ b/app/static/script/app/GeoExplorer.js @@ -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); @@ -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); @@ -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);