dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23949
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11679: (PT) New orgunit selection method: boundaries/groups + User orgunit grand children.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 11679 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-08-16 14:01:01 +0200
message:
(PT) New orgunit selection method: boundaries/groups + User orgunit grand children.
modified:
dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/i18n.vm
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm
--
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
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties 2013-08-13 14:49:26 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties 2013-08-15 11:35:41 +0000
@@ -18,8 +18,9 @@
organisation_unit=Organisation unit
organisation_units=Organisation units
parent_organisation_unit=Parent organisation unit
-user_organisation_unit=User organisation unit
-user_organisation_unit_children=User organisation unit children
+user_organisation_unit=User org unit
+user_organisation_unit_children=Org unit children
+user_organisation_unit_grandchildren=Org unit grand children
table_options=Table options
create=Create
update=Update
@@ -123,8 +124,8 @@
write_your_interpretation=Write a comment, question or interpretation
legend_set=Legend set
select_organisation_units=Select organisation units
-select_boundaries_and_level=Select boundaries and level
-select_organisation_unit_level=Select organisation unit level
+select_boundaries_and_levels=Select boundaries and levels
+select_organisation_unit_levels=Select organisation unit levels
totals=Totals
details=Details
select_boundaries_and_groups=Select boundaries and groups
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-08-13 14:49:26 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-08-16 11:55:26 +0000
@@ -2186,6 +2186,7 @@
treePanel,
userOrganisationUnit,
userOrganisationUnitChildren,
+ userOrganisationUnitGrandChildren,
userOrganisationUnitPanel,
organisationUnitLevel,
tool,
@@ -3414,13 +3415,15 @@
}
}
}),
- xable: function(checked, value) {
- if (checked || value) {
- this.disable();
- }
- else {
- this.enable();
- }
+ xable: function(values) {
+ for (var i = 0; i < values.length; i++) {
+ if (!!values[i]) {
+ this.disable();
+ return;
+ }
+ }
+
+ this.enable();
},
listeners: {
added: function() {
@@ -3466,42 +3469,43 @@
});
userOrganisationUnit = Ext.create('Ext.form.field.Checkbox', {
- columnWidth: 0.5,
+ columnWidth: 0.28,
style: 'padding-top:2px; padding-left:3px; margin-bottom:0',
boxLabel: PT.i18n.user_organisation_unit,
labelWidth: pt.conf.layout.form_label_width,
handler: function(chb, checked) {
- treePanel.xable(checked, userOrganisationUnitChildren.getValue());
+ treePanel.xable([checked, userOrganisationUnitChildren.getValue(), userOrganisationUnitGrandChildren.getValue()]);
}
});
userOrganisationUnitChildren = Ext.create('Ext.form.field.Checkbox', {
- columnWidth: 0.5,
+ columnWidth: 0.31,
style: 'padding-top:2px; margin-bottom:0',
boxLabel: PT.i18n.user_organisation_unit_children,
labelWidth: pt.conf.layout.form_label_width,
handler: function(chb, checked) {
- treePanel.xable(checked, userOrganisationUnit.getValue());
+ treePanel.xable([checked, userOrganisationUnit.getValue(), userOrganisationUnitGrandChildren.getValue()]);
}
});
-
- userOrganisationUnitPanel = Ext.create('Ext.panel.Panel', {
- columnWidth: 0.9,
- layout: 'column',
- bodyStyle: 'border:0 none; padding-bottom:3px; padding-left:7px',
- items: [
- userOrganisationUnit,
- userOrganisationUnitChildren
- ]
+
+ userOrganisationUnitGrandChildren = Ext.create('Ext.form.field.Checkbox', {
+ columnWidth: 0.41,
+ style: 'padding-top:2px; margin-bottom:0',
+ boxLabel: PT.i18n.user_organisation_unit_grandchildren,
+ labelWidth: pt.conf.layout.form_label_width,
+ handler: function(chb, checked) {
+ treePanel.xable([checked, userOrganisationUnit.getValue(), userOrganisationUnitChildren.getValue()]);
+ }
});
organisationUnitLevel = Ext.create('Ext.form.field.ComboBox', {
cls: 'pt-combo',
+ multiSelect: true,
style: 'margin-bottom:0',
width: pt.conf.layout.west_fieldset_width - pt.conf.layout.west_width_padding - 38,
valueField: 'level',
displayField: 'name',
- emptyText: PT.i18n.select_organisation_unit_level,
+ emptyText: PT.i18n.select_organisation_unit_levels,
editable: false,
hidden: true,
store: {
@@ -3545,6 +3549,7 @@
if (param === 'orgunit') {
userOrganisationUnit.show();
userOrganisationUnitChildren.show();
+ userOrganisationUnitGrandChildren.show();
organisationUnitLevel.hide();
organisationUnitGroup.hide();
@@ -3555,6 +3560,7 @@
else if (param === 'level') {
userOrganisationUnit.hide();
userOrganisationUnitChildren.hide();
+ userOrganisationUnitGrandChildren.hide();
organisationUnitLevel.show();
organisationUnitGroup.hide();
treePanel.enable();
@@ -3562,6 +3568,7 @@
else if (param === 'group') {
userOrganisationUnit.hide();
userOrganisationUnitChildren.hide();
+ userOrganisationUnitGrandChildren.hide();
organisationUnitLevel.hide();
organisationUnitGroup.show();
treePanel.enable();
@@ -3574,7 +3581,7 @@
iconCls: 'pt-menu-item-selected'
},
{
- text: PT.i18n.select_boundaries_and_level + ' ',
+ text: PT.i18n.select_boundaries_and_levels + ' ',
param: 'level'
},
{
@@ -3621,7 +3628,7 @@
};
if (toolMenu.menuValue === 'orgunit') {
- if (userOrganisationUnit.getValue() || userOrganisationUnitChildren.getValue()) {
+ if (userOrganisationUnit.getValue() || userOrganisationUnitChildren.getValue() || userOrganisationUnitGrandChildren.getValue()) {
if (userOrganisationUnit.getValue()) {
config.items.push({
id: 'USER_ORGUNIT',
@@ -3634,6 +3641,12 @@
name: ''
});
}
+ if (userOrganisationUnitGrandChildren.getValue()) {
+ config.items.push({
+ id: 'USER_ORGUNIT_GRANDCHILDREN',
+ name: ''
+ });
+ }
}
else {
for (var i = 0; i < r.length; i++) {
@@ -3642,9 +3655,18 @@
}
}
else if (toolMenu.menuValue === 'level') {
+ var levels = organisationUnitLevel.getValue();
+
+ for (var i = 0; i < levels.length; i++) {
+ config.items.push({
+ id: 'LEVEL-' + levels[i],
+ name: ''
+ });
+ }
+
for (var i = 0; i < r.length; i++) {
config.items.push({
- id: 'LEVEL-' + organisationUnitLevel.getValue() + '-' + r[i].data.id,
+ id: r[i].data.id,
name: ''
});
}
@@ -3652,14 +3674,19 @@
else if (toolMenu.menuValue === 'group') {
var groupIds = organisationUnitGroup.getValue();
- //for (var i = 0; i < r.length; i++) {
- for (var j = 0; j < groupIds.length; j++) {
- config.items.push({
- id: 'OU_GROUP-' + groupIds[j],// + '-' + r[i].data.id,
- name: ''
- });
- }
- //}
+ for (var i = 0; i < groupIds.length; i++) {
+ config.items.push({
+ id: 'OU_GROUP-' + groupIds[i],
+ name: ''
+ });
+ }
+
+ for (var i = 0; i < r.length; i++) {
+ config.items.push({
+ id: r[i].data.id,
+ name: ''
+ });
+ }
}
return config.items.length ? config : null;
@@ -3684,6 +3711,7 @@
items: [
userOrganisationUnit,
userOrganisationUnitChildren,
+ userOrganisationUnitGrandChildren,
organisationUnitLevel,
organisationUnitGroup
]
@@ -4331,7 +4359,9 @@
dimNames = [],
isOu = false,
isOuc = false,
- level;
+ isOugc = false,
+ levels = [],
+ groups = [];
// State
pt.viewport.interpretationButton.enable();
@@ -4491,20 +4521,31 @@
if (ouRecords[i].id === 'USER_ORGUNIT_CHILDREN') {
isOuc = true;
}
+ if (ouRecords[i].id === 'USER_ORGUNIT_GRANDCHILDREN') {
+ isOugc = true;
+ }
if (ouRecords[i].id.substr(0,5) === 'LEVEL') {
- level = parseInt(ouRecords[i].id.split('-')[1]);
+ levels.push(parseInt(ouRecords[i].id.split('-')[1]));
+ }
+ if (ouRecords[i].id.substr(0,8) === 'OU_GROUP') {
+ groups.push(parseInt(ouRecords[i].id.split('-')[1]));
}
}
}
- if (level) {
+ if (levels.length) {
toolMenu.clickHandler('level');
- organisationUnitLevel.setValue(level);
+ organisationUnitLevel.setValue(levels);
+ }
+ else if (groups.length) {
+ toolMenu.clickHandler('group');
+ organisationUnitGroup.setValue(groups);
}
else {
toolMenu.clickHandler('orgunit');
userOrganisationUnit.setValue(isOu);
userOrganisationUnitChildren.setValue(isOuc);
+ userOrganisationUnitGrandChildren.setValue(isOugc);
}
// If fav has organisation units, wait for tree callback before update
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-08-14 12:20:44 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-08-16 11:45:57 +0000
@@ -716,7 +716,8 @@
dimConf = conf.finals.dimension,
dims,
isOu = false,
- isOuc = false;
+ isOuc = false,
+ isOugc = false;
config.columns = getValidatedDimensionArray(config.columns);
config.rows = getValidatedDimensionArray(config.rows);
@@ -754,6 +755,9 @@
else if (dim.items[j].id === 'USER_ORGUNIT_CHILDREN') {
isOuc = true;
}
+ else if (dim.items[j].id === 'USER_ORGUNIT_GRANDCHILDREN') {
+ isOugc = true;
+ }
}
}
}
@@ -1212,6 +1216,7 @@
xOuDimension = xLayout.objectNameDimensionsMap[dimConf.organisationUnit.objectName],
isUserOrgunit = xOuDimension && Ext.Array.contains(xOuDimension.ids, 'USER_ORGUNIT'),
isUserOrgunitChildren = xOuDimension && Ext.Array.contains(xOuDimension.ids, 'USER_ORGUNIT_CHILDREN'),
+ isUserOrgunitGrandChildren = xOuDimension && Ext.Array.contains(xOuDimension.ids, 'USER_ORGUNIT_GRANDCHILDREN'),
isLevel = function() {
if (xOuDimension && Ext.isArray(xOuDimension.ids)) {
for (var i = 0; i < xOuDimension.ids.length; i++) {
@@ -1246,25 +1251,58 @@
// If ou and children
if (dim.dimensionName === ou) {
- if (isUserOrgunit || isUserOrgunitChildren) {
+ if (isUserOrgunit || isUserOrgunitChildren || isUserOrgunitGrandChildren) {
+ var userOu,
+ userOuc,
+ userOugc;
+
if (isUserOrgunit) {
- dim.items = dim.items.concat(pt.init.user.ou);
+ userOu = [{
+ id: pt.init.user.ou,
+ name: response.metaData.names[pt.init.user.ou]
+ }];
}
if (isUserOrgunitChildren) {
- dim.items = dim.items.concat(pt.init.user.ouc);
- }
+ userOuc = [];
+
+ for (var i = 0; i < pt.init.user.ouc.length; i++) {
+ userOuc.push({
+ id: pt.init.user.ouc[i],
+ name: response.metaData.names[pt.init.user.ouc[i]]
+ });
+ }
+
+ userOuc = pt.util.array.sortObjectsByString(userOuc);
+ }
+ if (isUserOrgunitGrandChildren) {
+ var userOuOuc = [].concat(pt.init.user.ou, pt.init.user.ouc),
+ responseOu = response.metaData.ou;
+
+ for (var i = 0; i < responseOu.length; i++) {
+ if (!Ext.Array.contains(userOuOuc, responseOu[i])) {
+ userOugc.push({
+ id: responseOu[i],
+ name: response.metaData.names[responseOu[i]]
+ });
+ }
+ }
+
+ userOugc = pt.util.array.sortObjectsByString(userOugc);
+ }
+
+ dim.items = [].concat(userOu || [], userOuc || [], userOugc || []);
}
else if (isLevel || isGroup) {
-
- // Items: get ids from metadata -> items
- for (var j = 0, ids = Ext.clone(response.metaData[dim.dimensionName]); j < ids.length; j++) {
+ var responseOu = response.metaData.ou;
+
+ for (var i = 0; i < responseOu.length; i++) {
dim.items.push({
- id: ids[j],
- name: response.metaData.names[ids[j]]
+ id: responseOu[i],
+ name: response.metaData.names[responseOu[i]]
});
-
- dim.items = pt.util.array.sortObjectsByString(dim.items);
}
+
+ dim.items = pt.util.array.sortObjectsByString(dim.items);
}
else {
dim.items = Ext.clone(xLayout.dimensionNameItemsMap[dim.dimensionName]);
@@ -2360,7 +2398,7 @@
},
disableCaching: false,
failure: function(r) {
- pt.util.mask.hideMask();
+ pt.util.mask.hideMask(pt.viewport.centerRegion);
alert(r.responseText);
},
success: function(r) {
@@ -2368,7 +2406,7 @@
response = pt.api.response.Response(Ext.decode(r.responseText));
if (!response) {
- pt.util.mask.hideMask();
+ pt.util.mask.hideMask(pt.viewport.centerRegion);
return;
}
@@ -2376,7 +2414,7 @@
xLayout = getSyncronizedXLayout(xLayout, response);
if (!xLayout) {
- pt.util.mask.hideMask();
+ pt.util.mask.hideMask(pt.viewport.centerRegion);
return;
}
@@ -2469,7 +2507,7 @@
};
failure = function(responseText) {
- util.mask.hideMask();
+ util.mask.hideMask(pt.viewport.centerRegion);
alert(responseText);
};
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/i18n.vm'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/i18n.vm 2013-08-13 14:49:26 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/i18n.vm 2013-08-15 11:35:41 +0000
@@ -124,10 +124,11 @@
write_your_interpretation: '$encoder.jsEscape($i18n.getString( 'write_your_interpretation' ) , "'")',
legend_set: '$encoder.jsEscape($i18n.getString( 'legend_set' ) , "'")',
select_organisation_units: '$encoder.jsEscape($i18n.getString( 'select_organisation_units' ) , "'")',
- select_boundaries_and_level: '$encoder.jsEscape($i18n.getString( 'select_boundaries_and_level' ) , "'")',
- select_organisation_unit_level: '$encoder.jsEscape($i18n.getString( 'select_organisation_unit_level' ) , "'")',
+ select_boundaries_and_levels: '$encoder.jsEscape($i18n.getString( 'select_boundaries_and_levels' ) , "'")',
+ select_organisation_unit_levels: '$encoder.jsEscape($i18n.getString( 'select_organisation_unit_levels' ) , "'")',
totals: '$encoder.jsEscape($i18n.getString( 'totals' ) , "'")',
details: '$encoder.jsEscape($i18n.getString( 'details' ) , "'")',
select_boundaries_and_groups: '$encoder.jsEscape($i18n.getString( 'select_boundaries_and_groups' ) , "'")',
- select_organisation_unit_groups: '$encoder.jsEscape($i18n.getString( 'select_organisation_unit_groups' ) , "'")'
+ select_organisation_unit_groups: '$encoder.jsEscape($i18n.getString( 'select_organisation_unit_groups' ) , "'")',
+ user_organisation_unit_grandchildren: '$encoder.jsEscape($i18n.getString( 'user_organisation_unit_grandchildren' ) , "'")'
};
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm 2013-08-03 11:22:56 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm 2013-08-16 11:45:57 +0000
@@ -5,8 +5,8 @@
{
"contextPath":"$!{contextPath}",
"user":{"id":"$!currentUser.uid","name":"$currentUser.name","isAdmin":true,
-"ou":{"id":"$currentUser.getOrganisationUnit().uid","name":"$currentUser.getOrganisationUnit().name"},
-"ouc":[#foreach($ou in $currentUser.getOrganisationUnit().getSortedChildren()){"id":"$ou.uid","name":"$ou.name"}#if($velocityCount < $oucSize),#end#end]},
+"ou":"$currentUser.getOrganisationUnit().uid",
+"ouc":[#foreach($ou in $currentUser.getOrganisationUnit().getSortedChildren())"$ou.uid"#if($velocityCount < $oucSize),#end#end]},
"rootNodes":[#foreach($node in $rootNodes){"id": "$!{node.uid}","text": "$!encoder.jsonEncode( ${node.name} )","level": 1,"hasChildrenWithCoordinates": $!{node.hasChildrenWithCoordinates()},"expanded": true}#if($velocityCount<$rootNodes.size()),#end#end],
"dimensions":[#foreach($dim in $dimensions){"id":"$!{dim.uid}","name":"$!encoder.jsonEncode($!{dim.name})"}#if($velocityCount<$dimensions.size()),#end#end],
"legendSets":[#foreach($set in $legendSets){"id":"$!{set.uid}","name":"$!encoder.jsonEncode($!{set.name})", "legends":[#foreach($legend in $set.mapLegends){"id":"$!{legend.uid}","name":"$!{legend.name}","sv":"$!{legend.startValue}", "ev":"$!{legend.endValue}", "color":"$!{legend.color}"}#if($velocityCount<$set.mapLegends.size()),#end#end]}#if($velocityCount<$legendSets.size()),#end#end],