Commit f8814250 authored by Tino Goratsch's avatar Tino Goratsch

allow to delete contact form messages

parent 7eb8e367
......@@ -116,7 +116,7 @@ class Action
}
/**
* @param string $action
* @param string|null $action
* @param callable $callback
* @param string|null $moduleConfirmUrl
* @param string|null $moduleIndexUrl
......@@ -144,7 +144,7 @@ class Action
}
/**
* @param string $action
* @param string|null $action
* @param callable $callback
* @param string|null $moduleConfirmUrl
* @param string|null $moduleIndexUrl
......@@ -300,13 +300,13 @@ class Action
/**
* helper function for deleting a result set.
*
* @param string $action
* @param string|null $action
* @param string|null $moduleConfirmUrl
* @param string|null $moduleIndexUrl
*
* @return array|JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*/
private function deleteItem(string $action, ?string $moduleConfirmUrl = null, ?string $moduleIndexUrl = null)
private function deleteItem(?string $action, ?string $moduleConfirmUrl = null, ?string $moduleIndexUrl = null)
{
$entries = $this->prepareRequestData();
......
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace ACP3\Modules\ACP3\Contact\Controller\Admin\Index;
use ACP3\Core;
use ACP3\Modules\ACP3\Contact\Model\ContactsModel;
class Delete extends Core\Controller\AbstractFrontendAction
{
/**
* @var \ACP3\Modules\ACP3\Contact\Model\ContactsModel
*/
private $contactsModel;
public function __construct(
Core\Controller\Context\FrontendContext $context,
ContactsModel $contactsModel
) {
parent::__construct($context);
$this->contactsModel = $contactsModel;
}
/**
* @param string $action
*
* @return mixed
*
* @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
*/
public function execute(?string $action)
{
return $this->actionHelper->handleDeleteAction(
$action,
function (array $items) {
return $this->contactsModel->delete($items);
}
);
}
}
......@@ -47,7 +47,7 @@ class Index extends Core\Controller\AbstractFrontendAction
->setRepository($this->dataGridRepository)
->setRecordsPerPage($this->resultsPerPage->getResultsPerPage(Schema::MODULE_NAME))
->setIdentifier('#contact-data-grid')
->setEnableOptions(false);
->setResourcePathDelete('admin/contact/index/delete');
$this->addDataGridColumns($input);
......@@ -81,6 +81,13 @@ class Index extends Core\Controller\AbstractFrontendAction
'label' => $this->translator->t('system', 'message'),
'type' => Core\DataGrid\ColumnRenderer\Nl2pColumnRenderer::class,
'fields' => ['message'],
], 10);
], 10)
->addColumn([
'label' => $this->translator->t('system', 'id'),
'type' => Core\DataGrid\ColumnRenderer\IntegerColumnRenderer::class,
'fields' => ['id'],
'primary' => true,
], 5)
;
}
}
......@@ -72,6 +72,7 @@ class Index extends Core\Controller\AbstractFrontendAction
/**
* @return array|string|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*
* @throws \Doctrine\DBAL\ConnectionException
* @throws \Doctrine\DBAL\DBALException
*/
......
......@@ -67,6 +67,9 @@ class Migration extends Modules\Installer\AbstractMigration
'ALTER TABLE `{pre}contacts` MODIFY COLUMN `message` TEXT {charset} NOT NULL;',
'ALTER TABLE `{pre}contacts` CONVERT TO {charset};',
],
43 => [
"INSERT INTO `{pre}acl_resources` (`module_id`, `area`, `controller`, `page`, `params`, `privilege_id`) VALUES ('{moduleId}', 'admin', 'index', 'delete', '', 6);",
],
];
}
......
......@@ -27,7 +27,7 @@ class Schema implements Modules\Installer\SchemaInterface
*/
public function getSchemaVersion()
{
return 42;
return 43;
}
/**
......@@ -83,6 +83,7 @@ class Schema implements Modules\Installer\SchemaInterface
return [
'admin' => [
'index' => [
'delete' => PrivilegeEnum::ADMIN_DELETE,
'index' => PrivilegeEnum::ADMIN_VIEW,
'settings' => PrivilegeEnum::ADMIN_SETTINGS,
],
......
{extends file="asset:System/Alerts/confirm_box_post.tpl"}
{extends file="asset:System/layout.admin-grid.tpl"}
{$DELETE_ROUTE={uri args="acp/contact/index/delete"}}
{block HEADER_BAR_OPTIONS}
{check_access mode="link" path="acp/contact/index/settings" class="glyphicon glyphicon-cog"}
{if $grid.show_mass_delete}
{check_access mode="button" path="acp/contact/index/delete" class="glyphicon glyphicon-remove text-danger" lang="system|delete_marked"}
{/if}
{/block}
{block ADMIN_GRID_CONTENT}
{include file="asset:System/Partials/datagrid.tpl" dataTable=$grid}
......
......@@ -3,6 +3,12 @@ services:
tags:
- { name: acp3.controller.action }
contact.controller.admin.index.delete:
class: ACP3\Modules\ACP3\Contact\Controller\Admin\Index\Delete
arguments:
- '@core.context.frontend'
- '@contact.model.contacts_model'
contact.controller.admin.index.index:
class: ACP3\Modules\ACP3\Contact\Controller\Admin\Index\Index
arguments:
......
......@@ -3,6 +3,7 @@
<keys>
<item key="address">Anschrift</item>
<item key="address_to_short">Die Anschrift darf nicht leer sein.</item>
<item key="admin_index_delete">Nachricht löschen</item>
<item key="admin_index_settings">Einstellungen</item>
<item key="ceo">Geschäftsführer</item>
<item key="contact">Kontakt</item>
......
......@@ -3,6 +3,7 @@
<keys>
<item key="address">Address</item>
<item key="address_to_short">The address should not be empty.</item>
<item key="admin_index_delete">Delete message</item>
<item key="admin_index_settings">Settings</item>
<item key="ceo">Chief executive officer</item>
<item key="contact">Contact</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment