[Commits] r2388 - in sandbox/camptocamp/geobretagne: lib/GeoExt/data tests/lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Wed Sep 22 10:12:45 CEST 2010
Author: elemoine
Date: 2010-09-22 10:12:45 +0200 (Wed, 22 Sep 2010)
New Revision: 2388
Modified:
sandbox/camptocamp/geobretagne/lib/GeoExt/data/PrintPage.js
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/PrintPage.html
Log:
apply patch-344-A0.diff from #344, this is the patch applied to trunk
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/PrintPage.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/PrintPage.js 2010-09-22 08:11:45 UTC (rev 2387)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/PrintPage.js 2010-09-22 08:12:45 UTC (rev 2388)
@@ -94,6 +94,18 @@
this.feature = new OpenLayers.Feature.Vector(
OpenLayers.Geometry.fromWKT("POLYGON((-1 -1,1 -1,1 1,-1 1,-1 -1))"));
+ if(this.printProvider.capabilities) {
+ this.setScale(this.printProvider.scales.getAt(0));
+ } else {
+ this.printProvider.on({
+ "loadcapabilities": function() {
+ this.setScale(this.printProvider.scales.getAt(0));
+ },
+ scope: this,
+ single: true
+ });
+ }
+
this.printProvider.on({
"layoutchange": this.onLayoutChange,
scope: this
@@ -262,7 +274,11 @@
if(this.printProvider.layout.get("rotation") === false) {
this.setRotation(0, true);
}
- this.setScale(this.scale);
+ // at init time the print provider triggers layoutchange
+ // before loadcapabilities, i.e. before we set this.scale
+ // to the first scale in the scales store, we need to
+ // guard against that
+ this.scale && this.setScale(this.scale);
},
/** private: method[destroy]
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/PrintPage.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/PrintPage.html 2010-09-22 08:11:45 UTC (rev 2387)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/PrintPage.html 2010-09-22 08:12:45 UTC (rev 2388)
@@ -29,7 +29,42 @@
printPage.destroy();
}
-
+
+ function test_init_setScale(t) {
+
+ // tests to check printPage.scale is set when the printProvider
+ // has received the print capabilities
+ // http://trac.geoext.org/ticket/344
+
+ t.plan(3);
+
+ var printProvider, printPage;
+
+ // test #1
+ printProvider = new GeoExt.data.PrintProvider({
+ capabilities: printCapabilities
+ });
+ printPage = new GeoExt.data.PrintPage({
+ printProvider: printProvider
+ });
+ t.eq(printPage.scale.get("name"), "1:4,000,000", "first scale set in page");
+ printPage.destroy();
+
+ // test #2
+ printProvider = new GeoExt.data.PrintProvider({
+ url: "foo", autoLoad: false
+ });
+ printPage = new GeoExt.data.PrintPage({
+ printProvider: printProvider
+ });
+ t.eq(printPage.scale, null,
+ "scale is null in page if provider hasn't received the caps");
+ printProvider.capabilities = printCapabilities;
+ printProvider.loadStores();
+ t.eq(printPage.scale.get("name"), "1:4,000,000", "first scale set in page");
+ printPage.destroy();
+ }
+
function test_setCenter(t) {
t.plan(1);
@@ -107,7 +142,8 @@
printPage.destroy();
mapPanel.destroy();
}
-
+
+
</script>
</head>
<body>
More information about the Commits
mailing list