From 5b3498c385650f5bf38cfd93366dcc22b51a148b Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 9 Dec 2024 19:02:12 +0000 Subject: [PATCH] feat: add ability to re-order placeholders and redesign leaderboards page to match member list (#3559) --- core/classes/Misc/Placeholders.php | 10 +- ...er_order_to_placeholder_settings_table.php | 15 +++ .../integrations/minecraft/placeholders.tpl | 44 +++++++- custom/panel_templates/Default/template.php | 4 + custom/templates/DefaultRevamp/css/custom.css | 35 ++++++ .../templates/DefaultRevamp/leaderboards.tpl | 90 +++++++++------- modules/Core/language/en_UK.json | 2 + modules/Core/pages/leaderboards.php | 10 +- modules/Core/pages/panel/placeholders.php | 102 +++++++++++------- 9 files changed, 225 insertions(+), 87 deletions(-) create mode 100644 core/migrations/20241201113419_add_placeholder_order_to_placeholder_settings_table.php diff --git a/core/classes/Misc/Placeholders.php b/core/classes/Misc/Placeholders.php index 2df5adadcc..bbc35dacbf 100644 --- a/core/classes/Misc/Placeholders.php +++ b/core/classes/Misc/Placeholders.php @@ -17,7 +17,13 @@ public function __construct() { $this->_db = DB::getInstance(); - $placeholders_query = $this->_db->get('placeholders_settings', ['name', '<>', ''])->results(); + $placeholders_query = $this->_db->query( + <<<'SQL' + SELECT * + FROM nl2_placeholders_settings + ORDER BY `order` + SQL + )->results(); $placeholders = []; foreach ($placeholders_query as $placeholder) { @@ -78,7 +84,7 @@ public function loadUserPlaceholders(string $uuid): array { $binUuid = hex2bin(str_replace('-', '', $uuid)); - $placeholder_query = $this->_db->query('SELECT * FROM nl2_users_placeholders up JOIN nl2_placeholders_settings ps ON up.name = ps.name AND up.server_id = ps.server_id WHERE up.uuid = ?', [$binUuid]); + $placeholder_query = $this->_db->query('SELECT * FROM nl2_users_placeholders up JOIN nl2_placeholders_settings ps ON up.name = ps.name AND up.server_id = ps.server_id WHERE up.uuid = ? ORDER BY ps.`order`', [$binUuid]); if (!$placeholder_query->count()) { return []; diff --git a/core/migrations/20241201113419_add_placeholder_order_to_placeholder_settings_table.php b/core/migrations/20241201113419_add_placeholder_order_to_placeholder_settings_table.php new file mode 100644 index 0000000000..2ca0b6e50e --- /dev/null +++ b/core/migrations/20241201113419_add_placeholder_order_to_placeholder_settings_table.php @@ -0,0 +1,15 @@ +table('nl2_placeholders_settings') + ->addColumn('order', 'integer', ['length' => 11, 'null' => true, 'default' => null]) + ->update(); + } +} diff --git a/custom/panel_templates/Default/integrations/minecraft/placeholders.tpl b/custom/panel_templates/Default/integrations/minecraft/placeholders.tpl index b7a04c4013..ef7219494b 100644 --- a/custom/panel_templates/Default/integrations/minecraft/placeholders.tpl +++ b/custom/panel_templates/Default/integrations/minecraft/placeholders.tpl @@ -39,7 +39,8 @@
{$INFO}
- {$PLACEHOLDERS_INFO} +

{$PLACEHOLDERS_INFO}

+

{$DRAG_AND_DROP_INFO}


@@ -95,9 +96,9 @@ - + {foreach from=$ALL_PLACEHOLDERS item=placeholder} - + {$placeholder->server_id} {$placeholder->name} @@ -216,8 +217,45 @@ }); } + {include file='scripts.tpl'} + + diff --git a/custom/panel_templates/Default/template.php b/custom/panel_templates/Default/template.php index e49ea3b5d6..af0a2317ce 100644 --- a/custom/panel_templates/Default/template.php +++ b/custom/panel_templates/Default/template.php @@ -413,6 +413,10 @@ public function onPageLoad() $this->addJSScript('$(".image-picker").imagepicker();'); } + } elseif (MINECRAFT_PAGE === 'placeholders') { + $this->assets()->include([ + AssetTree::JQUERY_UI, + ]); } break; diff --git a/custom/templates/DefaultRevamp/css/custom.css b/custom/templates/DefaultRevamp/css/custom.css index b9815c0e43..b62f360d55 100755 --- a/custom/templates/DefaultRevamp/css/custom.css +++ b/custom/templates/DefaultRevamp/css/custom.css @@ -275,6 +275,31 @@ body.pushable>.pusher { max-width: none; } +.ui.grid.segment.leaderboard_table { + margin-top: 0; +} + +.leaderboard_table .ui.list { + margin-left: -10px; +} + +.leaderboard_table .ui.list li a { + display: block; + height: 100%; + width: 100%; +} + +.leaderboard_table .middle.aligned.content { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis;; + white-space: nowrap; +} + +.leaderboard_table ol li:before { + display: none; +} + #reactions { margin-top: 1rem; padding: .7em 1.2em .7em 1.2em; @@ -1211,6 +1236,16 @@ body.dark .ui.vertical.menu { box-shadow: none; } +body.dark .ui.vertical.menu .active.item { + background-color: #464646; +} + +body.dark .ui.vertical.pointing.menu .active.item:after { + background-color: #464646; + border-top: 1px solid #464646; + border-right: 1px solid #464646; +} + body.dark .ui.segment#profile-header { border: none; } diff --git a/custom/templates/DefaultRevamp/leaderboards.tpl b/custom/templates/DefaultRevamp/leaderboards.tpl index bd27fb361b..e9781e23af 100644 --- a/custom/templates/DefaultRevamp/leaderboards.tpl +++ b/custom/templates/DefaultRevamp/leaderboards.tpl @@ -7,52 +7,62 @@
-
+
-
-