Commit 2d0f5f06 by Marcus Efraimsson

dashfolders: support creating new folder when saving a dashboard. #10197

parent 7f9c0df4
...@@ -22,13 +22,16 @@ const template = ` ...@@ -22,13 +22,16 @@ 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"
label-class="width-7"> label-class="width-7">
</folder-picker> </folder-picker>
</div> </div>
</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">Save</button> <button type="submit" class="btn btn-success" ng-disabled="ctrl.saveForm.$invalid || !ctrl.isValidFolderSelection">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>
...@@ -38,6 +41,7 @@ const template = ` ...@@ -38,6 +41,7 @@ const template = `
export class SaveDashboardAsModalCtrl { export class SaveDashboardAsModalCtrl {
clone: any; clone: any;
folderId: any; folderId: any;
isValidFolderSelection = true;
dismiss: () => void; dismiss: () => void;
/** @ngInject */ /** @ngInject */
...@@ -68,8 +72,16 @@ export class SaveDashboardAsModalCtrl { ...@@ -68,8 +72,16 @@ export class SaveDashboardAsModalCtrl {
return this.dashboardSrv.save(this.clone).then(this.dismiss); return this.dashboardSrv.save(this.clone).then(this.dismiss);
} }
onEnterFolderCreation() {
this.isValidFolderSelection = false;
}
onExitFolderCreation() {
this.isValidFolderSelection = true;
}
keyDown(evt) { keyDown(evt) {
if (evt.keyCode === 13) { if (this.isValidFolderSelection && evt.keyCode === 13) {
this.save(); this.save();
} }
} }
......
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