Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
file_rename
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
file_rename
Commits
16fbaa0f
Commit
16fbaa0f
authored
1 year ago
by
Nikolay Grachev
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3374512
by jdhildeb, ilfelice, granik: Only compatible with Claro (admin) theme?
parent
3a987bb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
file_rename.module
+5
-33
5 additions, 33 deletions
file_rename.module
with
5 additions
and
33 deletions
file_rename.module
+
5
−
33
View file @
16fbaa0f
...
...
@@ -64,36 +64,6 @@ function file_rename_field_widget_single_element_form_alter(&$element, FormState
}
/**
* Beatify rename button position on image widget.
*
* Implements hook_preprocess_HOOK().
*/
function
file_rename_preprocess_image_widget
(
&
$variables
)
{
if
(
isset
(
$variables
[
'data'
][
'rename_link'
]))
{
// Place 'Rename' button next to 'Remove'.
$variables
[
'main_items'
][
'rename_link'
]
=
$variables
[
'data'
][
'rename_link'
];
unset
(
$variables
[
'data'
][
'rename_link'
]);
}
}
/**
* Beatify rename button position on file widget.
*
* Implements hook_preprocess_HOOK().
*
* @todo Multiple file field is not fully supported yet.
* On remove one of the files the Rename button disappears.
* See: https://www.drupal.org/project/drupal/issues/3177977
*/
function
file_rename_preprocess_file_managed_file
(
&
$variables
)
{
if
(
isset
(
$variables
[
'element'
][
'rename_link'
]))
{
// Place 'Rename' button next to 'Remove'.
$variables
[
'main_items'
][
'rename_link'
]
=
$variables
[
'element'
][
'rename_link'
];
unset
(
$variables
[
'element'
][
'rename_link'
]);
}
}
/**
* Add 'show rename link' setting to widget settings.
*
...
...
@@ -169,8 +139,10 @@ function file_rename_file_prerename(FileInterface $file) {
* @param array $form
* Current form.
*
* @return mixed
* Processed render element.
* @todo Multiple file field is not fully supported yet.
* On remove one of the files the Rename button disappears.
* See: https://www.drupal.org/project/drupal/issues/3177977
*
*/
function
_file_rename_widget_custom_process
(
array
$element
,
FormStateInterface
$form_state
,
array
$form
)
{
$parents_prefix
=
implode
(
'_'
,
$element
[
'#parents'
]);
...
...
@@ -186,7 +158,7 @@ function _file_rename_widget_custom_process(array $element, FormStateInterface $
->
getPathInfo
();
}
$file_id
=
$element
[
'#default_value'
][
'target_id'
];
$element
[
'rename_link'
]
=
[
$element
[
'
file_'
.
$file_id
][
'
rename_link'
]
=
[
'#name'
=>
$parents_prefix
.
'_rename_link'
,
'#type'
=>
'link'
,
'#title'
=>
t
(
'Rename'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment