Skip to content

Commit 966bc06

Browse files
Pytalnextcloud-command
authored andcommitted
Create new file/folder labels
Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 63912cc commit 966bc06

8 files changed

Lines changed: 40 additions & 10 deletions

File tree

apps/files/js/newfilemenu.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
templateName: t('files', 'New folder'),
5252
iconClass: 'icon-folder',
5353
fileType: 'folder',
54+
actionLabel: t('files', 'Create new folder'),
5455
actionHandler: function(name) {
5556
self.fileList.createDirectory(name);
5657
}
@@ -112,10 +113,12 @@
112113

113114
var newName = $target.attr('data-templatename');
114115
var fileType = $target.attr('data-filetype');
116+
var actionLabel = $target.attr('data-action-label');
115117
var $form = $(OCA.Files.Templates['newfilemenu_filename_form']({
116118
fileName: newName,
117119
cid: this.cid,
118-
fileType: fileType
120+
fileType: fileType,
121+
actionLabel,
119122
}));
120123

121124
//this.trigger('actionPerformed', action);
@@ -207,6 +210,7 @@
207210
iconClass: actionSpec.iconClass,
208211
fileType: actionSpec.fileType,
209212
useInput: actionSpec.useInput,
213+
actionLabel: actionSpec.actionLabel,
210214
actionHandler: actionSpec.actionHandler,
211215
checkFilename: actionSpec.checkFilename,
212216
shouldShow: actionSpec.shouldShow,

apps/files/js/templates.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,12 @@ templates['newfilemenu'] = template({"1":function(container,depth0,helpers,parti
344344
+ 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)))
345345
+ "\" data-action=\""
346346
+ 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)))
347+
+ "\" data-action-label=\""
348+
+ 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)))
347349
+ "\"><span class=\"icon "
348-
+ alias4(((helper = (helper = lookupProperty(helpers,"iconClass") || (depth0 != null ? lookupProperty(depth0,"iconClass") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"iconClass","hash":{},"data":data,"loc":{"start":{"line":7,"column":137},"end":{"line":7,"column":150}}}) : helper)))
350+
+ alias4(((helper = (helper = lookupProperty(helpers,"iconClass") || (depth0 != null ? lookupProperty(depth0,"iconClass") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"iconClass","hash":{},"data":data,"loc":{"start":{"line":7,"column":173},"end":{"line":7,"column":186}}}) : helper)))
349351
+ " svg\"></span><span class=\"displayname\">"
350-
+ 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)))
352+
+ 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)))
351353
+ "</span></a>\n </li>\n";
352354
},"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
353355
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
379381
+ 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)))
380382
+ "\" type=\"text\" value=\""
381383
+ 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)))
382-
+ "\" autocomplete=\"off\" autocapitalize=\"off\">\n <input type=\"submit\" value=\" \" class=\"icon-confirm\" />\n</form>\n";
384+
+ "\" autocomplete=\"off\" autocapitalize=\"off\">\n <input type=\"submit\" value=\" \" class=\"icon-confirm\" aria-label=\""
385+
+ 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":3,"column":65},"end":{"line":3,"column":80}}}) : helper)))
386+
+ "\" />\n</form>\n";
383387
},"useData":true});
384388
templates['operationprogressbar'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
385389
var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {

apps/files/js/templates/newfilemenu.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</li>
55
{{#each items}}
66
<li>
7-
<a href="#" class="menuitem" data-templatename="{{templateName}}" data-filetype="{{fileType}}" data-action="{{id}}"><span class="icon {{iconClass}} svg"></span><span class="displayname">{{displayName}}</span></a>
7+
<a href="#" class="menuitem" data-templatename="{{templateName}}" data-filetype="{{fileType}}" data-action="{{id}}" data-action-label="{{actionLabel}}"><span class="icon {{iconClass}} svg"></span><span class="displayname">{{displayName}}</span></a>
88
</li>
99
{{/each}}
1010
</ul>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<form class="filenameform">
22
<input id="{{cid}}-input-{{fileType}}" type="text" value="{{fileName}}" autocomplete="off" autocapitalize="off">
3-
<input type="submit" value=" " class="icon-confirm" />
3+
<input type="submit" value=" " class="icon-confirm" aria-label="{{actionLabel}}" />
44
</form>

apps/files/src/templates.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ window.addEventListener('DOMContentLoaded', function() {
8080
templateName: t('files', 'Templates'),
8181
iconClass: 'icon-template-add',
8282
fileType: 'file',
83+
actionLabel: t('files', 'Create new templates folder'),
8384
actionHandler(name) {
8485
initTemplatesFolder(name)
8586
menu.removeMenuEntry('template-init')
@@ -109,6 +110,7 @@ templates.forEach((provider, index) => {
109110
templateName: provider.label + provider.extension,
110111
iconClass: provider.iconClass || 'icon-file',
111112
fileType: 'file',
113+
actionLabel: provider.actionLabel,
112114
actionHandler(name) {
113115
TemplatePicker.open(name, provider)
114116
},

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/public/Files/Template/TemplateFileCreator.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ final class TemplateFileCreator implements \JsonSerializable {
3737
protected $iconClass;
3838
protected $ratio = null;
3939
protected $order = 100;
40+
/**
41+
* @since 27.0.0
42+
*/
43+
protected string $actionLabel;
4044

4145
/**
4246
* @since 21.0.0
@@ -103,6 +107,21 @@ public function getOrder(): int {
103107
return $this->order;
104108
}
105109

110+
/**
111+
* @since 27.0.0
112+
*/
113+
public function setActionLabel(string $actionLabel): TemplateFileCreator {
114+
$this->actionLabel = $actionLabel;
115+
return $this;
116+
}
117+
118+
/**
119+
* @since 27.0.0
120+
*/
121+
public function getActionLabel(): string {
122+
return $this->actionLabel;
123+
}
124+
106125
/**
107126
* @since 21.0.0
108127
*/
@@ -113,7 +132,8 @@ public function jsonSerialize(): array {
113132
'extension' => $this->fileExtension,
114133
'iconClass' => $this->iconClass,
115134
'mimetypes' => $this->mimetypes,
116-
'ratio' => $this->ratio
135+
'ratio' => $this->ratio,
136+
'actionLabel' => $this->actionLabel,
117137
];
118138
}
119139
}

0 commit comments

Comments
 (0)