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

[NodeBundle] Undo deleting pages #2706

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Kunstmaan/NodeBundle/Controller/NodeAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Esites\CustomerAdminBundle\Entity\User;
JZuidema marked this conversation as resolved.
Show resolved Hide resolved
use InvalidArgumentException;
use Kunstmaan\AdminBundle\Entity\BaseUser;
use Kunstmaan\AdminBundle\Entity\EntityInterface;
Expand All @@ -16,6 +17,7 @@
use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionMap;
use Kunstmaan\AdminBundle\Service\AclManager;
use Kunstmaan\AdminListBundle\AdminList\AdminList;
use Kunstmaan\AdminListBundle\AdminList\ItemAction\SimpleItemAction;
use Kunstmaan\AdminListBundle\AdminList\ListAction\SimpleListAction;
use Kunstmaan\NodeBundle\AdminList\DeletedNodeAdminListConfigurator;
use Kunstmaan\NodeBundle\AdminList\NodeAdminListConfigurator;
Expand Down Expand Up @@ -359,7 +361,6 @@ public function unPublishAction(Request $request, $id)
$node = $this->em->getRepository(Node::class)->find($id);

$nodeTranslation = $node->getNodeTranslation($this->locale, true);
$request = $this->get('request_stack')->getCurrentRequest();
$this->nodePublisher->chooseHowToUnpublish($request, $nodeTranslation, $this->translator);

return $this->redirect($this->generateUrl('KunstmaanNodeBundle_nodes_edit', array('id' => $node->getId())));
Expand Down Expand Up @@ -512,7 +513,8 @@ function (EntityInterface $item) use ($locale, $acl) {

return null;
},
'undo'
'undo',
'@KunstmaanAdmin/Settings/button_resolve_all.html.twig'
);

return $this->renderAdminList($request, $nodeAdminListConfigurator);
Expand Down Expand Up @@ -1346,6 +1348,14 @@ private function undoDeleteNode(

$node->setDeleted(false);

foreach ($node->getNodeTranslations() as $nodeTranslation) {
if (!$nodeTranslation instanceof NodeTranslation) {
continue;
}

$this->nodePublisher->unPublish($nodeTranslation);
}

$this->em->persist($node);

foreach ($node->getChildren() as $child) {
Expand Down
8 changes: 5 additions & 3 deletions src/Kunstmaan/NodeBundle/Helper/Menu/ActionsMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@ public function createActionsMenu()
'action.undo_delete',
[
'linkAttributes' => [
'type' => 'submit',
'value' => 'undo_delete',
'name' => 'undo_delete',
'type' => 'button',
'class' => 'btn btn-default btn--raise-on-hover',
'data-toggle' => 'modal',
'data-keyboard' => 'true',
'data-target' => '#undo-delete-page-modal',
],
'extras' => ['renderType' => 'button'],
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ kuma_node:
locked_success: An automatic backup has been created because the page is being edited by another user
undo_delete:
flash:
success: The deleting the page has been undone
success: Deleting the page has been undone
error: There was an error while undoing deleting the page
new_page:
title:
Expand Down Expand Up @@ -172,6 +172,9 @@ kuma_node:
button:
delete: Delete
cancel: Cancel
undo_delete_page:
'title.%page%': Undo deleting page '%page%'
'body.%page%': This will undo deleting this page in all languages! Are you really sure about this?
duplicate_page:
'title.%page%': Duplicate page '%page%'
label:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ kuma_node:
button:
delete: Verwijder
cancel: Annuleer
undo_delete_page:
'title.%page%': Verwijderen van de pagina '%page% ongedaan maken'
'body.%page%': Hiermee maakt u het verwijderen van deze pagina ongedaan in alle talen! Bent u echt zeker over dit?
duplicate_page:
'title.%page%': Dupliceer pagina '%page%'
label:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<a href="#" class="link--text table__actions__item" data-toggle="modal" data-keyboard="true" data-target="#undo-delete-page-modal" title="{{ itemAction.labelFor(item)|trans }}">
<i class="fa fa-{{ itemAction.iconFor(item) }}"></i>
</a>

<!-- Modal - Undo delete page -->
{% include '@KunstmaanNode/NodeAdmin/Modals/_undo_delete.html.twig' with {
page: item,
node: item.node
} %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div id="undo-delete-page-modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">

<!-- Head -->
<div class="modal-header">
<button class="close" data-dismiss="modal">
<i class="fa fa-times"></i>
</button>
<h3>{{ 'kuma_node.modal.delete_page.title.%page%'|trans({'%page%': page.title}) }}</h3>
</div>

<!-- Body -->
<div class="modal-body">
<p>{{ 'kuma_node.modal.delete_page.body.%page%'|trans({'%page%': page.title}) }}</p>
</div>

<!-- Footer -->
<div class="modal-footer">
<form action="{{ path('KunstmaanNodeBundle_nodes_delete_undo', { 'id': node.id }) }}" method="post" novalidate="novalidate">
<button type="submit" name="submit" class="btn btn-danger btn--raise-on-hover">
{{ 'action.undo_delete'|trans() }}
</button>
<button class="btn btn-default btn--raise-on-hover" data-dismiss="modal">
{{ 'kuma_node.modal.delete_page.button.cancel'|trans() }}
</button>
</form>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{% include '@KunstmaanNode/NodeAdmin/Modals/_add_subpage.html.twig' %}
<!-- Modal - Delete page -->
{% include '@KunstmaanNode/NodeAdmin/Modals/_delete.html.twig' %}
<!-- Modal - Undo delete page -->
{% include '@KunstmaanNode/NodeAdmin/Modals/_undo_delete.html.twig' %}
<!-- Modal - Duplicate page -->
{% include '@KunstmaanNode/NodeAdmin/Modals/_duplicate.html.twig' %}
{% if showDuplicateWithChildren %}
Expand Down