dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35820
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18337: EV value and aggregation types implemented.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18337 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-19 18:09:40 +0100
message:
EV value and aggregation types implemented.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/i18n_app.properties
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/i18n/i18n_app.properties
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/styles/style.css
--
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-apps/src/main/webapp/dhis-web-event-reports/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/i18n_app.properties 2015-02-18 12:37:04 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/i18n_app.properties 2015-02-19 17:03:12 +0000
@@ -177,6 +177,7 @@
column_dimensions=Column dimensions
row_dimensions=Row dimensions
report_filter=Report filter
+value=Value
average=Average
count=Count
sum=Sum
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-02-19 11:36:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-02-19 17:03:12 +0000
@@ -1089,6 +1089,7 @@
filter.setHeight(defaultHeight - fixedFilterHeight);
};
+ // gui
col = Ext.create('Ext.ux.form.MultiSelect', {
cls: 'ns-toolbar-multiselect-leftright',
width: defaultWidth,
@@ -1328,7 +1329,7 @@
xtype: 'label',
height: 22,
style: 'padding-left: 6px; line-height: 22px',
- text: 'Value'
+ text: NS.i18n.value
},
'->',
aggregationType
@@ -6128,13 +6129,19 @@
};
web.window.addDestroyOnBlurHandler = function(w) {
- var el = Ext.get(Ext.query('.x-mask')[0]);
-
- el.on('click', function() {
- if (w.destroyOnBlur) {
- w.destroy();
- }
- });
+ var masks = Ext.query('.x-mask');
+
+ for (var i = 0, el; i < masks.length; i++) {
+ el = Ext.get(masks[i]);
+
+ if (el.getWidth() == Ext.getBody().getWidth()) {
+ el.on('click', function() {
+ if (w.destroyOnBlur) {
+ w.destroy();
+ }
+ });
+ }
+ }
w.hasDestroyOnBlurHandler = true;
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/i18n/i18n_app.properties 2015-02-16 16:00:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/i18n/i18n_app.properties 2015-02-19 17:03:12 +0000
@@ -1,7 +1,4 @@
dimensions=Dimensions
-row=Row
-column=Column
-filter=Filter
table_layout=Table layout
show_totals=Show totals
show_subtotals=Show sub-totals
@@ -158,8 +155,6 @@
area_chart=Area chart
pie_chart=Pie chart
radar_chart=Radar chart
-series=Series
-category=Category
events=Events
tracked_entity_instances=Tracked entity instances
count_type=Count type
@@ -204,3 +199,17 @@
event=Event
tracked_entity_instance=Tracked entity instance
enrollment=Enrollment
+series_dimension=Series dimension
+category_dimension=Category dimension
+chart_filter=Chart filter
+value=Value
+average=Average
+count=Count
+sum=Sum
+by_data_element=By data element
+stddev=Std Dev
+variance=Variance
+min=Min
+max=Max
+number_of_events=Number of events
+
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js 2015-02-16 16:00:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js 2015-02-19 17:03:12 +0000
@@ -1004,7 +1004,9 @@
fixedFilterStore,
filter,
filterStore,
+ onValueSelect,
value,
+ aggregationType,
getStore,
getStoreKeys,
@@ -1021,11 +1023,12 @@
window,
margin = 1,
- defaultWidth = 160,
+ defaultWidth = 210,
defaultHeight = 220,
maxHeight = (ns.app.viewport.getHeight() - 100) / 2,
- dataType = 'aggregated_values';
+ dataType = 'aggregated_values',
+ defaultValueId = 'default';
getStore = function(data) {
var config = {};
@@ -1066,6 +1069,17 @@
rowStore = getStore();
fixedFilterStore = getStore();
filterStore = getStore();
+ valueStore = getStore();
+
+ // store functions
+ valueStore.addDefaultData = function() {
+ if (!this.getById(defaultValueId)) {
+ this.insert(0, {
+ id: defaultValueId,
+ name: NS.i18n.number_of_events
+ });
+ }
+ };
fixedFilterStore.setListHeight = function() {
var fixedFilterHeight = 26 + (this.getRange().length * 21) + 1;
@@ -1073,6 +1087,7 @@
filter.setHeight(defaultHeight - fixedFilterHeight);
};
+ // gui
col = Ext.create('Ext.ux.form.MultiSelect', {
cls: 'ns-toolbar-multiselect-leftright',
width: defaultWidth,
@@ -1087,7 +1102,7 @@
height: 25,
items: {
xtype: 'label',
- text: NS.i18n.series,
+ text: NS.i18n.series_dimension,
cls: 'ns-toolbar-multiselect-leftright-label'
}
},
@@ -1129,7 +1144,7 @@
cls: 'ns-toolbar-multiselect-leftright',
width: defaultWidth,
height: defaultHeight,
- style: 'margin-bottom:0px',
+ style: 'margin-right:' + margin + 'px; margin-bottom:0px',
valueField: 'id',
displayField: 'name',
dragGroup: 'layoutDD',
@@ -1139,7 +1154,7 @@
height: 25,
items: {
xtype: 'label',
- text: NS.i18n.category,
+ text: NS.i18n.category_dimension,
cls: 'ns-toolbar-multiselect-leftright-label'
}
},
@@ -1189,7 +1204,7 @@
height: 25,
items: {
xtype: 'label',
- text: NS.i18n.filter,
+ text: NS.i18n.chart_filter,
cls: 'ns-toolbar-multiselect-leftright-label'
}
},
@@ -1225,6 +1240,91 @@
}
});
+ aggregationType = Ext.create('Ext.form.field.ComboBox', {
+ cls: 'ns-combo h22',
+ width: 70,
+ height: 22,
+ style: 'margin: 0',
+ fieldStyle: 'height: 22px',
+ queryMode: 'local',
+ valueField: 'id',
+ editable: false,
+ disabled: true,
+ value: 'COUNT',
+ disabledValue: 'COUNT',
+ defaultValue: 'AVERAGE',
+ setDisabled: function() {
+ this.setValue(this.disabledValue);
+ this.disable();
+ },
+ setEnabled: function() {
+ this.setValue(this.defaultValue);
+ this.enable();
+ },
+ store: Ext.create('Ext.data.Store', {
+ fields: ['id', 'text'],
+ data: [
+ {id: 'COUNT', text: NS.i18n.count},
+ {id: 'AVERAGE', text: NS.i18n.average},
+ {id: 'SUM', text: NS.i18n.sum},
+ {id: 'STDDEV', text: NS.i18n.stddev},
+ {id: 'VARIANCE', text: NS.i18n.variance},
+ {id: 'MIN', text: NS.i18n.min},
+ {id: 'MAX', text: NS.i18n.max}
+ ]
+ }),
+ resetData: function() {
+ this.setDisabled();
+ }
+ });
+
+ onValueSelect = function(id) {
+ if (id === defaultValueId) {
+ aggregationType.setDisabled();
+ }
+ else {
+ aggregationType.setEnabled();
+
+ // remove ux and layout item
+ if (hasDimension(id, valueStore)) {
+ ns.app.accordion.getUx(id).removeDataElement();
+ }
+ }
+ };
+
+ value = Ext.create('Ext.form.field.ComboBox', {
+ cls: 'ns-combo h24',
+ width: defaultWidth - 4,
+ height: 24,
+ fieldStyle: 'height: 24px',
+ queryMode: 'local',
+ valueField: 'id',
+ displayField: 'name',
+ editable: false,
+ store: valueStore,
+ value: defaultValueId,
+ setDefaultData: function() {
+ valueStore.addDefaultData();
+ this.setValue(defaultValueId);
+ aggregationType.resetData();
+ },
+ setDefaultDataIf: function() {
+ if (!value.getValue()) {
+ this.setDefaultData();
+ }
+ },
+ resetData: function() {
+ valueStore.removeAll();
+ this.clearValue();
+ aggregationType.resetData();
+ },
+ listeners: {
+ select: function(cb, r) {
+ onValueSelect(r[0].data.id);
+ }
+ }
+ });
+
selectPanel = Ext.create('Ext.panel.Panel', {
bodyStyle: 'border:0 none',
items: [
@@ -1245,39 +1345,61 @@
]
},
{
- layout: 'column',
+ xtype: 'container',
+ layout: 'column',
bodyStyle: 'border:0 none',
items: [
- row
+ row,
+ {
+ xtype: 'panel',
+ bodyStyle: 'padding: 1px',
+ width: defaultWidth,
+ height: 220,
+ items: value,
+ tbar: {
+ height: 25,
+ style: 'padding: 1px',
+ items: [
+ {
+ xtype: 'label',
+ height: 22,
+ style: 'padding-left: 6px; line-height: 22px',
+ text: NS.i18n.value
+ },
+ '->',
+ aggregationType
+ ]
+ }
+ }
]
}
]
});
- addDimension = function(record, store) {
+ addDimension = function(record, store, excludedStores) {
var store = dimensionStoreMap[record.id] || store || filterStore;
- if (!hasDimension(record.id)) {
+ if (!hasDimension(record.id, excludedStores) && record.id !== value.getValue()) {
store.add(record);
}
};
- removeDimension = function(dataElementId) {
- var stores = [colStore, rowStore, filterStore, fixedFilterStore];
+ removeDimension = function(id, excludedStores) {
+ var stores = Ext.Array.difference([colStore, rowStore, filterStore, fixedFilterStore, valueStore], Ext.Array.from(excludedStores));
for (var i = 0, store, index; i < stores.length; i++) {
store = stores[i];
- index = store.findExact('id', dataElementId);
+ index = store.findExact('id', id);
if (index != -1) {
store.remove(store.getAt(index));
- dimensionStoreMap[dataElementId] = store;
+ dimensionStoreMap[id] = store;
}
}
};
- hasDimension = function(id) {
- var stores = [colStore, rowStore, filterStore, fixedFilterStore];
+ hasDimension = function(id, excludedStores) {
+ var stores = Ext.Array.difference([colStore, rowStore, filterStore, fixedFilterStore, valueStore], Ext.Array.from(excludedStores));
for (var i = 0, store, index; i < stores.length; i++) {
store = stores[i];
@@ -1329,6 +1451,8 @@
rowStore.removeAll();
fixedFilterStore.removeAll();
filterStore.removeAll();
+ valueStore.removeAll();
+ value.clearValue();
if (!isAll) {
filterStore.add({id: dimConf.organisationUnit.dimensionName, name: dimConf.organisationUnit.name});
@@ -1349,12 +1473,25 @@
rowStore: rowStore,
fixedFilterStore: fixedFilterStore,
filterStore: filterStore,
+ valueStore: valueStore,
+ value: value,
addDimension: addDimension,
removeDimension: removeDimension,
hasDimension: hasDimension,
saveState: saveState,
resetData: resetData,
reset: reset,
+ getValueConfig: function() {
+ var config = {},
+ valueId = value.getValue();
+
+ if (valueId && valueId !== defaultValueId) {
+ config.value = {id: valueId};
+ config.aggregationType = aggregationType.getValue();
+ }
+
+ return config;
+ },
hideOnBlur: true,
items: selectPanel,
bbar: [
@@ -1383,6 +1520,9 @@
ns.core.web.window.addHideOnBlurHandler(w);
}
}
+
+ // value
+ value.setDefaultDataIf();
},
render: function() {
reset();
@@ -1705,7 +1845,7 @@
modal: true,
resizable: false,
hideOnBlur: true,
- getOptions: function() {
+ getOptions: function() {
return {
showValues: showValues.getValue(),
hideEmptyRows: hideEmptyRows.getValue(),
@@ -3013,7 +3153,16 @@
property: 'name',
direction: 'ASC'
}
- ]
+ ],
+ onLoadData: function() {
+ var layoutWindow = ns.app.aggregateLayoutWindow;
+
+ this.each( function(record) {
+ if (Ext.Array.contains(['int', 'number'], (record.data.valueType || record.data.type))) {
+ layoutWindow.valueStore.add(record.data);
+ }
+ });
+ }
});
organisationUnitGroupStore = Ext.create('Ext.data.Store', {
@@ -3308,6 +3457,7 @@
onStageSelect = function(stageId, layout) {
if (!layout) {
dataElementSelected.removeAllDataElements(true);
+ ns.app.aggregateLayoutWindow.value.resetData();
}
loadDataElements(stageId, layout);
@@ -3324,6 +3474,7 @@
data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
dataElementsByStageStore.loadData(data);
+ dataElementsByStageStore.onLoadData();
if (layout) {
var dataDimensions = ns.core.service.layout.getDataDimensionsFromLayout(layout),
@@ -3463,6 +3614,17 @@
return hasDataElement;
},
+ getUxById: function(dataElementId) {
+ var ux;
+
+ this.items.each(function(item) {
+ if (item.dataElement.id === dataElementId) {
+ ux = item;
+ }
+ });
+
+ return ux;
+ },
removeAllDataElements: function(reset) {
var items = this.items.items,
len = items.length;
@@ -3518,7 +3680,7 @@
dataElementsByStageStore.sort();
}
- ns.app.aggregateLayoutWindow.removeDimension(element.id);
+ ns.app.aggregateLayoutWindow.removeDimension(element.id, ns.app.aggregateLayoutWindow.valueStore);
}
};
@@ -3600,19 +3762,22 @@
element.name = element.name || element.displayName;
recordMap[element.id] = element;
- ux = addUxFromDataElement(element);
+ // add ux if not selected as value
+ if (element.id !== aggWindow.value.getValue()) {
+ ux = addUxFromDataElement(element);
- if (layout) {
- ux.setRecord(element);
+ if (layout) {
+ ux.setRecord(element);
+ }
}
- store = Ext.Array.contains(includeKeys, element.type) || element.optionSet ? aggWindow.colStore : aggWindow.fixedFilterStore;
+ store = Ext.Array.contains(includeKeys, element.type) || element.optionSet ? aggWindow.rowStore : aggWindow.fixedFilterStore;
if (store === aggWindow.fixedFilterStore) {
fixedFilterElementIds.push(element.id);
}
- aggWindow.addDimension(element, store);
+ aggWindow.addDimension(element, store, valueStore);
}
if (layout) { // && layout.dataType === 'aggregated_values') {
@@ -5389,8 +5554,6 @@
});
}
- // view
-
if (columns.length) {
view.columns = columns;
}
@@ -5401,6 +5564,9 @@
view.filters = filters;
}
+ // value, aggregation type
+ Ext.apply(view, layoutWindow.getValueConfig());
+
return view;
};
@@ -5621,25 +5787,37 @@
};
web.window.addHideOnBlurHandler = function(w) {
- var el = Ext.get(Ext.query('.x-mask')[0]);
-
- el.on('click', function() {
- if (w.hideOnBlur) {
- w.hide();
- }
- });
+ var masks = Ext.query('.x-mask');
+
+ for (var i = 0, el; i < masks.length; i++) {
+ el = Ext.get(masks[i]);
+
+ if (el.getWidth() == Ext.getBody().getWidth()) {
+ el.on('click', function() {
+ if (w.hideOnBlur) {
+ w.hide();
+ }
+ });
+ }
+ }
w.hasHideOnBlurHandler = true;
};
web.window.addDestroyOnBlurHandler = function(w) {
- var el = Ext.get(Ext.query('.x-mask')[0]);
-
- el.on('click', function() {
- if (w.destroyOnBlur) {
- w.destroy();
- }
- });
+ var masks = Ext.query('.x-mask');
+
+ for (var i = 0, el; i < masks.length; i++) {
+ el = Ext.get(masks[i]);
+
+ if (el.getWidth() == Ext.getBody().getWidth()) {
+ el.on('click', function() {
+ if (w.destroyOnBlur) {
+ w.destroy();
+ }
+ });
+ }
+ }
w.hasDestroyOnBlurHandler = true;
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js 2015-02-16 16:00:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js 2015-02-19 17:03:12 +0000
@@ -588,8 +588,17 @@
layout.hideTitle = Ext.isBoolean(config.hideTitle) ? config.hideTitle : false;
layout.title = Ext.isString(config.title) && !Ext.isEmpty(config.title) ? config.title : null;
+ // value
+ if ((Ext.isObject(config.value) && Ext.isString(config.value.id)) || Ext.isString(config.value)) {
+ layout.value = Ext.isString(config.value) ? {id: config.value} : config.value;
+ }
+
+ // aggregation type
+ if (layout.value && Ext.isString(config.aggregationType)) {
+ layout.aggregationType = config.aggregationType;
+ }
+
layout.parentGraphMap = Ext.isObject(config.parentGraphMap) ? config.parentGraphMap : null;
-
layout.legend = Ext.isObject(config.legend) ? config.legend : null;
//layout.sorting = Ext.isObject(config.sorting) && Ext.isDefined(config.sorting.id) && Ext.isString(config.sorting.direction) ? config.sorting : null;
@@ -2024,6 +2033,19 @@
}
}
+ // value
+ if (Ext.isString(layout.value)) {
+ paramString += '&value=' + layout.value;
+ }
+ else if (Ext.isObject(layout.value) && Ext.isString(layout.value.id)) {
+ paramString += '&value=' + layout.value.id;
+ }
+
+ // aggregation type
+ if (layout.aggregationType) {
+ paramString += '&aggregationType=' + layout.aggregationType;
+ }
+
// dates
if (layout.startDate && layout.endDate) {
paramString += '&startDate=' + layout.startDate + '&endDate=' + layout.endDate;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/styles/style.css 2014-11-06 15:44:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/styles/style.css 2015-02-19 17:03:12 +0000
@@ -412,6 +412,16 @@
border-radius: 1px 0px 0px 0px;
}
+ /* Custom */
+.ns-combo.h21 .x-form-trigger {
+ height: 21px;
+}
+.ns-combo.h22 .x-form-trigger {
+ height: 22px;
+}
+.ns-combo.h24 .x-form-trigger {
+ height: 24px;
+}
/*----------------------------------------------------------------------------
* PT Trigger