active_scaffold 3.1.5 → 3.1.6

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.
Files changed (27) hide show
  1. data/app/assets/javascripts/active_scaffold.js.erb +1 -0
  2. data/app/assets/javascripts/active_scaffold.js.erb~ +16 -0
  3. data/app/assets/javascripts/jquery/active_scaffold.js +4 -0
  4. data/app/assets/javascripts/jquery/active_scaffold.js~ +5 -0
  5. data/app/assets/javascripts/jquery/draggable_lists.js +27 -0
  6. data/app/assets/javascripts/jquery/draggable_lists.js~ +27 -0
  7. data/app/assets/javascripts/prototype/active_scaffold.js +4 -0
  8. data/app/assets/javascripts/prototype/active_scaffold.js~ +1 -0
  9. data/app/assets/stylesheets/active_scaffold.css.erb +4 -0
  10. data/app/assets/stylesheets/active_scaffold.css.erb~ +1098 -0
  11. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  12. data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
  13. data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
  14. data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
  15. data/frontends/default/views/_show.html.erb~ +9 -0
  16. data/frontends/default/views/on_create.js.erb +1 -1
  17. data/frontends/default/views/on_create.js.erb~ +45 -0
  18. data/frontends/default/views/on_update.js.erb +1 -1
  19. data/frontends/default/views/on_update.js.erb~ +31 -0
  20. data/lib/active_scaffold/actions/core.rb +1 -1
  21. data/lib/active_scaffold/bridges/file_column/form_ui.rb +23 -26
  22. data/lib/active_scaffold/config/base.rb +2 -1
  23. data/lib/active_scaffold/config/base.rb~ +70 -0
  24. data/lib/active_scaffold/helpers/form_column_helpers.rb +1 -1
  25. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +1 -2
  26. data/lib/active_scaffold/version.rb +1 -1
  27. metadata +13 -5
@@ -1,7 +1,7 @@
1
1
  <thead>
2
2
  <tr>
3
3
  <%
4
- active_scaffold_config_for(record.class).subform.columns.each :for => record.class, :flatten => true do |column|
4
+ active_scaffold_config_for(record.class).subform.columns.each :for => record.class, :crud_type => :read, :flatten => true do |column|
5
5
  hidden = column_renders_as(column) == :hidden
6
6
  next unless in_subform?(column, parent_record)
7
7
  -%>
@@ -1,7 +1,7 @@
1
1
  <thead>
2
2
  <tr>
3
3
  <%
4
- active_scaffold_config_for(@record.class).subform.columns.each :for => @record.class, :flatten => true do |column|
4
+ active_scaffold_config_for(record.class).subform.columns.each :for => record.class, :flatten => true do |column|
5
5
  hidden = column_renders_as(column) == :hidden
6
6
  next unless in_subform?(column, parent_record)
7
7
  -%>
@@ -8,7 +8,7 @@
8
8
  tr_id = "association-#{options[:id]}"
9
9
  %>
10
10
  <tr id="<%= tr_id %>" class="association-record <%= 'association-record-new' if @record.new_record? -%> <%= 'locked' if locked -%>">
11
- <% config.subform.columns.each :for => @record.class, :crud_type => crud_type, :flatten => true do |column| %>
11
+ <% config.subform.columns.each :for => @record.class, :crud_type => :read, :flatten => true do |column| %>
12
12
  <%
13
13
  next unless in_subform?(column, parent_record)
14
14
  show_actions = true
@@ -15,7 +15,7 @@
15
15
  column = column.clone
16
16
  column.form_ui ||= :select if column.association
17
17
  -%>
18
- <td class="<%= 'hidden' if column_renders_as(column) == :hidden %>">
18
+ <td<%= ' class="hidden"'.html_safe if column_renders_as(column) == :hidden %>>
19
19
  <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%>
20
20
  <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
21
21
  <% else -%>
@@ -0,0 +1,9 @@
1
+ <% debugger %>
2
+ <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : clean_column_value(@record.to_label)) %></h4>
3
+
4
+ <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
5
+
6
+ <p class="form-footer">
7
+ <%= link_to as_(:close), main_path_to_return, :class => 'as_cancel', :remote => request.xhr?, 'data-refresh' => false %>
8
+ <%= loading_indicator_tag(:action => :create, :id => params[:id]) %>
9
+ </p>
@@ -2,7 +2,7 @@ try {
2
2
  <% form_selector = "#{element_form_id(:action => :create)}"
3
3
  insert_at ||= :top %>
4
4
  var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
5
- action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
5
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages'))%>');
6
6
  <% if controller.send :successful? %>
7
7
  <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
8
8
  <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
@@ -0,0 +1,45 @@
1
+ try {
2
+ <% form_selector = "#{element_form_id(:action => :create)}"
3
+ insert_at ||= :top %>
4
+ var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
5
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
6
+ <% if controller.send :successful? %>
7
+ <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
8
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
9
+ <% if nested_singular_association? %>
10
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
11
+ <% else %>
12
+ <% if render_parent_action == :row %>
13
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(parent_rendered)%>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
14
+ <% elsif render_parent_action == :index %>
15
+ <%= escape_javascript(parent_rendered) %>
16
+ <% end %>
17
+ action_link.close();
18
+ <% end %>
19
+ <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
20
+ <% elsif (active_scaffold_config.create.refresh_list) %>
21
+ ActiveScaffold.replace_html(<%= active_scaffold_content_id%>, <%= escape_javascript(render(:partial => 'list', :layout => false)) %>);
22
+ <% elsif params[:parent_controller].nil? %>
23
+ <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
24
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%=escape_javascript(new_row)%>', <%={:insert_at => insert_at}.to_json.html_safe%>);
25
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
26
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <% unless render_parent? %>
31
+ <% if (active_scaffold_config.create.persistent) %>
32
+ action_link.reload();
33
+ <% else %>
34
+ action_link.close();
35
+ <% end %>
36
+ <% if (active_scaffold_config.create.action_after_create) %>
37
+ var link = $('<%=action_link_id active_scaffold_config.create.action_after_create, @record.id%>');
38
+ if (link) (function() { link.action_link.open() }).defer();
39
+ <% end %>
40
+ <% end %>
41
+ <% else %>
42
+ ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'create_form', :locals => {:xhr => true}))%>');
43
+ ActiveScaffold.scroll_to('<%=form_selector%>');
44
+ <% end %>
45
+ } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -1,7 +1,7 @@
1
1
  try {
2
2
  <% form_selector = "#{element_form_id(:action => :update)}" %>
3
3
  var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
4
- action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
4
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages'))%>');
5
5
  <% if controller.send :successful? %>
6
6
  <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
7
7
  <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
@@ -0,0 +1,31 @@
1
+ try {
2
+ <% form_selector = "#{element_form_id(:action => :update)}" %>
3
+ var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
4
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
5
+ <% if controller.send :successful? %>
6
+ <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
7
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
8
+ <% if nested_singular_association? %>
9
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
10
+ <% else %>
11
+ <% if render_parent_action == :row %>
12
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
13
+ <% elsif render_parent_action == :index %>
14
+ <%= escape_javascript(parent_rendered) %>
15
+ <% end %>
16
+ <% end %>
17
+ <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
18
+ <% elsif update_refresh_list? %>
19
+ ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%= escape_javascript(render(:partial => 'list', :layout => false))%>');
20
+ <% else %>
21
+ <% updated_row = render :partial => 'list_record', :locals => {:record => @record}%>
22
+ action_link.close('<%= escape_javascript(updated_row)%>');
23
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
24
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
25
+ <% end %>
26
+ <% end %>
27
+ <% else %>
28
+ ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'update_form', :locals => {:xhr => true}))%>');
29
+ ActiveScaffold.scroll_to('<%=form_selector%>');
30
+ <% end %>
31
+ } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -165,7 +165,7 @@ module ActiveScaffold::Actions
165
165
  params = params[:record] || {} unless params[model.inheritance_column] # in create action must be inside record key
166
166
  model = params.delete(model.inheritance_column).camelize.constantize if params[model.inheritance_column]
167
167
  end
168
- model.respond_to?(:build) ? model.build(build_options || {}) : model.new
168
+ model.new(build_options || {})
169
169
  end
170
170
 
171
171
  private
@@ -3,35 +3,32 @@ module ActiveScaffold
3
3
  # Helpers that assist with the rendering of a Form Column
4
4
  module FormColumnHelpers
5
5
  def active_scaffold_input_file_column(column, options)
6
- if @record.send(column.name)
7
- # we already have a value? display the form for deletion.
6
+ if @record.send(column.name)
7
+ # we already have a value? display the form for deletion.
8
8
  if ActiveScaffold.js_framework == :jquery
9
- js_remove_file_code = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
9
+ remove_file_js = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
10
10
  else
11
- js_remove_file_code = "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show(); return false;";
11
+ remove_file_js = "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show(); return false;";
12
+ end
13
+
14
+ hidden_options = options.dup
15
+ hidden_options[:id] += '_delete'
16
+ hidden_options[:name].sub!("[#{column.name}]", "[delete_#{column.name}]")
17
+ hidden_options[:value] = 'false'
18
+ custom_hidden_field_tag = hidden_field(:record, column.name, hidden_options)
19
+
20
+ content_tag(:div) do
21
+ content_tag(:div) do
22
+ content = get_column_value(@record, column) + " #{custom_hidden_field_tag} | ".html_safe
23
+ content += content_tag(:a, as_(:remove_file), {:href => '#', :onclick => remove_file_js})
24
+ content += content_tag(:div, file_column_field("record", column.name, options), :style => "display: none")
25
+ end
12
26
  end
13
- content_tag(
14
- :div,
15
- content_tag(
16
- :div,
17
- get_column_value(@record, column) + " " +
18
- custom_hidden_field_tag +
19
- " | " +
20
- content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code}),
21
- {}
22
- ) +
23
- content_tag(
24
- :div,
25
- file_column_field("record", column.name, options),
26
- :style => "display: none"
27
- ),
28
- {}
29
- )
30
- else
31
- # no, just display the file_column_field
32
- file_column_field("record", column.name, options)
33
- end
34
- end
27
+ else
28
+ file_column_field("record", column.name, options)
29
+ end
30
+ end
31
+
35
32
  end
36
33
  end
37
34
  end
@@ -26,7 +26,8 @@ module ActiveScaffold::Config
26
26
  def crud_type; self.class.crud_type end
27
27
 
28
28
  def label(model = nil)
29
- as_(@label, :model => model || @core.label(:count => 1))
29
+ model ||= @core.label(:count => 1)
30
+ @label.nil? ? model : as_(@label, :model => model)
30
31
  end
31
32
 
32
33
  # the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
@@ -0,0 +1,70 @@
1
+ module ActiveScaffold::Config
2
+ class Base
3
+ include ActiveScaffold::Configurable
4
+ extend ActiveScaffold::Configurable
5
+
6
+ def initialize(core_config)
7
+ @core = core_config
8
+ end
9
+
10
+ def self.inherited(subclass)
11
+ class << subclass
12
+ # the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
13
+ # this is not a setting for the developer. it's self-description for the actions.
14
+ def crud_type; @crud_type; end
15
+
16
+ protected
17
+
18
+ def crud_type=(val)
19
+ raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
20
+ @crud_type = val.to_sym
21
+ end
22
+ end
23
+ end
24
+
25
+ # delegate
26
+ def crud_type; self.class.crud_type end
27
+
28
+ def label(model = @core.label(:count => 1))
29
+ @label.nil? ? model : as_(@label, :model => model)
30
+ end
31
+
32
+ # the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
33
+ attr_accessor :user
34
+
35
+ # define a default action_group for this action
36
+ # e.g. 'members.crud'
37
+ class_attribute :action_group
38
+
39
+ # action_group this action should belong to
40
+ attr_accessor :action_group
41
+
42
+ class UserSettings
43
+ def initialize(conf, storage, params)
44
+ # the session hash relevant to this action
45
+ @session = storage
46
+ # all the request params
47
+ @params = params
48
+ # the configuration object for this action
49
+ @conf = conf
50
+ end
51
+ end
52
+
53
+ def formats
54
+ @formats ||= []
55
+ end
56
+
57
+ def formats=(val)
58
+ @formats=val
59
+ end
60
+
61
+ private
62
+
63
+ def columns=(val)
64
+ @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
65
+ @columns.action = self
66
+ @columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
67
+ @columns
68
+ end
69
+ end
70
+ end
@@ -133,7 +133,7 @@ module ActiveScaffold
133
133
  end
134
134
  content
135
135
  end
136
- html << javascript_tag("new DraggableLists('#{options[:id]}')") if column.options[:draggable_lists]
136
+ html << javascript_tag("ActiveScaffold.draggable_lists('#{options[:id]}')") if column.options[:draggable_lists]
137
137
  html
138
138
  end
139
139
 
@@ -121,8 +121,7 @@ module ActiveScaffold
121
121
  end
122
122
 
123
123
  def active_scaffold_checkbox_list(column, select_options, associated_ids, options)
124
- options[:class] << " checkbox-list"
125
- html = content_tag :ul, :class => options[:class], :id => options[:id] do
124
+ html = content_tag :ul, :class => "#{options[:class]} checkbox-list", :id => options[:id] do
126
125
  content = "".html_safe
127
126
  select_options.each_with_index do |option, i|
128
127
  label, id = option
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 5
5
+ PATCH = 6
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 5
10
- version: 3.1.5
9
+ - 6
10
+ version: 3.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-07 00:00:00 Z
18
+ date: 2011-10-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -101,14 +101,18 @@ files:
101
101
  - app/assets/javascripts/jquery/active_scaffold.js
102
102
  - app/assets/javascripts/jquery/date_picker_bridge.js.erb
103
103
  - app/assets/javascripts/jquery/jquery.editinplace.js
104
+ - app/assets/javascripts/jquery/draggable_lists.js
104
105
  - app/assets/javascripts/jquery/active_scaffold.js~
106
+ - app/assets/javascripts/jquery/draggable_lists.js~
105
107
  - app/assets/javascripts/prototype/active_scaffold.js
106
108
  - app/assets/javascripts/prototype/dhtml_history.js
107
109
  - app/assets/javascripts/prototype/form_enhancements.js
108
110
  - app/assets/javascripts/prototype/rico_corner.js
109
111
  - app/assets/javascripts/prototype/active_scaffold.js~
112
+ - app/assets/javascripts/active_scaffold.js.erb~
110
113
  - app/assets/stylesheets/active_scaffold-ie.css
111
114
  - app/assets/stylesheets/active_scaffold.css.erb
115
+ - app/assets/stylesheets/active_scaffold.css.erb~
112
116
  - config/locales/de.yml
113
117
  - config/locales/en.yml
114
118
  - config/locales/es.yml
@@ -182,13 +186,13 @@ files:
182
186
  - frontends/default/views/_form.html.erb~
183
187
  - frontends/default/views/_row.html.erb~
184
188
  - frontends/default/views/render_field.js.erb~
185
- - frontends/default/views/_horizontal_subform_record.html.erb~
186
189
  - frontends/default/views/_form_association_footer.html.erb~
187
190
  - frontends/default/views/edit_associated.js.erb~
188
191
  - frontends/default/views/_list_inline_adapter.html.erb~
189
192
  - frontends/default/views/_form_association.html.erb~
190
193
  - frontends/default/views/_vertical_subform.html.erb~
191
194
  - frontends/default/views/_horizontal_subform.html.erb~
195
+ - frontends/default/views/_show.html.erb~
192
196
  - frontends/default/views/_horizontal_subform_header.html.erb~
193
197
  - frontends/default/views/_list_pagination.html.erb~
194
198
  - frontends/default/views/_list_actions.html.erb~
@@ -196,6 +200,9 @@ files:
196
200
  - frontends/default/views/_list_messages.html.erb~
197
201
  - frontends/default/views/_render_field.js.erb~
198
202
  - frontends/default/views/_action_group.html.erb~
203
+ - frontends/default/views/on_update.js.erb~
204
+ - frontends/default/views/on_create.js.erb~
205
+ - frontends/default/views/_horizontal_subform_record.html.erb~
199
206
  - lib/active_scaffold.rb
200
207
  - lib/active_scaffold_env.rb
201
208
  - lib/active_scaffold/actions/core.rb
@@ -233,6 +240,7 @@ files:
233
240
  - lib/active_scaffold/config/mark.rb
234
241
  - lib/active_scaffold/config/search.rb~
235
242
  - lib/active_scaffold/config/nested.rb~
243
+ - lib/active_scaffold/config/base.rb~
236
244
  - lib/active_scaffold/configurable.rb
237
245
  - lib/active_scaffold/constraints.rb
238
246
  - lib/active_scaffold/data_structures/action_columns.rb