dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36076
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18472: ER range support.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18472 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-03 18:56:52 +0100
message:
ER range support.
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-reports/scripts/core.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/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-25 14:51:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/i18n_app.properties 2015-03-03 15:19:07 +0000
@@ -188,3 +188,6 @@
max=Max
number_of_events=Number of events
this_financial_year=This financial year
+duplicate=Duplicate
+remove=Remove
+select=Select
=== 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-27 09:52:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-03-03 17:54:42 +0000
@@ -117,8 +117,9 @@
triggerCmpWidth = 17,
valueCmpWidth = 235,
rangeSetWidth = 135,
- namePadding = '2px 3px',
+ namePadding = '3px 3px',
margin = '3px 0 1px',
+ removeCmpStyle = 'padding: 0; margin-left: 3px',
defaultRangeSetId = 'default';
Ext.define('Ext.ux.panel.DataElementIntegerContainer', {
@@ -160,11 +161,13 @@
var a = record.filter.split(':');
if (a.length > 1 && Ext.isString(a[1])) {
- this.rangeValueCmp.setValue(a[1].split(';'));
+ this.onRangeSearchSelect(a[1].split(';'), true);
}
}
}
else if (record.filter) {
+ this.rangeSetCmp.pendingValue = defaultRangeSetId;
+
var a = record.filter.split(':');
if (a.length > 1) {
@@ -190,7 +193,7 @@
cls: 'ns-linkbutton',
style: 'padding: 0',
height: 18,
- text: 'Duplicate',
+ text: NS.i18n.duplicate,
handler: function() {
container.duplicateDataElement();
}
@@ -198,9 +201,9 @@
this.removeCmp = Ext.create('Ext.button.Button', {
cls: 'ns-linkbutton',
- style: 'padding: 0',
+ style: removeCmpStyle,
height: 18,
- text: 'Remove',
+ text: NS.i18n.remove,
handler: function() {
container.removeDataElement();
}
@@ -237,9 +240,16 @@
});
// function
- this.filterSearchStore = function() {
+ this.filterSearchStore = function(isLayout) {
var selected = container.rangeValueCmp.getValue();
+ // hack, using internal method to activate dropdown before filtering
+ if (isLayout) {
+ container.rangeSearchCmp.onTriggerClick();
+ container.rangeSearchCmp.collapse();
+ }
+
+ // filter
container.rangeSearchStore.clearFilter();
container.rangeSearchStore.filterBy(function(record) {
@@ -247,11 +257,31 @@
});
};
+ // function
+ this.onRangeSearchSelect = function(ids, isLayout) {
+ ids = Ext.Array.from(ids);
+
+ // store
+ for (var i = 0, id; i < ids.length; i++) {
+ id = ids[i];
+
+ if (container.rangeValueStore.findExact(idProperty, id) === -1) {
+ container.rangeValueStore.add(container.rangeSearchStore.getAt(container.rangeSearchStore.findExact(idProperty, id)).data);
+ }
+ }
+
+ // search cmp
+ container.rangeSearchCmp.select([]);
+
+ // filter
+ container.filterSearchStore(isLayout);
+ };
+
this.rangeSearchCmp = Ext.create('Ext.form.field.ComboBox', {
multiSelect: true,
width: operatorCmpWidth,
- style: 'margin-bottom:0',
- emptyText: 'Select..',
+ style: 'margin-bottom: 0',
+ emptyText: NS.i18n.select + '..',
valueField: idProperty,
displayField: displayProperty,
editable: false,
@@ -259,22 +289,11 @@
hidden: true,
store: this.rangeSearchStore,
listConfig: {
- minWidth: 326
+ minWidth: operatorCmpWidth + (nameCmpWidth - operatorCmpWidth - rangeSetWidth)
},
listeners: {
select: function() {
- var id = Ext.Array.from(this.getValue())[0];
-
- // value
- if (container.rangeValueStore.findExact(idProperty, id) === -1) {
- container.rangeValueStore.add(container.rangeSearchStore.getAt(container.rangeSearchStore.findExact(idProperty, id)).data);
- }
-
- // search
- this.select([]);
-
- // filter
- container.filterSearchStore();
+ container.onRangeSearchSelect(Ext.Array.from(this.getValue())[0]);
},
expand: function() {
container.filterSearchStore();
@@ -296,7 +315,7 @@
this.rangeValueCmp = Ext.create('Ext.form.field.ComboBox', {
multiSelect: true,
- style: 'margin-bottom:0',
+ style: 'margin-bottom: 0',
width: nameCmpWidth - operatorCmpWidth - rangeSetWidth,
valueField: idProperty,
displayField: nameProperty,
@@ -333,15 +352,15 @@
// function
this.onRangeSetSelect = function(id) {
- var ranges;
-
- if (id === defaultRangeSetId) {
+ if (!id || id === defaultRangeSetId) {
container.operatorCmp.show();
container.valueCmp.show();
container.rangeSearchCmp.hide();
container.rangeValueCmp.hide();
}
else {
+ var ranges;
+
container.operatorCmp.hide();
container.valueCmp.hide();
container.rangeSearchCmp.show();
@@ -362,6 +381,7 @@
this.rangeSetCmp = Ext.create('Ext.form.field.ComboBox', {
cls: 'ns-combo h22',
+ style: 'margin-bottom: 0',
width: rangeSetWidth,
height: 22,
fieldStyle: 'height: 22px',
@@ -374,6 +394,8 @@
setPendingValue: function() {
if (this.pendingValue) {
this.setValue(this.pendingValue);
+ container.onRangeSetSelect(this.pendingValue);
+
this.pendingValue = null;
}
},
@@ -387,7 +409,7 @@
name: 'No range set'
});
- cb.setValue(defaultRangeSetId);
+ //cb.setValue(defaultRangeSetId);
Ext.Ajax.request({
url: ns.core.init.contextPath + '/api/dataElements/' + container.dataElement.id + '.json?fields=legendSet[id,name]',
@@ -396,8 +418,13 @@
if (Ext.isObject(r) && Ext.isObject(r.legendSet)) {
cb.store.add(r.legendSet);
- cb.setPendingValue();
+
+ cb.setValue(r.legendSet.id);
+ container.onRangeSetSelect(r.legendSet.id);
}
+ },
+ callback: function() {
+ cb.setPendingValue();
}
});
},
@@ -473,7 +500,7 @@
this.removeCmp = Ext.create('Ext.button.Button', {
cls: 'ns-linkbutton',
- style: 'padding: 0',
+ style: removeCmpStyle,
height: 18,
text: 'Remove',
handler: function() {
@@ -570,7 +597,7 @@
this.removeCmp = Ext.create('Ext.button.Button', {
cls: 'ns-linkbutton',
- style: 'padding: 0',
+ style: removeCmpStyle,
height: 18,
text: 'Remove',
handler: function() {
@@ -668,7 +695,7 @@
this.removeCmp = Ext.create('Ext.button.Button', {
cls: 'ns-linkbutton',
- style: 'padding: 0',
+ style: removeCmpStyle,
height: 18,
text: 'Remove',
handler: function() {
@@ -779,7 +806,7 @@
this.removeCmp = Ext.create('Ext.button.Button', {
cls: 'ns-linkbutton',
- style: 'padding: 0',
+ style: removeCmpStyle,
height: 18,
text: 'Remove',
handler: function() {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-02-27 09:52:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-03-03 17:14:13 +0000
@@ -620,7 +620,7 @@
return array.length;
};
- support.prototype.array.sort = function(array, direction, key) {
+ support.prototype.array.sort = function(array, direction, key, emptyFirst) {
// supports [number], [string], [{key: number}], [{key: string}], [[string]], [[number]]
if (!support.prototype.array.getLength(array)) {
@@ -661,6 +661,14 @@
return direction === 'DESC' ? b - a : a - b;
}
+ else if (a === undefined || a === null) {
+ return emptyFirst ? -1 : 1;
+ }
+
+ else if (b === undefined || b === null) {
+ return emptyFirst ? 1 : -1;
+ }
+
return -1;
});
@@ -760,6 +768,29 @@
return o;
};
+ support.prototype.array.getObjectDataById = function(array, sourceArray, properties, idProperty) {
+ array = Ext.Array.from(array);
+ sourceArray = Ext.Array.from(sourceArray);
+ properties = Ext.Array.from(properties);
+ idProperty = idProperty || 'id';
+
+ for (var i = 0, obj; i < array.length; i++) {
+ obj = array[i];
+
+ for (var j = 0, sourceObj; j < sourceArray.length; j++) {
+ sourceObj = sourceArray[j];
+
+ if (Ext.isString(obj[idProperty]) && sourceObj[idProperty] && obj[idProperty].indexOf(sourceObj.id) !== -1) {
+ for (var k = 0, property; k < properties.length; k++) {
+ property = properties[k];
+
+ obj[property] = sourceObj[property];
+ }
+ }
+ }
+ }
+ };
+
// object
support.prototype.object = {};
@@ -1285,7 +1316,7 @@
}
}
- // restore order for options
+ // restore item order
for (var i = 0, orgDim; i < originalDimensions.length; i++) {
orgDim = originalDimensions[i];
@@ -1294,6 +1325,7 @@
continue;
}
+ // user specified options/legends
if (Ext.isString(orgDim.filter)) {
var a = orgDim.filter.split(':');
@@ -1322,6 +1354,21 @@
}
}
}
+ // no specified legends -> sort by start value
+ else if (orgDim.legendSet && orgDim.legendSet.id) {
+ for (var j = 0, dim, items; j < dimensions.length; j++) {
+ dim = dimensions[j];
+
+ if (dim.dimension === orgDim.dimension && dim.items && dim.items.length) {
+
+ // get start/end value
+ support.prototype.array.getObjectDataById(dim.items, init.idLegendSetMap[orgDim.legendSet.id].legends, ['startValue', 'endValue']);
+
+ // sort by start value
+ support.prototype.array.sort(dim.items, 'ASC', 'startValue');
+ }
+ }
+ }
}
// re-layout
@@ -1805,7 +1852,8 @@
displayId = Ext.isNumber(parsedId) ? parsedId : (names[id] || id);
// update names
- names[fullId] = (isMeta ? '' : header.column + ' ') + displayId;
+ //names[fullId] = (isMeta ? '' : header.column + ' ') + displayId;
+ names[fullId] = displayId;
// update rows
response.rows[j][i] = fullId;
@@ -1968,7 +2016,7 @@
return xResponse;
};
- }());
+ }());
// web
(function() {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css 2015-02-25 14:51:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css 2015-03-03 15:19:07 +0000
@@ -834,8 +834,8 @@
background: transparent;
}
.ns-linkbutton .x-btn-inner {
- color: #4a66ae;
color: #3162c5;
+ padding: 0;
}
.ns-linkbutton.x-btn-over .x-btn-inner {
text-decoration: underline;