# -*- coding: utf-8 -*- # Configures your navigation module SimpleNavigationn module Renderer class BootstrapBreadcrumbs < SimpleNavigation::Renderer::Base def render(item_container) content_tag(:ul, li_tags(item_container).join(join_with), id: item_container.dom_id, class: "page-breadcrumb breadcrumb") end protected def li_tags(item_container) item_container.items.inject([]) do |list, item| # rubocop:disable Style/IfInsideElse if item.selected? if include_sub_navigation?(item) list << content_tag(:li, link_to(item.name[:text], item.url, { method: item.method }.merge(item.html_options.except(:class, :id)))) if item.selected? list.concat li_tags(item.sub_navigation) elsif item.name.is_a? String list << content_tag(:li, item.name, class: 'active ') if item.selected? else list << content_tag(:li, item.name[:text], class: 'active ') if item.selected? end else next end # rubocop:enable Style/IfInsideElse end list end end def join_with @join_with ||= options[:join_with] || ' ' content_tag(:li, content_tag(:span, @join_with, class: 'divider')) end end end SimpleNavigation.register_renderer bootstrap_breadcrumbs: SimpleNavigationn::Renderer::BootstrapBreadcrumbs # rubocop:disable Metrics/BlockLength SimpleNavigation::Configuration.run do |navigation| navigation.renderer = SimpleNavigationRenderers::Bootstrap3 navigation.items do |primary| # clientes if can? :read, Customer primary.item :customers, { icon: "fa fa-fw fa-smile-o", text: "Clientes" }, customers_path, class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } sub_nav.item :list_customers, 'Lista de clientes', customers_path sub_nav.item :divider_after_list_customers, '#', divider: true sub_nav.item :debtor_customers, 'Clientes deudores', debtors_path if can? :debtors, Customer sub_nav.item :special_prices, 'Descuentos especiales por cliente', new_special_price_path if can? :create, SpecialPrice end end # productos primary.item :products, { icon: "fa fa-fw fa-cubes", text: "Productos" }, products_path, class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } if can? :read, Unit sub_nav.item :units, 'Unidades de medida', units_path sub_nav.item :divider_before_categories, '#', divider: true end if can? :read, Category sub_nav.item :list_categories, 'Lista de líneas de producto', categories_path sub_nav.item :divider_before_products, '#', divider: true end sub_nav.item :list_products, 'Lista de productos', products_path if can? :index, Product sub_nav.item :stock_by_pointsale, 'Existencias', stock_by_pointsale_path if can? :read, AvailableProduct sub_nav.item :list_waste_of_products, 'Lista de mermas de productos', product_wastes_path if can? :read, ProductWaste if can? :read, Purchase sub_nav.item :divider_before_purchases, '#', divider: true sub_nav.item :list_products, 'Lista de compras', purchases_path end if can? :read, Supplier sub_nav.item :divider_before_purchases, '#', divider: true sub_nav.item :list_suppliers, 'Lista de proveedores', suppliers_path end if can? :product_track, Product sub_nav.item :divider_before_purchases, '#', divider: true sub_nav.item :product_track, 'Seguimiento de productos', product_track_path end end # puntos de venta y caja registradora primary.item :pointsales, { icon: "fa fa-fw fa-cart-plus", text: "Puntos de venta" }, pointsales_path, class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } if can? :read, Pointsale sub_nav.item :list_pointsales, 'Lista de puntos de venta', pointsales_path sub_nav.item :divider_before_pointsales, '#', divider: true end sub_nav.item :list_cash_registers, 'Lista de cajas', cash_registers_path if can? :index, CashRegister sub_nav.item :list_cash_outs, 'Lista de cortes de caja', cash_outs_path if can? :read, CashOut sub_nav.item :divider_before_pointsales, '#', divider: true sub_nav.item :list_promotions, 'Promociones', promotions_path if can? :read, Promotion if can? :read, Seller sub_nav.item :divider_before_sellers, '#', divider: true sub_nav.item :list_sellers, 'Lista de vendedores', sellers_path end if can? :read, Transfer sub_nav.item :divider_after_sellers, '#', divider: true sub_nav.item :list_transfers, 'Lista de traspasos', transfers_path end if can? :read, Warehouse sub_nav.item :divider_after_list_users, '#', divider: true sub_nav.item :list_warehouse, 'Almacenes', warehouses_path end end # ventas if can? :read, Sale primary.item :sales, { icon: "fa fa-fw fa-money", text: "Ventas" }, sales_path, class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } sub_nav.item :list_sales, 'Lista de ventas', sales_path if can? :sales_reserved, Sale sub_nav.item :list_sales_reserved, 'Lista de apartados', sales_reserved_path end if can? :read, ProductsReturn sub_nav.item :list_products_return, 'Lista de devoluciones', products_returns_path end if can? :manage, Commission sub_nav.item :divider_after_list_returns, '#', divider: true sub_nav.item :commission, 'Lista de comisiones', commissions_path end end end # egresos if can? :read, Expense primary.item :expensesconcepts, { icon: "fa fa-fw fa-dollar", text: "Egresos" }, expensesconcepts_path, class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } if can? :read, Expensesconcept sub_nav.item :list_expensesconcepts, 'Lista de conceptos de egreso', expensesconcepts_path sub_nav.item :divider_after_list_expensesconcepts, '#', divider: true end sub_nav.item :list_expenses, 'Lista de egresos', expenses_path end end # reportes if current_user.usertype == "A" || current_user.usertype == "SS" primary.item :reports, { icon: "fa fa-bar-chart", text: "Reportes" }, '#', class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } sub_nav.item :sales_per_month, 'Ventas por mes', sales_per_month_report_path sub_nav.item :divider_after_sales_report, '#', divider: true sub_nav.item :purchases_per_month, 'Compras por mes', purchases_per_month_path sub_nav.item :divider_after_purchases_report, '#', divider: true sub_nav.item :minmax_report, 'Mínimos y Máximos', min_max_path sub_nav.item :divider_after_minmax_report, '#', divider: true sub_nav.item :utilities_report, 'Utilidades', utilities_report_path end end # soporte primary.item :support, { icon: "fa fa-fw fa-group", text: "Soporte" }, '#', class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: "dropdown-menu pull-left" } sub_nav.item :send_info, "Soporte técnico", contact_support_path sub_nav.item :updates, "Actualizaciones", system_updates_path end # configuracion general if can? :read, PosConfig primary.item :pos_config, { icon: "fa fa-fw fa-cog", text: "Configuración" }, '#', class: 'menu-dropdown classic-menu-dropdown' do |sub_nav| sub_nav.dom_attributes = { class: 'dropdown-menu pull-left' } if can? :manage, PosConfig sub_nav.item :pos_configs, 'Configurar parámetros generales', pos_configs_path sub_nav.item :divider_after_pos_config, '#', divider: true end sub_nav.item :list_products_initial_stock, 'Stock inicial de productos', products_initial_stock_path sub_nav.item :list_products_stock, 'Stock mínimo y máximo de productos', products_stock_path if can? :read, User sub_nav.item :divider_after_products_stock, '#', divider: true sub_nav.item :list_users, 'Usuarios del sistema', users_path end end end class BootstrapBreadcrumbs < SimpleNavigation::Renderer::Base def render(item_container) content_tag(:ul, li_tags(item_container).join(join_with), id: item_container.dom_id, class: "#{item_container.dom_class} breadcrumb") end protected def li_tags(item_container) item_container.items.inject([]) do |list, item| # rubocop:disable Style/IfInsideElse if item.selected? if include_sub_navigation?(item) list << content_tag(:li, link_to(item.name, item.url, { method: item.method }.merge(item.html_options.except(:class, :id)))) if item.selected? list.concat li_tags(item.sub_navigation) else list << content_tag(:li, item.name, class: 'active') if item.selected? end end # rubocop:enable Style/IfInsideElse list end end def join_with @join_with ||= options[:join_with] || '/'.html_safe end end end end # rubocop:enable Metrics/BlockLength