dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32434
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16552: PT respecting analysis display property, work in progress.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16552 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-08-28 12:32:33 +0200
message:
PT respecting analysis display property, work in progress.
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.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
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java 2014-08-28 10:29:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java 2014-08-28 10:31:16 +0000
@@ -34,7 +34,6 @@
import static org.hisp.dhis.user.UserSettingService.KEY_UI_LOCALE;
import static org.hisp.dhis.user.UserSettingService.KEY_ANALYSIS_DISPLAY_PROPERTY;
-
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2014-08-27 14:03:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2014-08-28 09:59:21 +0000
@@ -2616,10 +2616,10 @@
}
if (Ext.isString(uid)) {
- path = '/indicators.json?fields=id,name&filter=indicatorGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
+ path = '/indicators.json?fields=id,' + ns.core.init.namePropertyUrl + '&filter=indicatorGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
}
else if (uid === 0) {
- path = '/indicators.json?fields=id,name' + (filter ? '&filter=name:like:' + filter : '');
+ path = '/indicators.json?fields=id,' + ns.core.init.namePropertyUrl + '' + (filter ? '&filter=name:like:' + filter : '');
}
if (!path) {
@@ -2746,10 +2746,10 @@
}
if (Ext.isString(uid)) {
- path = '/dataElements.json?fields=id,name&filter=dataElementGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
+ path = '/dataElements.json?fields=id,' + ns.core.init.namePropertyUrl + '&filter=dataElementGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
}
else if (uid === 0) {
- path = '/dataElements.json?fields=id,name' + (filter ? '&filter=name:like:' + filter : '');
+ path = '/dataElements.json?fields=id,' + ns.core.init.namePropertyUrl + '' + (filter ? '&filter=name:like:' + filter : '');
}
if (!path) {
@@ -2788,10 +2788,10 @@
}
if (Ext.isString(uid)) {
- path = '/dataElementOperands.json?fields=id,name&filter=dataElement.dataElementGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
+ path = '/dataElementOperands.json?fields=id,' + ns.core.init.namePropertyUrl + '&filter=dataElement.dataElementGroups.id:eq:' + uid + (filter ? '&filter=name:like:' + filter : '');
}
else if (uid === 0) {
- path = '/dataElementOperands.json?fields=id,name' + (filter ? '&filter=name:like:' + filter : '');
+ path = '/dataElementOperands.json?fields=id,' + ns.core.init.namePropertyUrl + '' + (filter ? '&filter=name:like:' + filter : '');
}
if (!path) {
@@ -2892,7 +2892,7 @@
},
loadPage: function(filter, append) {
var store = this,
- path = '/dataSets.json?fields=id,name' + (filter ? '&filter=name:like:' + filter : '');
+ path = '/dataSets.json?fields=id,' + ns.core.init.namePropertyUrl + '' + (filter ? '&filter=name:like:' + filter : '');
filter = filter || dataSetFilter.getValue() || null;
@@ -3034,7 +3034,7 @@
fields: ['id', 'name'],
proxy: {
type: 'ajax',
- url: ns.core.init.contextPath + '/api/organisationUnitGroups.json?fields=id,name&paging=false',
+ url: ns.core.init.contextPath + '/api/organisationUnitGroups.json?fields=id,' + ns.core.init.namePropertyUrl + '&paging=false',
reader: {
type: 'json',
root: 'organisationUnitGroups'
@@ -4441,7 +4441,7 @@
format: 'json',
noCache: false,
extraParams: {
- fields: 'children[id,name,children::isNotEmpty|rename(hasChildren)&paging=false'
+ fields: 'children[id,' + ns.core.init.namePropertyUrl + ',children::isNotEmpty|rename(hasChildren)&paging=false'
},
url: ns.core.init.contextPath + '/api/organisationUnits',
reader: {
@@ -6153,59 +6153,74 @@
success: function(r) {
init.contextPath = Ext.decode(r.responseText).activities.dhis.href;
- // system info
+ // user-account
Ext.Ajax.request({
- url: init.contextPath + '/api/system/info.json',
+ url: init.contextPath + '/api/me/user-account.json',
success: function(r) {
- var info = Ext.decode(r.responseText);
-
- // context path
- init.contextPath = info.contextPath || init.contextPath;
-
- // calendars
- init.dateFormat = info.dateFormat || 'yyyy-mm-dd';
-
- (function() {
- var dhis2PeriodUrl = '../../dhis-web-commons/javascripts/dhis2/dhis2.period.js',
- defaultCalendarId = 'gregorian',
- calendarIdMap = {'iso8601': defaultCalendarId},
- calendarId = calendarIdMap[info.calendar] || info.calendar || defaultCalendarId,
- calendarIds = ['coptic', 'ethiopian', 'islamic', 'julian', 'nepali', 'thai'],
- calendarScriptUrl,
- createGenerator;
-
- // calendar
- createGenerator = function() {
- init.calendar = $.calendars.instance(calendarId);
- init.periodGenerator = new dhis2.period.PeriodGenerator(init.calendar, init.dateFormat);
- };
-
- if (Ext.Array.contains(calendarIds, calendarId)) {
- calendarScriptUrl = '../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.' + calendarId + '.min.js';
-
- Ext.Loader.injectScriptElement(calendarScriptUrl, function() {
- Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
- });
- }
- else {
- Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
- }
- }());
-
- // user info, i18n
- requests.push({
- url: init.contextPath + '/api/me/user-account.json',
+ init.userAccount = Ext.decode(r.responseText);
+
+ // system info
+ Ext.Ajax.request({
+ url: init.contextPath + '/api/system/info.json',
success: function(r) {
- var defaultKeyUiLocale = 'en';
- init.keyUiLocale = Ext.decode(r.responseText).settings.keyUiLocale || defaultKeyUiLocale;
+ init.systemInfo = Ext.decode(r.responseText);
+
+ // init
+ var defaultKeyUiLocale = 'en',
+ defaultKeyAnalysisDisplayProperty = 'name',
+ namePropertyUrl,
+ contextPath,
+ keyUiLocale,
+ dateFormat;
+
+ init.contextPath = init.systemInfo.contextPath || init.contextPath;
+ init.userAccount.settings.keyUiLocale = init.userAccount.settings.keyUiLocale || defaultKeyUiLocale;
+ init.userAccount.settings.keyAnalysisDisplayProperty = init.userAccount.settings.keyAnalysisDisplayProperty || defaultKeyAnalysisDisplayProperty;
+ init.systemInfo.dateFormat = init.systemInfo.dateFormat || 'yyyy-mm-dd';
+
+ contextPath = init.contextPath;
+ keyUiLocale = init.userAccount.settings.keyUiLocale;
+ keyAnalysisDisplayProperty = init.userAccount.settings.keyAnalysisDisplayProperty;
+ namePropertyUrl = keyAnalysisDisplayProperty === defaultKeyAnalysisDisplayProperty ? keyAnalysisDisplayProperty : keyAnalysisDisplayProperty + '|rename(' + defaultKeyAnalysisDisplayProperty + ')';
+ dateFormat = init.systemInfo.dateFormat;
+
+ init.namePropertyUrl = namePropertyUrl;
+
+ // calendar
+ (function() {
+ var dhis2PeriodUrl = '../../dhis-web-commons/javascripts/dhis2/dhis2.period.js',
+ defaultCalendarId = 'gregorian',
+ calendarIdMap = {'iso8601': defaultCalendarId},
+ calendarId = calendarIdMap[init.systemInfo.calendar] || init.systemInfo.calendar || defaultCalendarId,
+ calendarIds = ['coptic', 'ethiopian', 'islamic', 'julian', 'nepali', 'thai'],
+ calendarScriptUrl,
+ createGenerator;
+
+ // calendar
+ createGenerator = function() {
+ init.calendar = $.calendars.instance(calendarId);
+ init.periodGenerator = new dhis2.period.PeriodGenerator(init.calendar, init.dateFormat);
+ };
+
+ if (Ext.Array.contains(calendarIds, calendarId)) {
+ calendarScriptUrl = '../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.' + calendarId + '.min.js';
+
+ Ext.Loader.injectScriptElement(calendarScriptUrl, function() {
+ Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
+ });
+ }
+ else {
+ Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
+ }
+ }());
// i18n
- Ext.Ajax.request({
- url: 'i18n/' + init.keyUiLocale + '.properties',
+ requests.push({
+ url: 'i18n/' + keyUiLocale + '.properties',
success: function(r) {
NS.i18n = dhis2.util.parseJavaProperties(r.responseText);
- if (init.keyUiLocale !== defaultKeyUiLocale) {
+ if (keyUiLocale !== defaultKeyUiLocale) {
Ext.Ajax.request({
url: 'i18n/' + defaultKeyUiLocale + '.properties',
success: function(r) {
@@ -6219,107 +6234,107 @@
}
},
failure: function() {
- var failure = function() {
- alert('No translations found for system locale (' + init.keyUiLocale + ') or default locale (' + defaultKeyUiLocale + ').');
+ var onFailure = function() {
+ alert('No translations found for system locale (' + keyUiLocale + ') or default locale (' + defaultKeyUiLocale + ').');
};
- if (init.keyUiLocale !== defaultKeyUiLocale) {
+ if (keyUiLocale !== defaultKeyUiLocale) {
Ext.Ajax.request({
url: 'i18n/' + defaultKeyUiLocale + '.json',
success: function(r) {
- console.log('No translations found for system locale (' + init.keyUiLocale + ').');
+ console.log('No translations found for system locale (' + keyUiLocale + ').');
NS.i18n = dhis2.util.parseJavaProperties(r.responseText);
},
failure: function() {
- failure();
+ onFailure();
},
callback: fn
});
}
else {
fn();
- failure();
- }
- }
- });
- }
- });
-
- // root nodes
- requests.push({
- url: init.contextPath + '/api/organisationUnits.json?userDataViewFallback=true&paging=false&fields=id,name,children[id,name]',
- success: function(r) {
- init.rootNodes = Ext.decode(r.responseText).organisationUnits || [];
- fn();
- }
- });
-
- // organisation unit levels
- requests.push({
- url: init.contextPath + '/api/organisationUnitLevels.json?fields=id,name,level&paging=false',
- success: function(r) {
- init.organisationUnitLevels = Ext.decode(r.responseText).organisationUnitLevels || [];
-
- if (!init.organisationUnitLevels.length) {
- alert('No organisation unit levels');
- }
-
- fn();
- }
- });
-
- // user orgunits and children
- requests.push({
- url: init.contextPath + '/api/organisationUnits.json?userOnly=true&fields=id,name,children[id,name]&paging=false',
- success: function(r) {
- var organisationUnits = Ext.decode(r.responseText).organisationUnits || [],
- ou = [],
- ouc = [];
-
- if (organisationUnits.length) {
- for (var i = 0, org; i < organisationUnits.length; i++) {
- org = organisationUnits[i];
-
- ou.push(org.id);
-
- if (org.children) {
- ouc = Ext.Array.clean(ouc.concat(Ext.Array.pluck(org.children, 'id') || []));
- }
- }
-
- init.user = init.user || {};
- init.user.ou = ou;
- init.user.ouc = ouc;
- }
- else {
- alert('User is not assigned to any organisation units');
- }
-
- fn();
- }
- });
-
- // legend sets
- requests.push({
- url: init.contextPath + '/api/mapLegendSets.json?fields=id,name,mapLegends[id,name,startValue,endValue,color]&paging=false',
- success: function(r) {
- init.legendSets = Ext.decode(r.responseText).mapLegendSets || [];
- fn();
- }
- });
-
- // dimensions
- requests.push({
- url: init.contextPath + '/api/dimensions.json?links=false&paging=false',
- success: function(r) {
- init.dimensions = Ext.decode(r.responseText).dimensions || [];
- fn();
- }
- });
-
- for (var i = 0; i < requests.length; i++) {
- Ext.Ajax.request(requests[i]);
- }
+ onFailure();
+ }
+ }
+ });
+
+ // root nodes
+ requests.push({
+ url: contextPath + '/api/organisationUnits.json?userDataViewFallback=true&paging=false&fields=id,' + namePropertyUrl + ',children[id,' + namePropertyUrl + ']',
+ success: function(r) {
+ init.rootNodes = Ext.decode(r.responseText).organisationUnits || [];
+ fn();
+ }
+ });
+
+ // organisation unit levels
+ requests.push({
+ url: contextPath + '/api/organisationUnitLevels.json?fields=id,name,level&paging=false',
+ success: function(r) {
+ init.organisationUnitLevels = Ext.decode(r.responseText).organisationUnitLevels || [];
+
+ if (!init.organisationUnitLevels.length) {
+ alert('No organisation unit levels');
+ }
+
+ fn();
+ }
+ });
+
+ // user orgunits and children
+ requests.push({
+ url: contextPath + '/api/organisationUnits.json?userOnly=true&fields=id,' + namePropertyUrl + ',children[id,' + namePropertyUrl + ']&paging=false',
+ success: function(r) {
+ var organisationUnits = Ext.decode(r.responseText).organisationUnits || [],
+ ou = [],
+ ouc = [];
+
+ if (organisationUnits.length) {
+ for (var i = 0, org; i < organisationUnits.length; i++) {
+ org = organisationUnits[i];
+
+ ou.push(org.id);
+
+ if (org.children) {
+ ouc = Ext.Array.clean(ouc.concat(Ext.Array.pluck(org.children, 'id') || []));
+ }
+ }
+
+ init.user = init.user || {};
+ init.user.ou = ou;
+ init.user.ouc = ouc;
+ }
+ else {
+ alert('User is not assigned to any organisation units');
+ }
+
+ fn();
+ }
+ });
+
+ // legend sets
+ requests.push({
+ url: contextPath + '/api/mapLegendSets.json?fields=id,name,mapLegends[id,name,startValue,endValue,color]&paging=false',
+ success: function(r) {
+ init.legendSets = Ext.decode(r.responseText).mapLegendSets || [];
+ fn();
+ }
+ });
+
+ // dimensions
+ requests.push({
+ url: contextPath + '/api/dimensions.json?links=false&paging=false',
+ success: function(r) {
+ init.dimensions = Ext.decode(r.responseText).dimensions || [];
+ fn();
+ }
+ });
+
+ for (var i = 0; i < requests.length; i++) {
+ Ext.Ajax.request(requests[i]);
+ }
+ }
+ });
}
});
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js 2014-08-20 13:05:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js 2014-08-28 09:59:21 +0000
@@ -194,9 +194,9 @@
'*',
'program[id,name]',
'programStage[id,name]',
- 'columns[dimension,filter,items[id,name]]',
- 'rows[dimension,filter,items[id,name]]',
- 'filters[dimension,filter,items[id,name]]',
+ 'columns[dimension,filter,items[id,' + init.namePropertyUrl + ']]',
+ 'rows[dimension,filter,items[id,' + init.namePropertyUrl + ']]',
+ 'filters[dimension,filter,items[id,' + init.namePropertyUrl + ']]',
'!lastUpdated',
'!href',
'!created',