refactor render, see https://rails-bestpractices.com/posts/2010/12/04/simplify-render-in-views/
This commit is contained in:
parent
7960b865f4
commit
16ff3e5d67
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ docs/_templates
|
||||
.enable_*
|
||||
/node_modules
|
||||
/yarn.lock
|
||||
rails_best_practices_output.html
|
||||
|
@ -78,11 +78,11 @@ class DashboardsController < ApplicationController
|
||||
flash[:notice] = l :notice_successful_create
|
||||
redirect_to dashboard_link_path(@project, @dashboard)
|
||||
end
|
||||
format.api { render action: 'show', status: :created, location: dashboard_url(@dashboard, project_id: @project) }
|
||||
format.api { render action: :show, status: :created, location: dashboard_url(@dashboard, project_id: @project) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render action: 'new' }
|
||||
format.html { render :new }
|
||||
format.api { render_validation_errors @dashboard }
|
||||
end
|
||||
end
|
||||
@ -118,7 +118,7 @@ class DashboardsController < ApplicationController
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render action: 'edit' }
|
||||
format.html { render :edit }
|
||||
format.api { render_validation_errors @dashboard }
|
||||
end
|
||||
end
|
||||
|
@ -335,9 +335,7 @@ module DashboardsHelper
|
||||
.limit(max_entries)
|
||||
.to_a
|
||||
|
||||
render partial: 'dashboards/blocks/documents', locals: { block: block,
|
||||
max_entries: max_entries,
|
||||
documents: documents }
|
||||
render 'dashboards/blocks/documents', block: block, max_entries: max_entries, documents: documents
|
||||
end
|
||||
|
||||
def render_news_block(block, _block_definition, settings, dashboard)
|
||||
@ -354,9 +352,7 @@ module DashboardsHelper
|
||||
.to_a
|
||||
end
|
||||
|
||||
render partial: 'dashboards/blocks/news', locals: { block: block,
|
||||
max_entries: max_entries,
|
||||
news: news }
|
||||
render 'dashboards/blocks/news', block: block, max_entries: max_entries, news: news
|
||||
end
|
||||
|
||||
def render_my_spent_time_block(block, block_definition, settings, dashboard)
|
||||
@ -369,12 +365,12 @@ module DashboardsHelper
|
||||
entries_today = scope.where spent_on: User.current.today
|
||||
entries_days = scope.where spent_on: User.current.today - (days - 1)..User.current.today
|
||||
|
||||
render partial: 'dashboards/blocks/my_spent_time',
|
||||
locals: { block: block,
|
||||
block_definition: block_definition,
|
||||
entries_today: entries_today,
|
||||
entries_days: entries_days,
|
||||
days: days }
|
||||
render 'dashboards/blocks/my_spent_time',
|
||||
block: block,
|
||||
block_definition: block_definition,
|
||||
entries_today: entries_today,
|
||||
entries_days: entries_days,
|
||||
days: days
|
||||
end
|
||||
|
||||
def activity_dashboard_data(settings, dashboard)
|
||||
@ -443,10 +439,10 @@ module DashboardsHelper
|
||||
partial_locals = build_dashboard_partial_locals block, block_definition, settings, dashboard
|
||||
|
||||
if block_definition[:query_block] || block_definition[:async]
|
||||
render partial: 'dashboards/blocks/async', locals: partial_locals
|
||||
render 'dashboards/blocks/async', partial_locals
|
||||
elsif partial
|
||||
begin
|
||||
render partial: partial, locals: partial_locals
|
||||
render partial, partial_locals
|
||||
rescue ActionView::MissingTemplate
|
||||
Rails.logger.warn "Partial \"#{partial}\" missing for block \"#{block}\" found in #{dashboard.name} (id=#{dashboard.id})"
|
||||
nil
|
||||
|
@ -6,4 +6,4 @@ fieldset.box
|
||||
= render_query_columns_selection query, name: "settings[#{setting_name_columns}][column_names]"
|
||||
|
||||
- if !defined?(totalable_columns) || totalable_columns
|
||||
= render partial: 'additionals/settings_list_totals', locals: { query_class: query_class, query_type: query_type }
|
||||
= render 'additionals/settings_list_totals', query_class: query_class, query_type: query_type
|
||||
|
@ -2,7 +2,7 @@
|
||||
.additionals-chart-left
|
||||
canvas id="#{@chart[:id]}" style="width: #{@chart[:width]}px; height: #{@chart[:height]}px;"
|
||||
.additionals-table-of-values
|
||||
= render partial: 'additionals/chart_table_values'
|
||||
= render 'additionals/chart_table_values'
|
||||
|
||||
.clear-both
|
||||
|
||||
|
@ -5,4 +5,4 @@
|
||||
h3 = link_to title, activity_path(user_id: User.current,
|
||||
from: events_by_day.keys.first)
|
||||
|
||||
= render partial: 'activities/activities', locals: { events_by_day: events_by_day }
|
||||
= render 'activities/activities', events_by_day: events_by_day
|
||||
|
@ -8,11 +8,11 @@
|
||||
(!block_definition.key?(:with_settings_if) || block_definition[:with_settings_if].call(@project))
|
||||
div id="#{block}-settings" class="#{'hidden' if with_async}"
|
||||
= form_tag _update_layout_setting_dashboard_path(@project, dashboard), remote: true do
|
||||
= render partial: block_definition[:settings_partial].presence || "#{async[:partial]}_settings",
|
||||
locals: build_dashboard_partial_locals(block,
|
||||
block_definition,
|
||||
settings,
|
||||
dashboard).merge(with_async: with_async)
|
||||
= render block_definition[:settings_partial].presence || "#{async[:partial]}_settings",
|
||||
build_dashboard_partial_locals(block,
|
||||
block_definition,
|
||||
settings,
|
||||
dashboard).merge(with_async: with_async)
|
||||
|
||||
p
|
||||
= submit_tag l(:button_save)
|
||||
|
@ -20,12 +20,12 @@
|
||||
/ required by some helpers of other plugins
|
||||
- @query = query
|
||||
|
||||
= render partial: query_block[:list_partial],
|
||||
locals: { query_block[:entities_var] => query.send(query_block[:entries_method] || 'entries',
|
||||
= render query_block[:list_partial],
|
||||
query_block[:entities_var] => query.send(query_block[:entries_method] || 'entries',
|
||||
limit: settings[:max_entries] || DashboardContent::DEFAULT_MAX_ENTRIES),
|
||||
query: query,
|
||||
query_options: { sort_param: 'sort',
|
||||
sort_link_options: { method: :post, remote: true } } }
|
||||
query: query,
|
||||
query_options: { sort_param: 'sort',
|
||||
sort_link_options: { method: :post, remote: true } }
|
||||
- else
|
||||
p.nodata = l :label_no_data
|
||||
- else
|
||||
|
@ -8,7 +8,7 @@
|
||||
- if @can_edit
|
||||
.hidden id="#{block}-settings"
|
||||
= form_tag _update_layout_setting_dashboard_path(@project, @dashboard), remote: true do
|
||||
= render partial: 'dashboards/blocks/text_async_settings', locals: { block: block, settings: settings }
|
||||
= render 'dashboards/blocks/text_async_settings', block: block, settings: settings
|
||||
p
|
||||
= submit_tag l :button_save
|
||||
'
|
||||
|
@ -2,5 +2,5 @@ h2 = l :button_dashboard_edit
|
||||
= labelled_form_for :dashboard,
|
||||
@dashboard,
|
||||
html: { multipart: true, id: 'dashboard-form' } do |f|
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render 'form', f: f
|
||||
= submit_tag l(:button_save)
|
||||
|
@ -3,5 +3,5 @@ h2 = l :label_new_dashboard
|
||||
@dashboard,
|
||||
url: { action: 'create', project_id: @project },
|
||||
html: { multipart: true, id: 'dashboard-form' } do |f|
|
||||
= render partial: 'form', locals: { f: f }
|
||||
= render 'form', f: f
|
||||
= submit_tag l(:button_create)
|
||||
|
@ -63,7 +63,7 @@ h2 = project_overview_name @project, @dashboard
|
||||
span.icon.icon-lock
|
||||
= l :text_project_closed
|
||||
|
||||
= render partial: 'common/dashboard', locals: { dashboard: @dashboard }
|
||||
= render 'common/dashboard', dashboard: @dashboard
|
||||
= content_for :render_async
|
||||
|
||||
javascript:
|
||||
|
@ -27,14 +27,14 @@ h2 = welcome_overview_name @dashboard
|
||||
|
||||
= call_hook :view_welcome_index_top
|
||||
|
||||
= render partial: 'common/dashboard', locals: { dashboard: @dashboard }
|
||||
= render 'common/dashboard', dashboard: @dashboard
|
||||
= content_for :render_async
|
||||
|
||||
= call_hook :view_welcome_index_bottom
|
||||
|
||||
- if @dashboard_sidebar
|
||||
- content_for :sidebar do
|
||||
= render partial: 'sidebar'
|
||||
= render 'sidebar'
|
||||
= call_hook :view_welcome_show_sidebar_bottom
|
||||
|
||||
- content_for :header_tags do
|
||||
|
@ -79,9 +79,9 @@ module Additionals
|
||||
options[:title]
|
||||
end
|
||||
|
||||
render partial: 'wiki/user_macros', locals: { users: users,
|
||||
user_roles: user_roles,
|
||||
list_title: list_title }
|
||||
render 'wiki/user_macros', users: users,
|
||||
user_roles: user_roles,
|
||||
list_title: list_title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user