diff options
author | Julius Härtl <jus@bitgrid.net> | 2021-01-27 15:56:31 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2021-01-28 12:00:21 +0100 |
commit | 2d46971199eecb49b96d5031bdbad25e448d0b27 (patch) | |
tree | 95f457aba3ca0d8a6c40982434ad24e177682973 | |
parent | 01113815297b6f59b7eea96dcb55db2ec374e599 (diff) | |
download | nextcloud-server-2d46971199eecb49b96d5031bdbad25e448d0b27.tar.gz nextcloud-server-2d46971199eecb49b96d5031bdbad25e448d0b27.zip |
Hide new template directory entry after creating and allow setting existing directories
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | apps/files/js/newfilemenu.js | 21 | ||||
-rw-r--r-- | apps/files/src/templates.js | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js index 305af051271..742a5e95fe2 100644 --- a/apps/files/js/newfilemenu.js +++ b/apps/files/js/newfilemenu.js @@ -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); + } }, /** diff --git a/apps/files/src/templates.js b/apps/files/src/templates.js index c493e254caf..be41e864854 100644 --- a/apps/files/src/templates.js +++ b/apps/files/src/templates.js @@ -82,6 +82,7 @@ window.addEventListener('DOMContentLoaded', function() { fileType: 'file', actionHandler(name) { initTemplatesFolder(name) + menu.removeMenuEntry('template-init') }, }) }, |