Sha256: 80ccdefa8768b82683d2f006d80bfa0f50857359dcd7a728e1d5a765c3231250

Contents?: true

Size: 1 KB

Versions: 12

Compression:

Stored size: 1 KB

Contents

module Sis
  module Core
    class MenusController < ApplicationController
      skip_before_action :authenticate_request, only: [:menu]
      def menu
        app_module_id = ApplicationModule.find_by_code(params[:app_module]).id
        user_roles = User.find(params[:user_id]).user_roles.where(application_module_id: app_module_id)
        menus = []
        user_roles.each do |role|
          user_menus = role.menus.where(parent_id: nil, application_module_id: app_module_id)
          user_menus.each do |user_menu|
            children = user_menu.children.where(parent_id: user_menu.id, application_module_id: app_module_id)
            children = children.map { |c| { label: c.text, icon: c.icon_cls, routerLink: [c.location] } }
            menus.push({ id: user_menu.id, label: user_menu.text, icon: user_menu.icon_cls,
                         location: user_menu.location, items: children, expanded: true })
          end
        end
        render json: { success: true, data: menus }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sis_core-1.0.20 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.19 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.18 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.17 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.16 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.15 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.14 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.13 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.12 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.11 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.10 app/controllers/sis/core/menus_controller.rb
sis_core-1.0.9 app/controllers/sis/core/menus_controller.rb