active_scaffold_config_list 3.2.0

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/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 vhochstein
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,28 @@
1
+ This works with Rails 3 and rails 3 fork of ActiveScaffold:
2
+ http://github.com/vhochstein/active_scaffold
3
+
4
+ Usage:
5
+ active_scaffold :model do |conf|
6
+ conf.actions.add :config_list
7
+ end
8
+
9
+
10
+ Overview
11
+
12
+ A plugin for Active Scaffold that provides the ability to choose the column to show in the scaffold list at run-time
13
+
14
+ The configuration data will be saved on the session.
15
+
16
+
17
+ Rails 3.0 Gem:
18
+ gem 'active_scaffold_config_list_vho'
19
+ or
20
+ gem 'active_scaffold_config_list_vho', :git => 'git://github.com/vhochstein/active_scaffold_config_list.git', :branch => 'rails-3.0'
21
+
22
+ Rails 3.1 Gem:
23
+ gem 'active_scaffold_config_list_vho'
24
+ or
25
+ gem 'active_scaffold_config_list_vho', :git => 'git://github.com/vhochstein/active_scaffold_config_list.git'
26
+
27
+
28
+
@@ -0,0 +1,2 @@
1
+ /* IE hacks
2
+ ==================================== */
@@ -0,0 +1,17 @@
1
+ <% url_options = params_for(:action => :index, :escape => false, :config_list => nil) -%>
2
+ <%=
3
+ options = {:id => element_form_id(:action => :config_list),
4
+ :class => "as_form config_list",
5
+ :remote => request.xhr?,
6
+ :method => :get,
7
+ 'data-loading' => true}
8
+ form_tag url_options, options %>
9
+ <h4><%= active_scaffold_config.config_list.label -%></h4>
10
+ <%= render :partial => 'show_config_list_form_body', :locals => { :columns => active_scaffold_config.config_list } %>
11
+ <p class="form-footer">
12
+ <%= submit_tag as_(:config_list), :class => "submit" %>
13
+ <%= link_to as_(:reset), url_for(url_options.merge(:config_list => '')), :class => 'as_cancel', :remote => true, :data => {:refresh => true} %>
14
+ <%= loading_indicator_tag(:action => :config_list) %>
15
+ </p>
16
+ </form>
17
+ <%= javascript_tag("ActiveScaffold.focus_first_element_of_form('#{element_form_id(:action => :config_list)}');") %>
@@ -0,0 +1,21 @@
1
+ <ol id="<%= config_list_ol_id %>" class="form">
2
+ <% hidden_columns = if !config_list_params.nil? && config_list_params.is_a?(Array)
3
+ config_list = config_list_params
4
+ active_scaffold_config.list.columns.collect_visible.select{|column| config_list.exclude? column.name}
5
+ else
6
+ []
7
+ end %>
8
+ <% list_columns.concat(hidden_columns).each do |c| %>
9
+ <li class="form-element sortable">
10
+ <%= check_box_tag 'config_list[]', c.name.to_s, (config_list_params.nil? ? true : config_list_params.include?(c.name)), {:id => nil}%>
11
+ <label for="update_table_from"><%= c.label%></label>
12
+ </li>
13
+ <% end %>
14
+ </ol>
15
+ <% if ActiveScaffold.js_framework == :prototype %>
16
+ <%= sortable_element config_list_ol_id, {:tag => 'li', :url => nil} %>
17
+ <% elsif ActiveScaffold.js_framework == :jquery %>
18
+ <% reorder_params = {}
19
+ options = {:update => false} %>
20
+ <%= javascript_tag "ActiveScaffold.sortable('#{config_list_ol_id}', #{controller_name.to_json}, #{options.to_json}, #{reorder_params.to_json});" %>
21
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="config_list-view view">
3
+ <%= render :partial => 'show_config_list_form' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,54 @@
1
+ module ActiveScaffold::Actions
2
+ module ConfigList
3
+
4
+ def self.included(base)
5
+ base.before_filter :store_config_list_params_into_session, :only => [:index]
6
+ base.helper_method :config_list_params
7
+ end
8
+
9
+ def show_config_list
10
+ respond_to do |type|
11
+ type.html do
12
+ render(:action => 'show_config_list_form', :layout => true)
13
+ end
14
+ type.js do
15
+ render(:partial => 'show_config_list_form', :layout => false)
16
+ end
17
+ end
18
+ end
19
+
20
+ protected
21
+
22
+ def store_config_list_params_into_session
23
+ if params[:config_list]
24
+ active_scaffold_session_storage[:config_list] = params.delete :config_list
25
+ case active_scaffold_session_storage[:config_list]
26
+ when String
27
+ active_scaffold_session_storage[:config_list] = nil
28
+ when Array
29
+ active_scaffold_session_storage[:config_list].collect!{|col_name| col_name.to_sym}
30
+ end
31
+ end
32
+ end
33
+
34
+ def config_list_params
35
+ active_scaffold_session_storage[:config_list] || active_scaffold_config.config_list.default_columns
36
+ end
37
+
38
+ def list_columns
39
+ columns = super
40
+ if !config_list_params.nil? && config_list_params.is_a?(Array)
41
+ config_list = Hash[config_list_params.each_with_index.map]
42
+ columns.select{|column| config_list.include? column.name}.sort{|x,y| config_list[x.name] <=> config_list[y.name]}
43
+ else
44
+ columns
45
+ end
46
+ end
47
+
48
+ # The default security delegates to ActiveRecordPermissions.
49
+ # You may override the method to customize.
50
+ def config_list_authorized?
51
+ authorized_for?(:action => :read)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ module ActiveScaffold::Config
2
+ class ConfigList < Base
3
+ self.crud_type = :read
4
+ def initialize(*args)
5
+ super
6
+ @link = self.class.link.clone unless self.class.link.nil?
7
+ end
8
+
9
+ # global level configuration
10
+ # --------------------------
11
+ # the ActionLink for this action
12
+ def self.link
13
+ @@link
14
+ end
15
+ def self.link=(val)
16
+ @@link = val
17
+ end
18
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('show_config_list', :label => :config_list, :type => :collection, :security_method => :config_list_authorized?)
19
+
20
+ # configures where the plugin itself is located. there is no instance version of this.
21
+ cattr_accessor :plugin_directory
22
+ @@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/config_list.rb})[1]
23
+
24
+ # instance-level configuration
25
+ # ----------------------------
26
+ # the label= method already exists in the Form base class
27
+ def label
28
+ @label ? as_(@label) : as_(:config_list_model, :model => @core.label.singularize)
29
+ end
30
+
31
+ # if you do not want to show all columns as a default you may define some
32
+ # e.g. conf.config_list.default_columns = [:name, founded_on]
33
+ attr_accessor :default_columns
34
+
35
+ # provides access to the list of columns specifically meant for the config_list to use
36
+ def columns
37
+ unless @columns # lazy evaluation
38
+ self.columns = @core.columns._inheritable
39
+ self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :as_marked
40
+ self.columns.exclude *@core.columns.collect{|c| c.name if c.polymorphic_association?}.compact
41
+ end
42
+ @columns
43
+ end
44
+
45
+ public :columns=
46
+
47
+ # the ActionLink for this action
48
+ attr_accessor :link
49
+ end
50
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveScaffold
2
+ module Helpers
3
+ # Helpers that assist with the rendering of a Form Column
4
+ module ConfigListHelpers
5
+ def config_list_ol_id
6
+ "ol_#{element_form_id(:action => :config_list)}"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # Need to open the AS module carefully due to Rails 2.3 lazy loading
2
+ ActiveScaffold::Config::Core.class_eval do
3
+ ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:show_config_list] = :get
4
+ end
@@ -0,0 +1,13 @@
1
+ module ActiveScaffoldConfigList
2
+ class Engine < ::Rails::Engine
3
+ initializer("initialize_active_scaffold_config_list", :after => "initialize_active_scaffold") do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ require "active_scaffold_config_list/config/core.rb"
6
+ end
7
+
8
+ ActiveSupport.on_load(:action_view) do
9
+ include ActiveScaffold::Helpers::ConfigListHelpers
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveScaffoldConfigList
2
+ module Version
3
+ MAJOR = 3
4
+ MINOR = 2
5
+ PATCH = 0
6
+
7
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'active_scaffold_config_list/engine'
2
+ require 'active_scaffold_config_list/version'
3
+
4
+ module ActiveScaffoldConfigList
5
+ end
6
+
7
+ module ActiveScaffold
8
+ module Actions
9
+ ActiveScaffold.autoload_subdir('actions', self, File.dirname(__FILE__))
10
+ end
11
+
12
+ module Config
13
+ ActiveScaffold.autoload_subdir('config', self, File.dirname(__FILE__))
14
+ end
15
+
16
+ module Helpers
17
+ ActiveScaffold.autoload_subdir('helpers', self, File.dirname(__FILE__))
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_scaffold_config_list
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 3
8
+ - 2
9
+ - 0
10
+ version: 3.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Sergio Cambra
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-03-07 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :runtime
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 345615033
28
+ segments:
29
+ - 3
30
+ - 3
31
+ - 0
32
+ - rc
33
+ - 2
34
+ version: 3.3.0.rc2
35
+ version_requirements: *id001
36
+ prerelease: false
37
+ name: active_scaffold
38
+ description: User may reorder and hide/show list columns
39
+ email: activescaffold@googlegroups.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - README
46
+ files:
47
+ - app/assets/stylesheets/active_scaffold_config_list-ie.css
48
+ - app/assets/stylesheets/active_scaffold_config_list.css.erb
49
+ - app/views/active_scaffold_overrides/_show_config_list_form.html.erb
50
+ - app/views/active_scaffold_overrides/_show_config_list_form_body.html.erb
51
+ - app/views/active_scaffold_overrides/show_config_list_form.html.erb
52
+ - lib/active_scaffold/actions/config_list.rb
53
+ - lib/active_scaffold/config/config_list.rb
54
+ - lib/active_scaffold/helpers/config_list_helpers.rb
55
+ - lib/active_scaffold_config_list.rb
56
+ - lib/active_scaffold_config_list/config/core.rb
57
+ - lib/active_scaffold_config_list/engine.rb
58
+ - lib/active_scaffold_config_list/version.rb
59
+ - LICENSE.txt
60
+ - README
61
+ homepage: http://activescaffold.com
62
+ licenses:
63
+ - MIT
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.23
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: User specific column configuration for ActiveScaffold
94
+ test_files: []
95
+