Skip to content

Commit

Permalink
displays error & disables save when no dashboard name
Browse files Browse the repository at this point in the history
fixes getredash#76 and avoids the same error as getredash#54 (text box not-save)
  • Loading branch information
alison985 committed Jun 16, 2017
1 parent 984ecaf commit 892dce8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/app/pages/dashboards/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ function DashboardCtrl($rootScope, $routeParams, $location, $timeout, $q, $uibMo
};

this.editDashboard = () => {
this.dashboard.existing_name = this.dashboard.name;
$uibModal.open({
component: 'editDashboardDialog',
resolve: {
Expand Down
12 changes: 8 additions & 4 deletions client/app/pages/dashboards/edit-dashboard-dialog.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<div class="modal-header">
<button type="button" class="close" ng-click="$ctrl.dismiss()" ng-disabled="$ctrl.saveInProgress" aria-hidden="true">&times;</button>
<button type="button" class="close" ng-click="$ctrl.closeWithoutSave()" ng-disabled="$ctrl.saveInProgress" aria-hidden="true">&times;</button>
<h4 class="modal-title">Edit: {{$ctrl.dashboard.name}}</h4>
</div>
<div class="modal-body">
<p>
<input type="text" class="form-control" placeholder="Dashboard Name" ng-model="$ctrl.dashboard.name" required>
<form name="myForm">
<input name="dashboardName" type="text" class="form-control" placeholder="Dashboard Name" ng-model="$ctrl.dashboard.name" required>
</form>
</p>
<p ng-if="myForm.dashboardName.$invalid" class="alert alert-warning">A name is required.</p>


<div gridster="$ctrl.gridsterOptions" ng-if="$ctrl.items | notEmpty">
<ul>
Expand All @@ -16,6 +20,6 @@ <h4 class="modal-title">Edit: {{$ctrl.dashboard.name}}</h4>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.dismiss()">Close</button>
<button type="button" class="btn btn-primary" ng-disabled="$ctrl.saveInProgress" ng-click="$ctrl.saveDashboard()">Save</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 || myForm.dashboardName.$invalid" ng-click="$ctrl.saveDashboard()">Save</button>
</div>
4 changes: 4 additions & 0 deletions client/app/pages/dashboards/edit-dashboard-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const EditDashboardDialog = {
Events.record('create', 'dashboard');
}
};
this.closeWithoutSave = () => {
this.dashboard.name = this.dashboard.existing_name;
this.dismiss();
};
},
};

Expand Down

0 comments on commit 892dce8

Please sign in to comment.