From e21656c5504174b9726799cea2a8c66fac7f4fcb Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 9 Sep 2015 09:51:02 +0000 Subject: [PATCH] #1142 Dashboard editor: protects from unwanted "exit" without saving the modifications: - mark the dashboard as modified when a dashlet was added / moved / deleted - prevent clicking on the hyperlinks inside the preview of the dashboard Unrelated modification of the stylesheet to make "actions" buttons look nicer (no gap in the background color) when the displayed at a zoom level different from 100% (e.g. 90% or 75 %) SVN:trunk[3739] --- css/light-grey.css | 11 ++++++++--- css/light-grey.scss | 9 ++++++--- js/dashboard.js | 10 ++++++++++ js/dashlet.js | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/css/light-grey.css b/css/light-grey.css index 0a2cd2e45..df9cf2d9e 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -340,7 +340,7 @@ a.small_action { padding-left: 5px; padding-top: 2px; padding-bottom: 2px; - background: url(../images/actions_left.png) no-repeat left; + background: #e87c1e url(../images/actions_left.png) no-repeat left; } @@ -593,7 +593,7 @@ div.actions_menu > ul { */ padding-left: 5px; - background: url(../images/actions_left.png) no-repeat top left; + background: #e87c1e url(../images/actions_left.png) no-repeat top left; cursor: pointer; margin: 0; } @@ -1484,7 +1484,7 @@ img.first, img.last, img.next, img.prev { div.actions_button { float: right; - background: url("../images/actions_left.png") no-repeat scroll left top transparent; + background: #e87c1e url("../images/actions_left.png") no-repeat scroll left top transparent; padding-left: 5px; margin-top: 0; margin-right: 10px; @@ -1522,6 +1522,11 @@ select#org_id { } +.itop-dashboard a { + cursor: not-allowed; +} + + .dragHover { background: url(./ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png); } diff --git a/css/light-grey.scss b/css/light-grey.scss index 4f1ab67d1..f9a1398b2 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -272,7 +272,7 @@ a.small_action { padding-left: 5px; padding-top: 2px; padding-bottom: 2px; - background: url(../images/actions_left.png) no-repeat left; + background: $highlight-color url(../images/actions_left.png) no-repeat left; } .actions_details span{ background: url(../images/actions_right.png) no-repeat right; @@ -450,7 +450,7 @@ div.actions_menu > ul { display:block; nowidth:70px; /* Nasty work-around for IE... en attendant mieux */ padding-left: 5px; - background: url(../images/actions_left.png) no-repeat top left; + background: $highlight-color url(../images/actions_left.png) no-repeat top left; cursor: pointer; margin: 0; } @@ -1105,7 +1105,7 @@ img.prev, img.first, img.next, img.last { } div.actions_button { float:right; - background: url("../images/actions_left.png") no-repeat scroll left top transparent; + background: $highlight-color url("../images/actions_left.png") no-repeat scroll left top transparent; padding-left: 5px; margin-top: 0; margin-right: 10px; @@ -1134,6 +1134,9 @@ select#org_id { .itop-dashboard { background-color: #fff; } +.itop-dashboard a { + cursor: unquote("not-allowed"); +} .dragHover { background: url(./ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png); } diff --git a/js/dashboard.js b/js/dashboard.js index 4559de5d7..c7749d375 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -39,6 +39,10 @@ $(function() this.ajax_div = $('
'); this.element.after(this.ajax_div); this._make_draggable(); + + // Make sure we don't click on something we'll regret + $('.itop-dashboard').on('click', 'a', function(e) { e.preventDefault(); }); + }, // called when created, and later when changing options @@ -318,7 +322,13 @@ $(function() $.post(this.options.render_to, oParams, function(data){ me.ajax_div.html(data); me.add_dashlet_finalize(options, sDashletId, sDashletClass); + me.mark_as_modified(); }); + }, + on_dashlet_moved: function(oDashlet, oReceiver, bRefresh) + { + this._superApply(arguments); + this.mark_as_modified(); } }); }); diff --git a/js/dashlet.js b/js/dashlet.js index 7e44973ee..7794baf06 100644 --- a/js/dashlet.js +++ b/js/dashlet.js @@ -130,6 +130,7 @@ $(function() $('#dashlet_properties_'+iDashletId).remove(); this.element.remove(); $('#event_bus').trigger('dashlet-removed', {'dashlet_id': iDashletId, 'dashlet_class': sDashletClass, 'container': oContainer}); + $('.itop-dashboard').trigger('mark_as_modified'); } }); }); \ No newline at end of file