Fixes dashboard textbox editing

Combines mozilla/redash PR’s 86 and 95.

There was a bug that saved textbox content on a dashboard when you
tried to close without saving. This fixes it.
This commit is contained in:
Alison 2017-07-26 23:15:22 -05:00
parent aae77a8b25
commit a795f1463b
3 changed files with 11 additions and 3 deletions

View File

@ -17,6 +17,7 @@ const AddWidgetDialog = {
this.query = {};
this.selected_query = undefined;
this.text = '';
this.existing_text = '';
this.widgetSizes = [{
name: 'Regular',
value: 1,

View File

@ -1,5 +1,5 @@
<div class="modal-header">
<button type="button" class="close" aria-label="Close" ng-click="$ctrl.close()"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" aria-label="Close" ng-click="$ctrl.closeWithoutSave()"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Edit TextBox</h4>
</div>
<div class="modal-body">
@ -13,6 +13,6 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.close()">Close</button>
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.closeWithoutSave()">Close</button>
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.saveWidget()">Save</button>
</div>

View File

@ -8,7 +8,7 @@ const EditTextBoxComponent = {
close: '&',
dismiss: '&',
},
controller(toastr) {
controller($rootScope, $location, $http, toastr) {
'ngInject';
this.saveInProgress = false;
@ -23,6 +23,10 @@ const EditTextBoxComponent = {
this.saveInProgress = false;
});
};
this.closeWithoutSave = () => {
this.widget.text = this.widget.existing_text;
this.close();
};
},
};
@ -30,11 +34,14 @@ function DashboardWidgetCtrl($location, $uibModal, $window, Events, currentUser)
this.canViewQuery = currentUser.hasPermission('view_query');
this.editTextBox = () => {
this.widget.existing_text = this.widget.text;
$uibModal.open({
component: 'editTextBox',
resolve: {
widget: this.widget,
},
backdrop: 'static',
keyboard: false,
});
};