active_scaffold_vho 3.0.19 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/active_scaffold_vho.gemspec +2 -2
- data/frontends/default/images/close_touch.png +0 -0
- data/frontends/default/javascripts/jquery/active_scaffold.js +6 -2
- data/frontends/default/stylesheets/stylesheet.css +2 -2
- data/frontends/default/views/on_action_update.js.rjs +3 -1
- data/frontends/default/views/on_mark_all.js.rjs +9 -1
- data/lib/active_scaffold.rb +7 -3
- data/lib/active_scaffold/actions/list.rb +15 -7
- data/lib/active_scaffold/actions/mark.rb +16 -4
- data/lib/active_scaffold/actions/nested.rb +1 -1
- data/lib/active_scaffold/config/list.rb +6 -0
- data/lib/active_scaffold/config/mark.rb +15 -2
- data/lib/active_scaffold/helpers/list_column_helpers.rb +8 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb +6 -2
- data/lib/active_scaffold/helpers/view_helpers.rb +10 -5
- data/lib/active_scaffold/version.rb +1 -1
- metadata +4 -4
    
        data/active_scaffold_vho.gemspec
    CHANGED
    
    | @@ -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. | 
| 8 | 
            +
              s.version = "3.0.20"
         | 
| 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- | 
| 12 | 
            +
              s.date = %q{2011-05-27}
         | 
| 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 = [
         | 
| Binary file | 
| @@ -160,7 +160,11 @@ $(document).ready(function() { | |
| 160 160 | 
             
                    params = as_form.serialize();
         | 
| 161 161 | 
             
                    params += '&' + $.param({source_id: element.attr('id')});
         | 
| 162 162 | 
             
                  } else {
         | 
| 163 | 
            -
                     | 
| 163 | 
            +
                    if (element.is("input:checkbox")) {
         | 
| 164 | 
            +
                      params = {value: element.is(":checked")};
         | 
| 165 | 
            +
                    } else {
         | 
| 166 | 
            +
                      params = {value: element.val()};
         | 
| 167 | 
            +
                    }
         | 
| 164 168 | 
             
                    params.source_id = element.attr('id');
         | 
| 165 169 | 
             
                  }
         | 
| 166 170 |  | 
| @@ -593,7 +597,7 @@ var ActiveScaffold = { | |
| 593 597 | 
             
              },
         | 
| 594 598 |  | 
| 595 599 | 
             
              highlight: function(element) {
         | 
| 596 | 
            -
                if (typeof(element) == 'string') element = '#' + element;
         | 
| 600 | 
            +
                if (typeof(element) == 'string') element = $('#' + element);
         | 
| 597 601 | 
             
                if (typeof(element.effect) == 'function') {
         | 
| 598 602 | 
             
                  element.effect("highlight", {}, 3000);
         | 
| 599 603 | 
             
                }
         | 
| @@ -1,8 +1,10 @@ | |
| 1 | 
            -
            page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, render(:partial => 'messages')
         | 
| 2 1 | 
             
            if controller.send :successful?
         | 
| 2 | 
            +
              page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, render(:partial => 'messages')
         | 
| 3 3 | 
             
              page.call 'ActiveScaffold.update_row', element_row_id(:action => :list, :id => @record.id), render(:partial => 'list_record', :locals => {:record => @record}) if @record
         | 
| 4 4 | 
             
              page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
         | 
| 5 5 | 
             
            else
         | 
| 6 | 
            +
              flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)
         | 
| 7 | 
            +
              page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, render(:partial => 'messages')
         | 
| 6 8 | 
             
              page.call 'ActiveScaffold.scroll_to', active_scaffold_messages_id
         | 
| 7 9 | 
             
            end
         | 
| 8 10 |  | 
| @@ -1,4 +1,12 @@ | |
| 1 1 | 
             
            options = {:checked => mark_all,
         | 
| 2 2 | 
             
                       :include_mark_all => true}
         | 
| 3 3 | 
             
            page << "ActiveScaffold.mark_records('#{active_scaffold_tbody_id}', #{options.to_json});"
         | 
| 4 | 
            -
             | 
| 4 | 
            +
            if active_scaffold_config.model.marked.length>0 then
         | 
| 5 | 
            +
              if active_scaffold_config.model.marked.length < @page.pager.count then
         | 
| 6 | 
            +
                page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, active_scaffold_config.model.marked.length.to_s + " records marked. Press <a href=\""+url_for(:action=>"mark_all",:mark_target=>"scope")+"\">here</a> to select all #{@page.pager.count} records.".html_safe
         | 
| 7 | 
            +
              else
         | 
| 8 | 
            +
                page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, "All #{@page.pager.count} records marked"
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            else
         | 
| 11 | 
            +
              page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, ""
         | 
| 12 | 
            +
            end
         | 
    
        data/lib/active_scaffold.rb
    CHANGED
    
    | @@ -237,9 +237,9 @@ module ActiveScaffold | |
| 237 237 | 
             
                  end
         | 
| 238 238 | 
             
                end
         | 
| 239 239 |  | 
| 240 | 
            -
                def  | 
| 240 | 
            +
                def active_scaffold_controller_for_column(column, options = {})
         | 
| 241 241 | 
             
                  begin
         | 
| 242 | 
            -
                     | 
| 242 | 
            +
                    if column.polymorphic_association?
         | 
| 243 243 | 
             
                      :polymorph
         | 
| 244 244 | 
             
                    elsif options.include?(:controller)
         | 
| 245 245 | 
             
                      "#{options[:controller].to_s.camelize}Controller".constantize
         | 
| @@ -247,8 +247,12 @@ module ActiveScaffold | |
| 247 247 | 
             
                      active_scaffold_controller_for(column.association.klass)
         | 
| 248 248 | 
             
                    end
         | 
| 249 249 | 
             
                  rescue ActiveScaffold::ControllerNotFound
         | 
| 250 | 
            -
                     | 
| 250 | 
            +
                    nil        
         | 
| 251 251 | 
             
                  end
         | 
| 252 | 
            +
                end
         | 
| 253 | 
            +
                
         | 
| 254 | 
            +
                def link_for_association(column, options = {})
         | 
| 255 | 
            +
                  controller = active_scaffold_controller_for_column(column, options)
         | 
| 252 256 |  | 
| 253 257 | 
             
                  unless controller.nil?
         | 
| 254 258 | 
             
                    options.reverse_merge! :label => column.label, :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : controller.controller_path), :column => column
         | 
| @@ -65,14 +65,14 @@ module ActiveScaffold::Actions | |
| 65 65 | 
             
                  self.active_scaffold_includes.concat includes_for_list_columns
         | 
| 66 66 |  | 
| 67 67 | 
             
                  options = { :sorting => active_scaffold_config.list.user.sorting,
         | 
| 68 | 
            -
             | 
| 68 | 
            +
                    :count_includes => active_scaffold_config.list.user.count_includes }
         | 
| 69 69 | 
             
                  paginate = (params[:format].nil?) ? (accepts? :html, :js) : ['html', 'js'].include?(params[:format])
         | 
| 70 70 | 
             
                  if paginate
         | 
| 71 71 | 
             
                    options.merge!({
         | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 72 | 
            +
                        :per_page => active_scaffold_config.list.user.per_page,
         | 
| 73 | 
            +
                        :page => active_scaffold_config.list.user.page,
         | 
| 74 | 
            +
                        :pagination => active_scaffold_config.list.pagination
         | 
| 75 | 
            +
                      })
         | 
| 76 76 | 
             
                  end
         | 
| 77 77 |  | 
| 78 78 | 
             
                  page = find_page(options);
         | 
| @@ -83,11 +83,19 @@ module ActiveScaffold::Actions | |
| 83 83 | 
             
                  @page, @records = page, page.items
         | 
| 84 84 | 
             
                end
         | 
| 85 85 |  | 
| 86 | 
            +
                def each_record_in_page
         | 
| 87 | 
            +
                  _page = active_scaffold_config.list.user.page
         | 
| 88 | 
            +
                  do_search if respond_to? :do_search
         | 
| 89 | 
            +
                  active_scaffold_config.list.user.page = _page
         | 
| 90 | 
            +
                  do_list
         | 
| 91 | 
            +
                  @page.items.each {|record| yield record}
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
             | 
| 86 94 | 
             
                def each_record_in_scope
         | 
| 87 95 | 
             
                  do_search if respond_to? :do_search
         | 
| 88 96 | 
             
                  finder_options = { :order => "#{active_scaffold_config.model.connection.quote_table_name(active_scaffold_config.model.table_name)}.#{active_scaffold_config.model.primary_key} ASC",
         | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 97 | 
            +
                    :conditions => all_conditions,
         | 
| 98 | 
            +
                    :joins => joins_for_finder}
         | 
| 91 99 | 
             
                  finder_options.merge! custom_finder_options
         | 
| 92 100 | 
             
                  finder_options.merge! :include => (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
         | 
| 93 101 | 
             
                  klass = beginning_of_chain
         | 
| @@ -8,14 +8,14 @@ module ActiveScaffold::Actions | |
| 8 8 | 
             
                end
         | 
| 9 9 |  | 
| 10 10 | 
             
                def mark_all
         | 
| 11 | 
            -
                  if mark_all?
         | 
| 11 | 
            +
                  if mark_all? || mark_all_scope_forced?
         | 
| 12 12 | 
             
                    do_mark_all
         | 
| 13 13 | 
             
                  else
         | 
| 14 14 | 
             
                    do_demark_all
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 | 
             
                  respond_to_action(:mark_all)
         | 
| 17 17 | 
             
                end
         | 
| 18 | 
            -
             | 
| 18 | 
            +
                protected
         | 
| 19 19 |  | 
| 20 20 | 
             
                def mark_all_respond_to_html
         | 
| 21 21 | 
             
                  do_list
         | 
| @@ -42,12 +42,24 @@ module ActiveScaffold::Actions | |
| 42 42 | 
             
                  @mark_all ||= [true, 'true', 1, '1', 'T', 't'].include?(params[:value].class == String ? params[:value].downcase : params[:value])
         | 
| 43 43 | 
             
                end
         | 
| 44 44 |  | 
| 45 | 
            +
                def mark_all_scope_forced?
         | 
| 46 | 
            +
                  !params[:mark_target].nil? && params[:mark_target]=='scope'
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
                
         | 
| 45 49 | 
             
                def do_mark_all
         | 
| 46 | 
            -
                   | 
| 50 | 
            +
                  if active_scaffold_config.mark.mark_all_mode == :page && !mark_all_scope_forced? then
         | 
| 51 | 
            +
                    each_record_in_page {|record| marked_records << record.id}
         | 
| 52 | 
            +
                  else
         | 
| 53 | 
            +
                    each_record_in_scope {|record| marked_records << record.id}
         | 
| 54 | 
            +
                  end
         | 
| 47 55 | 
             
                end
         | 
| 48 56 |  | 
| 49 57 | 
             
                def do_demark_all
         | 
| 50 | 
            -
                   | 
| 58 | 
            +
                  if active_scaffold_config.mark.mark_all_mode == :page then
         | 
| 59 | 
            +
                    each_record_in_page {|record| marked_records.delete(record.id)}
         | 
| 60 | 
            +
                  else
         | 
| 61 | 
            +
                    each_record_in_scope {|record| marked_records.delete(record.id)}
         | 
| 62 | 
            +
                  end
         | 
| 51 63 | 
             
                end
         | 
| 52 64 |  | 
| 53 65 | 
             
                # The default security delegates to ActiveRecordPermissions.
         | 
| @@ -19,7 +19,7 @@ module ActiveScaffold::Actions | |
| 19 19 | 
             
                def nested
         | 
| 20 20 | 
             
                  @nested ||= ActiveScaffold::DataStructures::NestedInfo.get(active_scaffold_config.model, active_scaffold_session_storage)
         | 
| 21 21 | 
             
                  if !@nested.nil? && @nested.new_instance?
         | 
| 22 | 
            -
                    register_constraints_with_action_columns(@nested.constrained_fields)
         | 
| 22 | 
            +
                    register_constraints_with_action_columns(@nested.constrained_fields,  active_scaffold_config.list.hide_nested_column ? [] : [:list])
         | 
| 23 23 | 
             
                    active_scaffold_constraints[:id] = params[:id] if @nested.belongs_to?
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 | 
             
                  @nested
         | 
| @@ -114,6 +114,12 @@ module ActiveScaffold::Config | |
| 114 114 | 
             
                def always_show_create
         | 
| 115 115 | 
             
                  @always_show_create && @core.actions.include?(:create)
         | 
| 116 116 | 
             
                end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                # if list view is nested hide nested_column
         | 
| 119 | 
            +
                attr_writer :hide_nested_column
         | 
| 120 | 
            +
                def hide_nested_column
         | 
| 121 | 
            +
                  @hide_nested_column.nil? ? true : @hide_nested_column
         | 
| 122 | 
            +
                end
         | 
| 117 123 |  | 
| 118 124 | 
             
                # might be set to open nested_link automatically in view
         | 
| 119 125 | 
             
                # conf.nested.add_link(:players)
         | 
| @@ -1,11 +1,24 @@ | |
| 1 1 | 
             
            module ActiveScaffold::Config
         | 
| 2 2 | 
             
              class Mark < Base
         | 
| 3 3 | 
             
                self.crud_type = :read
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                # What kind of mark all mode to use:
         | 
| 6 | 
            +
                # * :search: de-/mark all records using current search conditions
         | 
| 7 | 
            +
                # * :page: de-/mark all records on current page
         | 
| 8 | 
            +
                cattr_accessor :mark_all_mode
         | 
| 9 | 
            +
                @@mark_all_mode = :search
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                attr_accessor :mark_all_mode
         | 
| 4 12 |  | 
| 5 13 | 
             
                def initialize(core_config)
         | 
| 6 14 | 
             
                  @core = core_config
         | 
| 7 | 
            -
                  @ | 
| 8 | 
            -
                   | 
| 15 | 
            +
                  @mark_all_mode = self.class.mark_all_mode
         | 
| 16 | 
            +
                  if core_config.actions.include?(:update)
         | 
| 17 | 
            +
                    @core.model.send(:include, ActiveScaffold::MarkedModel) unless @core.model.ancestors.include?(ActiveScaffold::MarkedModel)
         | 
| 18 | 
            +
                    add_mark_column
         | 
| 19 | 
            +
                  else
         | 
| 20 | 
            +
                    raise "Mark action requires update action in controller for model: #{core_config.model.to_s}"
         | 
| 21 | 
            +
                  end
         | 
| 9 22 | 
             
                end
         | 
| 10 23 |  | 
| 11 24 | 
             
                protected
         | 
| @@ -313,7 +313,14 @@ module ActiveScaffold | |
| 313 313 | 
             
                  end
         | 
| 314 314 |  | 
| 315 315 | 
             
                  def mark_column_heading
         | 
| 316 | 
            -
                     | 
| 316 | 
            +
                    if active_scaffold_config.mark.mark_all_mode == :page then
         | 
| 317 | 
            +
                      all_marked = true
         | 
| 318 | 
            +
                      @page.items.each do |record|
         | 
| 319 | 
            +
                        all_marked = false if !marked_records.entries.include?(record.id)
         | 
| 320 | 
            +
                      end
         | 
| 321 | 
            +
                    else
         | 
| 322 | 
            +
                      all_marked = (marked_records.length >= @page.pager.count)
         | 
| 323 | 
            +
                    end
         | 
| 317 324 | 
             
                    tag_options = {:id => "#{controller_id}_mark_heading", :class => "mark_heading in_place_editor_field"}
         | 
| 318 325 | 
             
                    tag_options['data-ie_url'] = url_for({:controller => params_for[:controller], :action => 'mark_all', :eid => params[:eid]})
         | 
| 319 326 | 
             
                    content_tag(:span, check_box_tag("#{controller_id}_mark_heading_span_input", !all_marked, all_marked), tag_options)
         | 
| @@ -122,9 +122,13 @@ module ActiveScaffold | |
| 122 122 |  | 
| 123 123 | 
             
                  end
         | 
| 124 124 |  | 
| 125 | 
            +
                  def active_scaffold_search_range_string?(column)
         | 
| 126 | 
            +
                    (column.column && column.column.text?) || column.search_ui == :string
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
             | 
| 125 129 | 
             
                  def active_scaffold_search_range_comparator_options(column)
         | 
| 126 130 | 
             
                    select_options = ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
         | 
| 127 | 
            -
                    if column | 
| 131 | 
            +
                    if active_scaffold_search_range_string?(column)
         | 
| 128 132 | 
             
                      select_options.unshift *ActiveScaffold::Finder::StringComparators.collect {|title, comp| [as_(title), comp]}
         | 
| 129 133 | 
             
                    end
         | 
| 130 134 | 
             
                    select_options
         | 
| @@ -134,7 +138,7 @@ module ActiveScaffold | |
| 134 138 | 
             
                    opt_value, from_value, to_value = field_search_params_range_values(column)
         | 
| 135 139 |  | 
| 136 140 | 
             
                    select_options = active_scaffold_search_range_comparator_options(column)
         | 
| 137 | 
            -
                    if column | 
| 141 | 
            +
                    if active_scaffold_search_range_string?(column)
         | 
| 138 142 | 
             
                      text_field_size = 15
         | 
| 139 143 | 
             
                      opt_value ||= '%?%'
         | 
| 140 144 | 
             
                    else
         | 
| @@ -148,7 +148,7 @@ module ActiveScaffold | |
| 148 148 | 
             
                  def action_link_url_options(link, url_options, record, options = {})
         | 
| 149 149 | 
             
                    url_options = url_options.clone
         | 
| 150 150 | 
             
                    url_options[:action] = link.action
         | 
| 151 | 
            -
                    url_options[:controller] = link.controller if link.controller
         | 
| 151 | 
            +
                    url_options[:controller] = link.controller.to_s if link.controller
         | 
| 152 152 | 
             
                    url_options.delete(:search) if link.controller and link.controller.to_s != params[:controller]
         | 
| 153 153 | 
             
                    url_options.merge! link.parameters if link.parameters
         | 
| 154 154 | 
             
                    @link_record = record
         | 
| @@ -228,10 +228,15 @@ module ActiveScaffold | |
| 228 228 | 
             
                  def url_options_for_sti_link(column, record, link, url_options, options = {})
         | 
| 229 229 | 
             
                    #need to find out controller of current record type
         | 
| 230 230 | 
             
                    #and set parameters
         | 
| 231 | 
            -
                     | 
| 232 | 
            -
                    if  | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 231 | 
            +
                    # its quite difficult to detect an sti link
         | 
| 232 | 
            +
                    # if link.column.nil? we are sure that it is nt an singular association inline autolink
         | 
| 233 | 
            +
                    # howver that will not work if a sti parent is an singular association inline autolink
         | 
| 234 | 
            +
                    if link.column.nil?
         | 
| 235 | 
            +
                      sti_controller_path = controller_path_for_activerecord(record.class)
         | 
| 236 | 
            +
                      if sti_controller_path
         | 
| 237 | 
            +
                        url_options[:controller] = sti_controller_path
         | 
| 238 | 
            +
                        url_options[:parent_sti] = controller_path
         | 
| 239 | 
            +
                      end
         | 
| 235 240 | 
             
                    end
         | 
| 236 241 | 
             
                  end
         | 
| 237 242 |  | 
    
        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:  | 
| 4 | 
            +
              hash: 47
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 3
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 3.0. | 
| 9 | 
            +
              - 20
         | 
| 10 | 
            +
              version: 3.0.20
         | 
| 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- | 
| 18 | 
            +
            date: 2011-05-27 00:00:00 +02:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         |