From a56433b67c12da8c0ce06bc095e888cc338c382c Mon Sep 17 00:00:00 2001 From: lukasNo1 Date: Thu, 19 Oct 2023 11:06:16 +0200 Subject: [PATCH] Sort sites by group id --- CHANGELOG.md | 7 +++++++ composer.json | 2 +- src/services/SiteCopy.php | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e743fe7..19f9723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.0.10 - 2023-10-19 + +### Changed + +- The list of sites to copy to is now sorted by site group to provide a better ui for multisite setups [#6](https://github.com/Goldinteractive/craft-sitecopy/issues/6) + + ## 1.0.9 - 2023-10-16 ### Added diff --git a/composer.json b/composer.json index 2221cee..25c3379 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "goldinteractive/craft-sitecopy", "description": "", - "version": "1.0.9", + "version": "1.0.10", "license": "proprietary", "type": "craft-plugin", "minimum-stability": "dev", diff --git a/src/services/SiteCopy.php b/src/services/SiteCopy.php index b9b6547..54b648f 100644 --- a/src/services/SiteCopy.php +++ b/src/services/SiteCopy.php @@ -147,6 +147,7 @@ function ($site) use ($exclude) { $site = [ 'label' => $site->name, 'value' => $site->id, + 'groupId' => $site->groupId, 'inputAttributes' => ['onclick' => 'updateSitecopyToggleAll(this)'], ]; } else { @@ -164,11 +165,16 @@ function ($site) use ($exclude) { $sites = array_filter($sites); + usort($sites, function ($a, $b) { + return $a['groupId'] - $b['groupId']; + }); + if (count($sites) > 1) { array_unshift($sites, [ 'id' => 'sitecopy-toggle-all', 'label' => Craft::t('site-copy-x', 'Select all'), 'value' => '', + 'groupId' => null, 'inputAttributes' => ['onclick' => 'toggleSitecopyTargets(this)'], ]); }