Skip to content

Commit 5bd12df

Browse files
authored
Merge pull request #6244 from WoltLab/6.2-UserTrophyListPage-to-grid-view
Migrate `TrophyListPage` to grid view
2 parents ac132c1 + a45ad8b commit 5bd12df

17 files changed

Lines changed: 599 additions & 127 deletions
Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,39 @@
11
{include file='header' pageTitle='wcf.acp.menu.link.trophy.list'}
22

3-
<script data-relocate="true">
4-
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
5-
new UiSortableList({
6-
containerId: 'trophyList',
7-
className: 'wcf\\data\\trophy\\TrophyAction',
8-
offset: {@$startIndex}
9-
});
10-
});
11-
</script>
12-
133
<header class="contentHeader">
144
<div class="contentHeaderTitle">
15-
<h1 class="contentTitle">{lang}wcf.acp.menu.link.trophy.list{/lang}{if $items} <span class="badge badgeInverse">{#$items}</span>{/if}</h1>
5+
<h1 class="contentTitle">{lang}wcf.acp.menu.link.trophy.list{/lang} <span class="badge badgeInverse">{#$gridView->countRows()}</span></h1>
166
</div>
177

188
<nav class="contentHeaderNavigation">
199
<ul>
10+
{if $gridView->countRows() > 1}
11+
<li>
12+
<button type="button" class="button jsChangeShowOrder">{icon name='up-down'} <span>{lang}wcf.global.changeShowOrder{/lang}</span></button>
13+
</li>
14+
{/if}
2015
<li><a href="{link controller='TrophyAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.menu.link.trophy.add{/lang}</span></a></li>
2116

2217
{event name='contentHeaderNavigation'}
2318
</ul>
2419
</nav>
2520
</header>
26-
{hascontent}
27-
<div class="paginationTop">
28-
{content}
29-
{pages print=true assign=pagesLinks controller='TrophyList' link="pageNo=%d"}
30-
{/content}
31-
</div>
32-
{/hascontent}
3321

34-
{if $objects|count}
35-
<div class="section sortableListContainer" id="trophyList">
36-
<ol class="sortableList jsReloadPageWhenEmpty jsObjectActionContainer" data-object-action-class-name="wcf\data\trophy\TrophyAction" data-object-id="0" start="{@($pageNo - 1) * $itemsPerPage + 1}">
37-
{foreach from=$objects item='trophy'}
38-
<li class="sortableNode sortableNoNesting trophyRow jsObjectActionObject" data-object-id="{@$trophy->getObjectID()}">
39-
<span class="sortableNodeLabel">
40-
{@$trophy->renderTrophy(32)}
41-
<a href="{link controller='TrophyEdit' object=$trophy}{/link}">{$trophy->getTitle()}</a>
42-
43-
<span class="statusDisplay sortableButtonContainer">
44-
<span class="sortableNodeHandle">
45-
{icon name='arrows-up-down-left-right'}
46-
</span>
47-
{objectAction action="toggle" isDisabled=$trophy->isDisabled}
48-
<a href="{link controller='TrophyEdit' object=$trophy}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip">{icon name='pencil'}</a>
49-
{objectAction action="delete" objectTitle=$trophy->getTitle()}
50-
51-
{event name='itemButtons'}
52-
</span>
53-
</span>
54-
</li>
55-
{/foreach}
56-
</ol>
57-
</div>
58-
59-
<div class="formSubmit">
60-
<button type="button" class="button buttonPrimary" data-type="submit">{lang}wcf.global.button.saveSorting{/lang}</button>
61-
</div>
62-
63-
<footer class="contentFooter">
64-
{hascontent}
65-
<div class="paginationBottom">
66-
{content}{@$pagesLinks}{/content}
67-
</div>
68-
{/hascontent}
22+
<div class="section">
23+
{unsafe:$gridView->render()}
24+
</div>
6925

70-
<nav class="contentFooterNavigation">
71-
<ul>
72-
<li><a href="{link controller='TrophyAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.menu.link.trophy.add{/lang}</span></a></li>
26+
{if $gridView->countRows() > 1}
27+
<script data-relocate="true">
28+
require(["WoltLabSuite/Core/Component/ChangeShowOrder"], ({ setup }) => {
29+
{jsphrase name='wcf.global.changeShowOrder'}
7330
74-
{event name='contentHeaderNavigation'}
75-
</ul>
76-
</nav>
77-
</footer>
78-
{else}
79-
<woltlab-core-notice type="info">{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
31+
setup(
32+
document.querySelector('.jsChangeShowOrder'),
33+
'core/trophies/show-order',
34+
);
35+
});
36+
</script>
8037
{/if}
8138

8239
{include file='footer'}

wcfsetup/install/files/lib/acp/page/TrophyListPage.class.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
namespace wcf\acp\page;
44

5-
use wcf\data\trophy\TrophyList;
6-
use wcf\page\MultipleLinkPage;
5+
use wcf\page\AbstractGridViewPage;
6+
use wcf\system\gridView\AbstractGridView;
7+
use wcf\system\gridView\admin\TrophyGridView;
78

89
/**
910
* Trophy list page.
1011
*
11-
* @author Joshua Ruesweg
12-
* @copyright 2001-2019 WoltLab GmbH
12+
* @author Olaf Braun, Joshua Ruesweg
13+
* @copyright 2001-2025 WoltLab GmbH
1314
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14-
* @since 3.1
15+
* @since 3.1
1516
*
16-
* @extends MultipleLinkPage<TrophyList>
17+
* @extends AbstractGridViewPage<TrophyGridView>
1718
*/
18-
class TrophyListPage extends MultipleLinkPage
19+
class TrophyListPage extends AbstractGridViewPage
1920
{
2021
/**
2122
* @inheritDoc
@@ -32,18 +33,9 @@ class TrophyListPage extends MultipleLinkPage
3233
*/
3334
public $neededPermissions = ['admin.trophy.canManageTrophy'];
3435

35-
/**
36-
* @inheritDoc
37-
*/
38-
public $sortField = 'trophy.showOrder';
39-
40-
/**
41-
* @inheritDoc
42-
*/
43-
public $sortOrder = 'ASC';
44-
45-
/**
46-
* @inheritDoc
47-
*/
48-
public $objectListClassName = TrophyList::class;
36+
#[\Override]
37+
protected function createGridView(): AbstractGridView
38+
{
39+
return new TrophyGridView();
40+
}
4941
}

wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ static function (\wcf\event\endpoint\ControllerCollecting $event) {
211211
$event->register(new \wcf\system\endpoint\controller\core\users\groups\assignment\DisableAssignment());
212212
$event->register(new \wcf\system\endpoint\controller\core\users\groups\DeleteGroup());
213213
$event->register(new \wcf\system\endpoint\controller\core\menus\DeleteMenu());
214+
$event->register(new \wcf\system\endpoint\controller\core\trophies\EnableTrophy());
215+
$event->register(new \wcf\system\endpoint\controller\core\trophies\DisableTrophy());
216+
$event->register(new \wcf\system\endpoint\controller\core\trophies\DeleteTrophy());
217+
$event->register(new \wcf\system\endpoint\controller\core\trophies\GetShowOrder());
218+
$event->register(new \wcf\system\endpoint\controller\core\trophies\ChangeShowOrder());
214219
}
215220
);
216221

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace wcf\data\trophy;
4+
5+
use wcf\data\I18nDatabaseObjectList;
6+
7+
/**
8+
* Represents a trophy list.
9+
*
10+
* @author Olaf Braun
11+
* @copyright 2001-2025 WoltLab GmbH
12+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13+
* @since 6.2
14+
*
15+
* @extends I18nDatabaseObjectList<Trophy>
16+
*/
17+
class I18nTrophyList extends I18nDatabaseObjectList
18+
{
19+
/**
20+
* @inheritDoc
21+
*/
22+
public $i18nFields = ['title' => 'titleI18n'];
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public $className = Trophy::class;
28+
}

wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace wcf\data\trophy;
44

55
use wcf\data\AbstractDatabaseObjectAction;
6-
use wcf\data\ISortableAction;
76
use wcf\data\IToggleAction;
87
use wcf\data\IUploadAction;
98
use wcf\data\TDatabaseObjectToggle;
@@ -29,7 +28,7 @@
2928
*
3029
* @extends AbstractDatabaseObjectAction<Trophy, TrophyEditor>
3130
*/
32-
class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction, ISortableAction
31+
class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction
3332
{
3433
use TDatabaseObjectToggle;
3534

@@ -310,46 +309,4 @@ protected function updateTrophyImage(Trophy $trophy)
310309
}
311310
}
312311
}
313-
314-
/**
315-
* @inheritDoc
316-
*/
317-
public function validateUpdatePosition()
318-
{
319-
WCF::getSession()->checkPermissions($this->permissionsUpdate);
320-
321-
if (!isset($this->parameters['data']['structure']) || !\is_array($this->parameters['data']['structure'])) {
322-
throw new UserInputException('structure');
323-
}
324-
325-
$trophyList = new TrophyList();
326-
$trophyList->setObjectIDs($this->parameters['data']['structure'][0]);
327-
$trophyList->readObjects();
328-
if (\count($trophyList) !== \count($this->parameters['data']['structure'][0])) {
329-
throw new UserInputException('structure');
330-
}
331-
332-
$this->readInteger('offset', true, 'data');
333-
}
334-
335-
/**
336-
* @inheritDoc
337-
*/
338-
public function updatePosition()
339-
{
340-
$sql = "UPDATE wcf1_trophy
341-
SET showOrder = ?
342-
WHERE trophyID = ?";
343-
$statement = WCF::getDB()->prepare($sql);
344-
345-
$showOrder = $this->parameters['data']['offset'];
346-
WCF::getDB()->beginTransaction();
347-
foreach ($this->parameters['data']['structure'][0] as $trophyID) {
348-
$statement->execute([
349-
$showOrder++,
350-
$trophyID,
351-
]);
352-
}
353-
WCF::getDB()->commitTransaction();
354-
}
355312
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace wcf\event\gridView\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\gridView\admin\TrophyGridView;
7+
8+
/**
9+
* Indicates that the trophy grid view has been initialized.
10+
*
11+
* @author Olaf Braun
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class TrophyGridViewInitialized implements IPsr14Event
17+
{
18+
public function __construct(public readonly TrophyGridView $param)
19+
{
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace wcf\event\interaction\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\interaction\admin\TrophyInteractions;
7+
8+
/**
9+
* Indicates that the provider for trophies is collecting interactions.
10+
*
11+
* @author Olaf Braun
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class TrophyInteractionCollecting implements IPsr14Event
17+
{
18+
public function __construct(public readonly TrophyInteractions $param)
19+
{
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace wcf\event\interaction\bulk\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\interaction\bulk\admin\TrophyBulkInteractions;
7+
8+
/**
9+
* Indicates that the provider for trophy bulk interactions is collecting interactions.
10+
*
11+
* @author Olaf Braun
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class TrophyBulkInteractionCollecting implements IPsr14Event
17+
{
18+
public function __construct(public readonly TrophyBulkInteractions $param)
19+
{
20+
}
21+
}

0 commit comments

Comments
 (0)