dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41643
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21227: GIS support for db translations.
------------------------------------------------------------
revno: 21227
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-11-29 19:32:14 +0100
message:
GIS support for db translations.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/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-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-11-23 13:15:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2015-11-29 18:32:14 +0000
@@ -613,7 +613,7 @@
fields: ['id', 'name'],
proxy: {
type: 'ajax',
- url: gis.init.contextPath + '/api/legendSets.json?fields=id,name&paging=false',
+ url: gis.init.contextPath + '/api/legendSets.json?fields=id,displayName|rename(name)&paging=false',
reader: {
type: 'json',
root: 'legendSets'
@@ -650,7 +650,7 @@
isLoaded: false,
pageSize: 10,
page: 1,
- defaultUrl: gis.init.contextPath + '/api/maps.json?fields=id,name,access',
+ defaultUrl: gis.init.contextPath + '/api/maps.json?fields=id,displayName|rename(name),access',
loadStore: function(url) {
this.proxy.url = url || this.defaultUrl;
@@ -2847,7 +2847,7 @@
this.currentValue = this.getValue();
var value = this.getValue(),
- url = value ? gis.init.contextPath + '/api/maps.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+ url = value ? gis.init.contextPath + '/api/maps.json?fields=id,displayName|rename(name),access' + (value ? '&filter=displayName:ilike:' + value : '') : null;
store = gis.store.maps;
store.page = 1;
@@ -2863,7 +2863,7 @@
text: GIS.i18n.prev,
handler: function() {
var value = searchTextfield.getValue(),
- url = value ? gis.init.contextPath + '/api/maps.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+ url = value ? gis.init.contextPath + '/api/maps.json?fields=id,displayName|rename(name),access' + (value ? '&filter=displayName:ilike:' + value : '') : null;
store = gis.store.maps;
store.page = store.page <= 1 ? 1 : store.page - 1;
@@ -2875,7 +2875,7 @@
text: GIS.i18n.next,
handler: function() {
var value = searchTextfield.getValue(),
- url = value ? gis.init.contextPath + '/api/maps.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+ url = value ? gis.init.contextPath + '/api/maps.json?fields=id,displayName|rename(name),access' + (value ? '&filter=displayName:ilike:' + value : '') : null;
store = gis.store.maps;
store.page = store.page + 1;
@@ -3253,7 +3253,7 @@
fields: ['id', 'name'],
proxy: {
type: 'ajax',
- url: gis.init.contextPath + '/api/legendSets.json?fields=id,name&paging=false',
+ url: gis.init.contextPath + '/api/legendSets.json?fields=id,displayName|rename(name)&paging=false',
reader: {
type: 'json',
root: 'legendSets'
@@ -3840,7 +3840,7 @@
});
if (id) {
- legendStore.proxy.url = gis.init.contextPath + '/api/legendSets/' + id + '.json?fields=legends[id,name,startValue,endValue,color]';
+ legendStore.proxy.url = gis.init.contextPath + '/api/legendSets/' + id + '.json?fields=legends[id,displayName|rename(name),startValue,endValue,color]';
legendStore.load();
legendSetName.setValue(legendSetStore.getById(id).data.name);
@@ -4372,7 +4372,10 @@
baseWidth = 444,
toolWidth = 36,
- accBaseWidth = baseWidth - 2;
+ accBaseWidth = baseWidth - 2,
+
+ namePropertyUrl = gis.init.namePropertyUrl,
+ nameProperty = gis.init.userAccount.settings.keyAnalysisDisplayProperty;
// stores
@@ -4380,7 +4383,7 @@
fields: ['id', 'name'],
proxy: {
type: 'ajax',
- url: gis.init.contextPath + '/api/programs.json?fields=id,name&paging=false',
+ url: gis.init.contextPath + '/api/programs.json?fields=id,displayName|rename(name)&paging=false',
reader: {
type: 'json',
root: 'programs'
@@ -4512,7 +4515,7 @@
}
else {
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programStages[id,name],programTrackedEntityAttributes[trackedEntityAttribute[id,name,valueType,optionSet[id,name]]]&paging=false',
+ url: gis.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programStages[id,displayName|rename(name)],programTrackedEntityAttributes[trackedEntityAttribute[id,displayName|rename(name),valueType,optionSet[id,displayName|rename(name)]]]&paging=false',
success: function(r) {
var program = Ext.decode(r.responseText).programs[0],
stages,
@@ -4621,7 +4624,7 @@
}
else {
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/programStages.json?filter=id:eq:' + stageId + '&fields=programStageDataElements[dataElement[id,' + gis.init.namePropertyUrl + ',type,optionSet[id,name]]]',
+ url: gis.init.contextPath + '/api/programStages.json?filter=id:eq:' + stageId + '&fields=programStageDataElements[dataElement[id,' + gis.init.namePropertyUrl + ',type,optionSet[id,displayName|rename(name)]]]',
success: function(r) {
var objects = Ext.decode(r.responseText).programStages,
dataElements;
@@ -5015,7 +5018,7 @@
format: 'json',
noCache: false,
extraParams: {
- fields: 'children[id,' + gis.init.namePropertyUrl + ',children::isNotEmpty|rename(hasChildren)&paging=false'
+ fields: 'children[id,' + nameProperty + '|rename(text),children::isNotEmpty|rename(hasChildren)&paging=false'
},
url: gis.init.contextPath + '/api/organisationUnits',
reader: {
@@ -7277,7 +7280,7 @@
fields: ['id', 'name'],
proxy: {
type: 'ajax',
- url: gis.init.contextPath + '/api/programs.json?fields=id,name&paging=false',
+ url: gis.init.contextPath + '/api/programs.json?fields=id,displayName|rename(name)&paging=false',
reader: {
type: 'json',
root: 'programs'
@@ -7754,7 +7757,7 @@
eventDataItem.clearValue();
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/programs.json?paging=false&fields=programTrackedEntityAttributes[trackedEntityAttribute[id,name,valueType]],programStages[programStageDataElements[dataElement[id,name,valueType]]]&filter=id:eq:' + programId,
+ url: gis.init.contextPath + '/api/programs.json?paging=false&fields=programTrackedEntityAttributes[trackedEntityAttribute[id,displayName|rename(name),valueType]],programStages[programStageDataElements[dataElement[id,' + namePropertyUrl + ',valueType]]]&filter=id:eq:' + programId,
success: function(r) {
r = Ext.decode(r.responseText);
@@ -7835,7 +7838,7 @@
programIndicator.clearValue();
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/programs.json?paging=false&fields=programIndicators[id,name]&filter=id:eq:' + programId,
+ url: gis.init.contextPath + '/api/programs.json?paging=false&fields=programIndicators[id,displayName|rename(name)]&filter=id:eq:' + programId,
success: function(r) {
r = Ext.decode(r.responseText);
@@ -10117,20 +10120,26 @@
// init
var defaultKeyUiLocale = 'en',
- defaultKeyAnalysisDisplayProperty = 'name',
+ defaultKeyAnalysisDisplayProperty = 'displayName',
+ displayPropertyMap = {
+ 'name': 'displayName',
+ 'displayName': 'displayName',
+ 'shortName': 'displayShortName',
+ 'displayShortName': 'displayShortName'
+ },
namePropertyUrl,
contextPath,
keyUiLocale,
dateFormat;
init.userAccount.settings.keyUiLocale = init.userAccount.settings.keyUiLocale || defaultKeyUiLocale;
- init.userAccount.settings.keyAnalysisDisplayProperty = init.userAccount.settings.keyAnalysisDisplayProperty || defaultKeyAnalysisDisplayProperty;
+ init.userAccount.settings.keyAnalysisDisplayProperty = displayPropertyMap[init.userAccount.settings.keyAnalysisDisplayProperty] || defaultKeyAnalysisDisplayProperty;
// local vars
contextPath = init.contextPath;
keyUiLocale = init.userAccount.settings.keyUiLocale;
keyAnalysisDisplayProperty = init.userAccount.settings.keyAnalysisDisplayProperty;
- namePropertyUrl = keyAnalysisDisplayProperty === defaultKeyAnalysisDisplayProperty ? keyAnalysisDisplayProperty : keyAnalysisDisplayProperty + '|rename(' + defaultKeyAnalysisDisplayProperty + ')';
+ namePropertyUrl = keyAnalysisDisplayProperty + '|rename(name)';
dateFormat = init.systemInfo.dateFormat;
init.namePropertyUrl = namePropertyUrl;
@@ -10212,7 +10221,7 @@
// organisation unit levels
requests.push({
- url: contextPath + '/api/organisationUnitLevels.json?fields=id,name,level&paging=false',
+ url: contextPath + '/api/organisationUnitLevels.json?fields=id,displayName|rename(name),level&paging=false',
success: function(r) {
init.organisationUnitLevels = Ext.decode(r.responseText).organisationUnitLevels || [];
@@ -10266,7 +10275,7 @@
// indicator groups
requests.push({
- url: init.contextPath + '/api/indicatorGroups.json?fields=id,name&paging=false',
+ url: init.contextPath + '/api/indicatorGroups.json?fields=id,displayName|rename(name)&paging=false',
success: function(r) {
init.indicatorGroups = Ext.decode(r.responseText).indicatorGroups || [];
fn();
@@ -10291,7 +10300,7 @@
if (!Ext.isObject(obj)) {
Ext.Ajax.request({
- url: init.contextPath + '/api/indicatorGroups.json?fields=id,name,indicators[id,name]&pageSize=1',
+ url: init.contextPath + '/api/indicatorGroups.json?fields=id,displayName|rename(name),indicators[id,' + namePropertyUrl + ']&pageSize=1',
success: function(r) {
r = Ext.decode(r.responseText);
init.systemSettings.infrastructuralIndicatorGroup = r.indicatorGroups ? r.indicatorGroups[0] : null;
@@ -10314,7 +10323,7 @@
if (!Ext.isObject(obj)) {
Ext.Ajax.request({
- url: init.contextPath + '/api/dataElementGroups.json?fields=id,name,dataElements[id,name]&pageSize=1',
+ url: init.contextPath + '/api/dataElementGroups.json?fields=id,' + namePropertyUrl + ',dataElements[id,' + namePropertyUrl + ']&pageSize=1',
success: function(r) {
r = Ext.decode(r.responseText);
init.systemSettings.infrastructuralDataElementGroup = r.dataElementGroups ? r.dataElementGroups[0] : null;
@@ -10352,7 +10361,7 @@
store.getKeys('optionSets').done( function(keys) {
if (keys.length === 0) {
Ext.Ajax.request({
- url: contextPath + '/api/optionSets.json?fields=id,name,version,options[code,name]&paging=false',
+ url: contextPath + '/api/optionSets.json?fields=id,displayName|rename(name),version,options[code,displayName|rename(name)]&paging=false',
success: function(r) {
var sets = Ext.decode(r.responseText).optionSets;
@@ -10388,7 +10397,7 @@
}
Ext.Ajax.request({
- url: contextPath + '/api/optionSets.json?fields=id,name,version,options[code,name]&paging=false' + url,
+ url: contextPath + '/api/optionSets.json?fields=id,displayName|rename(name),version,options[code,displayName|rename(name)]&paging=false' + url,
success: function(r) {
var sets = Ext.decode(r.responseText).optionSets;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-10-20 15:42:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2015-11-29 18:32:14 +0000
@@ -499,7 +499,7 @@
// Infrastructural data
showInfo = function() {
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/organisationUnits/' + att.id + '.json?fields=id,name,code,address,email,phoneNumber,coordinates,parent[id,name],organisationUnitGroups[id,name]',
+ url: gis.init.contextPath + '/api/organisationUnits/' + att.id + '.json?fields=id,' + gis.init.namePropertyUrl + ',code,address,email,phoneNumber,coordinates,parent[id,' + gis.init.namePropertyUrl + '],organisationUnitGroups[id,' + gis.init.namePropertyUrl + ']',
success: function(r) {
var ou = Ext.decode(r.responseText);
@@ -1586,6 +1586,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
isPlugin = GIS.plugin && !GIS.app,
+ propertyMap = {
+ 'name': 'name',
+ 'displayName': 'name',
+ 'shortName': 'shortName',
+ 'displayShortName': 'shortName'
+ },
+ keyAnalysisDisplayProperty = gis.init.userAccount.settings.keyAnalysisDisplayProperty,
+ displayProperty = propertyMap[keyAnalysisDisplayProperty] || propertyMap[xLayout.displayProperty] || 'name',
url = function() {
var params = '?ou=ou:';
@@ -1594,7 +1602,7 @@
params += i !== items.length - 1 ? ';' : '';
}
- params += '&displayProperty=' + gis.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();
+ params += '&displayProperty=' + displayProperty.toUpperCase();
if (Ext.isArray(view.userOrgUnit) && view.userOrgUnit.length) {
params += '&userOrgUnit=';
@@ -1673,7 +1681,7 @@
loadLegend = function(view) {
var isPlugin = GIS.plugin && !GIS.app,
type = isPlugin ? 'jsonp' : 'json',
- url = gis.init.contextPath + '/api/organisationUnitGroupSets/' + view.organisationUnitGroupSet.id + '.' + type + '?fields=organisationUnitGroups[id,name,symbol]',
+ url = gis.init.contextPath + '/api/organisationUnitGroupSets/' + view.organisationUnitGroupSet.id + '.' + type + '?fields=organisationUnitGroups[id,' + gis.init.namePropertyUrl + ',symbol]',
success;
view = view || layer.core.view;
@@ -1871,6 +1879,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
isPlugin = GIS.plugin && !GIS.app,
+ propertyMap = {
+ 'name': 'name',
+ 'displayName': 'name',
+ 'shortName': 'shortName',
+ 'displayShortName': 'shortName'
+ },
+ keyAnalysisDisplayProperty = gis.init.userAccount.settings.keyAnalysisDisplayProperty,
+ displayProperty = propertyMap[keyAnalysisDisplayProperty] || propertyMap[xLayout.displayProperty] || 'name',
url = function() {
var params = '?ou=ou:';
@@ -1879,7 +1895,7 @@
params += i !== items.length - 1 ? ';' : '';
}
- params += '&displayProperty=' + gis.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();
+ params += '&displayProperty=' + displayProperty.toUpperCase();
if (Ext.isArray(view.userOrgUnit) && view.userOrgUnit.length) {
params += '&userOrgUnit=';
@@ -2234,6 +2250,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
isPlugin = GIS.plugin && !GIS.app,
+ propertyMap = {
+ 'name': 'name',
+ 'displayName': 'name',
+ 'shortName': 'shortName',
+ 'displayShortName': 'shortName'
+ },
+ keyAnalysisDisplayProperty = gis.init.userAccount.settings.keyAnalysisDisplayProperty,
+ displayProperty = propertyMap[keyAnalysisDisplayProperty] || propertyMap[view.displayProperty] || 'name',
url = function() {
var params = '?ou=ou:';
@@ -2242,7 +2266,7 @@
params += i !== items.length - 1 ? ';' : '';
}
- params += '&displayProperty=' + gis.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();
+ params += '&displayProperty=' + displayProperty.toUpperCase();
if (Ext.isArray(view.userOrgUnit) && view.userOrgUnit.length) {
params += '&userOrgUnit=';
@@ -2318,7 +2342,15 @@
dxItems = view.columns[0].items,
isOperand = view.columns[0].dimension === dimConf.operand.objectName,
peItems = view.filters[0].items,
- ouItems = view.rows[0].items;
+ ouItems = view.rows[0].items,
+ propertyMap = {
+ 'name': 'name',
+ 'displayName': 'name',
+ 'shortName': 'shortName',
+ 'displayShortName': 'shortName'
+ },
+ keyAnalysisDisplayProperty = gis.init.userAccount.settings.keyAnalysisDisplayProperty,
+ displayProperty = propertyMap[keyAnalysisDisplayProperty] || propertyMap[view.displayProperty] || 'name';
// ou
paramString += 'dimension=ou:';
@@ -2352,7 +2384,7 @@
}
// display property
- paramString += '&displayProperty=' + gis.init.userAccount.settings.keyAnalysisDisplayProperty.toUpperCase();
+ paramString += '&displayProperty=' + displayProperty.toUpperCase();
if (Ext.isArray(view.userOrgUnit) && view.userOrgUnit.length) {
paramString += '&userOrgUnit=';
@@ -2572,7 +2604,7 @@
}
Ext.Ajax.request({
- url: gis.init.contextPath + '/api/' + elementUrl + '.json?fields=legendSet[id,name]&paging=false&filter=id:eq:' + id,
+ url: gis.init.contextPath + '/api/' + elementUrl + '.json?fields=legendSet[id,displayName|rename(name)]&paging=false&filter=id:eq:' + id,
success: function(r) {
var elements = Ext.decode(r.responseText)[elementUrl],
set;
@@ -3029,7 +3061,7 @@
];
conf.url.legendSetFields = [
- 'id,name,legends[' + conf.url.legendFields.join(',') + ']'
+ 'id,displayName|rename(name),legends[' + conf.url.legendFields.join(',') + ']'
];
}());