active_scaffold 3.4.5 → 3.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -0
- data/app/views/active_scaffold_overrides/on_create.js.erb +1 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +2 -0
- data/lib/active_scaffold/actions/core.rb +9 -5
- data/lib/active_scaffold/attribute_params.rb +8 -8
- data/lib/active_scaffold/bridges/paper_trail.rb +10 -0
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +23 -0
- data/lib/active_scaffold/bridges/paper_trail/config.rb +29 -0
- data/lib/active_scaffold/bridges/paper_trail/helper.rb +20 -0
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +17 -0
- data/lib/active_scaffold/core.rb +1 -1
- data/lib/active_scaffold/data_structures/sorting.rb +4 -2
- data/lib/active_scaffold/helpers/pagination_helpers.rb +1 -1
- data/lib/active_scaffold/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac10aec1fac3d66afecec71c2262dedb311c000c
|
4
|
+
data.tar.gz: 77208c9dbc9f3c50b8bd88265ba645be6fe6e857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd83d6362143864a3cf2c753163562821da1c32ebb641f0b0e25e49459b3bbee91c415db5f1a256b13a8a06a1d774361c0233bdffd1902ae0f9417b9e004b62
|
7
|
+
data.tar.gz: da1a7da25ad88b2d88ce8811e5d6d4b830c2991a673bc90412f68b30244e4141a51b2119cf0415a11daa8a2f99ad99166f3d7845921e671d6ed0ac37653a5c0d
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
= 3.4.7 (not released yet)
|
2
|
+
- sorting by primary key added by default only for postgres, on mysql it will avoid using index to sort (you can see using filesort on explain), slowdown sorting
|
3
|
+
- fix set_parent on rails 3.2 with attr_accessible
|
4
|
+
- fix saving changes on render_field when blank row is changed and request render_field action
|
5
|
+
|
6
|
+
= 3.4.6
|
7
|
+
- Add paper_trail bridge (requires 3.0.5 version for nested support). It adds:
|
8
|
+
- a collection link to deleted action which display deleted_records
|
9
|
+
- a member link to PaperTrail::VersionsController which display changes for current record. PaperTrail::VersionsController must be added, not included with ActiveScaffold.
|
10
|
+
- Focus first element on persistent create forms when form is reloaded
|
11
|
+
- Fix linking to non-namespaced controller from namespaced controller
|
12
|
+
|
1
13
|
= 3.4.5
|
2
14
|
- Fix default sorting on ruby 1.8
|
3
15
|
- Fix add existing button, broken on 3.4.4
|
@@ -30,6 +30,7 @@ action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'mes
|
|
30
30
|
ActiveScaffold.reset_form('<%= form_selector %>');
|
31
31
|
<% elsif params[:dont_close] %>
|
32
32
|
ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render(:partial => 'create_form', :locals => {:xhr => true})) %>');
|
33
|
+
ActiveScaffold.focus_first_element_of_form('<%= form_selector %>');
|
33
34
|
<% else %>
|
34
35
|
action_link.close();
|
35
36
|
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -21,6 +21,7 @@ en:
|
|
21
21
|
between: Between
|
22
22
|
cancel: Cancel
|
23
23
|
cant_destroy_record: "%{record} can't be destroyed"
|
24
|
+
changes: Changes
|
24
25
|
click_to_edit: "Click to edit"
|
25
26
|
click_to_reset: "Click to reset"
|
26
27
|
close: Close
|
@@ -43,6 +44,7 @@ en:
|
|
43
44
|
days: Days
|
44
45
|
delete: Delete
|
45
46
|
deleted_model: "Deleted %{model}"
|
47
|
+
deleted_records: "List Deleted Records"
|
46
48
|
delimiter: Delimiter
|
47
49
|
download: Download
|
48
50
|
edit: Edit
|
data/config/locales/es.yml
CHANGED
@@ -21,6 +21,7 @@ es:
|
|
21
21
|
between: Entre
|
22
22
|
cancel: Cancelar
|
23
23
|
cant_destroy_record: "No se pudo borrar %{record}"
|
24
|
+
changes: Cambios
|
24
25
|
click_to_edit: "Pulsa para editar"
|
25
26
|
click_to_reset: "Pulsa para restaurar"
|
26
27
|
close: Cerrar
|
@@ -43,6 +44,7 @@ es:
|
|
43
44
|
days: Días
|
44
45
|
delete: Borrar
|
45
46
|
deleted_model: "%{model} borrado"
|
47
|
+
deleted_records: "Ver Eliminados"
|
46
48
|
delimiter: Delimitador
|
47
49
|
download: Descargar
|
48
50
|
edit: Editar
|
@@ -84,7 +84,7 @@ module ActiveScaffold::Actions
|
|
84
84
|
@record.id = params[:id]
|
85
85
|
end
|
86
86
|
set_parent(@record) if @record.id.nil? && params[:parent_controller] && @scope
|
87
|
-
|
87
|
+
|
88
88
|
after_render_field(@record, @column)
|
89
89
|
end
|
90
90
|
end
|
@@ -97,7 +97,7 @@ module ActiveScaffold::Actions
|
|
97
97
|
parent = parent_model.new
|
98
98
|
copy_attributes(parent_model.find(params[:parent_id]), parent) if params[:parent_id]
|
99
99
|
parent.id = params[:parent_id]
|
100
|
-
parent = update_record_from_params(parent, active_scaffold_config_for(parent_model).send(params[:parent_id] ? :update : :create).columns, params[:record]) if @column.send_form_on_update_column
|
100
|
+
parent = update_record_from_params(parent, active_scaffold_config_for(parent_model).send(params[:parent_id] ? :update : :create).columns, params[:record], true) if @column.send_form_on_update_column
|
101
101
|
apply_constraints_to_record(parent) if params[:parent_id]
|
102
102
|
if record.class.reflect_on_association(association).collection?
|
103
103
|
record.send(association) << parent
|
@@ -107,10 +107,14 @@ module ActiveScaffold::Actions
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
def copy_attributes(orig, dst)
|
110
|
+
def copy_attributes(orig, dst = nil)
|
111
|
+
dst ||= orig.class.new
|
111
112
|
attributes = orig.attributes
|
112
|
-
if orig.class.respond_to?
|
113
|
-
|
113
|
+
if orig.class.respond_to?(:accessible_attributes) && orig.class.accessible_attributes.present?
|
114
|
+
attributes.each { |attr, value| dst.send :write_attribute, attr, value if orig.class.accessible_attributes.deny? attr }
|
115
|
+
attributes = attributes.slice(*orig.class.accessible_attributes)
|
116
|
+
elsif orig.class.respond_to? :protected_attributes
|
117
|
+
orig.class.protected_attributes.each { |attr| dst.send :write_attribute, attr, orig[attr] }
|
114
118
|
attributes = attributes.except(*orig.class.protected_attributes)
|
115
119
|
end
|
116
120
|
dst.attributes = attributes
|
@@ -59,7 +59,7 @@ module ActiveScaffold
|
|
59
59
|
if multi_parameter_attributes.has_key? column.name.to_s
|
60
60
|
parent_record.send(:assign_multiparameter_attributes, multi_parameter_attributes[column.name.to_s])
|
61
61
|
elsif attributes.has_key? column.name
|
62
|
-
value = column_value_from_param_value(parent_record, column, attributes[column.name])
|
62
|
+
value = column_value_from_param_value(parent_record, column, attributes[column.name], avoid_changes)
|
63
63
|
if avoid_changes && column.plural_association?
|
64
64
|
parent_record.association(column.name).target = value
|
65
65
|
else
|
@@ -84,13 +84,13 @@ module ActiveScaffold
|
|
84
84
|
parent_record
|
85
85
|
end
|
86
86
|
|
87
|
-
def column_value_from_param_value(parent_record, column, value)
|
87
|
+
def column_value_from_param_value(parent_record, column, value, avoid_changes = false)
|
88
88
|
# convert the value, possibly by instantiating associated objects
|
89
89
|
form_ui = column.form_ui || column.column.try(:type)
|
90
90
|
if form_ui && self.respond_to?("column_value_for_#{form_ui}_type", true)
|
91
91
|
self.send("column_value_for_#{form_ui}_type", parent_record, column, value)
|
92
92
|
elsif value.is_a?(Hash)
|
93
|
-
column_value_from_param_hash_value(parent_record, column, value)
|
93
|
+
column_value_from_param_hash_value(parent_record, column, value, avoid_changes)
|
94
94
|
else
|
95
95
|
column_value_from_param_simple_value(parent_record, column, value)
|
96
96
|
end
|
@@ -146,25 +146,25 @@ module ActiveScaffold
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
def column_value_from_param_hash_value(parent_record, column, value)
|
149
|
+
def column_value_from_param_hash_value(parent_record, column, value, avoid_changes = false)
|
150
150
|
if column.singular_association?
|
151
|
-
manage_nested_record_from_params(parent_record, column, value)
|
151
|
+
manage_nested_record_from_params(parent_record, column, value, avoid_changes)
|
152
152
|
elsif column.plural_association?
|
153
153
|
value = value.sort if RUBY_VERSION < '1.9'
|
154
154
|
# HACK to be able to delete all associated records, hash will include "0" => ""
|
155
|
-
value.collect {|key, value| manage_nested_record_from_params(parent_record, column, value) unless value == ""}.compact
|
155
|
+
value.collect {|key, value| manage_nested_record_from_params(parent_record, column, value, avoid_changes) unless value == ""}.compact
|
156
156
|
else
|
157
157
|
value
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
def manage_nested_record_from_params(parent_record, column, attributes)
|
161
|
+
def manage_nested_record_from_params(parent_record, column, attributes, avoid_changes = false)
|
162
162
|
return nil unless build_record_from_params(attributes, column, parent_record)
|
163
163
|
record = find_or_create_for_params(attributes, column, parent_record)
|
164
164
|
if record
|
165
165
|
record_columns = active_scaffold_config_for(column.association.klass).subform.columns
|
166
166
|
record_columns.constraint_columns = [column.association.reverse]
|
167
|
-
update_record_from_params(record, record_columns, attributes)
|
167
|
+
update_record_from_params(record, record_columns, attributes, avoid_changes)
|
168
168
|
record.unsaved = true
|
169
169
|
end
|
170
170
|
record
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class ActiveScaffold::Bridges::PaperTrail < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
require File.join(File.dirname(__FILE__), "paper_trail/paper_trail_bridge")
|
4
|
+
require File.join(File.dirname(__FILE__), "paper_trail/actions")
|
5
|
+
require File.join(File.dirname(__FILE__), "paper_trail/config")
|
6
|
+
require File.join(File.dirname(__FILE__), "paper_trail/helper")
|
7
|
+
ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::PaperTrail::PaperTrailBridge
|
8
|
+
ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:deleted] = :get
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveScaffold::Actions
|
2
|
+
module DeletedRecords
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
config = active_scaffold_config
|
6
|
+
if config.actions.include?(:nested) && config.deleted_records.nested_link_group
|
7
|
+
config.configure { nested.add_link :versions, :label => config.deleted_records.nested_link_label, :action_group => config.deleted_records.nested_link_group }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def deleted
|
13
|
+
query = PaperTrail::Version.destroys.where(:item_type => active_scaffold_config.model)
|
14
|
+
query = query.where_object(nested.child_association.foreign_key => nested.parent_id) if nested? && nested.child_association.macro == :belongs_to && PaperTrail::Version.respond_to?(:where_object)
|
15
|
+
pager = Paginator.new(query.count, active_scaffold_config.list.per_page) do |offset, per_page|
|
16
|
+
query.offset(offset).limit(per_page).map(&:reify)
|
17
|
+
end
|
18
|
+
@page = pager.page(params[:page] || 1)
|
19
|
+
@records = @page.items
|
20
|
+
respond_to_action(:list)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveScaffold::Config
|
2
|
+
class DeletedRecords < Base
|
3
|
+
self.crud_type = :read
|
4
|
+
|
5
|
+
def initialize(core_config)
|
6
|
+
super
|
7
|
+
@nested_link_label = self.class.nested_link_label
|
8
|
+
@nested_link_group = self.class.nested_link_group
|
9
|
+
end
|
10
|
+
|
11
|
+
# the ActionLink for this action
|
12
|
+
cattr_accessor :link
|
13
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new(:deleted, :label => :deleted_records, :type => :collection)
|
14
|
+
|
15
|
+
# label for versions nested link
|
16
|
+
cattr_accessor :nested_link_label
|
17
|
+
@@nested_link_label = :changes
|
18
|
+
|
19
|
+
# group for versions nested link
|
20
|
+
cattr_accessor :nested_link_group
|
21
|
+
@@nested_link_group = 'member'
|
22
|
+
|
23
|
+
# label for versions nested link
|
24
|
+
attr_accessor :nested_link_label
|
25
|
+
|
26
|
+
# group for versions nested link
|
27
|
+
attr_accessor :nested_link_group
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveScaffold::Bridges
|
2
|
+
class PaperTrail
|
3
|
+
module Helper
|
4
|
+
def filter_action_links_for_deleted(action_links, record, options)
|
5
|
+
end
|
6
|
+
|
7
|
+
def display_action_links(action_links, record, options, &block)
|
8
|
+
if action_name == 'deleted'
|
9
|
+
action_links = filter_action_links_for_deleted(action_links, record, options)
|
10
|
+
return unless action_links
|
11
|
+
end
|
12
|
+
super(action_links, record, options, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
ActionView::Base.class_eval do
|
19
|
+
include ActiveScaffold::Bridges::PaperTrail::Helper
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class PaperTrail
|
4
|
+
module PaperTrailBridge
|
5
|
+
def initialize_with_paper_trail(model_id)
|
6
|
+
initialize_without_paper_trail(model_id)
|
7
|
+
return unless self.model < ::PaperTrail::Model::InstanceMethods
|
8
|
+
self.actions << :deleted_records
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.alias_method_chain :initialize, :paper_trail
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/active_scaffold/core.rb
CHANGED
@@ -171,7 +171,7 @@ module ActiveScaffold
|
|
171
171
|
controller = active_scaffold_controller_for_column(column, options)
|
172
172
|
|
173
173
|
unless controller.nil?
|
174
|
-
options.reverse_merge! :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : controller.controller_path), :column => column
|
174
|
+
options.reverse_merge! :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : "/#{controller.controller_path}"), :column => column
|
175
175
|
options[:parameters] ||= {}
|
176
176
|
options[:parameters].reverse_merge! :association => column.association.name
|
177
177
|
if column.plural_association?
|
@@ -4,6 +4,7 @@ module ActiveScaffold::DataStructures
|
|
4
4
|
include Enumerable
|
5
5
|
|
6
6
|
attr_accessor :constraint_columns
|
7
|
+
attr_accessor :sorting_by_primary_key
|
7
8
|
|
8
9
|
def initialize(columns)
|
9
10
|
@columns = columns
|
@@ -18,7 +19,8 @@ module ActiveScaffold::DataStructures
|
|
18
19
|
# fallback to setting primary key ordering
|
19
20
|
if model.column_names.include?(model.primary_key)
|
20
21
|
set([model.primary_key, 'ASC'])
|
21
|
-
@
|
22
|
+
@primary_key_clause = clause
|
23
|
+
@sorting_by_primary_key = model.connection.try(:adapter_name) == 'PostgreSQL' # mandatory for postgres, so enabled by default
|
22
24
|
end
|
23
25
|
# If an ORDER BY clause is found set default sorting according to it
|
24
26
|
if order_clause
|
@@ -121,7 +123,7 @@ module ActiveScaffold::DataStructures
|
|
121
123
|
order << Array(sql).map {|column| "#{column} #{sort_direction}"}.join(', ')
|
122
124
|
end
|
123
125
|
|
124
|
-
order << @
|
126
|
+
order << @primary_key_clause if @sorting_by_primary_key
|
125
127
|
order unless order.empty?
|
126
128
|
end
|
127
129
|
|
@@ -6,7 +6,7 @@ module ActiveScaffold
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def pagination_url_options(url_options = nil)
|
9
|
-
url_options ||= params_for
|
9
|
+
url_options ||= params_for
|
10
10
|
unless active_scaffold_config.store_user_settings
|
11
11
|
url_options.merge!(:search => search_params) if search_params.present?
|
12
12
|
if active_scaffold_config.list.user.user_sorting?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Many, see README
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -230,6 +230,11 @@ files:
|
|
230
230
|
- lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb
|
231
231
|
- lib/active_scaffold/bridges/file_column/test/mock_model.rb
|
232
232
|
- lib/active_scaffold/bridges/file_column/test/test_helper.rb
|
233
|
+
- lib/active_scaffold/bridges/paper_trail.rb
|
234
|
+
- lib/active_scaffold/bridges/paper_trail/actions.rb
|
235
|
+
- lib/active_scaffold/bridges/paper_trail/config.rb
|
236
|
+
- lib/active_scaffold/bridges/paper_trail/helper.rb
|
237
|
+
- lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb
|
233
238
|
- lib/active_scaffold/bridges/paperclip.rb
|
234
239
|
- lib/active_scaffold/bridges/paperclip/form_ui.rb
|
235
240
|
- lib/active_scaffold/bridges/paperclip/list_ui.rb
|