1
0

Introduced plugin layout instead of using Redmine ViewListener render_on

This commit is contained in:
cryptogopher 2020-02-22 22:39:12 +01:00
parent 0f8f74ffec
commit 2d778c831b
13 changed files with 27 additions and 45 deletions

View File

@ -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

View 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

View File

@ -1,8 +1,6 @@
class IngredientsController < ApplicationController
class IngredientsController < BodyTrackingPluginController
require 'csv'
menu_item :body_trackers
helper :body_trackers
helper_method :current_view

View File

@ -1,6 +1,4 @@
class MeasurementsController < ApplicationController
menu_item :body_trackers
class MeasurementsController < BodyTrackingPluginController
helper :body_trackers
before_action :init_session_filters

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -3,5 +3,7 @@
<% end %>
<% content_for :sidebar do %>
<%= render partial: 'body_trackers/sidebar' %>
<%= render partial: 'layouts/sidebar' %>
<% end %>
<%= render :file => "layouts/base" %>

View File

@ -45,6 +45,7 @@ en:
body_trackers:
index:
heading: 'Summary'
layouts:
sidebar:
heading_body_trackers: 'Body trackers'
heading_measurements: 'Measurements'

View File

@ -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

View File

@ -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

View File

@ -1,5 +0,0 @@
module BodyTracking
class BodyTrackersViewListener < Redmine::Hook::ViewListener
render_on :view_layouts_base_html_head, partial: 'layouts/body_tracking'
end
end