Introduced plugin layout instead of using Redmine ViewListener render_on
This commit is contained in:
parent
0f8f74ffec
commit
2d778c831b
@ -1,6 +1,4 @@
|
||||
class BodyTrackersController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
class BodyTrackersController < BodyTrackingPluginController
|
||||
before_action :find_project_by_project_id, only: [:index, :defaults]
|
||||
before_action :authorize
|
||||
|
||||
|
17
app/controllers/body_tracking_plugin_controller.rb
Normal file
17
app/controllers/body_tracking_plugin_controller.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class BodyTrackingPluginController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
layout 'body_tracking'
|
||||
|
||||
private
|
||||
|
||||
def find_quantity(id = :id)
|
||||
@quantity = Quantity.find(params[id])
|
||||
@project = @quantity.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_quantity_by_quantity_id
|
||||
find_quantity(:quantity_id)
|
||||
end
|
||||
end
|
@ -1,8 +1,6 @@
|
||||
class IngredientsController < ApplicationController
|
||||
class IngredientsController < BodyTrackingPluginController
|
||||
require 'csv'
|
||||
|
||||
menu_item :body_trackers
|
||||
|
||||
helper :body_trackers
|
||||
helper_method :current_view
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
class MeasurementsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
class MeasurementsController < BodyTrackingPluginController
|
||||
helper :body_trackers
|
||||
|
||||
before_action :init_session_filters
|
||||
|
@ -1,6 +1,4 @@
|
||||
class QuantitiesController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
class QuantitiesController < BodyTrackingPluginController
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create, :filter, :parents]
|
||||
before_action :find_quantity, only: [:edit, :update, :destroy, :move,
|
||||
|
@ -1,6 +1,4 @@
|
||||
class SourcesController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
class SourcesController < BodyTrackingPluginController
|
||||
before_action :find_project_by_project_id, only: [:index, :create]
|
||||
before_action :find_source, only: [:destroy]
|
||||
before_action :authorize
|
||||
|
@ -1,6 +1,4 @@
|
||||
class UnitsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
class UnitsController < BodyTrackingPluginController
|
||||
before_action :find_project_by_project_id, only: [:index, :create]
|
||||
before_action :find_unit, only: [:destroy]
|
||||
before_action :authorize
|
||||
|
@ -3,5 +3,7 @@
|
||||
<% end %>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render partial: 'body_trackers/sidebar' %>
|
||||
<%= render partial: 'layouts/sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<%= render :file => "layouts/base" %>
|
@ -45,6 +45,7 @@ en:
|
||||
body_trackers:
|
||||
index:
|
||||
heading: 'Summary'
|
||||
layouts:
|
||||
sidebar:
|
||||
heading_body_trackers: 'Body trackers'
|
||||
heading_measurements: 'Measurements'
|
||||
|
3
init.rb
3
init.rb
@ -1,7 +1,4 @@
|
||||
require_dependency 'body_tracking/body_trackers_view_listener'
|
||||
|
||||
(Rails::VERSION::MAJOR < 5 ? ActionDispatch : ActiveSupport)::Reloader.to_prepare do
|
||||
ApplicationController.include BodyTracking::ApplicationControllerPatch
|
||||
Project.include BodyTracking::ProjectPatch
|
||||
end
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
module BodyTracking
|
||||
module ApplicationControllerPatch
|
||||
ApplicationController.class_eval do
|
||||
private
|
||||
|
||||
def find_quantity(id = :id)
|
||||
@quantity = Quantity.find(params[id])
|
||||
@project = @quantity.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_quantity_by_quantity_id
|
||||
find_quantity(:quantity_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
module BodyTracking
|
||||
class BodyTrackersViewListener < Redmine::Hook::ViewListener
|
||||
render_on :view_layouts_base_html_head, partial: 'layouts/body_tracking'
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user