← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13149: (PT) New share menu item: Embed plugin config.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 13149 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 11:27:37 +0100
message:
  (PT) New share menu item: Embed plugin config.
modified:
  dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json
  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/core.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/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-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties	2013-11-01 15:43:02 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/resources/org/hisp/dhis/pivot/i18n_module.properties	2013-12-04 12:50:08 +0000
@@ -143,4 +143,5 @@
 yearly=Yearly
 financial_oct=Financial October
 financial_july=Financial July
-financial_april=Financial April
\ No newline at end of file
+financial_april=Financial April
+plugin_config=Plugin config
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json	2013-11-25 13:57:03 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/i18n.json	2013-12-04 12:53:04 +0000
@@ -144,5 +144,6 @@
 "yearly",
 "financial_oct",
 "financial_july",
-"financial_april"
+"financial_april",
+"plugin_config"
 ]

=== 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-12-03 16:59:29 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-12-05 10:23:38 +0000
@@ -886,7 +886,7 @@
 
 								ns.app.stores.reportTable.loadStore();
 
-								ns.app.interpretationButton.enable();
+								ns.app.shareButton.enable();
 
 								window.destroy();
 							}
@@ -1125,7 +1125,7 @@
 
 													ns.app.stores.reportTable.loadStore();
 
-													ns.app.interpretationButton.enable();
+													ns.app.shareButton.enable();
 												}
 											});
 										}
@@ -1642,7 +1642,7 @@
 							headers: {'Content-Type': 'text/html'},
 							success: function() {
 								textArea.reset();
-								ns.app.interpretationButton.disable();
+								ns.app.shareButton.disable();
 								window.hide();
 							}
 						});
@@ -1675,7 +1675,7 @@
 				},
 				listeners: {
 					show: function(w) {
-						ns.core.web.window.setAnchorPosition(w, ns.app.interpretationButton);
+						ns.core.web.window.setAnchorPosition(w, ns.app.shareButton);
 
 						document.body.oncontextmenu = true;
 
@@ -1956,8 +1956,8 @@
 							valueEl.dom.uuidDimUuidsMap = uuidDimUuidsMap;
 							valueEl.dom.uuidObjectMap = uuidObjectMap;
 							valueEl.dom.setAttribute('onclick', 'this.onValueMouseClick(this.layout, this.response, this.uuidDimUuidsMap, this.uuidObjectMap, this.id);');
-							valueEl.dom.setAttribute('onmouseover', 'this.onValueMouseOver(this.id);');
-							valueEl.dom.setAttribute('onmouseout', 'this.onValueMouseOut(this.id);');
+							valueEl.dom.setAttribute('onmouseover', 'this.onValueMouseOver(this);');
+							valueEl.dom.setAttribute('onmouseout', 'this.onValueMouseOut(this);');
 						}
 					}
 				}
@@ -2409,6 +2409,9 @@
 			favoriteButton,
 			openTableLayoutTab,
 			downloadButton,
+			interpretationItem,
+			pluginItem,
+			shareButton,
 
 			accordionBody,
 			accordion,
@@ -4723,6 +4726,20 @@
 								window.open(ns.core.init.contextPath + '/api/analytics.jrxml' + ns.app.paramString, '_blank');
 							}
 						}
+					},
+					{
+						xtype: 'label',
+						text: NS.i18n.plugin_config,
+						style: 'padding:7px 5px 5px 7px; font-weight:bold'
+					},
+					{
+						text: 'JSON',
+						iconCls: 'ns-menu-item-datasource',
+						handler: function() {
+							if (ns.app.layout) {
+								alert(JSON.stringify(ns.core.service.layout.layout2plugin(ns.app.layout)));
+							}
+						}
 					}
 				],
 				listeners: {
@@ -4736,30 +4753,18 @@
 			}
 		});
 
-		interpretationButton = Ext.create('Ext.button.Button', {
-			text: NS.i18n.share,
-			menu: {},
+		interpretationItem = Ext.create('Ext.menu.Item', {
+			text: 'Write interpretation' + '&nbsp;&nbsp;',
+			iconCls: 'ns-menu-item-tablelayout',
 			disabled: true,
 			xable: function() {
 				if (ns.app.layout.id) {
 					this.enable();
-					this.disabledTooltip.destroy();
 				}
 				else {
-					if (ns.app.xLayout) {
-						this.disable();
-						this.createTooltip();
-					}
+					this.disable();
 				}
 			},
-			disabledTooltip: null,
-			createTooltip: function() {
-				this.disabledTooltip = Ext.create('Ext.tip.ToolTip', {
-					target: this.getEl(),
-					html: NS.i18n.save_load_favorite_before_sharing,
-					'anchor': 'bottom'
-				});
-			},
 			handler: function() {
 				if (ns.app.interpretationWindow) {
 					ns.app.interpretationWindow.destroy();
@@ -4768,10 +4773,94 @@
 
 				ns.app.interpretationWindow = InterpretationWindow();
 				ns.app.interpretationWindow.show();
+			}
+		});
+
+		pluginItem = Ext.create('Ext.menu.Item', {
+			text: 'Embed as plugin' + '&nbsp;&nbsp;',
+			iconCls: 'ns-menu-item-datasource',
+			disabled: true,
+			xable: function() {
+				if (ns.app.layout) {
+					this.enable();
+				}
+				else {
+					this.disable();
+				}
+			},
+			handler: function() {
+				var textArea,
+					window;
+
+				textArea = Ext.create('Ext.form.field.TextArea', {
+					width: 400,
+					height: 200,
+					readOnly: true,
+					cls: 'ns-textarea monospaced',
+					value: JSON.stringify(ns.core.service.layout.layout2plugin(ns.app.layout)),
+					listeners: {
+						afterrender: function(ta) {
+							Ext.defer(function() {
+								ta.selectText();
+							}, 50);
+						}
+					}
+				});
+
+				window = Ext.create('Ext.window.Window', {
+					title: 'Plugin configuration',
+					layout: 'fit',
+					modal: true,
+					resizable: false,
+					items: textArea,
+					bodyStyle: 'color:blue',
+					destroyOnBlur: true,
+					listeners: {
+						show: function(w) {
+							ns.core.web.window.setAnchorPosition(w, ns.app.shareButton);
+
+							document.body.oncontextmenu = true;
+
+							if (!w.hasDestroyOnBlurHandler) {
+								ns.core.web.window.addDestroyOnBlurHandler(w);
+							}
+						},
+						hide: function() {
+							document.body.oncontextmenu = function(){return false;};
+						}
+					}
+				});
+
+				window.show();
+			}
+		});
+
+		shareButton = Ext.create('Ext.button.Button', {
+			text: NS.i18n.share,
+			xableItems: function() {
+				interpretationItem.xable();
+				pluginItem.xable();
+			},
+			menu: {
+				cls: 'ns-menu',
+				shadow: false,
+				showSeparator: false,
+				items: [
+					interpretationItem,
+					pluginItem
+				],
+				listeners: {
+					afterrender: function() {
+						this.getEl().addCls('ns-toolbar-btn-menu');
+					},
+					show: function() {
+						shareButton.xableItems();
+					}
+				}
 			},
 			listeners: {
 				added: function() {
-					ns.app.interpretationButton = this;
+					ns.app.shareButton = this;
 				}
 			}
 		});
@@ -4822,7 +4911,7 @@
 					},
 					favoriteButton,
 					downloadButton,
-					interpretationButton,
+					shareButton,
 					'->',
 					defaultButton,
 					{
@@ -4997,7 +5086,7 @@
 			downloadButton.enable();
 
 			if (layout.id) {
-				interpretationButton.enable();
+				shareButton.enable();
 			}
 
 			// Set gui

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-12-03 17:05:57 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-12-05 10:23:38 +0000
@@ -643,6 +643,7 @@
 			support.prototype.str.toggleDirection = function(direction) {
 				return direction === 'DESC' ? 'ASC' : 'DESC';
 			};
+
 				// number
 			support.prototype.number = {};
 
@@ -1516,6 +1517,81 @@
 				return layout.showHierarchy && Ext.isObject(response.metaData.ouHierarchy) && response.metaData.ouHierarchy.hasOwnProperty(id);
 			};
 
+			service.layout.layout2plugin = function(layout) {
+				var layout = Ext.clone(layout),
+					dimensions = Ext.Array.clean([].concat(layout.columns || [], layout.rows || [], layout.filters || []));
+
+				if (Ext.isString(layout.id)) {
+					return {id: layout.id};
+				}
+
+				for (var i = 0, dimension, item; i < dimensions.length; i++) {
+					dimension = dimensions[i];
+
+					delete dimension.id;
+					delete dimension.ids;
+					delete dimension.type;
+					delete dimension.dimensionName;
+					delete dimension.objectName;
+
+					for (var j = 0, item; j < dimension.items.length; j++) {
+						item = dimension.items[j];
+
+						delete item.name;
+						delete item.code;
+						delete item.created;
+						delete item.lastUpdated;
+					}
+				}
+
+				if (layout.showTotals) {
+					delete layout.showTotals;
+				}
+
+				if (layout.showSubTotals) {
+					delete layout.showSubTotals;
+				}
+
+				if (!layout.hideEmptyRows) {
+					delete layout.hideEmptyRows;
+				}
+
+				if (!layout.showHierarchy) {
+					delete layout.showHierarchy;
+				}
+
+				if (layout.displayDensity === 'normal') {
+					delete layout.displayDensity;
+				}
+
+				if (layout.fontSize === 'normal') {
+					delete layout.fontSize;
+				}
+
+				if (layout.digitGroupSeparator === 'space') {
+					delete layout.digitGroupSeparator;
+				}
+
+				if (!layout.legendSet) {
+					delete layout.legendSet;
+				}
+
+				if (!layout.sorting) {
+					delete layout.sorting;
+				}
+
+				delete layout.parentGraphMap;
+				delete layout.reportingPeriod;
+				delete layout.organisationUnit;
+				delete layout.parentOrganisationUnit;
+				delete layout.regression;
+				delete layout.cumulative;
+				delete layout.sortOrder;
+				delete layout.topLimit;
+
+				return layout;
+			};
+
 			// response
 			service.response = {};
 

=== 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-12-03 11:12:47 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css	2013-12-04 17:23:27 +0000
@@ -204,6 +204,10 @@
 	background-color: #bac6d8;
 	text-align: center;
 }
+.pivot-dim-total.highlighted {
+	background-color: #adb8c9;
+}
+
 .pivot-dim-empty {
 	background-color: #dae6f8;
 	text-align: center;
@@ -977,3 +981,8 @@
 .ns-textarea .x-form-field {
 	font-size: 11px;
 }
+
+.ns-textarea.monospaced textarea {
+	font-family: monospace, consolas, courier new;
+	padding: 4px;
+}