Skip to content

Commit

Permalink
EZP-31602: Moving to trash confirmation modal is not updated after su…
Browse files Browse the repository at this point in the history
…b-items bulk move (#1744)

* EZP-31602: Moving to trash confirmation modal is not updated after sub-items bulk move

* After CR

* After CR

* After CR
  • Loading branch information
lucasOsti authored May 5, 2021
1 parent 64052bd commit 07b8ba8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
32 changes: 32 additions & 0 deletions src/bundle/Resources/public/js/scripts/admin.trash.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,38 @@
button.disabled = true;
button.classList.add('disabled');
};
const refreshTrashModal = (event) => {
const { numberOfSubitems } = event.detail;
const sendToTrashModal = document.querySelector('.ez-modal--trash-location');
const modalBody = sendToTrashModal.querySelector('.modal-body');
const modalSendToTrashButton = sendToTrashModal.querySelector('.modal-footer .ez-modal-button--send-to-trash');
const { contentName } = sendToTrashModal.dataset;

if (numberOfSubitems) {
const message = Translator.trans(
/*@Desc("Sending '%content_name%' and its %children_count% Content item(s) to Trash will also send the sub-items of this Location to Trash.")*/ 'trash_container.modal.message_main',
{
content_name: contentName,
children_count: numberOfSubitems,
},
'content'
);

modalBody.querySelector('.ez-modal__option-description').innerHTML = message;
} else {
const message = Translator.trans(
/*@Desc("Are you sure you want to send this Content item to Trash?")*/ 'trash.modal.message',
{},
'content'
);

modalBody.innerHTML = message;
modalSendToTrashButton.removeAttribute('disabled');
modalSendToTrashButton.classList.remove('disabled');
}
};

doc.body.addEventListener('ez-trash-modal-refresh', refreshTrashModal, false);

if (!confirmCheckbox) {
enableButton(submitButton);
Expand Down
10 changes: 10 additions & 0 deletions src/bundle/Resources/translations/content.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
<target state="new">Content '%name%' has been revealed.</target>
<note>key: content.reveal.success</note>
</trans-unit>
<trans-unit id="2720e3018fc8b1158cb728b1d5dc377ef7293b57" resname="trash.modal.message">
<source>Are you sure you want to send this Content item to Trash?</source>
<target state="new">Are you sure you want to send this Content item to Trash?</target>
<note>key: trash.modal.message</note>
</trans-unit>
<trans-unit id="1e6a1d97cca01a288e47d2d14479274b90e6c6c1" resname="trash_container.modal.message_main">
<source>Sending '%content_name%' and its %children_count% Content item(s) to Trash will also send the sub-items of this Location to Trash.</source>
<target state="new">Sending '%content_name%' and its %children_count% Content item(s) to Trash will also send the sub-items of this Location to Trash.</target>
<note>key: trash_container.modal.message_main</note>
</trans-unit>
<trans-unit id="4492a79e25635e7612f98971e02b4d0e6a408394" resname="user.delete.success">
<source>User with login '%login%' deleted.</source>
<target state="new">User with login '%login%' deleted.</target>
Expand Down
5 changes: 4 additions & 1 deletion src/bundle/Resources/views/content/locationview.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@
</div>
</div>
{% if form_location_trash is defined and form_user_delete is not defined %}
{% include '@ezdesign/content/modal_location_trash.html.twig' with {'form': form_location_trash} only %}
{% include '@ezdesign/content/modal_location_trash.html.twig' with {
'form': form_location_trash,
'content_name': ez_content_name(content)
} only %}
{% endif %}
{% if form_user_delete is defined %}
{% include '@ezdesign/content/modal_user_delete.html.twig' with {'form': form_user_delete} only %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% form_theme form '@ezdesign/form_fields.html.twig' %}

<div class="modal fade ez-modal ez-modal--send-to-trash ez-modal--trash-location" id="trash-location-modal" tabindex="-1" role="dialog">
<div
class="modal fade ez-modal ez-modal--send-to-trash ez-modal--trash-location"
id="trash-location-modal"
tabindex="-1"
role="dialog"
data-content-name="{{ content_name|default('') }}"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
Expand Down Expand Up @@ -44,7 +50,7 @@
{{ 'trash.form.cancel'|trans|desc('Cancel') }}
</button>
{{ form_widget(form.trash,
{'attr': {'class': 'btn-danger font-weight-bold disabled', 'disabled': true}})
{'attr': {'class': 'btn-danger font-weight-bold disabled ez-modal-button ez-modal-button--send-to-trash', 'disabled': true}})
}}
</div>
{{ form_end(form) }}
Expand Down

0 comments on commit 07b8ba8

Please sign in to comment.