=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html 2013-09-30 13:40:30 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/plugin.html 2013-09-30 15:43:49 +0000 @@ -8,16 +8,16 @@ -

My map 1

+

MAP BY UID

-

My map 2

+

MAP BY CONFIG

@@ -43,13 +43,22 @@ GIS.getMap({ url: url, el: "map1", - id: "bhmHJ4ZCdCd" + id: "ytkZY3ChM6J" }); GIS.getMap({ url: url, el: "map2", - id: "eDlFx0jTtV9" + mapViews: [{ + columns: [{dimension: 'in', items: [{id: 'Uvn6LCg7dVU'}]}], // data + rows: [{dimension: 'ou', items: [{id: 'LEVEL-3'}, {id: 'ImspTQPwCqd'}]}], // organisation units + filters: [{dimension: 'pe', items: [{id: 'LAST_3_MONTHS'}]}], // period + classes: 7, + colorLow: '02079c', + colorHigh: 'e5ecff', + opacity: 0.9 + //legendSet: {id: 'fqs276KXCXi'} + }] }); }); === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2013-09-30 13:40:30 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2013-09-30 15:43:49 +0000 @@ -752,8 +752,7 @@ }; setMap = function() { - var view, - views = gis.map.mapViews, + var views = gis.map.mapViews, loader; if (!(Ext.isArray(views) && views.length)) { @@ -761,6 +760,16 @@ alert(GIS.i18n.favorite_outdated_create_new); return; } + + for (var i = 0; i < views.length; i++) { + views[i] = gis.api.layout.Layout(views[i]); + } + + views = Ext.Array.clean(views); + + if (!views.length) { + return; + } if (gis.viewport && gis.viewport.favoriteWindow && gis.viewport.favoriteWindow.isVisible()) { gis.viewport.favoriteWindow.destroy(); @@ -768,13 +777,13 @@ gis.olmap.closeAllLayers(); - for (var i = 0; i < views.length; i++) { - view = views[i]; + for (var i = 0, layout; i < views.length; i++) { + layout = views[i]; - loader = gis.layer[view.layer].core.getLoader(); + loader = gis.layer[layout.layer].core.getLoader(); loader.updateGui = !gis.el; loader.callBack = callBack; - loader.load(view); + loader.load(layout); } }; @@ -2100,10 +2109,24 @@ } } - if (!(dxDim && peDim && ouDim)) { + if (!dxDim) { return; } + if (!peDim) { + peDim = { + dimension: 'pe', + items: [{id: 'LAST_MONTH'}] + }; + } + + if (!ouDim) { + ouDim = { + dimension: 'ou', + items: [{id: 'LEVEL-2'}] + }; + } + config.columns = [dxDim]; config.rows = [ouDim]; config.filters = [peDim]; @@ -2127,7 +2150,7 @@ // Config must be an object if (!(config && Ext.isObject(config))) { - alert(init.el + ': Data, period and organisation unit dimensions required'); + alert(gis.el + ': Data required'); return; } === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2013-09-30 14:23:38 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2013-09-30 14:47:45 +0000 @@ -1,29 +1,4 @@ Ext.onReady( function() { - /* - CONFIG TYPE DEFAULT DESCRIPTION - - url string (Required) The base url of the DHIS instance. - el string (Required) The element id to render the map. - id string (Optional) A map uid. If provided, only 'el' and 'url' are required. - longitude number (Optional) Initial map center longitude. - latitude number (Optional) Initial map center latitude. - zoom number (Optional) Initial zoom level. - mapViews [object] (Required*) Array of mapViews. *Required if no map id is provided. - - layer string 'thematic1' (Optional) 'boundary', 'thematic1', 'thematic2' or 'facility'. - indicator string (Required*) Indicator uid. *Required if no data element is provided. - dataelement string (Required*) Data element uid. *Required if no indicator is provided. - period string (Required) Fixed period ISO. - level number 2 (Optional) Organisation unit level. - parent string (Required) Parent organisation unit uid. - legendSet string (Optional) Legend set uid. - classes number 5 (Optional) Automatic legend set, number of classes. - method number 2 (Optional) Automatic legend set, method. 2 = by class range. 3 = by class count. - colorLow string 'ff0000' (red) (Optional) Automatic legend set, low color. - colorHigh string '00ff00' (green) (Optional) Automatic legend set, high color. - radiusLow number 5 (Optional) Automatic legend set, low radius for points. - radiusHigh number 15 (Optional) Automatic legend set, high radius for points. - */ // css var css = 'body { font-family: arial, sans-serif, liberation sans, consolas !important; font-size: 11px; } \n'; @@ -84,56 +59,22 @@ initialize; validateConfig = function() { - if (!config.url || !Ext.isString(config.url)) { + if (!Ext.isString(config.url)) { alert('Invalid url (' + config.el + ')'); - return false; + return; } - if (!config.el || !Ext.isString(config.el)) { + if (!Ext.isString(config.el)) { alert('Invalid html element id (' + config.el + ')'); - return false; - } - - if (config.id) { - if (Ext.isString(config.id)) { - return true; - } - else { - alert('Invalid map id (' + config.el + ')'); - return false; - } - } - else { - if (!config.indicator && !config.dataelement) { - alert('No indicator or data element (' + config.el + ')'); - return false; - } - else { - if (config.indicator && !Ext.isString(config.indicator)) { - alert('Invalid indicator id (' + config.el + ')'); - return false; - } - if (config.dataelement && !Ext.isString(config.dataelement)) { - alert('Invalid dataelement id (' + config.el + ')'); - return false; - } - } - - if (!config.period) { - alert('No period (' + config.el + ')'); - return false; - } - - if (!config.level || !Ext.isNumber(config.level)) { - alert('Invalid organisation unit level (' + config.el + ')'); - return false; - } - - if (!config.parent || !Ext.isNumber(config.parent)) { - alert('Invalid parent organisation unit (' + config.el + ')'); - return false; - } - } + return; + } + + if (config.id && !Ext.isString(config.id)) { + alert('Invalid map id (' + config.el + ')'); + return; + } + + return true; }; afterRender = function(vp) { @@ -320,13 +261,7 @@ GIS.core.createSelectHandlers(gis, gis.layer.thematic4); GIS.core.createSelectHandlers(gis, gis.layer.facility); - gis.map = { - id: config.id, - longitude: config.longitude, - latitude: config.latitude, - zoom: config.zoom, - mapViews: getViews() - }; + gis.map = config; gis.viewport = createViewport();