Hide new template directory entry after creating and allow setting existing directories

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2021-01-27 15:56:31 +01:00
parent 0111381529
commit 2d46971199
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 21 additions and 1 deletions

View File

@ -119,6 +119,11 @@
var lastPos;
var checkInput = function () {
// Special handling for the setup template directory
if ($target.attr('data-action') === 'template-init') {
return true;
}
var filename = $input.val();
try {
if (!Files.isFileNameValid(filename)) {
@ -198,7 +203,21 @@
iconClass: actionSpec.iconClass,
fileType: actionSpec.fileType,
actionHandler: actionSpec.actionHandler,
});
checkFilename: actionSpec.checkFilename
});
},
/**
* Remove a menu item from the "New" file menu
* @param {string} actionId
*/
removeMenuEntry: function(actionId) {
var index = this._menuItems.findIndex(function (actionSpec) {
return actionSpec.id === actionId;
});
if (index > -1) {
this._menuItems.splice(index, 1);
}
},
/**

View File

@ -82,6 +82,7 @@ window.addEventListener('DOMContentLoaded', function() {
fileType: 'file',
actionHandler(name) {
initTemplatesFolder(name)
menu.removeMenuEntry('template-init')
},
})
},