Skip to content

Commit

Permalink
"Replace" actions for element select inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Sep 9, 2024
1 parent 55bebbb commit ce92893
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Content Management
- Improved the styling of element cards with thumbnails. ([#15692](https://github.com/craftcms/cms/pull/15692), [#15673](https://github.com/craftcms/cms/issues/15673))
- Elements within element selection inputs now have “Replace” actions.

### Administration
- All relation fields can now be selected as field layouts’ thumbnail providers. ([#15651](https://github.com/craftcms/cms/discussions/15651))
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@
'Replace files' => 'Replace files',
'Replace it' => 'Replace it',
'Replace the folder (all existing files will be deleted)' => 'Replace the folder (all existing files will be deleted)',
'Replace' => 'Replace',
'Replacing “{find}” with “{replace}”' => 'Replacing “{find}” with “{replace}”',
'Reply To' => 'Reply To',
'Reply-To Address' => 'Reply-To Address',
Expand Down
1 change: 1 addition & 0 deletions src/web/assets/cp/CpAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private function _registerTranslations(View $view): void
'Reorder',
'Replace it',
'Replace the folder (all existing files will be deleted)',
'Replace',
'Required',
'Rotate',
'Row could not be added. Maximum number of rows reached.',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/web/assets/cp/src/js/BaseElementSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ Craft.BaseElementSelectInput = Garnish.Base.extend(
}

if (this.settings.allowRemove) {
actions.push({
icon: 'arrows-rotate',
label: Craft.t('app', 'Replace'),
callback: () => {
this.removeElement($element);
this.showModal();
},
});

actions.push({
icon: 'remove',
label: Craft.t('app', 'Remove'),
Expand All @@ -452,7 +461,6 @@ Craft.BaseElementSelectInput = Garnish.Base.extend(
this.removeElement($element);
}
},
destructive: true,
});
}

Expand Down

0 comments on commit ce92893

Please sign in to comment.