forked from deblan/side_menu
add custom apps sorting
This commit is contained in:
parent
7d82c78581
commit
84c620637e
8 changed files with 85 additions and 1 deletions
|
|
@ -95,6 +95,7 @@ class JsController extends Controller
|
|||
{
|
||||
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
|
||||
$topSideMenuApps = $this->config->getAppValueArray('top-side-menu-apps', '[]');
|
||||
$topMenuAppsOrder = $this->config->getAppValueArray('top-menu-apps-order', '[]');
|
||||
$targetBlankApps = $this->config->getAppValueArray('target-blank-apps', '[]');
|
||||
$useAvatar = $this->config->getAppValueBool('use-avatar', '0');
|
||||
$isForced = $this->config->getAppValueBool('force', '0');
|
||||
|
|
@ -164,6 +165,7 @@ class JsController extends Controller
|
|||
'avatar' => $avatar,
|
||||
'top-menu-apps' => $topMenuApps,
|
||||
'top-side-menu-apps' => $topSideMenuApps,
|
||||
'top-menu-apps-order' => $topMenuAppsOrder,
|
||||
'target-blank-apps' => $targetBlankApps,
|
||||
'settings' => $settings,
|
||||
'logo' => $this->themingDefaults->getLogo(),
|
||||
|
|
|
|||
|
|
@ -105,4 +105,23 @@ class AppRepository
|
|||
|
||||
return $visibleApps;
|
||||
}
|
||||
|
||||
public function getTopMenuOrderedApps()
|
||||
{
|
||||
$apps = $this->getVisibleApps();
|
||||
$orders = $this->config->getAppValueArray('top-menu-apps-order', '[]');
|
||||
|
||||
usort($apps, function ($a, $b) use ($orders) {
|
||||
$ak = array_keys($orders, $a['id'])[0] ?? null;
|
||||
$bk = array_keys($orders, $b['id'])[0] ?? null;
|
||||
|
||||
if ($ak === null || $bk === null) {
|
||||
return ($a['name'] < $b['name']) ? -1 : 1;
|
||||
}
|
||||
|
||||
return $ak < $bk ? -1 : 1;
|
||||
});
|
||||
|
||||
return $apps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,9 +159,11 @@ class Admin implements ISettings
|
|||
'force' => $this->config->getAppValue('force', '0'),
|
||||
'target-blank-apps' => $this->config->getAppValueArray('target-blank-apps', '[]'),
|
||||
'top-menu-apps' => $this->config->getAppValueArray('top-menu-apps', '[]'),
|
||||
'top-menu-apps-order' => $this->config->getAppValueArray('top-menu-apps-order', '[]'),
|
||||
'top-side-menu-apps' => $this->config->getAppValueArray('top-side-menu-apps', '[]'),
|
||||
'default-enabled' => $this->config->getAppValue('default-enabled', '1'),
|
||||
'apps' => $this->appRepository->getVisibleApps(),
|
||||
'top-menu-ordered-apps' => $this->appRepository->getTopMenuOrderedApps(),
|
||||
'apps-categories-custom' => $this->config->getAppValueArray('apps-categories-custom', '[]'),
|
||||
'categories-order-type' => $this->config->getAppValue('categories-order-type', 'default'),
|
||||
'categories-order' => $this->config->getAppValueArray('categories-order', '[]'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue