dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33676
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17234: GIS using indexeddb for option sets + ER EV option set bug fixed.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 17234 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 11:13:36 +0200
message:
GIS using indexeddb for option sets + ER EV option set bug fixed.
modified:
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/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/i18n/en.properties
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/index.html
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
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/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/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2014-10-22 16:41:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2014-10-23 09:11:36 +0000
@@ -7401,6 +7401,7 @@
if (++callbacks === optionSets.length) {
if (!ids.length) {
fn();
+ return;
}
for (var i = 0; i < ids.length; i++) {
=== 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 2014-10-22 16:41:32 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js 2014-10-23 09:11:36 +0000
@@ -7040,6 +7040,7 @@
if (++callbacks === optionSets.length) {
if (!ids.length) {
fn();
+ return;
}
for (var i = 0; i < ids.length; i++) {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/i18n/en.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/i18n/en.properties 2014-09-16 00:11:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/i18n/en.properties 2014-10-23 09:11:36 +0000
@@ -413,3 +413,4 @@
clear=Clear
select_sub_units=Select sub-units
you_do_not_have_access_to_all_items_in_this_favorite=You do not have access to all items in this favorite
+initializing=Initializing
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/index.html 2014-08-31 15:21:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/index.html 2014-10-23 09:11:36 +0000
@@ -10,6 +10,8 @@
</head>
<body>
+ <div id="init"></div>
+
<div id="layerItems"></div>
<form id="exportForm" method="post">
@@ -35,6 +37,11 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.util.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/date.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
+
<script type="text/javascript" src="scripts/core.js"></script>
<script type="text/javascript" src="scripts/mapfish/MapFish.js"></script>
=== 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 2014-10-21 08:22:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js 2014-10-23 09:11:36 +0000
@@ -1531,37 +1531,17 @@
fields: [idProperty, 'name'],
data: [],
loadOptionSet: function(optionSetId, key, pageSize) {
- var store = this,
- params = {};
+ var store = this;
optionSetId = optionSetId || container.dataElement.optionSet.id;
-
- //if (key) {
- //params['key'] = key;
- //}
-
- params['max'] = pageSize || 15;
-
- Ext.Ajax.request({
- url: gis.init.contextPath + '/api/optionSets/' + optionSetId + '.json?fields=options[' + idProperty + ',' + nameProperty + ']',
- params: params,
- disableCaching: false,
- success: function(r) {
- var options = Ext.decode(r.responseText).options,
- data = [];
-
- for (var i = 0; i < options.length; i++) {
- if (container.valueStore.findExact(idProperty, options[i][idProperty]) === -1) {
- data.push(options[i]);
- }
- }
-
- store.removeAll();
- store.loadData(data);
-
- container.triggerCmp.storage = Ext.clone(options);
- }
- });
+ pageSize = pageSize || 100;
+
+ dhis2.gis.store.get('optionSets', optionSetId).done( function(obj) {
+ if (Ext.isObject(obj) && Ext.isArray(obj.options) && obj.options.length) {
+ store.removeAll();
+ store.loadData(obj.options.slice(0, pageSize));
+ }
+ });
},
listeners: {
datachanged: function(s) {
@@ -1641,15 +1621,8 @@
disabledCls: 'gis-button-combotrigger-disabled',
width: 18,
height: 22,
- storage: [],
handler: function(b) {
- if (b.storage.length) {
- container.searchStore.removeAll();
- container.searchStore.add(Ext.clone(b.storage));
- }
- else {
- container.searchStore.loadOptionSet();
- }
+ container.searchStore.loadOptionSet();
}
});
@@ -9086,6 +9059,8 @@
});
onRender = function(vp) {
+ document.getElementById('init').remove();
+
gis.olmap.mask = Ext.create('Ext.LoadMask', vp.getEl(), {
msg: 'Loading'
});
@@ -9282,6 +9257,15 @@
init.namePropertyUrl = namePropertyUrl;
+ // dhis2
+ dhis2.util.namespace('dhis2.gis');
+
+ dhis2.gis.store = dhis2.gis.store || new dhis2.storage.Store({
+ name: 'dhis2',
+ adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
+ objectStores: ['optionSets']
+ });
+
// calendar
(function() {
var dhis2PeriodUrl = '../dhis-web-commons/javascripts/dhis2/dhis2.period.js',
@@ -9315,6 +9299,7 @@
url: 'i18n/' + keyUiLocale + '.properties',
success: function(r) {
GIS.i18n = dhis2.util.parseJavaProperties(r.responseText);
+ Ext.get('init').update(GIS.i18n.initializing + '..');
if (keyUiLocale !== defaultKeyUiLocale) {
Ext.Ajax.request({
@@ -9457,6 +9442,58 @@
}
});
+ // option sets
+ requests.push({
+ url: contextPath + '/api/optionSets.json?fields=id,version&paging=false',
+ success: function(r) {
+ var optionSets = Ext.decode(r.responseText).optionSets || [],
+ store = dhis2.gis.store,
+ ids = [],
+ url = '',
+ callbacks = 0,
+ checkOptionSet,
+ updateStore;
+
+ updateStore = function() {
+ if (++callbacks === optionSets.length) {
+ if (!ids.length) {
+ fn();
+ return;
+ }
+
+ for (var i = 0; i < ids.length; i++) {
+ url += '&filter=id:eq:' + ids[i];
+ }
+
+ Ext.Ajax.request({
+ url: contextPath + '/api/optionSets.json?fields=id,name,version,options[code,name]&paging=false' + url,
+ success: function(r) {
+ var sets = Ext.decode(r.responseText).optionSets;
+
+ store.setAll('optionSets', sets).done(fn);
+ }
+ });
+ }
+ };
+
+ registerOptionSet = function(optionSet) {
+ store.get('optionSets', optionSet.id).done( function(obj) {
+ if (!Ext.isObject(obj) || obj.version !== optionSet.version) {
+ ids.push(optionSet.id);
+ }
+
+ updateStore();
+ });
+ };
+
+ store.open().done( function() {
+ for (var i = 0; i < optionSets.length; i++) {
+ registerOptionSet(optionSets[i]);
+ }
+ });
+ }
+ });
+
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-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2014-10-21 16:30:56 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js 2014-10-23 09:11:36 +0000
@@ -872,7 +872,7 @@
gis.olmap.mask.hide();
if (Ext.Array.contains([403], r.status)) {
- alert(NS.i18n.you_do_not_have_access_to_all_items_in_this_favorite);
+ alert(GIS.i18n.you_do_not_have_access_to_all_items_in_this_favorite);
}
else {
alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css 2014-08-26 11:58:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/styles/style.css 2014-10-23 09:11:36 +0000
@@ -52,35 +52,38 @@
font-family: arial, sans-serif, liberation sans, consolas !important;
}
+#init {
+ width: 100%;
+ text-align: center;
+ margin-top: 200px;
+ font-size: 15px;
+}
+
/* Scrollbar Webkit */
::-webkit-scrollbar {
- width: 9px;
- height: 9px;
+ width: 8px;
+ height: 7px;
border: 0 none;
}
::-webkit-scrollbar-track:horizontal {
background-color: #ddd;
margin: 0 2px;
- border-top: 2px solid white;
- border-bottom: 2px solid white;
-}
+ border-bottom: 1px solid white;
+}
+::-webkit-scrollbar-thumb:horizontal {
+ background-color: #bbb;
+ border-bottom: 1px solid white;
+}
+
::-webkit-scrollbar-track:vertical {
- background-color: #ddd;
+ background-color: #e1e1e1;
margin: 2px 0;
border-right: 2px solid white;
- border-left: 2px solid white;
-}
-
-::-webkit-scrollbar-thumb:horizontal {
- background-color: #bbb;
- border-top: 2px solid white;
- border-bottom: 2px solid white;
}
::-webkit-scrollbar-thumb:vertical {
background-color: #bbb;
border-right: 2px solid white;
- border-left: 2px solid white;
}
/* Scrollbar */