Permalink
Browse files

Merge branch 'master' of https://github.com/activescaffold/active_sca…

  • Loading branch information...
2 parents 96ecd21 + af18b15 commit 0c40ec04bcd1d22c8caa8f3029aa141aa38f58d0 @clyfe clyfe committed Mar 6, 2012
View
27 README
@@ -1,7 +1,3 @@
-******************************************************************************************************
-** For all documentation see the project website: http://github.com/vhochstein/active_scaffold/wiki **
-******************************************************************************************************
-
ActiveScaffold Gem/Plugin by Scott Rutherford (scott@caronsoftware.com), Richard White (rrwhite@gmail.com), Lance Ivy (lance@cainlevy.net), Ed Moss, Tim Harper and Sergio Cambra (sergio@entrecables.com)
Uses DhtmlHistory by Brad Neuberg (bkn3@columbia.edu)
@@ -18,9 +14,16 @@ http://code.google.com/p/recordselect/
== Version Information
-Please note the following list of Active Scaffold branches and Rails versions. Master will not work with Rails < 3.1
+If you want to use the gem, add to your Gemfile:
+ gem "active_scaffold"
-Active Scaffold master currently supports rails-3.1, but incompatible changes can be introduced, if you want an stable version, use rails-3.0
+In case you would like to use most recent commit:
+ gem 'active_scaffold', :git => 'git://github.com/activescaffold/active_scaffold.git'
+
+3.1.* and 3.2.* versions works with rails 3.1 and 3.2, 3.0.* versions with rails 3.0.
+To use previous rails versions you will have to install the right branch as a plugin.
+
+Active Scaffold master currently supports rails 3.1 and rails 3.2, you can use following branches for previous rails versions:
Rails 3.0.*: Active Scaffold rails-3.0
Rails 2.3.*: Active Scaffold rails-2.3 and v2.4
Rails 2.2.*: Active Scaffold rails-2.2
@@ -31,19 +34,13 @@ Since Rails 2.3, render_component plugin is needed for nested and embedded scaff
script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3
Since Rails 3.0 render_component is not used for nesting, but is optional for embedded scaffolds.
-Since Rails 3.0, https://github.com/rails/verification.git is also needed.
+For Rails 3.0, https://github.com/rails/verification.git is also needed, not in rails 3.1 or higher.
If you want to install as plugins under vendor/plugins, install these versions:
rails plugin install git://github.com/vhochstein/render_component.git
rails plugin install git://github.com/rails/verification.git
rails plugin install git://github.com/activescaffold/active_scaffold.git -r 'rails-3.0'
-If you want to use the gem, add to your Gemfile:
- gem "active_scaffold"
-
-In case you would like to use most recent commit:
- gem 'active_scaffold', :git => 'git://github.com/activescaffold/active_scaffold.git', :branch => 'rails-3.0'
-
== Pick your own javascript framework
The Rails 3.0 version uses unobtrusive Javascript, so you are free to pick your javascript framework.
@@ -66,8 +63,4 @@ To configure the javascript framework when installed as a gem:
Add a config/initializers/active_scaffold.rb containing:
ActiveScaffold.js_framework = :jquery # :prototype is the default
-== Rails 3.1 compatible branch:
-under construction
-
-
Released under the MIT license (included)
@@ -1,6 +1,13 @@
+<%
+ column_count = if nested?
+ active_scaffold_config_for(nested.parent_model).list.columns.count + 1
+ else
+ active_scaffold_config.list.columns.count + 1
+ end
+%>
<%# nested_id, allows us to remove a nested scaffold programmatically %>
<tr class="inline-adapter" id="<%= element_row_id :action => :nested %>">
- <td colspan="99" class="inline-adapter-cell">
+ <td colspan="<%= column_count %>" class="inline-adapter-cell">
<div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{nested? ? nested.name : id_from_controller(params[:controller])}-view" %> view">
<%= link_to(as_(:close), '', :class => 'inline-adapter-close as_cancel', :remote => true, :title => as_(:close), 'data-refresh' => (action_name == 'index' ? true : false)) -%>
<%= payload -%>
@@ -2,7 +2,6 @@ module ActiveScaffold::Actions
module Core
def self.included(base)
base.class_eval do
- before_filter :register_constraints_with_action_columns
after_filter :clear_flashes
end
base.helper_method :nested?
@@ -34,7 +34,7 @@ def new_respond_to_js
def create_respond_to_html
if params[:iframe]=='true' # was this an iframe post ?
responds_to_parent do
- render :action => 'on_create.js', :layout => false
+ render :action => 'on_create', :format => [:js], :layout => false
end
else
if successful?
@@ -36,7 +36,7 @@ def list_respond_to_js
params.delete(:embedded)
render(:partial => 'list_with_header')
else
- render :action => 'refresh_list.js'
+ render :action => 'refresh_list', :format => [:js]
end
end
def list_respond_to_xml
@@ -2,7 +2,7 @@ module ActiveScaffold::Actions
module Subform
def edit_associated
do_edit_associated
- render :action => 'edit_associated.js'
+ render :action => 'edit_associated', :format => [:js]
end
protected
@@ -35,7 +35,7 @@ def edit_respond_to_js
def update_respond_to_html
if params[:iframe]=='true' # was this an iframe post ?
responds_to_parent do
- render :action => 'on_update.js', :layout => false
+ render :action => 'on_update', :format => [:js], :layout => false
end
else # just a regular post
if successful?
@@ -44,7 +44,7 @@ def active_scaffold_search_date_bridge_calendar_control(column, options, current
:class => 'text-input',
:id => "#{options[:id]}_#{name}",
:time => column_datetime?(column) ? true : false,
- :style => "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"})
+ :style => (options[:show].nil? || options[:show]) ? nil : "display: none"})
end
end
end
@@ -157,7 +157,7 @@ def active_scaffold_search_date_bridge_calendar_control(column, options, current
options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
options = active_scaffold_input_text_options(options.merge(column.options))
options[:class] << " #{column.search_ui.to_s}"
- options[:style] = "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"
+ options[:style] = (options[:show].nil? || options[:show]) ? nil : "display: none"
format = options.delete(:format) || :default
datepicker_format_options(column, format, options)
text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]"))
@@ -28,8 +28,8 @@ def active_scaffold_search_date_bridge_numeric_tag(column, options, current_sear
numeric_controls = "" <<
active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
- :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => "display:#{current_search['opt'] == 'BETWEEN' ? '' : 'none'}")
- content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => "display:#{ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? '' : 'none'}")
+ :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => current_search['opt'] == 'BETWEEN' ? nil : "display: none")
+ content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? nil : "display: none")
end
def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
@@ -45,7 +45,7 @@ def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
:class => 'text-input')
- content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => "display:#{trend_options[:show] ? '' : 'none'}")
+ content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => trend_options[:show] ? nil : "display: none")
end
def active_scaffold_search_date_bridge_trend_units(column)
@@ -58,7 +58,7 @@ def active_scaffold_search_date_bridge_range_tag(column, options, current_search
range_controls = select_tag("search[#{column.name}][range]",
options_for_select( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]),
:class => 'text-input')
- content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => "display:#{(current_search['opt'] == 'RANGE') ? '' : 'none'}")
+ content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => (current_search['opt'] == 'RANGE') ? nil : "display: none")
end
def column_datetime?(column)
@@ -142,6 +142,11 @@ def hide_nested_column
attr_accessor :nested_auto_open
class UserSettings < UserSettings
+ def initialize(conf, storage, params)
+ super(conf,storage,params)
+ @sorting = nil
+ end
+
# This label has alread been localized.
def label
@session[:label] ? @session[:label] : @conf.label
@@ -173,17 +178,20 @@ def default_sorting
end
def sorting
- # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
- @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
- @session['sort'] = nil if @params['sort_direction'] == 'reset'
-
- if @session['sort']
- sorting = @conf.sorting.clone
- sorting.set(*@session['sort'])
- return sorting
- else
- return default_sorting
+ if @sorting.nil?
+ # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
+ @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
+ @session['sort'] = nil if @params['sort_direction'] == 'reset'
+
+ if @session['sort']
+ sorting = @conf.sorting.clone
+ sorting.set(*@session['sort'])
+ @sorting = sorting
+ else
+ @sorting = default_sorting
+ end
end
+ @sorting
end
def count_includes
@@ -95,7 +95,7 @@ def clause
sql = sort_column.sort[:sql]
next if sql.nil? or sql.empty?
- order << "#{sql} #{sort_direction}"
+ order << Array(sql).map {|column| "#{column} #{sort_direction}"}.join(', ')
end
order.join(', ') unless order.empty?
@@ -265,7 +265,7 @@ def finder_options(options = {})
full_includes = (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
# create a general-use options array that's compatible with Rails finders
- finder_options = { :order => options[:sorting].try(:clause),
+ finder_options = { :reorder => options[:sorting].try(:clause),
:where => search_conditions,
:joins => joins_for_finder,
:includes => full_includes}
@@ -278,7 +278,7 @@ def finder_options(options = {})
# See finder_options for valid options
def count_options(find_options = {}, count_includes = nil)
count_includes ||= find_options[:includes] unless find_options[:where].nil?
- options = find_options.reject{|k,v| [:select, :order].include? k}
+ options = find_options.reject{|k,v| [:select, :reorder].include? k}
options[:includes] = count_includes
options
end
@@ -320,14 +320,8 @@ def find_page(options = {})
end
def append_to_query(query, options)
- options.assert_valid_keys :where, :select, :group, :order, :limit, :offset, :joins, :includes, :lock, :readonly, :from
+ options.assert_valid_keys :where, :select, :group, :reorder, :limit, :offset, :joins, :includes, :lock, :readonly, :from
options.reject{|k, v| v.blank?}.inject(query) do |query, (k, v)|
- # default ordering of model has a higher priority than current queries ordering
- # fix this by removing existing ordering from arel
- if k.to_sym == :order
- query = query.where('1=1') unless query.is_a?(ActiveRecord::Relation)
- query = query.except(:order)
- end
query.send((k.to_sym), v)
end
end
@@ -182,7 +182,7 @@ def active_scaffold_search_range(column, options)
html << ' ' << text_field_tag("#{options[:name]}[from]", from_value, active_scaffold_input_text_options(:id => options[:id], :size => text_field_size))
html << ' ' << content_tag(:span, (' - ' + text_field_tag("#{options[:name]}[to]", to_value,
active_scaffold_input_text_options(:id => "#{options[:id]}_to", :size => text_field_size))).html_safe,
- :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => "display:#{(opt_value == 'BETWEEN') ? '' : 'none'}")
+ :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => (opt_value == 'BETWEEN') ? nil : "display: none")
content_tag :span, html, :class => 'search_range'
end
alias_method :active_scaffold_search_integer, :active_scaffold_search_range

0 comments on commit 0c40ec0

Please sign in to comment.