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

Migrate ReactionTypeListPage to grid view #6248

Merged
merged 3 commits into from
Mar 19, 2025
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
92 changes: 20 additions & 72 deletions wcfsetup/install/files/acp/templates/reactionTypeList.tpl
Original file line number Diff line number Diff line change
@@ -1,91 +1,39 @@
{include file='header' pageTitle='wcf.acp.menu.link.reactionType.list'}

{if $objects|count}
<script data-relocate="true">
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
new UiSortableList({
containerId: 'reactionTypeList',
className: 'wcf\\data\\reaction\\type\\ReactionTypeAction',
offset: {@$startIndex}
});
});
</script>
{/if}

<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.menu.link.reactionType.list{/lang}{if $items} <span class="badge badgeInverse">{#$items}</span>{/if}</h1>
<h1 class="contentTitle">{lang}wcf.acp.menu.link.reactionType.list{/lang} <span class="badge badgeInverse">{#$gridView->countRows()}</span></h1>
</div>

<nav class="contentHeaderNavigation">
<ul>
{if $gridView->countRows() > 1}
<li>
<button type="button" class="button jsChangeShowOrder">{icon name='up-down'} <span>{lang}wcf.global.changeShowOrder{/lang}</span></button>
</li>
{/if}
<li><a href="{link controller='ReactionTypeAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.menu.link.reactionType.add{/lang}</span></a></li>

{event name='contentHeaderNavigation'}
</ul>
</nav>
</header>

{hascontent}
<div class="paginationTop">
{content}{pages print=true assign=pagesLinks controller="ReactionTypeList" link="pageNo=%d"}{/content}
</div>
{/hascontent}
<div class="section">
{unsafe:$gridView->render()}
</div>

{if $objects|count}
<div id="reactionTypeList" class="sortableListContainer section">
<ol class="sortableList jsReloadPageWhenEmpty jsObjectActionContainer" data-object-action-class-name="wcf\data\reaction\type\ReactionTypeAction" data-object-id="0" start="{@($pageNo - 1) * $itemsPerPage + 1}">
{foreach from=$objects item=reactionType}
<li class="sortableNode sortableNoNesting reactionTypeRow jsObjectActionObject" data-object-id="{@$reactionType->getObjectID()}">
<span class="sortableNodeLabel">
<a href="{link controller='ReactionTypeEdit' id=$reactionType->reactionTypeID}{/link}">{@$reactionType->renderIcon()} {$reactionType->getTitle()}</a>

<span class="statusDisplay sortableButtonContainer">
<span class="sortableNodeHandle">
{icon name='arrows-up-down-left-right'}
</span>
{assign var='reactionTypeIsDisabled' value=true}
{if $reactionType->isAssignable}
{assign var='reactionTypeIsDisabled' value=false}
{/if}
{objectAction action="toggle" isDisabled=$reactionTypeIsDisabled disableTitle='wcf.acp.reactionType.isAssignable' enableTitle='wcf.acp.reactionType.isNotAssignable'}
<a href="{link controller='ReactionTypeEdit' id=$reactionType->reactionTypeID}{/link}" class="jsTooltip" title="{lang}wcf.global.button.edit{/lang}">
{icon name='pencil'}
</a>
{objectAction action="delete" objectTitle=$reactionType->getTitle()}

{event name='itemButtons'}
</span>
</span>
<ol class="sortableList" data-object-id="{@$reactionType->reactionTypeID}"></ol>
</li>
{/foreach}
</ol>
</div>

<div class="formSubmit">
<button type="button" class="button buttonPrimary" data-type="submit">{lang}wcf.global.button.saveSorting{/lang}</button>
</div>

<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{@$pagesLinks}{/content}
</div>
{/hascontent}

{hascontent}
<nav class="contentFooterNavigation">
<ul>
{content}
{event name='contentFooterNavigation'}
{/content}
</ul>
</nav>
{/hascontent}
</footer>
{else}
<woltlab-core-notice type="info">{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
{if $gridView->countRows() > 1}
<script data-relocate="true">
require(["WoltLabSuite/Core/Component/ChangeShowOrder"], ({ setup }) => {
{jsphrase name='wcf.global.changeShowOrder'}

setup(
document.querySelector('.jsChangeShowOrder'),
'core/reactions/types/show-order',
);
});
</script>
{/if}

{include file='footer'}
27 changes: 12 additions & 15 deletions wcfsetup/install/files/lib/acp/page/ReactionTypeListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

namespace wcf\acp\page;

use wcf\data\reaction\type\ReactionTypeList;
use wcf\page\MultipleLinkPage;
use wcf\page\AbstractGridViewPage;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\admin\ReactionTypeGridView;

/**
* Shows the list of reaction types.
*
* @author Joshua Ruesweg
* @copyright 2001-2019 WoltLab GmbH
* @author Olaf Braun, Joshua Ruesweg
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*
* @extends MultipleLinkPage<ReactionTypeList>
* @extends AbstractGridViewPage<ReactionTypeGridView>
*/
class ReactionTypeListPage extends MultipleLinkPage
class ReactionTypeListPage extends AbstractGridViewPage
{
/**
* @inheritDoc
Expand All @@ -31,13 +32,9 @@ class ReactionTypeListPage extends MultipleLinkPage
*/
public $neededPermissions = ['admin.content.reaction.canManageReactionType'];

/**
* @inheritDoc
*/
public $sqlOrderBy = 'showOrder ASC, reactionTypeID ASC';

/**
* @inheritDoc
*/
public $objectListClassName = ReactionTypeList::class;
#[\Override]
protected function createGridView(): AbstractGridView
{
return new ReactionTypeGridView();
}
}
5 changes: 5 additions & 0 deletions wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ static function (\wcf\event\endpoint\ControllerCollecting $event) {
$event->register(new \wcf\system\endpoint\controller\core\notices\DeleteNotice());
$event->register(new \wcf\system\endpoint\controller\core\notices\GetShowOrder());
$event->register(new \wcf\system\endpoint\controller\core\notices\ChangeShowOrder());
$event->register(new \wcf\system\endpoint\controller\core\reactions\types\EnableType());
$event->register(new \wcf\system\endpoint\controller\core\reactions\types\DisableType());
$event->register(new \wcf\system\endpoint\controller\core\reactions\types\DeleteType());
$event->register(new \wcf\system\endpoint\controller\core\reactions\types\GetShowOrder());
$event->register(new \wcf\system\endpoint\controller\core\reactions\types\ChangeShowOrder());
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace wcf\data\reaction\type;

use wcf\data\I18nDatabaseObjectList;

/**
* I18n implementation of a reaction type list.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @extends I18nDatabaseObjectList<ReactionType>
*/
class I18nReactionTypeList extends I18nDatabaseObjectList
{
/**
* @inheritDoc
*/
public $i18nFields = ["title" => "titleI18n"];

/**
* @inheritDoc
*/
public $className = ReactionType::class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
namespace wcf\data\reaction\type;

use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
use wcf\data\TDatabaseObjectToggle;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\file\upload\UploadFile;
use wcf\system\language\I18nHandler;
use wcf\system\WCF;
Expand All @@ -22,7 +19,7 @@
*
* @extends AbstractDatabaseObjectAction<ReactionType, ReactionTypeEditor>
*/
class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction
class ReactionTypeAction extends AbstractDatabaseObjectAction implements IToggleAction
{
use TDatabaseObjectToggle;

Expand All @@ -39,7 +36,7 @@ class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortab
/**
* @inheritDoc
*/
protected $requireACP = ['delete', 'update', 'updatePosition'];
protected $requireACP = ['delete', 'update'];

/**
* @inheritDoc
Expand Down Expand Up @@ -179,47 +176,6 @@ public function update()
}
}

/**
* @inheritDoc
*/
public function validateUpdatePosition()
{
// validate permissions
if ($this->permissionsUpdate !== []) {
WCF::getSession()->checkPermissions($this->permissionsUpdate);
} else {
throw new PermissionDeniedException();
}

if (!isset($this->parameters['data']['structure'])) {
throw new UserInputException('structure');
}

$this->readInteger('offset', true, 'data');
}

/**
* @inheritDoc
*/
public function updatePosition()
{
$reactionTypeList = new ReactionTypeList();
$reactionTypeList->readObjects();

$i = $this->parameters['data']['offset'];
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'][0] as $reactionTypeID) {
$reactionType = $reactionTypeList->search($reactionTypeID);
if ($reactionType === null) {
continue;
}

$editor = new ReactionTypeEditor($reactionType);
$editor->update(['showOrder' => $i++]);
}
WCF::getDB()->commitTransaction();
}

/**
* @inheritDoc
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\gridView\admin;

use wcf\event\IPsr14Event;
use wcf\system\gridView\admin\ReactionTypeGridView;

/**
* Indicates that the reaction type grid view has been initialized.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class ReactionTypeGridViewInitialized implements IPsr14Event
{
public function __construct(public readonly ReactionTypeGridView $param)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\admin\ReactionTypeInteractions;

/**
* Indicates that the provider for reaction type interactions is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class ReactionTypeInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly ReactionTypeInteractions $param)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\bulk\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\bulk\admin\ReactionTypeBulkInteractions;

/**
* Indicates that the provider for reaction type bulk interactions is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class ReactionTypeBulkInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly ReactionTypeBulkInteractions $param)
{
}
}
Loading