Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-31602: merge up 2.5 -> 3.0 #1754

Merged
merged 4 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -116,6 +116,16 @@
<target state="new">Exit</target>
<note>key: tooltip.exit_label</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
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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/ui/form_fields.html.twig' %}

<div class="modal fade ez-modal ez-modal--no-header 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">
<button type="button" class="close" data-dismiss="modal" title="{{ 'trash.modal.close'|trans|desc('Close') }}">
Expand Down Expand Up @@ -40,7 +46,7 @@
</div>
<div class="modal-footer">
{{ form_widget(form.trash,
{'attr': {'class': 'btn-primary disabled ez-btn ez-btn--confirm-send-to-trash', 'disabled': true}})
{'attr': {'class': 'btn-danger font-weight-bold disabled ez-modal-button ez-modal-button--send-to-trash', 'disabled': true}})
}}
<button type="button" class="btn btn-secondary" data-dismiss="modal">
{{ 'trash.form.cancel'|trans|desc('Cancel') }}
Expand Down
25 changes: 20 additions & 5 deletions src/bundle/ui-dev/src/modules/sub-items/sub.items.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export default class SubItemsModule extends Component {
this.updateTotalCountState(totalCount - movedItems.length);
this.deselectAllItems();
this.discardActivePageItems();
this.updateTrashModal();

this.toggleBulkOperationStatusState(false);

Expand Down Expand Up @@ -403,7 +404,7 @@ export default class SubItemsModule extends Component {
),
};

window.eZ.helpers.notification.showSuccessNotification(message, () => { }, rawPlaceholdersMap);
window.eZ.helpers.notification.showSuccessNotification(message, () => {}, rawPlaceholdersMap);
}
}

Expand Down Expand Up @@ -549,7 +550,7 @@ export default class SubItemsModule extends Component {
),
};

window.eZ.helpers.notification.showSuccessNotification(message, () => { }, rawPlaceholdersMap);
window.eZ.helpers.notification.showSuccessNotification(message, () => {}, rawPlaceholdersMap);
}
}

Expand Down Expand Up @@ -652,6 +653,7 @@ export default class SubItemsModule extends Component {
this.updateTotalCountState(totalCount - deletedItems.length);
this.deselectAllItems();
this.discardActivePageItems();
this.updateTrashModal();

this.toggleBulkOperationStatusState(false);

Expand Down Expand Up @@ -946,7 +948,8 @@ export default class SubItemsModule extends Component {
isLoading={false}
size="medium"
footerChildren={this.renderDeleteConfirmationPopupFooter(selectionInfo)}
noHeader={true}>
noHeader={true}
>
<div className="m-sub-items__confirmation-modal-body">{confirmationMessage}</div>
</Popup>,
this.bulkActionModalContainer
Expand Down Expand Up @@ -974,7 +977,8 @@ export default class SubItemsModule extends Component {
isLoading={false}
size="medium"
footerChildren={this.renderHideConfirmationPopupFooter()}
noHeader={true}>
noHeader={true}
>
<div className="m-sub-items__confirmation-modal-body">{confirmationMessage}</div>
</Popup>,
this.bulkActionModalContainer
Expand Down Expand Up @@ -1002,7 +1006,8 @@ export default class SubItemsModule extends Component {
isLoading={false}
size="medium"
footerChildren={this.renderUnhideConfirmationPopupFooter()}
noHeader={true}>
noHeader={true}
>
<div className="m-sub-items__confirmation-modal-body">{confirmationMessage}</div>
</Popup>,
this.bulkActionModalContainer
Expand Down Expand Up @@ -1180,6 +1185,16 @@ export default class SubItemsModule extends Component {
);
}

updateTrashModal() {
document.body.dispatchEvent(
new CustomEvent('ez-trash-modal-refresh', {
detail: {
numberOfSubitems: this.state.totalCount,
},
})
);
}

render() {
const listTitle = Translator.trans(/*@Desc("Sub-items")*/ 'items_list.title', {}, 'sub_items');
const { selectedItems, activeView, totalCount, isDuringBulkOperation, activePageItems } = this.state;
Expand Down