← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10322: (DV) User access for favorites.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 10322 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-03-19 18:07:33 +0100
message:
  (DV) User access for favorites.
modified:
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css
  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/scripts/app.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-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-03-19 16:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-03-19 17:04:42 +0000
@@ -1023,7 +1023,7 @@
 			createButton,
 			updateButton,
 			cancelButton,
-			mapWindow,
+			favoriteWindow,
 
 		// Vars
 			windowWidth = 500,
@@ -1436,9 +1436,7 @@
 												params: Ext.encode(favorite),
 												success: function() {
 													pt.favorite = favorite;
-
 													//pt.viewport.interpretationButton.enable();
-
 													pt.store.tables.loadStore();
 												}
 											});

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css	2013-03-19 16:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css	2013-03-19 17:04:42 +0000
@@ -107,13 +107,6 @@
 	cursor: default !important;
 }
 
-/*
-.pt-invisible .x-form-item-body {
-    display: none;
-}
-*/
-
-
 
 	/* Collapse splitter column */
 .x-splitter {

=== 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	2013-03-15 16:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/css/style.css	2013-03-19 17:04:42 +0000
@@ -39,14 +39,53 @@
 	user-select: none;
 }
 
+	/* Scrollbar Webkit */
+::-webkit-scrollbar {
+    width: 9px;
+    height: 9px;
+    border: 0 none;
+}
+
+::-webkit-scrollbar-track:horizontal {
+    background-color: #ddd;
+    margin: 0 2px;
+    border-top: 2px solid white;
+    border-bottom: 2px solid white;
+}
+::-webkit-scrollbar-track:vertical {
+    background-color: #ddd;
+    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 */
+.x-scroller-vertical {
+	border: 0 none;
+}
+
+	/* Disabled icons */
+.disabled {
+	opacity: 0.4;
+	cursor: default !important;
+}
+
+	/* Options border */
 .dv-accordion-options .x-panel-body-default {
 	border: 0 none;
 }
 
-.dv-invisible .x-form-item-body { /* Disable class invisible */
-    display: none;
-}
-
 .x-splitter { /* Splitter column */
     display: none;
 }
@@ -118,15 +157,7 @@
 	background: url('../images/grid-delete_16.png') no-repeat;
 	margin-left: 4px;
 }
-.dv-grid-row-icon-disabled img.dv-grid-row-icon-edit,
-.dv-grid-row-icon-disabled img.dv-grid-row-icon-overwrite,
-.dv-grid-row-icon-disabled img.dv-grid-row-icon-delete {
-	opacity: 0;
-	filter:Alpha(opacity=0);
-}
-.dv-grid-row-icon-disabled * {
-	cursor: default !important;
-}
+
 .dv-grid-row-icon-disabled img.dv-grid-row-icon-sharing,
 .dv-grid-row-icon-disabled img.dv-grid-row-icon-dashboard {
 	cursor: pointer !important;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-03-19 14:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-03-19 17:04:42 +0000
@@ -1583,7 +1583,7 @@
 
         },
         favorite: Ext.create('Ext.data.Store', {
-            fields: ['id', 'name', 'lastUpdated', 'userId'],
+            fields: ['id', 'name', 'lastUpdated', 'access'],
             proxy: {
                 type: 'ajax',
                 reader: {
@@ -2630,7 +2630,7 @@
 			createButton,
 			updateButton,
 			cancelButton,
-			mapWindow,
+			favoriteWindow,
 
 		// Vars
 			windowWidth = 500,
@@ -2659,10 +2659,6 @@
 			if (DV.c.rendered) {
 				favorite = {};
 
-				// Server sync
-				//DV.c.lastMonth = DV.c.reportingMonth;
-				//DV.c.lastQuarter = DV.c.reportingQuarter;
-
 				favorite.type = DV.c.type;
 				favorite.series = DV.c.dimension.series;
 				favorite.category = DV.c.dimension.category;
@@ -2948,15 +2944,15 @@
 					width: windowCmpWidth - 88,
 					renderer: function(value, metaData, record) {
 						var fn = function() {
-							var el = Ext.get(record.data.id);
-							if (el) {
-								el = el.parent('td');
-								el.addClsOnOver('link');
-								el.favoriteId = record.data.id;
-								el.hideWindow = function() {
+							var element = Ext.get(record.data.id);
+							if (element) {
+								element = element.parent('td');
+								element.addClsOnOver('link');
+								element.load = function() {
 									favoriteWindow.hide();
+									DV.exe.execute(record.data.id);
 								};
-								el.dom.setAttribute('onclick', 'Ext.get(this).hideWindow(); DV.exe.execute(Ext.get(this).favoriteId);');
+								element.dom.setAttribute('onclick', 'Ext.get(this).load();');
 							}
 						};
 
@@ -2973,16 +2969,13 @@
 						{
 							iconCls: 'dv-grid-row-icon-edit',
 							getClass: function(value, metaData, record) {
-								if (DV.init.user.isAdmin) {
-									return 'tooltip-favorite-edit';
-								}
+								return 'tooltip-favorite-edit' + (!record.data.access.update ? ' disabled' : '');
 							},
 							handler: function(grid, rowIndex, colIndex, col, event) {
-								var record = this.up('grid').store.getAt(rowIndex),
-									id = record.data.id;
+								var record = this.up('grid').store.getAt(rowIndex);
 
-								if (DV.init.user.isAdmin) {
-									nameWindow = new NameWindow(id);
+								if (record.data.access.update) {
+									nameWindow = new NameWindow(record.data.id);
 									nameWindow.show();
 								}
 							}
@@ -2990,96 +2983,90 @@
 						{
 							iconCls: 'dv-grid-row-icon-overwrite',
 							getClass: function(value, metaData, record) {
-								if (DV.init.user.isAdmin) {
-									return 'tooltip-favorite-overwrite';
-								}
+								return 'tooltip-favorite-overwrite' + (!record.data.access.update ? ' disabled' : '');
 							},
 							handler: function(grid, rowIndex, colIndex, col, event) {
 								var record = this.up('grid').store.getAt(rowIndex),
-									id = record.data.id,
-									name = record.data.name,
-									message = 'Overwrite favorite?\n\n' + name,
+									message,
+									favorite;
+
+								if (record.data.access.update) {
+									message = 'Overwrite favorite?\n\n' + record.data.name;
 									favorite = getBody();
 
-								if (favorite) {
-									favorite.name = name;
+									if (favorite) {
+										favorite.name = record.data.name;
+
+										if (confirm(message)) {
+											Ext.Ajax.request({
+												url: DV.init.contextPath + '/api/charts/' + record.data.id,
+												method: 'PUT',
+												headers: {'Content-Type': 'application/json'},
+												params: Ext.encode(favorite),
+												success: function() {
+													//pt.favorite = favorite;
+													DV.cmp.toolbar.share.enable();
+													DV.store.favorite.loadStore();
+												}
+											});
+										}
+									}
+								}
+								else {
+									alert('Please create a table first'); //i18n
+								}
+							}
+						},
+						{
+							iconCls: 'dv-grid-row-icon-sharing',
+							getClass: function(value, metaData, record) {
+								return 'tooltip-favorite-sharing' + (!record.data.access.update ? ' disabled' : '');
+							},
+							handler: function(grid, rowIndex) {
+								var record = this.up('grid').store.getAt(rowIndex);
+
+								if (record.data.access.update) {
+									Ext.Ajax.request({
+										url: DV.init.contextPath + '/api/sharing?type=chart&id=' + record.data.id,
+										method: 'GET',
+										failure: function(r) {
+											DV.util.mask.hideMask();
+											alert(r.responseText);
+										},
+										success: function(r) {
+											var sharing = Ext.decode(r.responseText),
+												window = DV.app.SharingWindow(sharing);
+											window.show();
+										}
+									});
+								}
+							}
+						},
+						{
+							iconCls: 'dv-grid-row-icon-delete',
+							getClass: function(value, metaData, record) {
+								return 'tooltip-favorite-delete' + (!record.data.access['delete'] ? ' disabled' : '');
+							},
+							handler: function(grid, rowIndex, colIndex, col, event) {
+								var record = this.up('grid').store.getAt(rowIndex),
+									message;
+
+								if (record.data.access['delete']) {
+									message = 'Delete favorite?\n\n' + record.data.name;
 
 									if (confirm(message)) {
 										Ext.Ajax.request({
-											url: DV.init.contextPath + '/api/charts/' + id,
-											method: 'PUT',
-											headers: {'Content-Type': 'application/json'},
-											params: Ext.encode(favorite),
+											url: pt.baseUrl + '/api/charts/' + record.data.id,
+											method: 'DELETE',
 											success: function() {
-												//pt.favorite = favorite;
-
-												//pt.viewport.interpretationButton.enable();
-
 												DV.store.favorite.loadStore();
 											}
 										});
 									}
 								}
-								else {
-									alert('Please create a table first'); //i18n
-								}
-							}
-						},
-						{
-							iconCls: 'dv-grid-row-icon-sharing',
-							getClass: function() {
-								return 'tooltip-favorite-sharing';
-							},
-							handler: function(grid, rowIndex) {
-								var record = this.up('grid').store.getAt(rowIndex),
-									id = record.data.id,
-									window;
-
-								Ext.Ajax.request({
-									url: DV.init.contextPath + '/api/sharing?type=chart&id=' + id,
-									method: 'GET',
-									failure: function(r) {
-										DV.util.mask.hideMask();
-										alert(r.responseText);
-									},
-									success: function(r) {
-										var sharing = Ext.decode(r.responseText);
-										window = DV.app.SharingWindow(sharing);
-										window.show();
-									}
-								});
-							}
-						},
-						{
-							iconCls: 'dv-grid-row-icon-delete',
-							getClass: function(value, metaData, record) {
-								if (DV.init.user.isAdmin) {
-									return 'tooltip-favorite-delete';
-								}
-							},
-							handler: function(grid, rowIndex, colIndex, col, event) {
-								var record = this.up('grid').store.getAt(rowIndex),
-									id = record.data.id,
-									name = record.data.name,
-									message = 'Delete favorite?\n\n' + name;
-
-								if (confirm(message)) {
-									Ext.Ajax.request({
-										url: DV.init.contextPath + '/api/charts/' + id,
-										method: 'DELETE',
-										success: function() {
-											DV.store.favorite.loadStore();
-										}
-									});
-								}
-							}
-						}
-					],
-					renderer: function(value, metaData, record) {
-						if (!DV.init.user.isAdmin && !record.data.user) {
-							metaData.tdCls = 'dv-grid-row-icon-disabled';
-						}
-					}
+							}
+						}
+					]
 				},
 				{
 					sortable: false,