dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04289
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1407: (GIS) You may now remove selected orgunit relations. Earlier you had to remove either all or one ...
------------------------------------------------------------
revno: 1407
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-02-09 16:55:32 +0100
message:
(GIS) You may now remove selected orgunit relations. Earlier you had to remove either all or one by one.
removed:
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java
added:
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationsAction.java
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java 2009-09-05 16:19:02 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java 1970-01-01 00:00:00 +0000
@@ -1,100 +0,0 @@
-package org.hisp.dhis.mapping.action;
-
-/*
- * Copyright (c) 2004-2007, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.mapping.Map;
-import org.hisp.dhis.mapping.MapOrganisationUnitRelation;
-import org.hisp.dhis.mapping.MappingService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class DeleteMapOrganisationUnitRelationAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private MappingService mappingService;
-
- public void setMappingService( MappingService mappingService )
- {
- this.mappingService = mappingService;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private Integer organisationUnitId;
-
- public void setOrganisationUnitId( Integer organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
-
- private String mapLayerPath;
-
- public void setMapLayerPath( String mapLayerPath )
- {
- this.mapLayerPath = mapLayerPath;
- }
-
- // -------------------------------------------------------------------------
- // Action implemention
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
-
- MapOrganisationUnitRelation relation = mappingService.getMapOrganisationUnitRelation( map, unit );
-
- if ( relation != null )
- {
- mappingService.deleteMapOrganisationUnitRelation( relation );
- }
-
- return SUCCESS;
- }
-}
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationsAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationsAction.java 2010-02-09 15:55:32 +0000
@@ -0,0 +1,109 @@
+package org.hisp.dhis.mapping.action;
+
+/*
+ * Copyright (c) 2004-2007, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+
+import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.mapping.MapOrganisationUnitRelation;
+import org.hisp.dhis.mapping.MappingService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class DeleteMapOrganisationUnitRelationsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private MappingService mappingService;
+
+ public void setMappingService( MappingService mappingService )
+ {
+ this.mappingService = mappingService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Collection<Integer> organisationUnitIds;
+
+ public void setOrganisationUnitIds( Collection<Integer> organisationUnitIds )
+ {
+ this.organisationUnitIds = organisationUnitIds;
+ }
+
+ private String mapLayerPath;
+
+ public void setMapLayerPath( String mapLayerPath )
+ {
+ this.mapLayerPath = mapLayerPath;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ OrganisationUnit organisationUnit;
+
+ MapOrganisationUnitRelation relation;
+
+ for ( Integer organisationUnitId : organisationUnitIds )
+ {
+ organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ relation = mappingService.getMapOrganisationUnitRelation( map, organisationUnit );
+
+ if ( relation != null )
+ {
+ mappingService.deleteMapOrganisationUnitRelation( relation );
+ }
+ }
+
+ return SUCCESS;
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-09-22 00:35:09 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2010-02-09 15:55:32 +0000
@@ -149,8 +149,8 @@
ref="org.hisp.dhis.mapping.MappingService"/>
</bean>
- <bean id="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationAction"
- class="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationAction"
+ <bean id="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationsAction"
+ class="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationsAction"
scope="prototype">
<property name="mappingService"
ref="org.hisp.dhis.mapping.MappingService"/>
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml 2009-09-22 00:35:09 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml 2010-02-09 15:55:32 +0000
@@ -103,7 +103,7 @@
<result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
</action>
- <action name="deleteMapOrganisationUnitRelation" class="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationAction">
+ <action name="deleteMapOrganisationUnitRelations" class="org.hisp.dhis.mapping.action.DeleteMapOrganisationUnitRelationsAction">
<result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-02-03 10:18:27 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-02-09 15:55:32 +0000
@@ -2223,7 +2223,7 @@
}
}
});
-
+
/* ADMIN PANEL */
var adminPanel = new Ext.form.FormPanel({
id: 'admin_p',
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-02-05 15:12:26 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-02-09 15:55:32 +0000
@@ -251,7 +251,7 @@
autoExpandColumn: 'organisationUnitId',
enableHdMenu: true,
width: gridpanel_width,
- height: this.getGridPanelHeight(),
+ height: this.getGridPanelHeight(),
view: gridView,
style: 'left:0px',
bbar: new Ext.StatusBar({
@@ -278,50 +278,6 @@
},
{
xtype: 'button',
- id: 'removerelation_b',
- text: 'Remove',
- cls: 'aa_med',
- isVisible: false,
- handler: function()
- {
- if (!Ext.getCmp('maps_cb').getValue()) {
- Ext.messageRed.msg('Remove relation', 'Please select a map.');
- return;
- }
-
- if (!Ext.getCmp('grid_gp').getSelectionModel().getSelected()) {
- Ext.messageRed.msg('Remove relation', 'Please select an organisation unit from the list.');
- return;
- }
-
- var selected = Ext.getCmp('grid_gp').getSelectionModel().getSelected();
- var oui = selected.data['organisationUnitId'];
- var ou = selected.data['organisationUnit'];
- var mlp = Ext.getCmp('maps_cb').getValue();
-
- Ext.Ajax.request({
- url: path + 'deleteMapOrganisationUnitRelation' + type,
- method: 'GET',
- params: { mapLayerPath: mlp, organisationUnitId: oui },
-
- success: function( responseObject ) {
- var mlp = Ext.getCmp('maps_cb').getValue();
- Ext.getCmp('grid_gp').getStore().baseParams = { mapLayerPath: mlp, format: 'json' };
- Ext.getCmp('grid_gp').getStore().reload();
-
- Ext.messageBlack.msg('Remove relation', msg_highlight_start + ou + msg_highlight_end + ' relation removed.');
-
- mapping.classify(true);
- },
- failure: function() {
- alert('Error while deleting MapOrganisationUnitRelation');
- }
- });
- },
- scope: this
- },
- {
- xtype: 'button',
id: 'removeallrelations_b',
text: 'Remove all',
cls: 'aa_med',
@@ -354,6 +310,60 @@
});
},
scope: this
+ },
+ {
+ xtype: 'button',
+ id: 'removerelation_b',
+ text: 'Remove selected',
+ cls: 'aa_med',
+ isVisible: false,
+ handler: function()
+ {
+ if (!Ext.getCmp('maps_cb').getValue()) {
+ Ext.messageRed.msg('Remove relation', 'Please select a map.');
+ return;
+ }
+
+ var selection = Ext.getCmp('grid_gp').getSelectionModel().getSelections();
+ var mlp = Ext.getCmp('maps_cb').getValue();
+ var msg;
+
+ if (!selection) {
+ Ext.messageRed.msg('Remove relation', 'Please select at least one organisation unit in the list.');
+ return;
+ }
+
+ var params = '?organisationUnitIds=' + selection[0].data['organisationUnitId'];
+
+ if (selection.length > 1) {
+ for (var i = 1; i < selection.length; i++) {
+ params += '&organisationUnitIds=' + selection[i].data['organisationUnitId'];
+ }
+ msg = 'Selected relations removed.';
+ }
+ else {
+ msg = msg_highlight_start + selection[0].data['organisationUnit'] + msg_highlight_end + ' relation removed.'
+ }
+
+ params += '&mapLayerPath=' + mlp;
+
+ Ext.Ajax.request({
+ url: path + 'deleteMapOrganisationUnitRelations' + type + params,
+ method: 'GET',
+ success: function( responseObject ) {
+ Ext.getCmp('grid_gp').getStore().baseParams = { mapLayerPath: mlp, format: 'json' };
+ Ext.getCmp('grid_gp').getStore().reload();
+
+ Ext.messageBlack.msg('Remove relations', msg);
+
+ mapping.classify(true);
+ },
+ failure: function() {
+ alert('Error while deleting MapOrganisationUnitRelation');
+ }
+ });
+ },
+ scope: this
}
]
})