From 7cae9107c18b4af47057f71ac5e8d643dae57d4c Mon Sep 17 00:00:00 2001 From: Nikita <62756604+FlamesONE@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:08:16 +0500 Subject: [PATCH] v0.2.2.1-alpha --- .../Admin/Http/Views/assets/js/pages/footer/list.js | 7 +++++-- .../Http/Views/assets/js/pages/navigation/list.js | 7 +++++-- .../Admin/Http/Views/assets/js/pages/roles/list.js | 10 ++++++---- .../Admin/Http/Views/pages/main/items/app.blade.php | 2 +- app/Core/App.php | 2 +- app/Core/Helpers/Translation.php | 13 ++++++++----- app/Core/Template/TemplateAssets.php | 8 ++++---- 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/Core/Admin/Http/Views/assets/js/pages/footer/list.js b/app/Core/Admin/Http/Views/assets/js/pages/footer/list.js index 498a6ee..ed51a35 100644 --- a/app/Core/Admin/Http/Views/assets/js/pages/footer/list.js +++ b/app/Core/Admin/Http/Views/assets/js/pages/footer/list.js @@ -1,6 +1,8 @@ $(function () { const createSortableInstances = () => { - const nestedSortables = document.querySelectorAll('.footer-nested-sortable'); + const nestedSortables = document.querySelectorAll( + '.footer-nested-sortable', + ); return Array.from(nestedSortables).map( (nestedSortable) => new Sortable(nestedSortable, { @@ -27,7 +29,8 @@ $(function () { document .querySelector('.chrome-tabs') .addEventListener('contentRender', () => { - sortablesFooter = createSortableInstances(); + if ($('#saveFooter').length) + sortablesFooter = createSortableInstances(); }); $(document).on('click', '#saveFooter', () => { diff --git a/app/Core/Admin/Http/Views/assets/js/pages/navigation/list.js b/app/Core/Admin/Http/Views/assets/js/pages/navigation/list.js index 72d28a5..54e66f6 100644 --- a/app/Core/Admin/Http/Views/assets/js/pages/navigation/list.js +++ b/app/Core/Admin/Http/Views/assets/js/pages/navigation/list.js @@ -1,6 +1,8 @@ $(function () { const createNavSortableInstances = () => { - const nestedSortables = document.querySelectorAll('.nav-nested-sortable'); + const nestedSortables = document.querySelectorAll( + '.nav-nested-sortable', + ); return Array.from(nestedSortables).map( (nestedSortable) => new Sortable(nestedSortable, { @@ -27,7 +29,8 @@ $(function () { document .querySelector('.chrome-tabs') .addEventListener('contentRender', () => { - sortablesNav = createNavSortableInstances(); + if ($('#saveNavigation').length) + sortablesNav = createNavSortableInstances(); }); $(document).on('click', '#saveNavigation', () => { diff --git a/app/Core/Admin/Http/Views/assets/js/pages/roles/list.js b/app/Core/Admin/Http/Views/assets/js/pages/roles/list.js index bcfa50f..5fc68f2 100644 --- a/app/Core/Admin/Http/Views/assets/js/pages/roles/list.js +++ b/app/Core/Admin/Http/Views/assets/js/pages/roles/list.js @@ -13,9 +13,11 @@ $(function () { let sortableRoles = createRolesSortable(); - document.querySelector('.chrome-tabs').addEventListener('contentRender', () => { - sortableRoles = createRolesSortable(); - }); + document + .querySelector('.chrome-tabs') + .addEventListener('contentRender', () => { + if ($('#roles').length) sortableRoles = createRolesSortable(); + }); $(document).on('click', '#saveRoles', (e) => { let orderedIds = sortableRoles.toArray(); @@ -60,6 +62,6 @@ $(function () { $(document).on('click', '.roles-group .delete', async function () { let roleId = $(this).data('deleterole'); if (await asyncConfirm(translate('admin.roles.confirm_delete'))) - sendRequest({},u('admin/api/roles/' + roleId), 'DELETE'); + sendRequest({}, u('admin/api/roles/' + roleId), 'DELETE'); }); }); diff --git a/app/Core/Admin/Http/Views/pages/main/items/app.blade.php b/app/Core/Admin/Http/Views/pages/main/items/app.blade.php index 71a8f53..bfa0457 100644 --- a/app/Core/Admin/Http/Views/pages/main/items/app.blade.php +++ b/app/Core/Admin/Http/Views/pages/main/items/app.blade.php @@ -131,7 +131,7 @@ class="form-control" value="{{ config('app.timezone') }}"> @t('admin.app.maintenance_message_description')
-
diff --git a/app/Core/App.php b/app/Core/App.php index 4aa375d..a468e26 100644 --- a/app/Core/App.php +++ b/app/Core/App.php @@ -47,7 +47,7 @@ final class App * * @var string */ - public const VERSION = '0.2.2-alpha'; + public const VERSION = '0.2.2.1-alpha'; /** * Set the base path of the application diff --git a/app/Core/Helpers/Translation.php b/app/Core/Helpers/Translation.php index 42276d3..51746db 100644 --- a/app/Core/Helpers/Translation.php +++ b/app/Core/Helpers/Translation.php @@ -16,17 +16,20 @@ function __(?string $key, array $replacements = [], string $locale = null): stri { $translator = translation(); - // Если локаль не указана, используйте локаль по умолчанию if ($locale === null) { $locale = $translator->getLocale(); } - // Если у нас нет точки, т.е. массива, то мы не разделяем - if( strpos( $key, '.' ) !== false ) { - // Разделяем ключ на домен и ключ перевода + if (strpos($key, '.') !== false) { list($domain, $translationKey) = explode('.', $key, 2); - return $translator->trans($translationKey, $replacements, $domain, $locale); + $result = $translator->trans($translationKey, $replacements, $domain, $locale); + + if ($result === $translationKey) { + return $key; + } + + return $result; } return $translator->trans($key, $replacements, null, $locale); diff --git a/app/Core/Template/TemplateAssets.php b/app/Core/Template/TemplateAssets.php index a250bc2..8133ddf 100644 --- a/app/Core/Template/TemplateAssets.php +++ b/app/Core/Template/TemplateAssets.php @@ -110,7 +110,7 @@ private function processScssAsset(string $expression, string $scssPath): void } // Даже если сработало исключение, мы должны вернуть CSS - echo sprintf('', url($cssPath)); + echo sprintf('', url($cssPath), filemtime($cssBasePath)); } private function processCssAsset(string $expression, string $cssPathBase): void @@ -140,7 +140,7 @@ private function processCssAsset(string $expression, string $cssPathBase): void $this->saveAsset($cssBasePath, $cssPathBase); } - echo sprintf('', url($cssPath)); + echo sprintf('', url($cssPath), filemtime($cssBasePath)); } private function processJsAsset(string $expression, string $jsPathBase): void @@ -170,7 +170,7 @@ private function processJsAsset(string $expression, string $jsPathBase): void $this->saveAsset($jsBasePath, $jsPathBase); } - echo sprintf('', url($jsPath)); + echo sprintf('', url($jsPath), filemtime($jsBasePath)); } /** @@ -205,7 +205,7 @@ protected function processCdnAsset(string $url, string $type = "js"): string } } - return url($localPath); + return url($localPath) . "?" . filemtime($localPath); } private function processImageAsset(string $expression, string $imgPathBase, string $extension): void