Skip to content

Commit

Permalink
Print plugin issue with layouts with a name longer than 2 chars geoso…
Browse files Browse the repository at this point in the history
  • Loading branch information
mricca committed Oct 7, 2015
1 parent 25d216b commit 36ece1d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ GeoExt.plugins.PrintProviderField = Ext.extend(Ext.util.Observable, {
var printProvider = this.printProvider || field.ownerCt.printProvider;
if(field.store === printProvider.layouts) {


var cleanLayoutName = printProvider.layout.get('name').substr(0,2);
var cleanLayoutName = printProvider.checkLayoutName(printProvider.layout.get('name'),false);

if(cleanLayoutName){
var nr = printProvider.layouts.find("name", cleanLayoutName);
Expand Down Expand Up @@ -157,7 +156,9 @@ GeoExt.plugins.PrintProviderField = Ext.extend(Ext.util.Observable, {
if(record) {
switch(field.store) {
case printProvider.layouts:
var newLayoutName = record.get('name') + printProvider.layout.get('name').substr(2);
var name = record.get('name');
var layoutType = printProvider.checkLayoutName(printProvider.layout.get('name'),true);
var newLayoutName = name + layoutType;

var nr = printProvider.fullLayouts.find("name", newLayoutName);
var newLayout = printProvider.fullLayouts.getAt(nr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,31 @@ GeoExt.data.PrintProvider = Ext.extend(Ext.util.Observable, {
}];
}
}
}
},

/** private: method[checkLayoutName]
* :param currentLayout: ``string`` Current Layout in print plugin.
* :param onChange: ``Boolean`` True if call by onFieldChange PrintProviderField function.
*
* Check correct layout name.
*/
checkLayoutName: function(currentLayout,onChange) {
var layouts = [
'_2_pages_compact_legend',
'_2_pages_compact_legend_landscape',
'_compact_legend',
'_compact_legend_landscape',
'_2_pages_legend',
'_no_legend'
];

for (var i = 0;i<layouts.length;i++){
if(currentLayout.indexOf(layouts[i]) > 0){
var index = currentLayout.indexOf(layouts[i]);
return onChange ? layouts[i] : currentLayout.substr(0,index);
}
}

return '';
}
});

0 comments on commit 36ece1d

Please sign in to comment.