Commit 42d73080 by Torkel Ödegaard

fix: save as enter key now works and folder selection also works, fixes #10464

parent 5eb36e65
...@@ -86,7 +86,7 @@ export class DashboardSrv { ...@@ -86,7 +86,7 @@ export class DashboardSrv {
save(clone, options) { save(clone, options) {
options = options || {}; options = options || {};
options.folderId = this.dash.meta.folderId; options.folderId = options.folderId || this.dash.meta.folderId;
return this.backendSrv return this.backendSrv
.saveDashboard(clone, options) .saveDashboard(clone, options)
......
...@@ -9,29 +9,21 @@ ...@@ -9,29 +9,21 @@
</div> </div>
<input type="text" <input type="text"
class="gf-form-input max-width-10" class="gf-form-input max-width-10"
ng-show="ctrl.createNewFolder" ng-if="ctrl.createNewFolder"
give-focus="ctrl.createNewFolder" give-focus="ctrl.createNewFolder"
ng-model="ctrl.newFolderName" ng-model="ctrl.newFolderName"
ng-model-options="{ debounce: 400 }" ng-model-options="{ debounce: 400 }"
ng-class="{'validation-error': !ctrl.isNewFolderNameValid()}"
ng-change="ctrl.newFolderNameChanged()" /> ng-change="ctrl.newFolderNameChanged()" />
</div> </div>
<div class="gf-form" ng-show="ctrl.createNewFolder"> <div class="gf-form" ng-if="ctrl.createNewFolder">
<label class="gf-form-label text-success" <button class="btn btn-inverse"
ng-show="ctrl.newFolderNameTouched && !ctrl.hasValidationError">
<i class="fa fa-check"></i>
</label>
</div>
<div class="gf-form" ng-show="ctrl.createNewFolder">
<button class="gf-form-label"
ng-click="ctrl.createFolder($event)" ng-click="ctrl.createFolder($event)"
ng-disabled="!ctrl.newFolderNameTouched || ctrl.hasValidationError"> ng-disabled="!ctrl.newFolderNameTouched || ctrl.hasValidationError">
<i class="fa fa-fw fa-save"></i>&nbsp;Create <i class="fa fa-fw fa-save"></i>&nbsp;Create
</button> </button>
</div> </div>
<div class="gf-form" ng-show="ctrl.createNewFolder"> <div class="gf-form" ng-if="ctrl.createNewFolder">
<button class="gf-form-label" <button class="btn btn-inverse" ng-click="ctrl.cancelCreateFolder($event)">
ng-click="ctrl.cancelCreateFolder($event)">
Cancel Cancel
</button> </button>
</div> </div>
......
...@@ -13,7 +13,7 @@ const template = ` ...@@ -13,7 +13,7 @@ const template = `
</a> </a>
</div> </div>
<form name="ctrl.saveForm" ng-submit="ctrl.save()" class="modal-content" novalidate> <form name="ctrl.saveForm" class="modal-content" novalidate>
<div class="p-t-2"> <div class="p-t-2">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-7">New name</label> <label class="gf-form-label width-7">New name</label>
...@@ -22,8 +22,6 @@ const template = ` ...@@ -22,8 +22,6 @@ const template = `
<div class="gf-form"> <div class="gf-form">
<folder-picker initial-folder-id="ctrl.folderId" <folder-picker initial-folder-id="ctrl.folderId"
on-change="ctrl.onFolderChange($folder)" on-change="ctrl.onFolderChange($folder)"
enter-folder-creation="ctrl.onEnterFolderCreation()"
exit-folder-creation="ctrl.onExitFolderCreation()"
enable-create-new="true" enable-create-new="true"
label-class="width-7"> label-class="width-7">
</folder-picker> </folder-picker>
...@@ -31,7 +29,7 @@ const template = ` ...@@ -31,7 +29,7 @@ const template = `
</div> </div>
<div class="gf-form-button-row text-center"> <div class="gf-form-button-row text-center">
<button type="submit" class="btn btn-success" ng-disabled="ctrl.saveForm.$invalid || !ctrl.isValidFolderSelection">Save</button> <button type="submit" class="btn btn-success" ng-click="ctrl.save()">Save</button>
<a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a> <a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a>
</div> </div>
</form> </form>
...@@ -41,7 +39,6 @@ const template = ` ...@@ -41,7 +39,6 @@ const template = `
export class SaveDashboardAsModalCtrl { export class SaveDashboardAsModalCtrl {
clone: any; clone: any;
folderId: any; folderId: any;
isValidFolderSelection = true;
dismiss: () => void; dismiss: () => void;
/** @ngInject */ /** @ngInject */
...@@ -69,25 +66,17 @@ export class SaveDashboardAsModalCtrl { ...@@ -69,25 +66,17 @@ export class SaveDashboardAsModalCtrl {
} }
save() { save() {
return this.dashboardSrv.save(this.clone).then(this.dismiss); return this.dashboardSrv.save(this.clone, { folderId: this.folderId }).then(this.dismiss);
}
onEnterFolderCreation() {
this.isValidFolderSelection = false;
}
onExitFolderCreation() {
this.isValidFolderSelection = true;
} }
keyDown(evt) { keyDown(evt) {
if (this.isValidFolderSelection && evt.keyCode === 13) { if (evt.keyCode === 13) {
this.save(); this.save();
} }
} }
onFolderChange(folder) { onFolderChange(folder) {
this.clone.folderId = folder.id; this.folderId = folder.id;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment