Skip to content

Commit

Permalink
be able to close edit textbox w/o save
Browse files Browse the repository at this point in the history
getredash#54

Ignore my local branch name
  • Loading branch information
alison985 committed Jun 16, 2017
1 parent 2010969 commit cdbd2be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/app/pages/dashboards/add-widget-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const AddWidgetDialog = {
this.query = {};
this.selected_query = undefined;
this.text = '';
this.existing_text = '';
this.widgetSizes = [{
name: 'Regular',
value: 1,
Expand Down
4 changes: 2 additions & 2 deletions client/app/pages/dashboards/edit-text-box.html
Original file line number Diff line number Diff line change
@@ -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">
Expand All @@ -13,6 +13,6 @@ <h4 class="modal-title">Edit TextBox</h4>
</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>
7 changes: 6 additions & 1 deletion client/app/pages/dashboards/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const EditTextBoxComponent = {
close: '&',
dismiss: '&',
},
controller(toastr) {
controller($rootScope, $location, $http, toastr) {
'ngInject';

this.saveInProgress = false;
Expand All @@ -23,13 +23,18 @@ const EditTextBoxComponent = {
this.saveInProgress = false;
});
};
this.closeWithoutSave = () => {
this.widget.text = this.widget.existing_text;
this.close();
};
},
};

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: {
Expand Down

0 comments on commit cdbd2be

Please sign in to comment.