2016-11-22 15:17:37 +01:00
|
|
|
class RenderPartialService
|
|
|
|
attr_accessor :controller, :method
|
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
def initialize(controller, method)
|
2016-11-22 15:17:37 +01:00
|
|
|
@controller = controller
|
|
|
|
@method = method
|
|
|
|
end
|
|
|
|
|
|
|
|
def navbar
|
|
|
|
retrieve_navbar
|
|
|
|
end
|
|
|
|
|
|
|
|
def left_panel
|
|
|
|
retrieve_left_panel
|
|
|
|
end
|
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
def self.left_panel_exist?(left_panel_url)
|
2016-12-01 12:19:22 +01:00
|
|
|
file = left_panel_url.split('/').last
|
|
|
|
|
2018-12-24 17:37:57 +01:00
|
|
|
File.exist?(Rails.root.join('app', 'views', 'layouts', 'left_panels', "_#{file}.html.haml"))
|
2016-12-01 12:19:22 +01:00
|
|
|
end
|
|
|
|
|
2016-11-22 15:17:37 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def retrieve_navbar
|
2018-01-30 15:16:05 +01:00
|
|
|
"layouts/navbars/navbar_#{retrieve_name}"
|
2016-11-22 15:17:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def retrieve_left_panel
|
2018-01-30 15:16:05 +01:00
|
|
|
"layouts/left_panels/left_panel_#{retrieve_name}"
|
2016-11-22 15:17:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def retrieve_name
|
2018-01-15 21:41:16 +01:00
|
|
|
"#{controller.to_s.parameterize.underscore}_#{method.to_s}"
|
2016-11-22 15:17:37 +01:00
|
|
|
end
|
2016-11-22 16:03:32 +01:00
|
|
|
end
|