Merge pull request #1896 from StantonVentures/textbox_editing_fix

Textbox editing fix
This commit is contained in:
Arik Fraimovich 2017-09-13 16:03:22 +03:00 committed by GitHub
commit e76efc9cdf
3 changed files with 18 additions and 9 deletions

View File

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

View File

@ -4,11 +4,11 @@
</div>
<div class="modal-body">
<div class="form-group">
<textarea class="form-control" ng-model="$ctrl.widget.text" rows="3"></textarea>
<textarea class="form-control" ng-model="$ctrl.widget.new_text" rows="3"></textarea>
</div>
<div ng-show="$ctrl.widget.text">
<div ng-show="$ctrl.widget.new_text">
<strong>Preview:</strong>
<p ng-bind-html="$ctrl.widget.text | markdown"></p>
<p ng-bind-html="$ctrl.widget.new_text | markdown"></p>
</div>
</div>

View File

@ -15,6 +15,8 @@ const EditTextBoxComponent = {
this.widget = this.resolve.widget;
this.saveWidget = () => {
this.saveInProgress = true;
if (this.widget.new_text !== this.widget.existing_text) {
this.widget.text = this.widget.new_text;
this.widget.$save().then(() => {
this.close();
}).catch(() => {
@ -22,6 +24,9 @@ const EditTextBoxComponent = {
}).finally(() => {
this.saveInProgress = false;
});
} else {
this.close();
}
};
},
};
@ -30,6 +35,8 @@ function DashboardWidgetCtrl($location, $uibModal, $window, Events, currentUser)
this.canViewQuery = currentUser.hasPermission('view_query');
this.editTextBox = () => {
this.widget.existing_text = this.widget.text;
this.widget.new_text = this.widget.text;
$uibModal.open({
component: 'editTextBox',
resolve: {