dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19864
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8841: (GIS) Map loader + Fav/legend action button tooltips + System/user filter + Grids height auto adj...
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 8841 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-11-03 19:18:44 +0300
message:
(GIS) Map loader + Fav/legend action button tooltips + System/user filter + Grids height auto adjusted.
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/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-mapping/src/main/webapp/dhis-web-mapping/app/index.html'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html 2012-11-01 09:34:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html 2012-11-03 16:00:58 +0000
@@ -32,9 +32,7 @@
document.getElementById('slow').innerHTML = "<a href=''>SLOW CONNECTION?</a>";
</script>
-<!--
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
--->
<script type="text/javascript" src="../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
<script type="text/javascript">
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2012-11-02 20:09:03 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js 2012-11-03 16:00:58 +0000
@@ -641,25 +641,6 @@
fields: ['id', 'name'],
data: GIS.conf.period.periodTypes
});
-
- //GIS.store.organisationUnitHierarchy = Ext.create('Ext.data.TreeStore', {
- //proxy: {
- //type: 'ajax',
- //url: GIS.conf.url.path_gis + 'getOrganisationUnitChildren.action'
- //},
- //root: {
- //id: 'root',
- //expanded: true,
- //children: GIS.init.rootNodes
- //},
- //listeners: {
- //load: function(s, node, r) {
- //for (var i = 0; i < r.length; i++) {
- //r[i].data.text = GIS.util.jsonEncodeString(r[i].data.text);
- //}
- //}
- //}
- //});
GIS.store.organisationUnitLevels = Ext.create('Ext.data.Store', {
fields: ['id', 'name', 'level'],
@@ -807,7 +788,7 @@
});
GIS.store.maps = Ext.create('Ext.data.Store', {
- fields: ['id', 'name', 'lastUpdated', 'system'],
+ fields: ['id', 'name', 'lastUpdated', 'user'],
proxy: {
type: 'ajax',
reader: {
@@ -818,7 +799,7 @@
isLoaded: false,
pageSize: 10,
page: 1,
- defaultUrl: GIS.conf.url.path_api + 'maps.json?links=false',
+ defaultUrl: GIS.conf.url.path_api + 'maps.json?viewClass=detailed&links=false',
loadStore: function(url) {
this.proxy.url = url || this.defaultUrl;
@@ -1121,7 +1102,7 @@
if (!data.length) {
GIS.logg.push([data, base.widget.xtype + '.search.data: feature ids/names']);
- alert("no features"); //todo
+ alert('Layer has no organisation units'); //todo
return;
}
@@ -1614,6 +1595,7 @@
labelWidth: 70,
fieldLabel: 'System', //i18n
style: 'margin-bottom: 0',
+ disabled: !GIS.init.security.isAdmin,
value: id ? GIS.store.maps.getById(id).data.system : false
});
@@ -1629,44 +1611,52 @@
view,
map;
- if (name && layers.length) {
- for (var i = 0; i < layers.length; i++) {
- layer = layers[i];
- view = layer.base.widget.getView();
-
- // add
- view.layer = layer.base.id;
-
- // remove
- delete view.periodType;
- views.push(view);
- }
-
- map = {
- name: name,
- longitude: lonlat.lon,
- latitude: lonlat.lat,
- zoom: GIS.map.getZoom(),
- mapViews: views
- };
-
- if (!system) {
- map.user = {
- id: 'currentUser'
+ if (layers.length) {
+ if (name) {
+ for (var i = 0; i < layers.length; i++) {
+ layer = layers[i];
+ view = layer.base.widget.getView();
+
+ // add
+ view.layer = layer.base.id;
+
+ // remove
+ delete view.periodType;
+ views.push(view);
+ }
+
+ map = {
+ name: name,
+ longitude: lonlat.lon,
+ latitude: lonlat.lat,
+ zoom: GIS.map.getZoom(),
+ mapViews: views
};
- }
-
- Ext.Ajax.request({
- url: GIS.conf.url.path_api + 'maps/',
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- params: Ext.encode(map),
- success: function() {
- GIS.store.maps.loadStore();
-
- window.destroy();
+
+ if (!system) {
+ map.user = {
+ id: 'currentUser'
+ };
}
- });
+
+ Ext.Ajax.request({
+ url: GIS.conf.url.path_api + 'maps/',
+ method: 'POST',
+ headers: {'Content-Type': 'application/json'},
+ params: Ext.encode(map),
+ success: function() {
+ GIS.store.maps.loadStore();
+
+ window.destroy();
+ }
+ });
+ }
+ else {
+ alert('Please enter a name');
+ }
+ }
+ else {
+ alert('No layers to save');
}
}
});
@@ -1797,7 +1787,7 @@
var fn = function() {
var el = Ext.get(record.data.id).parent('td');
el.addClsOnOver('link');
- el.dom.setAttribute('onclick', 'GIS.cmp.mapWindow.destroy(); GIS.map.mapLoader = new GIS.obj.MapLoader(); GIS.map.mapLoader.load("' + record.data.id + '");');// GIS.util.map.getMap("' + record.data.id + '", true)');
+ el.dom.setAttribute('onclick', 'GIS.cmp.mapWindow.destroy(); GIS.map.mapLoader = new GIS.obj.MapLoader("' + record.data.id + '"); GIS.map.mapLoader.load();');
};
Ext.defer(fn, 100);
@@ -1812,14 +1802,27 @@
items: [
{
iconCls: 'gis-grid-row-icon-edit',
+ getClass: function() {
+ return 'tooltip-map-edit'; // tooltips removed if deleteArray is empty
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
- var id = this.up('grid').store.getAt(rowIndex).data.id;
- nameWindow = new NameWindow(id);
- nameWindow.show();
+ var record = this.up('grid').store.getAt(rowIndex),
+ id = record.data.id,
+ system = !record.data.user,
+ isAdmin = GIS.init.security.isAdmin;
+
+ if (isAdmin || (!isAdmin && !system)) {
+ var id = this.up('grid').store.getAt(rowIndex).data.id;
+ nameWindow = new NameWindow(id);
+ nameWindow.show();
+ }
}
},
{
iconCls: 'gis-grid-row-icon-overwrite',
+ getClass: function() {
+ return 'tooltip-map-overwrite'; // tooltips removed if deleteArray is empty
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
var record = this.up('grid').store.getAt(rowIndex),
id = record.data.id,
@@ -1832,8 +1835,8 @@
map,
message = 'Overwrite favorite?\n\n' + name;
- if (confirm(message)) {
- if (layers.length) {
+ if (layers.length) {
+ if (confirm(message)) {
for (var i = 0; i < layers.length; i++) {
layer = layers[i];
view = layer.base.widget.getView();
@@ -1864,10 +1867,21 @@
});
}
}
+ else {
+ alert('No layers to save'); //i18n
+ }
}
},
{
iconCls: 'gis-grid-row-icon-delete',
+ getClass: function(value, metaData, record) { // all tooltips removed if deleteArray is empty
+ var system = !record.data.user,
+ isAdmin = GIS.init.security.isAdmin;
+
+ if (isAdmin || (!isAdmin && !system)) {
+ return 'tooltip-map-delete';
+ }
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
var record = this.up('grid').store.getAt(rowIndex),
id = record.data.id,
@@ -1885,7 +1899,12 @@
}
}
}
- ]
+ ],
+ renderer: function(value, metaData, record) {
+ if (!GIS.init.security.isAdmin && !record.data.user) {
+ metaData.tdCls += ' gis-grid-row-icon-disabled';
+ }
+ }
}
],
store: GIS.store.maps,
@@ -1905,6 +1924,46 @@
this.store.page = 1;
this.store.loadStore();
},
+ afterrender: function() {
+ var fn = function() {
+ var editArray = document.getElementsByClassName('tooltip-map-edit'),
+ overwriteArray = document.getElementsByClassName('tooltip-map-overwrite'),
+ deleteArray = document.getElementsByClassName('tooltip-map-delete'),
+ len = deleteArray.length,
+ el;
+
+ for (var i = 0; i < len; i++) {
+ el = editArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Rename',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+
+ el = overwriteArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Overwrite',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+
+ el = deleteArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Delete',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+ }
+ };
+
+ Ext.defer(fn, 100);
+ },
itemmouseenter: function(grid, record, item) {
this.currentItem = Ext.get(item);
this.currentItem.removeCls('x-grid-row-over');
@@ -1947,7 +2006,7 @@
return mapWindow;
};
- GIS.obj.MapLoader = function() {
+ GIS.obj.MapLoader = function(id) {
var getMap,
setMap,
map,
@@ -1996,8 +2055,10 @@
};
loader = {
+ id: id,
load: function(id) {
- getMap(id);
+ this.id = id || this.id;
+ getMap(this.id);
},
callBack: function(widget) {
callbackRegister.push(widget);
@@ -2116,6 +2177,7 @@
legendSetGrid = Ext.create('Ext.grid.Panel', {
cls: 'gis-grid',
scroll: 'vertical',
+ height: true,
hideHeaders: true,
currentItem: null,
columns: [
@@ -2131,6 +2193,9 @@
items: [
{
iconCls: 'gis-grid-row-icon-edit',
+ getClass: function() {
+ return 'tooltip-legendset-edit';
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
var id = this.up('grid').store.getAt(rowIndex).data.id;
showUpdateLegendSet(id);
@@ -2138,9 +2203,18 @@
},
{
iconCls: 'gis-grid-row-icon-delete',
+ getClass: function() {
+ return 'tooltip-legendset-delete';
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
- var id = this.up('grid').store.getAt(rowIndex).data.id;
- deleteLegendSet(id);
+ var record = this.up('grid').store.getAt(rowIndex),
+ id = record.data.id,
+ name = record.data.name,
+ message = 'Delete legend set?\n\n' + name;
+
+ if (confirm(message)) {
+ deleteLegendSet(id);
+ }
}
}
]
@@ -2153,14 +2227,49 @@
store: legendSetStore,
listeners: {
render: function() {
+ var that = this,
+ maxHeight = GIS.cmp.region.center.getHeight() - 155,
+ height;
+
+ this.store.on('load', function() {
+ if (Ext.isDefined(that.setHeight)) {
+ height = 1 + that.store.getCount() * GIS.conf.layout.grid.row_height;
+ that.setHeight(height > maxHeight ? maxHeight : height);
+ window.doLayout();
+ }
+ });
+
this.store.load();
},
- resize: function() {
- var maxHeight = GIS.cmp.region.center.getHeight() - 155;
-
- if (this.getHeight() > maxHeight) {
- this.setHeight(maxHeight);
- }
+ afterrender: function() {
+ var fn = function() {
+ var editArray = document.getElementsByClassName('tooltip-legendset-edit'),
+ deleteArray = document.getElementsByClassName('tooltip-legendset-delete'),
+ len = editArray.length,
+ el;
+
+ for (var i = 0; i < len; i++) {
+ el = editArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Rename',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+
+ el = deleteArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Delete',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+ }
+ };
+
+ Ext.defer(fn, 100);
},
itemmouseenter: function(grid, record, item) {
this.currentItem = Ext.get(item);
@@ -2322,6 +2431,9 @@
items: [
{
iconCls: 'gis-grid-row-icon-delete',
+ getClass: function() {
+ return 'tooltip-legend-delete';
+ },
handler: function(grid, rowIndex, colIndex, col, event) {
var id = this.up('grid').store.getAt(rowIndex).data.id;
deleteLegend(id);
@@ -2345,6 +2457,26 @@
},
selectionchange: function() {
this.currentItem.removeCls('x-grid-row-focused');
+ },
+ afterrender: function() {
+ var fn = function() {
+ var deleteArray = document.getElementsByClassName('tooltip-legend-delete'),
+ len = deleteArray.length,
+ el;
+
+ for (var i = 0; i < len; i++) {
+ el = deleteArray[i];
+ Ext.create('Ext.tip.ToolTip', {
+ target: el,
+ html: 'Delete',
+ 'anchor': 'bottom',
+ anchorOffset: -14,
+ showDelay: 1000
+ });
+ }
+ };
+
+ Ext.defer(fn, 100);
}
}
});
@@ -2959,8 +3091,8 @@
'->',
{
text: 'Exit', //i18n
- handler: function() {
- alert('Exit');
+ handler: function() {
+ window.location.href = '../../dhis-web-commons-about/redirect.action';
}
},
{
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css 2012-10-30 17:51:51 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/styles/style.css 2012-11-03 11:15:24 +0000
@@ -14,6 +14,7 @@
* Checkbox
* NumberField
* Label
+ * Tooltip
*/
/* General */
@@ -456,6 +457,13 @@
background: url('../images/grid-delete_16.png') no-repeat;
margin-left: 4px;
}
+.gis-grid-row-icon-disabled img {
+ opacity: 0;
+ filter:Alpha(opacity=0);
+}
+.gis-grid-row-icon-disabled * {
+ cursor: default !important;
+}
.gis-grid .x-grid-cell-inner,
.gis-grid .x-grid-cell-inner * {
@@ -523,3 +531,22 @@
line-height: 21px;
}
+/* Tooltip */
+
+/* Tooltip */
+.x-tip {
+ border-radius: 2px;
+ padding: 1px 4px;
+ border: 1px solid #111;
+ background-color: #111;
+}
+
+.x-tip .x-tip-body {
+ font-size: 10px;
+ color: #fff;
+}
+
+.x-tip-anchor {
+ border-top-color: #111;
+}
+
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css 2012-07-30 09:51:01 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css 2012-11-03 09:10:29 +0000
@@ -352,7 +352,8 @@
background-image: linear-gradient(top, #f1f1f1,#f5f5f5);
}
-/* Tooltip */.x-tip {
+/* Tooltip */
+.x-tip {
border-radius: 2px;
padding: 1px 4px;
border: 1px solid #111;