active_scaffold_config_list 3.5.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +84 -0
- data/lib/active_scaffold/actions/config_list.rb +8 -16
- data/lib/active_scaffold_config_list/version.rb +1 -1
- metadata +4 -4
- data/README +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be3b1357610333757d013332316debd39b636bb7f690a3cf57ed27088faf9abe
|
4
|
+
data.tar.gz: 8940de8dc18e5575c74ed3604ddd22dfa6b06abf9a04503d1ffb2335858eb36c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8171e1910707eca649a41a9df49b7c4333be31a65fde1d9ddfc083c19f92dabc76fd5fef0f5cd3b8f245b5a252033484a3b559a2ccd78a324247042de32ae776
|
7
|
+
data.tar.gz: 6582db9e3c46b42c21330c4b67d0d726e6d55395db2e091849a59de9d09ff73b2b4ae261a2a6592819ffd7e9e7f308ca84660e57b35acbbe9b7daca05b40d73f
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
This works with Rails >= 4.0 and ActiveScaffold >= 3.4.4
|
2
|
+
Version 3.3.x worked with Rails 3.2 and ActiveScaffold >= 3.4.4
|
3
|
+
Version 3.2.x worked with Rails 3.2 and ActiveScaffold >= 3.3.0
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
|
7
|
+
```rb
|
8
|
+
active_scaffold :model do |conf|
|
9
|
+
conf.actions.add :config_list
|
10
|
+
end
|
11
|
+
````
|
12
|
+
|
13
|
+
|
14
|
+
Overview
|
15
|
+
========
|
16
|
+
|
17
|
+
A plugin for Active Scaffold that provides the ability to choose the column to show in the scaffold list at run-time.
|
18
|
+
|
19
|
+
You have the option of defining a default set of columns for the controller. For example:
|
20
|
+
```rb
|
21
|
+
config.config_list.default_columns = [:name, :project, :amount]
|
22
|
+
```
|
23
|
+
If this is not defined then active_scaffold_config.list.columns is used.
|
24
|
+
|
25
|
+
This is useful when you want the option to look at a potentially large number of columns but be able to
|
26
|
+
easily reset back to something that fits on the screen without horizontal scrolling.
|
27
|
+
|
28
|
+
The available columns in the configure action are the columns defined in `list.columns`. For that reason, if
|
29
|
+
`config_list.default_columns` is not defined, then it will default to `list.columns`, and the users only will be able
|
30
|
+
to remove some columns, they won't be able to add other columns.
|
31
|
+
|
32
|
+
The configuration data will be saved on the session. It can be saved on the DB defining a method on the user model
|
33
|
+
(the one returned by current_user method) to return a record for current controller, or empty record if user has no
|
34
|
+
list configuration, and setting config_list to use that method.
|
35
|
+
|
36
|
+
```rb
|
37
|
+
conf.config_list.save_to_user = :config_list_for
|
38
|
+
```
|
39
|
+
|
40
|
+
The model storing list configuration must have a config_list text column storing the columns list, and config_list_sort
|
41
|
+
serialized text column. For example:
|
42
|
+
|
43
|
+
```rb
|
44
|
+
# == Schema Information
|
45
|
+
#
|
46
|
+
# Table name: list_configurations
|
47
|
+
#
|
48
|
+
# id :bigint not null, primary key
|
49
|
+
# config_list :text
|
50
|
+
# config_list_sorting :text
|
51
|
+
# created_at :datetime not null
|
52
|
+
# updated_at :datetime not null
|
53
|
+
# controller_id :string(255)
|
54
|
+
# user_id :bigint
|
55
|
+
#
|
56
|
+
# Indexes
|
57
|
+
#
|
58
|
+
# index_list_configurations_on_user_id (user_id)
|
59
|
+
#
|
60
|
+
|
61
|
+
class ListConfiguration < ApplicationRecord
|
62
|
+
belongs_to :user
|
63
|
+
serialize :config_list_sorting, JSON
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Then in the User model, define the association, and the method returning the config list for the requested controller.
|
68
|
+
The method has 2 arguments, `controller_id` and `controller_name`, so only need to save one of them, depending if user
|
69
|
+
configuration must be shared on different conditions for embedded controllers, and each parent for nested controllers,
|
70
|
+
or save unique configurations. The `controller_id` argument will be different in embedded controllers, nested controllers
|
71
|
+
and regular controllers, as it will use `active_scaffold_session_storage_key`, and the controller_name will be the same
|
72
|
+
always.
|
73
|
+
|
74
|
+
```rb
|
75
|
+
class User < ActiveRecord::Base
|
76
|
+
has_many :list_configurations
|
77
|
+
def config_list_for(controller_id, controller_name)
|
78
|
+
# Use controller_id to allow having different columns on different nested or embedded conditions
|
79
|
+
list_configurations.where(controller_id: controller_id).first_or_initialize
|
80
|
+
# Or use controller_name for one configuration for the controller, even embedded or nested
|
81
|
+
list_configurations.where(controller_id: controller_name).first_or_initialize
|
82
|
+
end
|
83
|
+
end
|
84
|
+
```
|
@@ -4,17 +4,6 @@ module ActiveScaffold::Actions
|
|
4
4
|
def self.included(base)
|
5
5
|
base.before_action :store_config_list_params, :set_default_sorting, :only => [:index]
|
6
6
|
base.helper_method :config_list_params, :config_list_sorting
|
7
|
-
base.extend ClassMethods
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def config_list_session_storage_method
|
12
|
-
@config_list_session_storage_method
|
13
|
-
end
|
14
|
-
|
15
|
-
def config_list_session_storage_method=(value)
|
16
|
-
@config_list_session_storage_method = value
|
17
|
-
end
|
18
7
|
end
|
19
8
|
|
20
9
|
def show_config_list
|
@@ -57,12 +46,16 @@ module ActiveScaffold::Actions
|
|
57
46
|
end
|
58
47
|
|
59
48
|
def config_list_session_storage_method
|
60
|
-
|
49
|
+
@config_list_session_storage_method ||=
|
50
|
+
if respond_to?(:custom_config_list_session_storage)
|
51
|
+
:custom_config_list_session_storage
|
52
|
+
else
|
53
|
+
:active_scaffold_session_storage
|
54
|
+
end
|
61
55
|
end
|
62
56
|
|
63
57
|
def config_list_session_storage
|
64
|
-
|
65
|
-
send(self.class.config_list_session_storage_method)
|
58
|
+
send(config_list_session_storage_method)
|
66
59
|
end
|
67
60
|
|
68
61
|
def active_scaffold_current_user
|
@@ -77,7 +70,6 @@ module ActiveScaffold::Actions
|
|
77
70
|
config_list_session_storage['config_list_sorting'] = nil
|
78
71
|
end
|
79
72
|
active_scaffold_config.list.user['sort'] = nil
|
80
|
-
logger.debug "list #{active_scaffold_config.list.sorting.object_id}"
|
81
73
|
@config_list_params = nil
|
82
74
|
@config_list_sorting = nil
|
83
75
|
end
|
@@ -99,7 +91,7 @@ module ActiveScaffold::Actions
|
|
99
91
|
def objects_for_etag
|
100
92
|
# only override when list_columns is called, so
|
101
93
|
if @list_columns && config_list_record
|
102
|
-
@last_modified = [@last_modified, config_list_record.updated_at].compact.
|
94
|
+
@last_modified = [@last_modified, config_list_record.updated_at].compact.max if config_list_record.respond_to? :updated_at
|
103
95
|
objects = super
|
104
96
|
if objects.is_a? Hash
|
105
97
|
objects.merge(:etag => [objects[:etag], config_list_record])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_config_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_scaffold
|
@@ -43,10 +43,10 @@ email: activescaffold@googlegroups.com
|
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files:
|
46
|
-
- README
|
46
|
+
- README.md
|
47
47
|
files:
|
48
48
|
- LICENSE.txt
|
49
|
-
- README
|
49
|
+
- README.md
|
50
50
|
- app/views/active_scaffold_overrides/_show_config_list_form.html.erb
|
51
51
|
- app/views/active_scaffold_overrides/_show_config_list_form_body.html.erb
|
52
52
|
- app/views/active_scaffold_overrides/show_config_list_form.html.erb
|
data/README
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
This works with Rails >= 4.0 and ActiveScaffold >= 3.4.4
|
2
|
-
Version 3.3.x worked with Rails 3.2 and ActiveScaffold >= 3.4.4
|
3
|
-
Version 3.2.x worked with Rails 3.2 and ActiveScaffold >= 3.3.0
|
4
|
-
|
5
|
-
Usage:
|
6
|
-
active_scaffold :model do |conf|
|
7
|
-
conf.actions.add :config_list
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
Overview
|
12
|
-
|
13
|
-
A plugin for Active Scaffold that provides the ability to choose the column to show in the scaffold list at run-time
|
14
|
-
|
15
|
-
The configuration data will be saved on the session. It can be saved on the DB defining a method to return a record
|
16
|
-
for current controller, or empty record if user has no list configuration, and setting config_list to use that method.
|
17
|
-
|
18
|
-
conf.config_list.save_to_user = :config_list_for
|
19
|
-
|
20
|
-
class User < ActiveRecord::Base
|
21
|
-
has_many :list_configurations
|
22
|
-
def config_list_for(controller_id, controller_name)
|
23
|
-
list_configurations.where(:controller_id => controller_id).first_or_initialize # different columns on different nested or embedded conditions
|
24
|
-
list_configurations.where(:controller_id => controller_name).first_or_initialize # one configuration for the controller, even embedded or nested
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
The model storing list configuration must have a config_list text column storing the config list, and config_list_sort serialized text column.
|