← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13156: (DV) New share menuitem: Embed plugin config.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 13156 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 13:13:12 +0100
message:
  (DV) New share menuitem: Embed plugin config.
modified:
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  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/core.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/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/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-05 10:23:38 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-12-05 12:11:45 +0000
@@ -4726,20 +4726,6 @@
 								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: {
@@ -4797,14 +4783,7 @@
 					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);
-						}
-					}
+					value: JSON.stringify(ns.core.service.layout.layout2plugin(ns.app.layout))
 				});
 
 				window = Ext.create('Ext.window.Window', {
@@ -4813,8 +4792,23 @@
 					modal: true,
 					resizable: false,
 					items: textArea,
-					bodyStyle: 'color:blue',
 					destroyOnBlur: true,
+					bbar: [
+						'->',
+						{
+							text: 'Format',
+							handler: function() {
+								textArea.setValue(JSON.stringify(ns.core.service.layout.layout2plugin(ns.app.layout), null, 2));
+
+							}
+						},
+						{
+							text: 'Select',
+							handler: function() {
+								textArea.selectText();
+							}
+						}
+					],
 					listeners: {
 						show: function(w) {
 							ns.core.web.window.setAnchorPosition(w, ns.app.shareButton);

=== 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-12-03 09:32:56 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-12-05 12:11:45 +0000
@@ -499,7 +499,7 @@
 
 								ns.app.stores.chart.loadStore();
 
-								ns.app.interpretationButton.enable();
+								ns.app.shareButton.enable();
 
 								window.destroy();
 							}
@@ -738,7 +738,7 @@
 
 													ns.app.stores.chart.loadStore();
 
-													ns.app.interpretationButton.enable();
+													ns.app.shareButton.enable();
 												}
 											});
 										}
@@ -1255,7 +1255,7 @@
 							headers: {'Content-Type': 'text/html'},
 							success: function() {
 								textArea.reset();
-								ns.app.interpretationButton.disable();
+								ns.app.shareButton.disable();
 								window.hide();
 							}
 						});
@@ -1288,7 +1288,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;
 
@@ -4422,30 +4422,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();
@@ -4454,10 +4442,102 @@
 
 				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))
+				});
+
+				window = Ext.create('Ext.window.Window', {
+					title: 'Plugin configuration',
+					layout: 'fit',
+					modal: true,
+					resizable: false,
+					items: textArea,
+					destroyOnBlur: true,
+					bbar: [
+						'->',
+						{
+							text: 'Format',
+							handler: function() {
+								textArea.setValue(JSON.stringify(ns.core.service.layout.layout2plugin(ns.app.layout), null, 2));
+
+							}
+						},
+						{
+							text: 'Select',
+							handler: function() {
+								textArea.selectText();
+							}
+						}
+					],
+					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;
 				}
 			}
 		});
@@ -4507,7 +4587,7 @@
 					},
 					favoriteButton,
 					downloadButton,
-					interpretationButton,
+					shareButton,
 					'->',
 					{
 						text: NS.i18n.table,
@@ -4668,7 +4748,7 @@
 			downloadButton.enable();
 
 			if (layout.id) {
-				interpretationButton.enable();
+				shareButton.enable();
 			}
 
 			// Set gui

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-12-05 10:26:33 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-12-05 12:11:45 +0000
@@ -1199,6 +1199,93 @@
 				return null;
 			};
 
+			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.showTrendLine) {
+					delete layout.showTrendLine;
+				}
+
+				if (!layout.targetLineValue) {
+					delete layout.targetLineValue;
+				}
+
+				if (!layout.targetLineTitle) {
+					delete layout.targetLineTitle;
+				}
+
+				if (!layout.baseLineValue) {
+					delete layout.baseLineValue;
+				}
+
+				if (!layout.baseLineTitle) {
+					delete layout.baseLineTitle;
+				}
+
+				if (layout.showValues) {
+					delete layout.showValues;
+				}
+
+				if (!layout.hideLegend) {
+					delete layout.hideLegend;
+				}
+
+				if (!layout.hideTitle) {
+					delete layout.hideTitle;
+				}
+
+				if (!layout.title) {
+					delete layout.title;
+				}
+
+				if (!layout.domainAxisTitle) {
+					delete layout.domainAxisTitle;
+				}
+
+				if (!layout.rangeAxisTitle) {
+					delete layout.rangeAxisTitle;
+				}
+
+				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-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css	2013-11-29 11:52:49 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css	2013-12-05 12:11:45 +0000
@@ -397,6 +397,10 @@
     background-image:url('../images/dl_image.png');
     padding-left: 18px;
 }
+.ns-menu-item-tablelayout {
+    background-image:url('../images/dl_tablelayout.png');
+    padding-left: 18px;
+}
 .ns-menu-item-datasource {
     background-image:url('../images/dl_datasource.png');
     padding-left: 18px;
@@ -812,6 +816,12 @@
 	font-size: 11px;
 }
 
+.ns-textarea.monospaced textarea {
+	font-family: monospace, consolas, courier new;
+	padding: 4px;
+	border: 0 none;
+}
+
 
 /*----------------------------------------------------------------------------
  * DV Tips