dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23352
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11360: Add Layout menu to select position of Aggrgate Tabular report result.
------------------------------------------------------------
revno: 11360
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-07-08 12:59:46 +0700
message:
Add Layout menu to select position of Aggrgate Tabular report result.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.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-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-07-04 09:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-07-08 05:59:46 +0000
@@ -660,4 +660,5 @@
users_in_orgunit_registered = Users in organisation registered
message_is_sent = Message is sent.
enter_age_in_years = Enter age in years...
-send_to = Send to
\ No newline at end of file
+send_to = Send to
+table_layout = Layout
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-06-07 02:58:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-07-08 05:59:46 +0000
@@ -241,6 +241,7 @@
dataElementGroupBy:{}
},
options: {},
+ layoutWindow: {},
toolbar: {
menuitem: {}
},
@@ -2300,9 +2301,10 @@
// 1 - Rows
// 2 - Columns
// 3 - Filter
- var positionOrgunit = Ext.getCmp('positionOrgunitCbx').getValue();
- var positionPeriod = Ext.getCmp('positionPeriodCbx').getValue();
- var positionData = Ext.getCmp('positionDataCbx').getValue();
+
+ var positionOrgunit = TR.state.aggregateReport.getOrgunitPosition();
+ var positionPeriod = TR.state.aggregateReport.getPeriodPosition();
+ var positionData = TR.state.aggregateReport.getDataPosition();
// 1
if( positionOrgunit==1 && positionPeriod==2 && positionData==3 )
@@ -2356,6 +2358,68 @@
}
return '';
},
+ getOrgunitPosition: function() {
+
+ var orgunitPosition = 3;
+ // Row position
+ Ext.getCmp('positionRowCbx').store.each( function(r) {
+ if(r.data.id==1) // is orgunit
+ {
+ orgunitPosition = 1; // row
+ }
+ });
+
+ // Column position
+ Ext.getCmp('positionColCbx').store.each( function(r) {
+ if(r.data.id==1) // is orgunit
+ {
+ orgunitPosition = 2; // col
+ }
+ });
+
+ return orgunitPosition; // filter
+ },
+ getPeriodPosition: function() {
+ var periodPosition = 3;
+ // period position
+ Ext.getCmp('positionRowCbx').store.each( function(r) {
+ if(r.data.id==2) // is period
+ {
+ periodPosition = 1;
+ }
+ });
+
+ // Column position
+ Ext.getCmp('positionColCbx').store.each( function(r) {
+ if(r.data.id==2) // is period
+ {
+ periodPosition = 2;
+ }
+ });
+
+ return periodPosition; // filter
+ },
+ getDataPosition: function() {
+
+ var positionFilter = 3;
+ // period position
+ Ext.getCmp('positionRowCbx').store.each( function(r) {
+ if(r.data.id==3) // is data
+ {
+ positionFilter = 1;
+ }
+ });
+
+ // Column position
+ Ext.getCmp('positionColCbx').store.each( function(r) {
+ if(r.data.id==3) // is data
+ {
+ positionFilter = 2;
+ }
+ });
+
+ return positionFilter; // filter
+ },
getParams: function() {
var p = {};
p.programStageId = TR.cmp.params.programStage.getValue();
@@ -2674,11 +2738,10 @@
});
var position = TR.state.aggregateReport.getPosition();
+ var o = TR.state.aggregateReport.getOrgunitPosition();
+ var p = TR.state.aggregateReport.getPeriodPosition();
+ var d = TR.state.aggregateReport.getDataPosition();
if( position==''){
- var o = TR.cmp.settings.positionOrgunit.value;
- var p = TR.cmp.settings.positionPeriod.value;
- var d = TR.cmp.settings.positionData.value;
-
if( o!='1' && p!='1' && d!='1')
{
TR.util.notification.error(TR.i18n.please_select_one_position_for_row, TR.i18n.please_select_one_position_for_row);
@@ -2702,15 +2765,15 @@
}
// Check orgunit by period
- if( Ext.getCmp('positionOrgunitCbx').getValue() == 3
- && ( TR.state.orgunitIds.length > 1
+ if( o == 3 && ( TR.state.orgunitIds.length > 1
|| Ext.getCmp('userOrgunitChildren').getValue() ))
{
TR.util.notification.error(TR.i18n.multiple_orgunits_selected_as_filter, TR.i18n.multiple_orgunits_selected_as_filter);
}
// Check filter by period
- if( Ext.getCmp('positionPeriodCbx').getValue() == 3 )
+ if( p == 3 )
+ if( p == 3 )
{
var noPeriod = TR.store.dateRange.data.length + TR.cmp.params.fixedperiod.selected.store.data.length;
@@ -4023,81 +4086,6 @@
TR.app.OptionsWindow = function() {
var optionsWindow;
- var positionOrgunitField = Ext.create('Ext.form.field.ComboBox', {
- cls: 'tr-combo',
- id: 'positionOrgunitCbx',
- fieldLabel: TR.i18n.orgunit,
- labelWidth: 135,
- emptyText: TR.i18n.please_select,
- queryMode: 'local',
- editable: false,
- valueField: 'value',
- displayField: 'name',
- width: ( TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor ) - 40,
- store: new Ext.data.ArrayStore({
- fields: ['value', 'name'],
- data: [ ['1', TR.i18n.rows],
- ['2', TR.i18n.columns],
- ['3', TR.i18n.filters] ]
- }),
- value: '1',
- listeners: {
- added: function() {
- TR.cmp.settings.positionOrgunit = this;
- }
- }
- });
-
- var positionPeriodField = Ext.create('Ext.form.field.ComboBox', {
- cls: 'tr-combo',
- id: 'positionPeriodCbx',
- fieldLabel: TR.i18n.period,
- labelWidth: 135,
- emptyText: TR.i18n.please_select,
- queryMode: 'local',
- editable: false,
- valueField: 'value',
- displayField: 'name',
- width: TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor - 40,
- store: new Ext.data.ArrayStore({
- fields: ['value', 'name'],
- data: [ ['1', TR.i18n.rows],
- ['2', TR.i18n.columns],
- ['3', TR.i18n.filters] ]
- }),
- value: '2',
- listeners: {
- added: function() {
- TR.cmp.settings.positionPeriod = this;
- }
- }
- });
-
- var positionDataField = Ext.create('Ext.form.field.ComboBox', {
- cls: 'tr-combo',
- id: 'positionDataCbx',
- fieldLabel: TR.i18n.data,
- labelWidth: 135,
- emptyText: TR.i18n.please_select,
- queryMode: 'local',
- editable: false,
- valueField: 'value',
- displayField: 'name',
- width: TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor - 40,
- store: new Ext.data.ArrayStore({
- fields: ['value', 'name'],
- data: [ ['1', TR.i18n.rows],
- ['2', TR.i18n.columns],
- ['3', TR.i18n.filters] ]
- }),
- value: '3',
- listeners: {
- added: function() {
- TR.cmp.settings.positionData = this;
- }
- }
- });
-
var aggregateTypeField = Ext.create('Ext.form.RadioGroup', {
id: 'aggregateType',
fieldLabel: TR.i18n.aggregate_type,
@@ -4265,17 +4253,25 @@
TR.cmp.settings.dataElementGroupBy = this;
},
select: function(cb) {
+ var o = TR.state.aggregateReport.getOrgunitPosition();
+ var p = TR.state.aggregateReport.getPeriodPosition();
+ var d = TR.state.aggregateReport.getDataPosition();
if( cb.getValue()!=null && cb.getValue()!=''
- && Ext.getCmp('positionDataCbx').getValue() !='1'){
- if( Ext.getCmp('positionOrgunitCbx').getValue() == '1' ){
- Ext.getCmp('positionOrgunitCbx').setValue('3');
- Ext.getCmp('positionPeriodCbx').setValue('2');
+ && d !='1'){
+
+ Ext.getCmp('positionRowCbx').store.removeAll();
+ Ext.getCmp('positionColCbx').store.removeAll();
+ Ext.getCmp('positionFilterCbx').store.removeAll();
+
+ if( o == '1' ){
+ Ext.getCmp('positionColCbx').store.add({id:2, name:TR.i18n.periods});
+ Ext.getCmp('positionFilterCbx').store.add({id:1, name:TR.i18n.organisation_units});
}
else {
- Ext.getCmp('positionOrgunitCbx').setValue('2');
- Ext.getCmp('positionPeriodCbx').setValue('3');
+ Ext.getCmp('positionColCbx').store.add({id:1, name:TR.i18n.organisation_units});
+ Ext.getCmp('positionFilterCbx').store.add({id:2, name:TR.i18n.periods});
}
- Ext.getCmp('positionDataCbx').setValue('1');
+ Ext.getCmp('positionRowCbx').store.add({id:3, name:TR.i18n.data});
Ext.getCmp('aggregateType').items.items[1].setValue(false);
Ext.getCmp('aggregateType').items.items[2].setValue(false);
Ext.getCmp('aggregateType').items.items[1].disable();
@@ -4318,23 +4314,6 @@
items: [
{
xtype: 'fieldset',
- title: TR.i18n.position,
- id: 'positionField',
- layout: 'anchor',
- collapsible: false,
- collapsed: false,
- defaults: {
- anchor: '100%',
- labelStyle: 'padding-left:4px;'
- },
- items: [
- positionOrgunitField,
- positionPeriodField,
- positionDataField
- ]
- },
- {
- xtype: 'fieldset',
layout: 'anchor',
collapsible: false,
collapsed: false,
@@ -4662,6 +4641,256 @@
return window;
};
+ TR.app.LayoutWindow = function() {
+ var row,
+ rowStore,
+ col,
+ colStore,
+ filter,
+ filterStore,
+ value,
+
+ getStore,
+ getStoreKeys,
+ getCmpHeight,
+ getSetup,
+
+ selectPanel,
+ window,
+
+ margin = 2,
+ defaultWidth = 160,
+ defaultHeight = 50,
+ maxHeight = 200,
+
+ getStore = function(data) {
+ var config = {};
+
+ config.fields = ['id', 'name'];
+
+ if (data) {
+ config.data = data;
+ }
+ return Ext.create('Ext.data.Store', config);
+ };
+
+ getStoreKeys = function(store) {
+ var keys = [],
+ items = store.data.items;
+
+ if (items) {
+ for (var i = 0; i < items.length; i++) {
+ keys.push(items[i].data.id);
+ }
+ }
+
+ return keys;
+ };
+
+ rowStore = getStore();
+ rowStore.add({id: 1, name: TR.i18n.organisation_units});
+ colStore = getStore();
+ colStore.add({id: 2, name: TR.i18n.periods});
+ filterStore = getStore();
+ filterStore.add({id: 3, name: TR.i18n.data});
+
+ getCmpHeight = function() {
+ var size = 20,
+ expansion = 10,
+ height = defaultHeight,
+ diff;
+
+ if (size > 10) {
+ diff = size - 10;
+ height += (diff * expansion);
+ }
+
+ height = height > maxHeight ? maxHeight : height;
+
+ return height;
+ };
+
+ row = Ext.create('Ext.ux.form.MultiSelect', {
+ cls: 'tr-toolbar-multiselect-leftright',
+ id: 'positionRowCbx',
+ width: defaultWidth,
+ height: getCmpHeight(),
+ style: 'margin-bottom:0px',
+ valueField: 'id',
+ displayField: 'name',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
+ store: rowStore,
+ tbar: {
+ height: 25,
+ items: {
+ xtype: 'label',
+ text: TR.i18n.row,
+ cls: 'tr-toolbar-multiselect-leftright-label'
+ }
+ },
+ listeners: {
+ afterrender: function(ms) {
+ ms.boundList.on('itemdblclick', function(view, record) {
+ ms.store.remove(record);
+ });
+
+ ms.store.on('add', function() {
+ Ext.defer( function() {
+ ms.boundList.getSelectionModel().deselectAll();
+ }, 10);
+ });
+ }
+ }
+ });
+
+ col = Ext.create('Ext.ux.form.MultiSelect', {
+ cls: 'tr-toolbar-multiselect-leftright',
+ id: 'positionColCbx',
+ width: defaultWidth,
+ height: getCmpHeight(),
+ style: 'margin-bottom:' + margin + 'px',
+ valueField: 'id',
+ displayField: 'name',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
+ store: colStore,
+ tbar: {
+ height: 25,
+ items: {
+ xtype: 'label',
+ text: TR.i18n.column,
+ cls: 'tr-toolbar-multiselect-leftright-label'
+ }
+ },
+ listeners: {
+ afterrender: function(ms) {
+ ms.boundList.on('itemdblclick', function(view, record) {
+ ms.store.remove(record);
+ });
+
+ ms.store.on('add', function() {
+ Ext.defer( function() {
+ ms.boundList.getSelectionModel().deselectAll();
+ }, 10);
+ });
+ }
+ }
+ });
+
+ filter = Ext.create('Ext.ux.form.MultiSelect', {
+ cls: 'tr-toolbar-multiselect-leftright',
+ id: 'positionFilterCbx',
+ width: defaultWidth,
+ height: getCmpHeight(),
+ style: 'margin-right:' + margin + 'px; margin-bottom:' + margin + 'px',
+ valueField: 'id',
+ displayField: 'name',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
+ store: filterStore,
+ tbar: {
+ height: 25,
+ items: {
+ xtype: 'label',
+ text: TR.i18n.filter,
+ cls: 'tr-toolbar-multiselect-leftright-label'
+ }
+ },
+ listeners: {
+ afterrender: function(ms) {
+ ms.boundList.on('itemdblclick', function(view, record) {
+ ms.store.remove(record);
+ });
+
+ ms.store.on('add', function() {
+ Ext.defer( function() {
+ ms.boundList.getSelectionModel().deselectAll();
+ }, 10);
+ });
+ }
+ }
+ });
+
+ selectPanel = Ext.create('Ext.panel.Panel', {
+ bodyStyle: 'border:0 none',
+ items: [
+ {
+ layout: 'column',
+ bodyStyle: 'border:0 none',
+ items: [
+ filter,
+ col
+ ]
+ },
+ {
+ layout: 'column',
+ bodyStyle: 'border:0 none',
+ items: [
+ row
+ ]
+ }
+ ]
+ });
+
+ getSetup = function() {
+ return {
+ col: getStoreKeys(colStore),
+ row: getStoreKeys(rowStore),
+ filter: getStoreKeys(filterStore)
+ };
+ };
+
+ window = Ext.create('Ext.window.Window', {
+ title: TR.i18n.table_layout,
+ bodyStyle: 'background-color:#fff; padding:2px',
+ closeAction: 'hide',
+ autoShow: true,
+ modal: true,
+ resizable: false,
+ getSetup: getSetup,
+ rowStore: rowStore,
+ colStore: colStore,
+ filterStore: filterStore,
+ hideOnBlur: true,
+ items: {
+ layout: 'column',
+ bodyStyle: 'border:0 none',
+ items: [
+ selectPanel
+ ]
+ },
+ bbar: [
+ '->',
+ {
+ text: TR.i18n.hide,
+ listeners: {
+ added: function(b) {
+ b.on('click', function() {
+ window.hide();
+ });
+ }
+ }
+ },
+ {
+ text: '<b>' + TR.i18n.update + '</b>',
+ handler: function() {
+ TR.exe.execute();
+ layoutWindow.hide();
+ }
+ }
+ ],
+ listeners: {
+ show: function(w) {
+ TR.util.window.setAnchorPosition(w, TR.cmp.toolbar.favoritee);
+ }
+ }
+ });
+
+ return window;
+ };
+
+
TR.viewport = Ext.create('Ext.container.Viewport', {
layout: 'border',
renderTo: Ext.getBody(),
@@ -4711,11 +4940,11 @@
Ext.getCmp('aggregateType').setVisible(false);
Ext.getCmp('downloadPdfIcon').setVisible(false);
Ext.getCmp('downloadCvsIcon').setVisible(false);
- Ext.getCmp('positionField').setVisible(false);
Ext.getCmp('aggregateFavoriteBtn').setVisible(false);
Ext.getCmp('datePeriodRangeDiv').setVisible(false);
Ext.getCmp('deSumCbx').setVisible(false);
Ext.getCmp('displayTotalsOpt').setVisible(false);
+ Ext.getCmp('layoutBtn').setVisible(false);
Ext.getCmp('caseBasedFavoriteBtn').setVisible(true);
Ext.getCmp('levelCombobox').setVisible(true);
Ext.getCmp('displayOrgunitCode').setVisible(true);
@@ -4755,7 +4984,6 @@
Ext.getCmp('downloadPdfIcon').setVisible(true);
Ext.getCmp('downloadCvsIcon').setVisible(true);
Ext.getCmp('aggregateFavoriteBtn').setVisible(true);
- Ext.getCmp('positionField').setVisible(true);
Ext.getCmp('deSumCbx').setVisible(true);
Ext.getCmp('dateRangeDiv').setVisible(false);
Ext.getCmp('levelCombobox').setVisible(false);
@@ -4768,6 +4996,7 @@
Ext.getCmp('fixedPeriodsDiv').setVisible(true);
Ext.getCmp('relativePeriodsDiv').setVisible(true);
Ext.getCmp('displayTotalsOpt').setVisible(true);
+ Ext.getCmp('layoutBtn').setVisible(true);
Ext.getCmp('datePeriodRangeDiv').expand();
Ext.getCmp('filterPanel').setHeight(105);
@@ -6416,6 +6645,16 @@
{
xtype: 'button',
cls: 'tr-toolbar-btn-2',
+ id: 'layoutBtn',
+ text: TR.i18n.table_layout,
+ hidden: true,
+ handler: function() {
+ TR.cmp.layoutWindow.window.show();
+ }
+ },
+ {
+ xtype: 'button',
+ cls: 'tr-toolbar-btn-2',
text: TR.i18n.options,
handler: function() {
TR.cmp.options.window.show();
@@ -6622,6 +6861,10 @@
TR.init.initialize(vp);
TR.cmp.options.window = TR.app.OptionsWindow();
TR.cmp.options.window.hide();
+
+ TR.cmp.layoutWindow.window = TR.app.LayoutWindow();
+ TR.cmp.layoutWindow.window.hide();
+
Ext.getCmp('patientPropertiesDiv').setVisible(TR.init.system.accessPatientAttributes);
Ext.getCmp('reportTypeGroup').setValue(true);
Ext.getCmp('limitOption').setVisible(false);
@@ -6632,7 +6875,6 @@
Ext.getCmp('aggregateType').setVisible(false);
Ext.getCmp('downloadPdfIcon').setVisible(false);
Ext.getCmp('downloadCvsIcon').setVisible(false);
- Ext.getCmp('positionField').setVisible(false);
Ext.getCmp('aggregateFavoriteBtn').setVisible(false);
Ext.getCmp('datePeriodRangeDiv').setVisible(false);
Ext.getCmp('displayTotalsOpt').setVisible(false);
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-06-06 03:06:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-07-08 05:59:46 +0000
@@ -195,5 +195,9 @@
public_access: '$encoder.jsEscape($i18n.getString( 'public_access' ) , "'")',
display_orgunit_code: '$encoder.jsEscape($i18n.getString( 'display_orgunit_code' ) , "'")',
use_data_element_form_names: '$encoder.jsEscape($i18n.getString( 'use_data_element_form_names' ) , "'")',
-section: '$encoder.jsEscape($i18n.getString( 'section' ) , "'")'
+section: '$encoder.jsEscape($i18n.getString( 'section' ) , "'")',
+table_layout: '$encoder.jsEscape($i18n.getString( 'table_layout' ) , "'")',
+column: '$encoder.jsEscape($i18n.getString( 'column' ) , "'")',
+row: '$encoder.jsEscape($i18n.getString( 'row' ) , "'")',
+periods: '$encoder.jsEscape($i18n.getString( 'periods' ) , "'")',
};
\ No newline at end of file