diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js index a101eccef2977..088d8ecf09c76 100644 --- a/apps/files/js/newfilemenu.js +++ b/apps/files/js/newfilemenu.js @@ -51,6 +51,7 @@ templateName: t('files', 'New folder'), iconClass: 'icon-folder', fileType: 'folder', + actionLabel: t('files', 'Create new folder'), actionHandler: function(name) { self.fileList.createDirectory(name); } @@ -112,10 +113,12 @@ var newName = $target.attr('data-templatename'); var fileType = $target.attr('data-filetype'); + var actionLabel = $target.attr('data-action-label'); var $form = $(OCA.Files.Templates['newfilemenu_filename_form']({ fileName: newName, cid: this.cid, - fileType: fileType + fileType: fileType, + actionLabel, })); //this.trigger('actionPerformed', action); @@ -207,6 +210,7 @@ iconClass: actionSpec.iconClass, fileType: actionSpec.fileType, useInput: actionSpec.useInput, + actionLabel: actionSpec.actionLabel, actionHandler: actionSpec.actionHandler, checkFilename: actionSpec.checkFilename, shouldShow: actionSpec.shouldShow, @@ -230,6 +234,8 @@ * Renders the menu with the currently set items */ render: function() { + console.log(JSON.stringify(this._menuItems, null, 2)) + const menuItems = this._menuItems.filter(item => !item.shouldShow || (item.shouldShow instanceof Function && item.shouldShow() === true)) this.$el.html(this.template({ uploadMaxHumanFileSize: 'TODO', diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index d9d333648cedf..315f697728e6c 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -344,10 +344,12 @@ templates['newfilemenu'] = template({"1":function(container,depth0,helpers,parti + alias4(((helper = (helper = lookupProperty(helpers,"fileType") || (depth0 != null ? lookupProperty(depth0,"fileType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"fileType","hash":{},"data":data,"loc":{"start":{"line":7,"column":84},"end":{"line":7,"column":96}}}) : helper))) + "\" data-action=\"" + alias4(((helper = (helper = lookupProperty(helpers,"id") || (depth0 != null ? lookupProperty(depth0,"id") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data,"loc":{"start":{"line":7,"column":111},"end":{"line":7,"column":117}}}) : helper))) + + "\" data-action-label=\"" + + alias4(((helper = (helper = lookupProperty(helpers,"actionLabel") || (depth0 != null ? lookupProperty(depth0,"actionLabel") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"actionLabel","hash":{},"data":data,"loc":{"start":{"line":7,"column":138},"end":{"line":7,"column":153}}}) : helper))) + "\">" - + alias4(((helper = (helper = lookupProperty(helpers,"displayName") || (depth0 != null ? lookupProperty(depth0,"displayName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data,"loc":{"start":{"line":7,"column":189},"end":{"line":7,"column":204}}}) : helper))) + + alias4(((helper = (helper = lookupProperty(helpers,"displayName") || (depth0 != null ? lookupProperty(depth0,"displayName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data,"loc":{"start":{"line":7,"column":225},"end":{"line":7,"column":240}}}) : helper))) + "\n \n"; },"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) { @@ -379,7 +381,9 @@ templates['newfilemenu_filename_form'] = template({"compiler":[8,">= 4.3.0"],"ma + alias4(((helper = (helper = lookupProperty(helpers,"fileType") || (depth0 != null ? lookupProperty(depth0,"fileType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"fileType","hash":{},"data":data,"loc":{"start":{"line":2,"column":26},"end":{"line":2,"column":38}}}) : helper))) + "\" type=\"text\" value=\"" + alias4(((helper = (helper = lookupProperty(helpers,"fileName") || (depth0 != null ? lookupProperty(depth0,"fileName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"fileName","hash":{},"data":data,"loc":{"start":{"line":2,"column":59},"end":{"line":2,"column":71}}}) : helper))) - + "\" autocomplete=\"off\" autocapitalize=\"off\">\n \n\n"; + + "\" autocomplete=\"off\" autocapitalize=\"off\">\n \n\n"; },"useData":true}); templates['operationprogressbar'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) { diff --git a/apps/files/js/templates/newfilemenu.handlebars b/apps/files/js/templates/newfilemenu.handlebars index 0d9ad9682caf8..756595212d936 100644 --- a/apps/files/js/templates/newfilemenu.handlebars +++ b/apps/files/js/templates/newfilemenu.handlebars @@ -4,7 +4,7 @@ {{#each items}}
  • - {{displayName}} + {{displayName}}
  • {{/each}} diff --git a/apps/files/js/templates/newfilemenu_filename_form.handlebars b/apps/files/js/templates/newfilemenu_filename_form.handlebars index 5fc37ecf7813b..2d5af97ee76c0 100644 --- a/apps/files/js/templates/newfilemenu_filename_form.handlebars +++ b/apps/files/js/templates/newfilemenu_filename_form.handlebars @@ -1,4 +1,4 @@
    - +
    diff --git a/apps/files/src/templates.js b/apps/files/src/templates.js index 3a4f0133f9413..735380a05af02 100644 --- a/apps/files/src/templates.js +++ b/apps/files/src/templates.js @@ -52,7 +52,7 @@ TemplatePickerRoot.id = 'template-picker' document.body.appendChild(TemplatePickerRoot) // Retrieve and init templates -let templates = loadState('files', 'templates', []) +let templates = loadState('files', 'templates', []) // TODO Add action labels? let templatesPath = loadState('files', 'templates_path', false) logger.debug('Templates providers', templates) logger.debug('Templates folder', { templatesPath }) @@ -80,6 +80,7 @@ window.addEventListener('DOMContentLoaded', function() { templateName: t('files', 'Templates'), iconClass: 'icon-template-add', fileType: 'file', + actionLabel: t('files', 'Create new templates folder'), actionHandler(name) { initTemplatesFolder(name) menu.removeMenuEntry('template-init')