diff --git a/CHANGELOG.md b/CHANGELOG.md index ea91ae4..2eddb93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## [Unreleased] +## 3.2.0 +### Added +* use custom app names using 'app.navigation.name' (#148) +* app sorting with all displays (#147) + ## 3.1.0 ### Added * add global custom app sorting for the top menu diff --git a/appinfo/info.xml b/appinfo/info.xml index f8417ba..721427f 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -32,7 +32,7 @@ Notice Because I believe in a free and decentralized Internet, [Gitnet](https://gitnet.fr) is **self-hosted at home**. In case of downtime, you can download **Custom Menu** from [here](https://kim.deblan.fr/~side_menu/). ]]> - 3.1.0 + 3.2.0 agpl Simon Vieille SideMenu diff --git a/css/admin.css b/css/admin.css index 756d7ee..086d0d7 100644 --- a/css/admin.css +++ b/css/admin.css @@ -163,4 +163,15 @@ position: relative; top: -8px; left: 5px; + transition-duration: 0.8s; + transition-property: transform; + transform: rotate(360deg); +} + +.btn-reset--down { + top: 2px; +} + +.btn-reset--progress { + transform: rotate(-359deg); } diff --git a/lib/Controller/JsController.php b/lib/Controller/JsController.php index 2a3231f..32cd630 100644 --- a/lib/Controller/JsController.php +++ b/lib/Controller/JsController.php @@ -162,10 +162,10 @@ class JsController extends Controller 'side-with-categories' => $this->config->getAppValueBool('side-with-categories', '0'), 'big-menu' => $this->config->getAppValueBool('big-menu', '0'), 'big-menu-hidden-apps' => $this->config->getAppValueArray('big-menu-hidden-apps', '[]'), + 'apps-order' => $this->config->getAppValueArray('apps-order', '[]'), '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(), diff --git a/lib/Controller/NavController.php b/lib/Controller/NavController.php index 41aff0c..ac766a5 100644 --- a/lib/Controller/NavController.php +++ b/lib/Controller/NavController.php @@ -93,7 +93,7 @@ class NavController extends Controller ]); } - $apps = $this->appRepository->getVisibleApps(); + $apps = $this->appRepository->getOrderedApps(); $categoriesLabels = $this->categoryRepository->getOrderedCategories(); $hiddenApps = $this->config->getAppValueArray('big-menu-hidden-apps', '[]'); $isForced = $this->config->getAppValueBool('force', '0'); @@ -178,10 +178,6 @@ class NavController extends Controller foreach ($items as $category => $value) { if (empty($items[$category]['apps'])) { unset($items[$category]); - } else { - uasort($items[$category]['apps'], function ($a, $b) { - return ($a['name'] < $b['name']) ? -1 : 1; - }); } } diff --git a/lib/Service/AppRepository.php b/lib/Service/AppRepository.php index e35f65b..2ae59d5 100644 --- a/lib/Service/AppRepository.php +++ b/lib/Service/AppRepository.php @@ -36,8 +36,7 @@ class AppRepository IFactory $l10nFactory, ConfigProxy $config, CategoryRepository $categoryRepository - ) - { + ) { $this->ocApp = $ocApp; $this->l10nFactory = $l10nFactory; $this->config = $config; @@ -62,7 +61,7 @@ class AppRepository foreach ([$app['id'], $app['id'].'_index'] as $id) { if (isset($navigation[$id])) { - $app['name'] = $this->l10nFactory->get($id)->t($app['name']); + $app['name'] = $this->getAppName($app); $app['href'] = $navigation[$id]['href']; $app['icon'] = $navigation[$id]['icon']; @@ -75,7 +74,7 @@ class AppRepository if ('external_index' === substr($app['id'], 0, 14)) { $visibleApps[$app['id']] = [ 'id' => $app['id'], - 'name' => $this->l10nFactory->get($app['id'])->t($app['name']), + 'name' => $this->getAppName($app), 'href' => $app['href'], 'icon' => $app['icon'], 'category' => [ @@ -85,7 +84,7 @@ class AppRepository } elseif ('files' === $app['id']) { $visibleApps[$app['id']] = [ 'id' => $app['id'], - 'name' => $this->l10nFactory->get($app['id'])->t($app['name']), + 'name' => $this->getAppName($app), 'href' => $app['href'], 'icon' => $app['icon'], 'category' => [], @@ -99,23 +98,28 @@ class AppRepository } } - usort($visibleApps, function ($a, $b) { - return ($a['name'] < $b['name']) ? -1 : 1; - }); - return $visibleApps; } - public function getTopMenuOrderedApps() + public function getAppName($app) + { + return $this->config->getAppValue( + 'app.navigation.name', + $this->l10nFactory->get($app['id'])->t($app['name']), + $app['id'] + ); + } + + public function getOrderedApps() { $apps = $this->getVisibleApps(); - $orders = $this->config->getAppValueArray('top-menu-apps-order', '[]'); + $orders = $this->config->getAppValueArray('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) { + if (null === $ak || null === $bk) { return ($a['name'] < $b['name']) ? -1 : 1; } diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 20aa9fd..12be78a 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -159,11 +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', '[]'), + 'apps-order' => $this->config->getAppValueArray('apps-order', '[]'), + 'ordered-apps' => $this->appRepository->getOrderedApps(), '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', '[]'), diff --git a/src/AppMenu.vue b/src/AppMenu.vue index 015f8af..20fc9db 100644 --- a/src/AppMenu.vue +++ b/src/AppMenu.vue @@ -82,7 +82,7 @@ export default { this.apps = {} let orders = {} - Array.from(window.topMenuAppsOrder).forEach((app, order) => { + window.menuAppsOrder.forEach((app, order) => { orders[app] = order + 1 }) diff --git a/src/SideMenu.vue b/src/SideMenu.vue index 998d792..ee9d477 100644 --- a/src/SideMenu.vue +++ b/src/SideMenu.vue @@ -86,7 +86,7 @@ export default { let orders = {} let finalApps = [] - Array.from(window.topMenuAppsOrder).forEach((app, order) => { + window.menuAppsOrder.forEach((app, order) => { orders[app] = order + 1 }) diff --git a/src/admin.js b/src/admin.js index e2f38be..66fb71d 100644 --- a/src/admin.js +++ b/src/admin.js @@ -159,9 +159,15 @@ document.addEventListener('DOMContentLoaded', () => { const target = event.target const values = JSON.parse(target.getAttribute('data-reset')) + target.classList.toggle('btn-reset--progress', true) + for (let i in values) { document.querySelector(`#${i}`).value = values[i] } + + window.setTimeout(() => { + target.classList.toggle('btn-reset--progress', false) + }, 800) }) } @@ -249,7 +255,6 @@ document.addEventListener('DOMContentLoaded', () => { let value = [] for (let item of document.querySelectorAll('#categories-list .side-menu-setting-list-item')) { - console.log(item.getAttribute('data-id')) value.push(item.getAttribute('data-id')) } @@ -258,20 +263,19 @@ document.addEventListener('DOMContentLoaded', () => { } catch (e) { } - sortable('#top-menu-apps-order-list .side-menu-setting-list', { + sortable('#apps-order-list .side-menu-setting-list', { placeholderClass: 'side-menu-setting-list-drop' }) try { - sortable('#top-menu-apps-order-list .side-menu-setting-list')[0].addEventListener('sortstop', (e) => { + sortable('#apps-order-list .side-menu-setting-list')[0].addEventListener('sortstop', (e) => { let value = [] - for (let item of document.querySelectorAll('#top-menu-apps-order-list .side-menu-setting-list-item')) { - console.log(item.getAttribute('data-id')) + for (let item of document.querySelectorAll('#apps-order-list .side-menu-setting-list-item')) { value.push(item.getAttribute('data-id')) } - document.querySelector('input[name="top-menu-apps-order"]').value = JSON.stringify(value) + document.querySelector('input[name="apps-order"]').value = JSON.stringify(value) }) } catch (e) { } diff --git a/src/l10n/fixtures/cs.yaml b/src/l10n/fixtures/cs.yaml index b96c0eb..920f630 100644 --- a/src/l10n/fixtures/cs.yaml +++ b/src/l10n/fixtures/cs.yaml @@ -109,6 +109,3 @@ "Normal text": "Normální text" "Big text": "Velký text" "Applications": "Applications" -"This feature is not compatible with big menu and with categories displays.": "This\ - \ feature is not compatible with big menu and with categories\ - \ displays." diff --git a/src/l10n/fixtures/de.yaml b/src/l10n/fixtures/de.yaml index d87d2af..134b29f 100644 --- a/src/l10n/fixtures/de.yaml +++ b/src/l10n/fixtures/de.yaml @@ -112,6 +112,3 @@ "Normal text": "Normaler Text" "Big text": "Großer Text" "Applications": "Applications" -"This feature is not compatible with big menu and with categories displays.": "This\ - \ feature is not compatible with big menu and with categories\ - \ displays." diff --git a/src/l10n/fixtures/fr.yaml b/src/l10n/fixtures/fr.yaml index 02938a5..fa3eccd 100644 --- a/src/l10n/fixtures/fr.yaml +++ b/src/l10n/fixtures/fr.yaml @@ -114,6 +114,3 @@ \ et latéral" "Reset to default": "Restaurer les valeurs par défaut" "Applications": "Applications" -"This feature is not compatible with big menu and with categories displays.": "Cette\ - \ fonctionnalité n'est pas compatible avec les affichages Menu large\ - \ et Avec les catégories." diff --git a/src/l10n/fixtures/tpl/base.yaml b/src/l10n/fixtures/tpl/base.yaml index d6d9a84..e7c1980 100644 --- a/src/l10n/fixtures/tpl/base.yaml +++ b/src/l10n/fixtures/tpl/base.yaml @@ -93,4 +93,3 @@ "Apps visible in the top and side menus": "" "Reset to default": "" "Applications": "" -"This feature is not compatible with big menu and with categories displays.": "" diff --git a/src/l10n/fixtures/zh_CN.yaml b/src/l10n/fixtures/zh_CN.yaml index 81bef84..8fdec79 100644 --- a/src/l10n/fixtures/zh_CN.yaml +++ b/src/l10n/fixtures/zh_CN.yaml @@ -90,4 +90,3 @@ "Normal text": "普通文本" "Big text": "大文本" "Applications": "Applications" -"This feature is not compatible with big menu and with categories displays.": "This feature is not compatible with big menu and with categories displays." diff --git a/templates/js/script.php b/templates/js/script.php index 9911141..797f013 100644 --- a/templates/js/script.php +++ b/templates/js/script.php @@ -25,8 +25,8 @@ if ($_['always-displayed']) { const targetBlankApps = window.topMenuApps = - window.topMenuAppsOrder = - window.topSideMenuApps = + window.topSideMenuApps = + window.menuAppsOrder = sideMenu.setAttribute('data-bigmenu', '1') diff --git a/templates/settings/admin-form.php b/templates/settings/admin-form.php index 1769bdb..5a55946 100644 --- a/templates/settings/admin-form.php +++ b/templates/settings/admin-form.php @@ -839,19 +839,19 @@ $labelReset = 'Reset to default';
t('Customize sorting')); ?> -
- - t('This feature is not compatible with big menu and with categories displays.'); ?> -
- + 🖱️ t($labelShowHideApps)); ?> -