Improve a sort order of wall entry creating tab menu and form

This commit is contained in:
Yuriy Bakhtin 2023-09-19 13:14:44 +02:00
parent a6c7abd3a7
commit 62596ca4e2
5 changed files with 20 additions and 14 deletions

View File

@ -13,6 +13,7 @@ HumHub Changelog
- Fix #6349: Fix error on login new user from external service when maintenance is enabled
- Fix #6557: Fix not initialized groups array on the module administration
- Fix #6556: Fix command `theme/switch`
- Fix #6574: Improve a sort order of wall entry creating tab menu and form
1.14.3 (July 27, 2023)
----------------------

View File

@ -29,13 +29,22 @@ class Sort
$sortA = static::getSortValue($a, $field, $default);
$sortB = static::getSortValue($b, $field, $default);
if ($sortA == $sortB) {
return 0;
} elseif ($sortA < $sortB) {
return -1;
} else {
return 1;
if (!is_array($sortA)) {
$sortA = [$sortA];
}
if (!is_array($sortB)) {
$sortB = [$sortB];
}
foreach ($sortA as $s => $sortAItem) {
$sortBItem = $sortB[$s] ?? $default;
if ($sortAItem == $sortBItem) {
// Go to compare next sort value
continue;
}
return $sortAItem < $sortBItem ? -1 : 1;
}
return 0;
});
return $arr;

View File

@ -11,8 +11,6 @@ use humhub\libs\Sort;
use humhub\modules\content\widgets\stream\WallStreamEntryWidget;
use humhub\components\Widget;
use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\content\components\ContentActiveRecord;
use Yii;
use yii\web\HttpException;
/**
@ -71,7 +69,7 @@ class WallCreateContentFormContainer extends Widget
$forms[] = [
'class' => $wallEntryWidget->createFormClass,
'sortOrder' => $wallEntryWidget->createFormSortOrder ?? '9999999-' . $content->getContentName(),
'sortOrder' => [$wallEntryWidget->createFormSortOrder, ucfirst($content->getContentName())]
];
}

View File

@ -7,12 +7,10 @@
namespace humhub\modules\content\widgets;
use humhub\modules\content\components\ContentActiveRecord;
use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\content\widgets\stream\WallStreamEntryWidget;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\ui\menu\widgets\Menu;
use Yii;
/**
* WallCreateContentMenu is the widget for Menu above wall create content Form
@ -80,10 +78,10 @@ class WallCreateContentMenu extends Menu
}
$menuOptions = [
'label' => ucfirst($content->getContentName()),
'label' => $label = ucfirst($content->getContentName()),
'icon' => $content->getIcon(),
'url' => '#',
'sortOrder' => $wallEntryWidget->createFormSortOrder ?? '9999999-' . $content->getContentName(),
'sortOrder' => [$wallEntryWidget->createFormSortOrder, $label]
];
$url = $this->contentContainer->createUrl($wallEntryWidget->createRoute);

View File

@ -163,7 +163,7 @@ abstract class WallStreamEntryWidget extends StreamEntryWidget
/**
* @var int Sort order of create form and tab menu on wall stream
*/
public $createFormSortOrder;
public $createFormSortOrder = 1000000;
/**
* @var string Class name of the Form to create a Content from wall stream,