active_scaffold_vho 3.0.16 → 3.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_scaffold_vho}
8
- s.version = "3.0.16"
8
+ s.version = "3.0.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Many, see README"]
12
- s.date = %q{2011-03-07}
12
+ s.date = %q{2011-03-14}
13
13
  s.description = %q{Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.}
14
14
  s.email = %q{activescaffold@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -14,7 +14,7 @@ form_tag url_options, options %>
14
14
  <% unless hiddens.empty? -%>
15
15
  <li class="sub-section">
16
16
  <h5><%= as_(:optional_attributes) %></h5>
17
- <ol id ="<%= sub_section_id(:sub_section => 'further_options') %>" class="form" 'style="display: none;"'>
17
+ <ol id ="<%= sub_section_id(:sub_section => 'further_options') %>" class="form" style="display:none;">
18
18
  <% hiddens.each do |column| -%>
19
19
  <%= render :partial => 'search_attribute', :locals => {:column => column} %>
20
20
  <% end -%>
@@ -1,5 +1,5 @@
1
1
  <% subsection_id ||= nil %>
2
- <ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= 'style="display: none;"' if columns.collapsed -%>>
2
+ <ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= "style=\"display: none;\"" if columns.collapsed %>>
3
3
  <% columns.each :for => @record do |column| %>
4
4
  <% renders_as = column_renders_as(column) %>
5
5
  <% if renders_as == :subsection -%>
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  parent_record = @record
3
- associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a
3
+ associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).all
4
4
  associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order)
5
5
  if column.show_blank_record? associated
6
6
  associated << if column.singular_association?
@@ -1,9 +1,13 @@
1
1
  <table cellpadding="0" cellspacing="0">
2
- <%
3
- @record = if column.singular_association?
4
- parent_record.send("build_#{column.name}".to_sym)
2
+ <%
3
+ if associated.empty?
4
+ @record = if column.singular_association?
5
+ parent_record.send("build_#{column.name}".to_sym)
6
+ else
7
+ parent_record.send(column.name).build
8
+ end
5
9
  else
6
- parent_record.send(column.name).build
10
+ @record = associated.last
7
11
  end
8
12
  -%>
9
13
  <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record} %>
@@ -49,5 +49,11 @@ end
49
49
 
50
50
  require File.join(File.dirname(__FILE__), 'shared', 'date_bridge.rb')
51
51
  Dir[File.join(File.dirname(__FILE__), "*/bridge.rb")].each{|bridge_require|
52
- require bridge_require
52
+ load_bridge = true
53
+ unless ActiveScaffold.exclude_bridges.empty?
54
+ match = bridge_require.match('bridges\/(.*)\/bridge.rb')
55
+ bridge_name = match[1] ? match[1] : nil
56
+ load_bridge = ActiveScaffold.exclude_bridges.exclude?(bridge_name.to_sym) if bridge_name
57
+ end
58
+ require bridge_require if load_bridge == true
53
59
  }
@@ -2,8 +2,9 @@ ActiveScaffold::Bridges.bridge "CanCan" do
2
2
  install do
3
3
  require File.join(File.dirname(__FILE__), "lib", "cancan_bridge.rb")
4
4
 
5
- ActiveScaffold::Actions::Core.send :include, ActiveScaffold::CancanBridge::Core
6
- ActiveScaffold::Actions::Nested.send :include, ActiveScaffold::CancanBridge::Core
5
+ ActiveScaffold::ClassMethods.send :include, ActiveScaffold::CancanBridge::ClassMethods
6
+ ActiveScaffold::Actions::Core.send :include, ActiveScaffold::CancanBridge::Actions::Core
7
+ ActiveScaffold::Actions::Nested.send :include, ActiveScaffold::CancanBridge::Actions::Core
7
8
  ActionController::Base.send :include, ActiveScaffold::CancanBridge::ModelUserAccess::Controller
8
9
  ActiveRecord::Base.send :include, ActiveScaffold::CancanBridge::ModelUserAccess::Model
9
10
  ActiveRecord::Base.send :include, ActiveScaffold::CancanBridge::ActiveRecord
@@ -1,14 +1,35 @@
1
1
  module ActiveScaffold
2
2
  module CancanBridge
3
3
 
4
- module Core
4
+ # controller level authorization
5
+ # As already has callbacks to ensure authorization at controller method via "authorization_method"
6
+ # but let's include this too, just in case, no sure how performance is affected tough :TODO benchmark
7
+ module ClassMethods
5
8
  extend ActiveSupport::Concern
6
9
  included do
7
- alias_method_chain :beginning_of_chain, :cancan
10
+ alias_method_chain :active_scaffold, :cancan
8
11
  end
9
- # :TODO can this be expanded more ?
10
- def beginning_of_chain_with_cancan
11
- beginning_of_chain_without_cancan.accessible_by(current_ability)
12
+
13
+ def active_scaffold_with_cancan(model_id = nil, &block)
14
+ active_scaffold_without_cancan(model_id, &block)
15
+ authorize_resource(
16
+ :class => active_scaffold_config.model,
17
+ :instance => :record
18
+ )
19
+ end
20
+ end
21
+
22
+ # beginning of chain integration
23
+ module Actions
24
+ module Core
25
+ extend ActiveSupport::Concern
26
+ included do
27
+ alias_method_chain :beginning_of_chain, :cancan
28
+ end
29
+ # :TODO can this be expanded more ?
30
+ def beginning_of_chain_with_cancan
31
+ beginning_of_chain_without_cancan.accessible_by(current_ability)
32
+ end
12
33
  end
13
34
  end
14
35
 
@@ -47,6 +68,7 @@ module ActiveScaffold
47
68
  end
48
69
 
49
70
 
71
+ # plug into AS#authorized_for calls
50
72
  module ActiveRecord
51
73
  extend ActiveSupport::Concern
52
74
  included do
@@ -4,7 +4,7 @@ module ActiveScaffold
4
4
  def active_scaffold_input_carrierwave(column, options)
5
5
  options = active_scaffold_input_text_options(options)
6
6
  carrierwave = @record.send("#{column.name}")
7
- if carrierwave.file.present? && !carrierwave.file.empty?
7
+ if !carrierwave.file.blank?
8
8
 
9
9
  remove_field_options = {
10
10
  :name => options[:name].gsub(/\[#{column.name}\]$/, "[remove_#{column.name}]"),
@@ -3,7 +3,7 @@ module ActiveScaffold
3
3
  module ListColumnHelpers
4
4
  def active_scaffold_column_carrierwave(column, record)
5
5
  carrierwave = record.send("#{column.name}")
6
- return nil unless carrierwave.file.present? && !carrierwave.file.empty?
6
+ return nil unless !carrierwave.file.blank?
7
7
  thumbnail_style = ActiveScaffold::Bridges::Carrierwave::Lib::CarrierwaveBridgeHelpers.thumbnail_style
8
8
  content = if carrierwave.versions.keys.include?(thumbnail_style)
9
9
  image_tag(carrierwave.url(thumbnail_style), :border => 0).html_safe
@@ -153,7 +153,10 @@ module ActiveScaffold::DataStructures
153
153
  # a collection of associations to pre-load when finding the records on a page
154
154
  attr_reader :includes
155
155
  def includes=(value)
156
- @includes = value.is_a?(Array) ? value : [value] # automatically convert to an array
156
+ @includes = case value
157
+ when Array, Hash then value
158
+ else [value] # automatically convert to an array
159
+ end
157
160
  end
158
161
 
159
162
  # a collection of columns to load when eager loading is disabled, if it's nil all columns will be loaded
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 16
5
+ PATCH = 17
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -107,6 +107,20 @@ module ActiveScaffold
107
107
  @@js_framework ||= :prototype
108
108
  end
109
109
 
110
+ # exclude bridges you do not need
111
+ # name of bridge subdir should be used to exclude it
112
+ # eg
113
+ # ActiveScaffold.exclude_bridges = [:cancan, :ancestry]
114
+ # if you are using Activescaffold as a gem add to initializer
115
+ # if you are using Activescaffold as a plugin add to active_scaffold_env.rb
116
+ def self.exclude_bridges=(bridges)
117
+ @@exclude_bridges = bridges
118
+ end
119
+
120
+ def self.exclude_bridges
121
+ @@exclude_bridges ||= []
122
+ end
123
+
110
124
  def self.root
111
125
  File.dirname(__FILE__) + "/.."
112
126
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_vho
3
3
  version: !ruby/object:Gem::Version
4
- hash: 39
4
+ hash: 37
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 16
10
- version: 3.0.16
9
+ - 17
10
+ version: 3.0.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 +01:00
18
+ date: 2011-03-14 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency