active_scaffold_config_list_vho 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE.txt +20 -0
- data/README +17 -0
- data/Rakefile +55 -0
- data/frontends/default/stylesheets/cf_as-stylesheet-ie.css +2 -0
- data/frontends/default/stylesheets/cf_as-stylesheet.css +1 -0
- data/frontends/default/views/_show_config_list_form.html.erb +17 -0
- data/frontends/default/views/_show_config_list_form_body.html.erb +21 -0
- data/frontends/default/views/show_config_list_form.html.erb +5 -0
- data/init.rb +9 -0
- data/lib/active_scaffold/actions/config_list.rb +59 -0
- data/lib/active_scaffold/config/config_list.rb +34 -0
- data/lib/active_scaffold/helpers/config_list_helpers.rb +21 -0
- data/lib/active_scaffold_config_list.rb +40 -0
- data/lib/active_scaffold_config_list/config/core.rb +4 -0
- data/lib/active_scaffold_config_list/version.rb +9 -0
- data/lib/active_scaffold_config_list_vho.rb +2 -0
- data/uninstall.rb +1 -0
- metadata +159 -0
data/.document
ADDED
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,17 @@
|
|
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
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
require './lib/active_scaffold_config_list/version.rb'
|
14
|
+
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "active_scaffold_config_list_vho"
|
18
|
+
gem.version = ActiveScaffoldConfigList::Version::STRING
|
19
|
+
gem.homepage = "http://github.com/vhochstein/active_scaffold_config_list"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{User specific column configuration for ActiveScaffold}
|
22
|
+
gem.description = %Q{User may reorder and hide/show list columns}
|
23
|
+
gem.email = "activescaffold@googlegroups.com"
|
24
|
+
gem.authors = ["Volker Hochstein"]
|
25
|
+
gem.add_runtime_dependency 'active_scaffold_vho', '~> 3.0'
|
26
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
27
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
28
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
29
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
30
|
+
end
|
31
|
+
Jeweler::RubygemsDotOrgTasks.new
|
32
|
+
|
33
|
+
require 'rake/testtask'
|
34
|
+
Rake::TestTask.new(:test) do |test|
|
35
|
+
test.libs << 'lib' << 'test'
|
36
|
+
test.pattern = 'test/**/test_*.rb'
|
37
|
+
test.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'rcov/rcovtask'
|
41
|
+
Rcov::RcovTask.new do |test|
|
42
|
+
test.libs << 'test'
|
43
|
+
test.pattern = 'test/**/test_*.rb'
|
44
|
+
test.verbose = true
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :test
|
48
|
+
|
49
|
+
require 'rake/rdoctask'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "active_scaffold_config_list #{ActiveScaffoldConfigList::Version::STRING}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -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 => true,
|
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 %>
|
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 %>
|
data/init.rb
ADDED
@@ -0,0 +1,59 @@
|
|
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
|
+
|
8
|
+
as_config_list_plugin_path = File.join(ActiveScaffold::Config::ConfigList.plugin_directory, 'frontends', 'default' , 'views')
|
9
|
+
|
10
|
+
base.add_active_scaffold_path as_config_list_plugin_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_config_list
|
14
|
+
respond_to do |type|
|
15
|
+
type.html do
|
16
|
+
render(:action => 'show_config_list_form', :layout => true)
|
17
|
+
end
|
18
|
+
type.js do
|
19
|
+
render(:partial => 'show_config_list_form', :layout => false)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def store_config_list_params_into_session
|
27
|
+
if params[:config_list]
|
28
|
+
active_scaffold_session_storage[:config_list] = params.delete :config_list
|
29
|
+
case active_scaffold_session_storage[:config_list]
|
30
|
+
when String
|
31
|
+
active_scaffold_session_storage[:config_list] = nil
|
32
|
+
when Array
|
33
|
+
active_scaffold_session_storage[:config_list].collect!{|col_name| col_name.to_sym}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def config_list_params
|
39
|
+
active_scaffold_session_storage[:config_list] || active_scaffold_config.config_list.default_columns
|
40
|
+
end
|
41
|
+
|
42
|
+
def do_config_list
|
43
|
+
active_scaffold_config.list.columns.column_order.clear
|
44
|
+
if !config_list_params.nil? && config_list_params.is_a?(Array)
|
45
|
+
active_scaffold_config.list.columns.column_order.concat(config_list_params)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def list_columns
|
50
|
+
columns = super
|
51
|
+
if !config_list_params.nil? && config_list_params.is_a?(Array)
|
52
|
+
config_list = config_list_params
|
53
|
+
columns.select{|column| config_list.include? column.name}.sort{|x,y| config_list.index(x.name) <=> config_list.index(y.name)}
|
54
|
+
else
|
55
|
+
columns
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ActiveScaffold::Config
|
2
|
+
class ConfigList < Form
|
3
|
+
self.crud_type = :create
|
4
|
+
def initialize(*args)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
# global level configuration
|
9
|
+
# --------------------------
|
10
|
+
# the ActionLink for this action
|
11
|
+
def self.link
|
12
|
+
@@link
|
13
|
+
end
|
14
|
+
def self.link=(val)
|
15
|
+
@@link = val
|
16
|
+
end
|
17
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('show_config_list', :label => :config_list, :type => :collection, :security_method => :create_authorized?)
|
18
|
+
|
19
|
+
# configures where the plugin itself is located. there is no instance version of this.
|
20
|
+
cattr_accessor :plugin_directory
|
21
|
+
@@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/config_list.rb})[1]
|
22
|
+
|
23
|
+
# instance-level configuration
|
24
|
+
# ----------------------------
|
25
|
+
# the label= method already exists in the Form base class
|
26
|
+
def label
|
27
|
+
@label ? as_(@label) : as_(:config_list_model, :model => @core.label.singularize)
|
28
|
+
end
|
29
|
+
|
30
|
+
# if you do not want to show all columns as a default you may define same
|
31
|
+
# e.g. conf.config_list.default_columns = [:name, founded_on]
|
32
|
+
attr_accessor :default_columns
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
# Helpers that assist with the rendering of a Form Column
|
4
|
+
module ConfigListHelpers
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.alias_method_chain :active_scaffold_includes, :cf_as
|
8
|
+
end
|
9
|
+
# Add the cf_as plugin includes
|
10
|
+
def active_scaffold_includes_with_cf_as(frontend = :default)
|
11
|
+
css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path('cf_as-stylesheet.css', frontend))
|
12
|
+
ie_css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path("cf_as-stylesheet-ie.css", frontend))
|
13
|
+
active_scaffold_includes_without_cf_as + "\n" + css + "\n<!--[if IE]>".html_safe + ie_css + "<![endif]-->\n".html_safe
|
14
|
+
end
|
15
|
+
|
16
|
+
def config_list_ol_id
|
17
|
+
"ol_#{element_form_id(:action => :config_list)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Make sure that ActiveScaffold has already been included
|
2
|
+
ActiveScaffold rescue throw "should have included ActiveScaffold plug in first. Please make sure that this overwrite plugging comes alphabetically after the ActiveScaffold plug in"
|
3
|
+
|
4
|
+
# Load our overrides
|
5
|
+
require "#{File.dirname(__FILE__)}/active_scaffold_config_list/config/core.rb"
|
6
|
+
|
7
|
+
module ActiveScaffoldConfigList
|
8
|
+
def self.root
|
9
|
+
File.dirname(__FILE__) + "/.."
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ActiveScaffold
|
14
|
+
module Actions
|
15
|
+
ActiveScaffold.autoload_subdir('actions', self, File.dirname(__FILE__))
|
16
|
+
end
|
17
|
+
|
18
|
+
module Config
|
19
|
+
ActiveScaffold.autoload_subdir('config', self, File.dirname(__FILE__))
|
20
|
+
end
|
21
|
+
|
22
|
+
module Helpers
|
23
|
+
ActiveScaffold.autoload_subdir('helpers', self, File.dirname(__FILE__))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
ActionView::Base.send(:include, ActiveScaffold::Helpers::ConfigListHelpers)
|
28
|
+
|
29
|
+
|
30
|
+
##
|
31
|
+
## Run the install assets script, too, just to make sure
|
32
|
+
## But at least rescue the action in production
|
33
|
+
##
|
34
|
+
Rails::Application.initializer("active_scaffold_config_list.install_assets", :after => "active_scaffold.install_assets") do
|
35
|
+
begin
|
36
|
+
ActiveScaffoldAssets.copy_to_public(ActiveScaffoldConfigList.root)
|
37
|
+
rescue
|
38
|
+
raise $! unless Rails.env == 'production'
|
39
|
+
end
|
40
|
+
end unless defined?(ACTIVE_SCAFFOLD_CONFIG_LIST_INSTALLED) && ACTIVE_SCAFFOLD_CONFIG_LIST_INSTALLED == :plugin
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# see active_scaffold/uninstall.rb
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_scaffold_config_list_vho
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 3.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Volker Hochstein
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-26 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
name: shoulda
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
requirement: *id001
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
prerelease: false
|
37
|
+
name: bundler
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
version: 1.0.0
|
49
|
+
requirement: *id002
|
50
|
+
type: :development
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
prerelease: false
|
53
|
+
name: jeweler
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 7
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 5
|
63
|
+
- 2
|
64
|
+
version: 1.5.2
|
65
|
+
requirement: *id003
|
66
|
+
type: :development
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
prerelease: false
|
69
|
+
name: rcov
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirement: *id004
|
80
|
+
type: :development
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
prerelease: false
|
83
|
+
name: active_scaffold_vho
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 7
|
90
|
+
segments:
|
91
|
+
- 3
|
92
|
+
- 0
|
93
|
+
version: "3.0"
|
94
|
+
requirement: *id005
|
95
|
+
type: :runtime
|
96
|
+
description: User may reorder and hide/show list columns
|
97
|
+
email: activescaffold@googlegroups.com
|
98
|
+
executables: []
|
99
|
+
|
100
|
+
extensions: []
|
101
|
+
|
102
|
+
extra_rdoc_files:
|
103
|
+
- LICENSE.txt
|
104
|
+
- README
|
105
|
+
files:
|
106
|
+
- .document
|
107
|
+
- LICENSE.txt
|
108
|
+
- README
|
109
|
+
- Rakefile
|
110
|
+
- frontends/default/stylesheets/cf_as-stylesheet-ie.css
|
111
|
+
- frontends/default/stylesheets/cf_as-stylesheet.css
|
112
|
+
- frontends/default/views/_show_config_list_form.html.erb
|
113
|
+
- frontends/default/views/_show_config_list_form_body.html.erb
|
114
|
+
- frontends/default/views/show_config_list_form.html.erb
|
115
|
+
- init.rb
|
116
|
+
- lib/active_scaffold/actions/config_list.rb
|
117
|
+
- lib/active_scaffold/config/config_list.rb
|
118
|
+
- lib/active_scaffold/helpers/config_list_helpers.rb
|
119
|
+
- lib/active_scaffold_config_list.rb
|
120
|
+
- lib/active_scaffold_config_list/config/core.rb
|
121
|
+
- lib/active_scaffold_config_list/version.rb
|
122
|
+
- lib/active_scaffold_config_list_vho.rb
|
123
|
+
- uninstall.rb
|
124
|
+
has_rdoc: true
|
125
|
+
homepage: http://github.com/vhochstein/active_scaffold_config_list
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
version: "0"
|
151
|
+
requirements: []
|
152
|
+
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.3.7
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: User specific column configuration for ActiveScaffold
|
158
|
+
test_files: []
|
159
|
+
|