Commit 760dced8 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Christian Kuhn
Browse files

[FEATURE] Add option to edit metadata of file via ContextMenu

To further improve the FileList and to ease the use for
editors, the context menu for files has been extended
by a new option, which allows editing of the files' metadata.

Resolves: #94524
Releases: master
Change-Id: I8a3772a544a906c660ceac26703886a4649c1e88
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69802

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 4488cffd
......@@ -40,6 +40,18 @@ class ContextMenuActions {
);
}
public static editMetadata(): void {
const metadataUid: string = $(this).data('metadata-uid');
if (!metadataUid) {
return;
}
top.TYPO3.Backend.ContentContainer.setUrl(
top.TYPO3.settings.FormEngine.moduleUrl
+ '&edit[sys_file_metadata][' + parseInt(metadataUid, 10) + ']=edit'
+ '&returnUrl=' + ContextMenuActions.getReturnUrl()
);
}
public static editFileStorage(table: string, uid: string): void {
top.TYPO3.Backend.ContentContainer.setUrl(
top.TYPO3.settings.FormEngine.moduleUrl
......
.. include:: ../../Includes.txt
===============================================================
Feature: #94524 - Edit metadata for a file via the context menu
===============================================================
See :issue:`94524`
Description
===========
Editing metadata of files is an important task for editors.
To ease the use, the context menu for files has been extended
by a new option "Edit metadata of this file", which can be
used to direly jump into the corresponding editing mask.
Impact
======
It's now possible to edit a files' metadata directly via the
context menu.
.. index:: Backend, ext:filelist
......@@ -41,10 +41,15 @@ class FileProvider extends AbstractProvider
*/
protected $itemsConfiguration = [
'edit' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.edit',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent',
'iconIdentifier' => 'actions-page-open',
'callbackAction' => 'editFile'
],
'editMetadata' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata',
'iconIdentifier' => 'actions-open',
'callbackAction' => 'editMetadata'
],
'rename' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.rename',
'iconIdentifier' => 'actions-edit-rename',
......@@ -150,6 +155,9 @@ class FileProvider extends AbstractProvider
case 'edit':
$canRender = $this->canBeEdited();
break;
case 'editMetadata':
$canRender = $this->canEditMetadata();
break;
case 'info':
$canRender = $this->canShowInfo();
break;
......@@ -199,6 +207,18 @@ class FileProvider extends AbstractProvider
&& $this->record->isTextFile();
}
/**
* @return bool
*/
protected function canEditMetadata(): bool
{
return $this->isFile()
&& $this->record->isIndexed()
&& $this->record->checkActionPermission('editMeta')
&& $this->record->getMetaData()->offsetExists('uid')
&& $this->backendUser->check('tables_modify', 'sys_file_metadata');
}
/**
* @return bool
*/
......@@ -401,6 +421,11 @@ class FileProvider extends AbstractProvider
'data-button-ok-text' => htmlspecialchars($okText),
];
}
if ($itemName === 'editMetadata') {
$attributes += [
'data-metadata-uid' => htmlspecialchars((string)$this->record->getMetaData()->offsetGet('uid'))
];
}
return $attributes;
}
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r,s){"use strict";o=__importDefault(o);class i{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+i.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFilemount(t,e){const n=e.split(":");2===n.length&&top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_filemounts][0]=new&defVals[sys_filemounts][base]="+encodeURIComponent(n[0])+"&defVals[sys_filemounts][path]="+encodeURIComponent(n[1])+"&returnUrl="+i.getReturnUrl())}static deleteFile(t,e){const a=o.default(this),s=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+i.getReturnUrl())};if(!a.data("title"))return void s();r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o.default(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.target.name&&s(),r.dismiss()})}static copyFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const a=o.default(this),s=a.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+i.getReturnUrl())};if(!s)return void l();r.confirm(s,a.data("message"),n.SeverityEnum.warning,[{text:o.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o.default(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),r.dismiss()})}static dropInto(t,e,n){const a=o.default(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+i.getReturnUrl())}static dropMoveInto(t,e){i.dropInto.bind(o.default(this))(t,e,"move")}static dropCopyInto(t,e){i.dropInto.bind(o.default(this))(t,e,"copy")}}return i}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r,s){"use strict";o=__importDefault(o);class i{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editMetadata(){const t=o.default(this).data("metadata-uid");t&&top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_metadata]["+parseInt(t,10)+"]=edit&returnUrl="+i.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+i.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFilemount(t,e){const n=e.split(":");2===n.length&&top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_filemounts][0]=new&defVals[sys_filemounts][base]="+encodeURIComponent(n[0])+"&defVals[sys_filemounts][path]="+encodeURIComponent(n[1])+"&returnUrl="+i.getReturnUrl())}static deleteFile(t,e){const a=o.default(this),s=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+i.getReturnUrl())};if(!a.data("title"))return void s();r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o.default(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.target.name&&s(),r.dismiss()})}static copyFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const a=o.default(this),s=a.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+i.getReturnUrl())};if(!s)return void l();r.confirm(s,a.data("message"),n.SeverityEnum.warning,[{text:o.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o.default(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),r.dismiss()})}static dropInto(t,e,n){const a=o.default(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+i.getReturnUrl())}static dropMoveInto(t,e){i.dropInto.bind(o.default(this))(t,e,"move")}static dropCopyInto(t,e){i.dropInto.bind(o.default(this))(t,e,"copy")}}return i}));
\ No newline at end of file
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