active_scaffold_config_list 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
data/README
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
This works with Rails 3 and
|
2
|
-
http://github.com/vhochstein/active_scaffold
|
1
|
+
This works with Rails 3.2 and ActiveScaffold >= 3.3
|
3
2
|
|
4
3
|
Usage:
|
5
4
|
active_scaffold :model do |conf|
|
@@ -11,18 +10,16 @@ Overview
|
|
11
10
|
|
12
11
|
A plugin for Active Scaffold that provides the ability to choose the column to show in the scaffold list at run-time
|
13
12
|
|
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'
|
13
|
+
The configuration data will be saved on the session. It can be saved on the DB defining a method to return a record
|
14
|
+
for current controller, or empty record if user has no list configuration, and setting config_list to use that method.
|
26
15
|
|
16
|
+
conf.config_list.save_to_user = :config_list_for
|
27
17
|
|
18
|
+
class User < ActiveRecord::Base
|
19
|
+
has_many :list_configurations
|
20
|
+
def config_list_for(controller_id)
|
21
|
+
list_configurations.where(:controller_id => controller_id).first_or_initialize
|
22
|
+
end
|
23
|
+
end
|
28
24
|
|
25
|
+
The model storing list configuration must have a config_list attribute storing the config list.
|
@@ -2,7 +2,7 @@ module ActiveScaffold::Actions
|
|
2
2
|
module ConfigList
|
3
3
|
|
4
4
|
def self.included(base)
|
5
|
-
base.before_filter :
|
5
|
+
base.before_filter :store_config_list_params, :only => [:index]
|
6
6
|
base.helper_method :config_list_params
|
7
7
|
end
|
8
8
|
|
@@ -19,20 +19,44 @@ module ActiveScaffold::Actions
|
|
19
19
|
|
20
20
|
protected
|
21
21
|
|
22
|
-
def
|
22
|
+
def store_config_list_params
|
23
23
|
if params[:config_list]
|
24
|
-
|
25
|
-
case
|
24
|
+
config_list = params.delete :config_list
|
25
|
+
case config_list
|
26
26
|
when String
|
27
|
-
|
27
|
+
delete_config_list_params
|
28
28
|
when Array
|
29
|
-
|
29
|
+
save_config_list_params(config_list)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def delete_config_list_params
|
35
|
+
if active_scaffold_config.config_list.save_to_user && current_user
|
36
|
+
current_user.send(active_scaffold_config.config_list.save_to_user, active_scaffold_session_storage_key).destroy
|
37
|
+
else
|
38
|
+
active_scaffold_session_storage[:config_list] = nil
|
39
|
+
end
|
40
|
+
@config_list_params = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def save_config_list_params(config_list)
|
44
|
+
if active_scaffold_config.config_list.save_to_user && current_user
|
45
|
+
current_user.send(active_scaffold_config.config_list.save_to_user, active_scaffold_session_storage_key).update_attribute :config_list, config_list.join(',')
|
46
|
+
else
|
47
|
+
active_scaffold_session_storage[:config_list] = config_list.map(&:to_sym)
|
48
|
+
end
|
49
|
+
@config_list_params = config_list.map(&:to_sym)
|
50
|
+
end
|
51
|
+
|
34
52
|
def config_list_params
|
35
|
-
|
53
|
+
@config_list_params = if active_scaffold_config.config_list.save_to_user && current_user
|
54
|
+
params = current_user.send(active_scaffold_config.config_list.save_to_user, active_scaffold_session_storage_key).config_list
|
55
|
+
params.split(',').map(&:to_sym) if params
|
56
|
+
else
|
57
|
+
active_scaffold_session_storage[:config_list]
|
58
|
+
end unless defined? @config_list_params
|
59
|
+
@config_list_params || active_scaffold_config.config_list.default_columns
|
36
60
|
end
|
37
61
|
|
38
62
|
def list_columns
|
@@ -4,6 +4,7 @@ module ActiveScaffold::Config
|
|
4
4
|
def initialize(*args)
|
5
5
|
super
|
6
6
|
@link = self.class.link.clone unless self.class.link.nil?
|
7
|
+
@save_to_user = self.class.save_to_user
|
7
8
|
end
|
8
9
|
|
9
10
|
# global level configuration
|
@@ -21,6 +22,9 @@ module ActiveScaffold::Config
|
|
21
22
|
cattr_accessor :plugin_directory
|
22
23
|
@@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/config_list.rb})[1]
|
23
24
|
|
25
|
+
# configures the method in user model to save list configuration for every controller
|
26
|
+
cattr_accessor :save_to_user
|
27
|
+
|
24
28
|
# instance-level configuration
|
25
29
|
# ----------------------------
|
26
30
|
# the label= method already exists in the Form base class
|
@@ -32,6 +36,9 @@ module ActiveScaffold::Config
|
|
32
36
|
# e.g. conf.config_list.default_columns = [:name, founded_on]
|
33
37
|
attr_accessor :default_columns
|
34
38
|
|
39
|
+
# configures the method in user model to save list configuration for every controller
|
40
|
+
attr_accessor :save_to_user
|
41
|
+
|
35
42
|
# provides access to the list of columns specifically meant for the config_list to use
|
36
43
|
def columns
|
37
44
|
unless @columns # lazy evaluation
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_config_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 2
|
10
|
+
version: 3.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Cambra
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-03-
|
18
|
+
date: 2013-03-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash: -
|
27
|
+
hash: -614877838
|
28
28
|
segments:
|
29
29
|
- 3
|
30
30
|
- 3
|