document.head.insertAdjacentHTML('beforeend','') PouchDB = require 'app/utils/pouch' # Иконки для меню (упрощенные компоненты) MenuIcons = SliderIcon: template: '' ProductsIcon: template: '' ClientsIcon: template: '' BlogIcon: template: '' RoutesIcon: template: '' SettingsIcon: template: '' module.exports = name: 'AdminPanel' components: MenuIcons render: (new Function '_ctx', '_cache', renderFns['app/pages/Admin/index.pug'])() data: -> return { currentDomain: window.location.hostname mobileMenuOpen: false menuItems: [ { id: 'slider' name: 'Слайдер' path: '/admin/slider' icon: 'SliderIcon' } { id: 'products' name: 'Товары' path: '/admin/products' icon: 'ProductsIcon' } { id: 'clients' name: 'Клиенты' path: '/admin/clients' icon: 'ClientsIcon' } { id: 'blog' name: 'Блог' path: '/admin/blog' icon: 'BlogIcon' } { id: 'routes' name: 'Маршруты' path: '/admin/routes' icon: 'RoutesIcon' } { id: 'settings' name: 'Настройки' path: '/admin/settings' icon: 'SettingsIcon' } ] } computed: currentRoute: -> @$route.path.split('/').pop() || 'settings' showMobileMenuButton: -> window.innerWidth < 1024 methods: navigateTo: (path) -> @mobileMenuOpen = false @$router.push(path) toggleMobileMenu: -> @mobileMenuOpen = !@mobileMenuOpen getMenuItemClass: (item) -> baseClass = 'admin__nav-item' isActive = @currentRoute == item.id if isActive return "#{baseClass} admin__nav-item--active" else return "#{baseClass} admin__nav-item--inactive" getSidebarClass: -> if @mobileMenuOpen return 'admin__sidebar--visible' else return 'admin__sidebar--hidden' loadDomainSettings: -> PouchDB.getDocument("domain_settings:#{@currentDomain}") .then (settings) => @domainSettings = settings .catch (error) => debug.log 'Настройки домена не найдены, используются значения по умолчанию' @domainSettings = null handleResize: -> if window.innerWidth >= 1024 @mobileMenuOpen = false mounted: -> @loadDomainSettings() window.addEventListener 'resize', @handleResize beforeUnmount: -> window.removeEventListener 'resize', @handleResize