Skip to content

Commit a818f64

Browse files
committed
Cleanup trailing whitespace
1 parent 3d33e03 commit a818f64

File tree

72 files changed

+1803
-1803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1803
-1803
lines changed

.rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--color
1+
--color

Rakefile

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Add your own tasks in files placed in lib/tasks ending in .rake,
2-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3-
4-
Dir['lib/tasks/*.rake'].each { |rake| load rake }
5-
6-
require "rubygems"
7-
require "bundler/setup"
8-
require 'rspec/core/rake_task'
9-
10-
RSpec::Core::RakeTask.new(:spec)
11-
12-
task :test => :spec
13-
task :default => :spec
14-
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
Dir['lib/tasks/*.rake'].each { |rake| load rake }
5+
6+
require "rubygems"
7+
require "bundler/setup"
8+
require 'rspec/core/rake_task'
9+
10+
RSpec::Core::RakeTask.new(:spec)
11+
12+
task :test => :spec
13+
task :default => :spec
14+

app/controllers/rails_admin/application_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ def to_model_name(param)
2222
model_name = to_model_name_with_singularize(param)
2323
presented_model_name?(model_name)? model_name : to_model_name_without_singularize(param)
2424
end
25-
25+
2626
def to_model_name_without_singularize(param)
2727
parts = param.split("~")
2828
parts.map(&:camelize).join("::")
2929
end
30-
30+
3131
def to_model_name_with_singularize(param)
3232
parts = param.split("~")
3333
parts[-1] = parts.last.singularize
3434
parts.map(&:camelize).join("::")
3535
end
36-
36+
3737
def presented_model_name?(model_name)
3838
!RailsAdmin::AbstractModel.lookup(model_name).nil?
3939
end
40-
40+
4141
def get_object
4242
@object = @abstract_model.get(params[:id])
4343
not_found unless @object
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
module RailsAdmin
2-
class HistoryController < RailsAdmin::ApplicationController
3-
before_filter :get_model
4-
before_filter :get_object, :except => :for_model
5-
6-
def for_model
7-
@authorization_adapter.authorize(:history) if @authorization_adapter
8-
@page_type = @abstract_model.pretty_name.downcase
9-
@page_name = t("admin.history.page_name", :name => @model_config.label.downcase)
10-
@general = true
11-
@history = History.history_for_model(@abstract_model, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page])
12-
13-
render "show", :layout => request.xhr? ? false : 'rails_admin/application'
14-
end
15-
16-
def for_object
17-
@authorization_adapter.authorize(:history) if @authorization_adapter
18-
@page_type = @abstract_model.pretty_name.downcase
19-
@page_name = t("admin.history.page_name", :name => "#{@model_config.label.downcase} '#{@model_config.with(:object => @object).object_label}'")
20-
@general = false
21-
@history = History.history_for_object(@abstract_model, @object, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page])
22-
23-
render "show", :layout => request.xhr? ? false : 'rails_admin/application'
24-
end
25-
end
26-
end
1+
module RailsAdmin
2+
class HistoryController < RailsAdmin::ApplicationController
3+
before_filter :get_model
4+
before_filter :get_object, :except => :for_model
5+
6+
def for_model
7+
@authorization_adapter.authorize(:history) if @authorization_adapter
8+
@page_type = @abstract_model.pretty_name.downcase
9+
@page_name = t("admin.history.page_name", :name => @model_config.label.downcase)
10+
@general = true
11+
@history = History.history_for_model(@abstract_model, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page])
12+
13+
render "show", :layout => request.xhr? ? false : 'rails_admin/application'
14+
end
15+
16+
def for_object
17+
@authorization_adapter.authorize(:history) if @authorization_adapter
18+
@page_type = @abstract_model.pretty_name.downcase
19+
@page_name = t("admin.history.page_name", :name => "#{@model_config.label.downcase} '#{@model_config.with(:object => @object).object_label}'")
20+
@general = false
21+
@history = History.history_for_object(@abstract_model, @object, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page])
22+
23+
render "show", :layout => request.xhr? ? false : 'rails_admin/application'
24+
end
25+
end
26+
end

app/controllers/rails_admin/main_controller.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def dashboard
1616

1717
@history= History.all
1818
@abstract_models = RailsAdmin::Config.visible_models.map(&:abstract_model)
19-
19+
2020
@most_recent_changes = {}
2121
@count = {}
2222
@max = 0
@@ -230,15 +230,15 @@ def bulk_delete
230230
@page_type = @abstract_model.pretty_name.downcase
231231
@objects = list_entries(@model_config, :destroy)
232232
not_found and return if @objects.empty?
233-
233+
234234
render :action => 'bulk_delete'
235235
end
236236

237237
def bulk_destroy
238238
@authorization_adapter.authorize(:bulk_destroy, @abstract_model) if @authorization_adapter
239239
@objects = list_entries(@model_config, :destroy)
240240
processed_objects = @abstract_model.destroy(@objects)
241-
241+
242242
destroyed = processed_objects.select(&:destroyed?)
243243
not_destroyed = processed_objects - destroyed
244244

@@ -256,17 +256,17 @@ def bulk_destroy
256256
end
257257

258258
redirect_to index_path
259-
end
260-
259+
end
260+
261261
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all]))
262262
scope = @authorization_adapter && @authorization_adapter.query(auth_scope_key, model_config.abstract_model)
263263
scope = model_config.abstract_model.scoped.merge(scope)
264264
scope = scope.instance_eval(&additional_scope) if additional_scope
265265
get_collection(model_config, scope, pagination)
266266
end
267-
267+
268268
private
269-
269+
270270
def get_sort_hash(model_config)
271271
abstract_model = model_config.abstract_model
272272
params[:sort] = params[:sort_reverse] = nil unless model_config.list.with(:view => self, :object => abstract_model.model.new).visible_fields.map {|f| f.name.to_s}.include? params[:sort]
@@ -294,7 +294,7 @@ def get_sort_hash(model_config)
294294
{:sort => column, :sort_reverse => (params[:sort_reverse] == reversed_sort.to_s)}
295295
end
296296

297-
297+
298298
def get_attributes
299299
@attributes = params[@abstract_model.to_param.singularize.gsub('~','_')] || {}
300300
@attributes.each do |key, value|
@@ -306,7 +306,7 @@ def get_attributes
306306
@attributes[key] = nil if value.blank?
307307
end
308308
end
309-
309+
310310
def redirect_to_on_success
311311
notice = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.#{params[:action]}d"))
312312
if params[:_add_another]
@@ -329,11 +329,11 @@ def handle_save_error whereto = :new
329329
format.js { render whereto, :layout => false, :status => :not_acceptable }
330330
end
331331
end
332-
332+
333333
def check_for_cancel
334334
redirect_to index_path, :flash => { :warning => t("admin.flash.noaction") } if params[:_continue]
335335
end
336-
336+
337337
def get_collection(model_config, scope, pagination)
338338
associations = model_config.list.fields.select {|f| f.type == :belongs_to_association && !f.polymorphic? }.map {|f| f.association[:name] }
339339
options = {}
@@ -342,10 +342,10 @@ def get_collection(model_config, scope, pagination)
342342
options = options.merge(get_sort_hash(model_config)) unless params[:associated_collection]
343343
options = options.merge(model_config.abstract_model.get_conditions_hash(model_config, params[:query], params[:f])) if (params[:query].present? || params[:f].present?)
344344
options = options.merge(:bulk_ids => params[:bulk_ids]) if params[:bulk_ids]
345-
345+
346346
objects = model_config.abstract_model.all(options, scope)
347347
end
348-
348+
349349
def get_association_scope_from_params
350350
return nil unless params[:associated_collection].present?
351351
source_abstract_model = RailsAdmin::AbstractModel.new(to_model_name(params[:source_abstract_model]))
@@ -355,7 +355,7 @@ def get_association_scope_from_params
355355
association = source_model_config.send(action).fields.find{|f| f.name == params[:associated_collection].to_sym }.with(:controller => self, :object => source_object)
356356
association.associated_collection_scope
357357
end
358-
358+
359359
def associations_hash
360360
associations = {}
361361
@abstract_model.associations.each do |association|
+52-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| "<span class=\"field_with_errors\">#{html_tag}</span>".html_safe }
2-
3-
module RailsAdmin
4-
class FormBuilder < ActionView::Helpers::FormBuilder
5-
def render action
6-
@template.instance_variable_get(:@model_config).send(action).with(:form => self, :object => @object, :view => @template).visible_groups.map do |fieldset|
7-
fieldset_for fieldset
8-
end.join.html_safe +
9-
@template.render(:partial => 'submit_buttons')
10-
end
11-
12-
def fieldset_for fieldset
13-
if (fields = fieldset.fields.map{ |f| f.with(:form => self, :object => @object, :view => @template) }.select(&:visible?)).length > 0
14-
@template.content_tag :fieldset do
15-
@template.content_tag(:legend, fieldset.label.html_safe + (fieldset.help.present? ? @template.content_tag(:small, fieldset.help) : '')) +
16-
fields.map{ |field| field_wrapper_for(field) }.join.html_safe
17-
end
18-
end
19-
end
20-
21-
def field_wrapper_for field
22-
@template.content_tag(:div, :class => "clearfix field #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => field.dom_id + '_field') do
23-
label(field.method_name, field.label) +
24-
input_for(field)
25-
end
26-
end
27-
28-
def input_for field
29-
@template.content_tag(:div, :class => 'input') do
30-
field_for(field) +
31-
errors_for(field) +
32-
help_for(field)
33-
end
34-
end
35-
36-
def errors_for field
37-
field.errors.present? ? @template.content_tag(:span, "#{field.label} #{field.errors.first}", :class => 'help-inline') : ''
38-
end
39-
40-
def help_for field
41-
field.help.present? ? @template.content_tag(:span, field.help, :class => 'help-block') : ''
42-
end
43-
44-
def field_for field
45-
if field.read_only
46-
field.pretty_value.to_s.html_safe
47-
else
48-
field.render.html_safe
49-
end
50-
end
51-
end
52-
end
1+
ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| "<span class=\"field_with_errors\">#{html_tag}</span>".html_safe }
2+
3+
module RailsAdmin
4+
class FormBuilder < ActionView::Helpers::FormBuilder
5+
def render action
6+
@template.instance_variable_get(:@model_config).send(action).with(:form => self, :object => @object, :view => @template).visible_groups.map do |fieldset|
7+
fieldset_for fieldset
8+
end.join.html_safe +
9+
@template.render(:partial => 'submit_buttons')
10+
end
11+
12+
def fieldset_for fieldset
13+
if (fields = fieldset.fields.map{ |f| f.with(:form => self, :object => @object, :view => @template) }.select(&:visible?)).length > 0
14+
@template.content_tag :fieldset do
15+
@template.content_tag(:legend, fieldset.label.html_safe + (fieldset.help.present? ? @template.content_tag(:small, fieldset.help) : '')) +
16+
fields.map{ |field| field_wrapper_for(field) }.join.html_safe
17+
end
18+
end
19+
end
20+
21+
def field_wrapper_for field
22+
@template.content_tag(:div, :class => "clearfix field #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", :id => field.dom_id + '_field') do
23+
label(field.method_name, field.label) +
24+
input_for(field)
25+
end
26+
end
27+
28+
def input_for field
29+
@template.content_tag(:div, :class => 'input') do
30+
field_for(field) +
31+
errors_for(field) +
32+
help_for(field)
33+
end
34+
end
35+
36+
def errors_for field
37+
field.errors.present? ? @template.content_tag(:span, "#{field.label} #{field.errors.first}", :class => 'help-inline') : ''
38+
end
39+
40+
def help_for field
41+
field.help.present? ? @template.content_tag(:span, field.help, :class => 'help-block') : ''
42+
end
43+
44+
def field_for field
45+
if field.read_only
46+
field.pretty_value.to_s.html_safe
47+
else
48+
field.render.html_safe
49+
end
50+
end
51+
end
52+
end
+31-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
require 'builder'
2-
3-
module RailsAdmin
4-
module MainHelper
5-
def get_indicator(percent)
6-
return "" if percent < 0 # none
7-
return "notice" if percent < 34 # < 1/100 of max
8-
return "success" if percent < 67 # < 1/10 of max
9-
return "warning" if percent < 84 # < 1/3 of max
10-
return "important" # > 1/3 of max
11-
end
12-
13-
def get_column_sets(properties)
14-
sets = []
15-
property_index = 0
16-
set_index = 0
17-
18-
while (property_index < properties.length)
19-
current_set_width = 0
20-
begin
21-
sets[set_index] ||= []
22-
sets[set_index] << properties[property_index]
23-
current_set_width += (properties[property_index].column_width || 120)
24-
property_index += 1
25-
end while (current_set_width < RailsAdmin::Config.total_columns_width) && (property_index < properties.length)
26-
set_index += 1
27-
end
28-
sets
29-
end
30-
end
31-
end
1+
require 'builder'
2+
3+
module RailsAdmin
4+
module MainHelper
5+
def get_indicator(percent)
6+
return "" if percent < 0 # none
7+
return "notice" if percent < 34 # < 1/100 of max
8+
return "success" if percent < 67 # < 1/10 of max
9+
return "warning" if percent < 84 # < 1/3 of max
10+
return "important" # > 1/3 of max
11+
end
12+
13+
def get_column_sets(properties)
14+
sets = []
15+
property_index = 0
16+
set_index = 0
17+
18+
while (property_index < properties.length)
19+
current_set_width = 0
20+
begin
21+
sets[set_index] ||= []
22+
sets[set_index] << properties[property_index]
23+
current_set_width += (properties[property_index].column_width || 120)
24+
property_index += 1
25+
end while (current_set_width < RailsAdmin::Config.total_columns_width) && (property_index < properties.length)
26+
set_index += 1
27+
end
28+
sets
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)