active_scaffold 3.1.8 → 3.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -147,12 +147,17 @@ $(document).ready(function() {
147
147
  return true;
148
148
  } else return false;
149
149
  });
150
- $('input.update_form, select.update_form').live('change', function(event) {
150
+ $('input.update_form, textarea.update_form, select.update_form').live('change', function(event) {
151
151
  var element = $(this);
152
152
  var value = element.is("input:checkbox:not(:checked)") ? null : element.val();
153
153
  ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
154
154
  return true;
155
155
  });
156
+ $('input.recordselect.update_form').live('recordselect:change', function(event, id, label) {
157
+ var element = $(this);
158
+ ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), id);
159
+ return true;
160
+ });
156
161
 
157
162
  $('select.as_search_range_option').live('change', function(event) {
158
163
  ActiveScaffold[$(this).val() == 'BETWEEN' ? 'show' : 'hide']($(this).parent().find('.as_search_range_between'));
@@ -147,7 +147,7 @@ $(document).ready(function() {
147
147
  return true;
148
148
  } else return false;
149
149
  });
150
- $('input.update_form, select.update_form').live('change', function(event) {
150
+ $('input.update_form, text_area.update_form, select.update_form').live('change', function(event) {
151
151
  var element = $(this);
152
152
  var value = element.is("input:checkbox:not(:checked)") ? null : element.val();
153
153
  ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
@@ -507,7 +507,7 @@ var ActiveScaffold = {
507
507
  }
508
508
  var associated = $(record).next();
509
509
  this.remove(record);
510
- while (associated && associated.hasClassName('associated-record')) {
510
+ while (associated.hasClass('associated-record')) {
511
511
  record = associated;
512
512
  associated = $(record).next();
513
513
  this.remove(record);
@@ -236,11 +236,16 @@ document.observe("dom:loaded", function() {
236
236
  event.memo.url = url;
237
237
  return true;
238
238
  });
239
- document.on('change', 'input.update_form, select.update_form', function(event) {
239
+ document.on('change', 'input.update_form, textarea.update_form, select.update_form', function(event) {
240
240
  var element = event.findElement();
241
241
  ActiveScaffold.update_column(element, element.readAttribute('data-update_url'), element.hasAttribute('data-update_send_form'), element.readAttribute('id'), element.getValue());
242
242
  return true;
243
243
  });
244
+ document.on('recordselect:change', 'input.recordselect.update_form', function(event) {
245
+ var element = event.findElement();
246
+ ActiveScaffold.update_column(element, element.readAttribute('data-update_url'), element.hasAttribute('data-update_send_form'), element.readAttribute('id'), element.memo.id);
247
+ return true;
248
+ });
244
249
  document.on('change', 'select.as_search_range_option', function(event) {
245
250
  var element = event.findElement();
246
251
  Element[element.value == 'BETWEEN' ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_between'));
@@ -1,4 +1,4 @@
1
- <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : clean_column_value(@record.to_label)) %></h4>
1
+ <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : @record.to_label) %></h4>
2
2
 
3
3
  <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
4
4
 
@@ -1,4 +1,3 @@
1
- <% debugger %>
2
1
  <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : clean_column_value(@record.to_label)) %></h4>
3
2
 
4
3
  <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
@@ -3,4 +3,4 @@
3
3
  :form_action => form_action ||= :update,
4
4
  :method => method ||= :put,
5
5
  :cancel_link => cancel_link,
6
- :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => clean_column_value(@record.to_label))} %>
6
+ :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => @record.to_label)} %>
@@ -0,0 +1,6 @@
1
+ <% cancel_link = true if cancel_link.nil? %>
2
+ <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
3
+ :form_action => form_action ||= :update,
4
+ :method => method ||= :put,
5
+ :cancel_link => cancel_link,
6
+ :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => clean_column_value(@record.to_label))} %>
@@ -5,7 +5,7 @@
5
5
  <% end%>
6
6
  <% column = active_scaffold_config.columns[params[:column]]%>
7
7
  <% if column.inplace_edit%>
8
- ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
8
+ ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(get_column_value(@record, column))%>');
9
9
  <% else%>
10
10
  <% formatted_value = get_column_value(@record, column)%>
11
11
  ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(formatted_value)%>');
@@ -5,10 +5,10 @@
5
5
  <% end%>
6
6
  <% column = active_scaffold_config.columns[params[:column]]%>
7
7
  <% if column.inplace_edit%>
8
- ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
8
+ ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
9
9
  <% else%>
10
10
  <% formatted_value = get_column_value(@record, column)%>
11
- ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(formatted_value)%>');
11
+ ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(formatted_value)%>');
12
12
  <% end%>
13
13
  <% if column.calculation?%>
14
14
  ActiveScaffold.replace_html('<%=active_scaffold_calculations_id(column)%>', '<%=escape_javascript(render_column_calculation(column))%>');
@@ -33,17 +33,10 @@ class ActiveScaffold::Bridges::RecordSelect
33
33
  params.merge!({column.association.primary_key_name => ''})
34
34
  end
35
35
 
36
- record_select_options = active_scaffold_input_text_options(
37
- :controller => remote_controller,
38
- :id => options[:id],
39
- :class => options[:class].gsub(/update_form/, '')
36
+ record_select_options = active_scaffold_input_text_options(options).merge(
37
+ :controller => remote_controller
40
38
  )
41
39
  record_select_options.merge!(column.options)
42
- if options['data-update_url']
43
- record_select_options[:onchange] = %|function(id, label) {
44
- ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
45
- }|
46
- end
47
40
 
48
41
  html = if multiple
49
42
  record_multi_select_field(options[:name], value || [], record_select_options)
@@ -55,17 +48,9 @@ class ActiveScaffold::Bridges::RecordSelect
55
48
  end
56
49
 
57
50
  def active_scaffold_record_select_autocomplete(column, options)
58
- record_select_options = active_scaffold_input_text_options(
59
- :controller => active_scaffold_controller_for(@record.class).controller_path,
60
- :id => options[:id],
61
- :class => options[:class].gsub(/update_form/, '')
51
+ record_select_options = active_scaffold_input_text_options(options).merge(
52
+ :controller => remote_controller
62
53
  )
63
- if options['data-update_url']
64
- record_select_options[:onchange] = %|function(id, label) {
65
- ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
66
- }|
67
- end
68
-
69
54
  html = record_select_autocomplete(options[:name], @record, record_select_options)
70
55
  html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
71
56
  html
@@ -119,7 +119,7 @@ module ActiveScaffold
119
119
  ## Overrides
120
120
  ##
121
121
  def active_scaffold_column_text(column, record)
122
- truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
122
+ clean_column_value(truncate(record.send(column.name), :length => column.options[:truncate] || 50))
123
123
  end
124
124
 
125
125
  def active_scaffold_column_checkbox(column, record)
@@ -190,25 +190,25 @@ module ActiveScaffold
190
190
  end
191
191
 
192
192
  def format_association_value(value, column, size)
193
- case column.association.macro
193
+ format_value case column.association.macro
194
194
  when :has_one, :belongs_to
195
195
  if column.polymorphic_association?
196
- format_value("#{value.class.model_name.human}: #{value.to_label}")
196
+ "#{value.class.model_name.human}: #{value.to_label}"
197
197
  else
198
- format_value(value.to_label)
198
+ value.to_label
199
199
  end
200
200
  when :has_many, :has_and_belongs_to_many
201
201
  if column.associated_limit.nil?
202
- firsts = value.collect { |v| clean_column_value(v.to_label) }
202
+ firsts = value.collect { |v| v.to_label }
203
203
  else
204
204
  firsts = value.first(column.associated_limit)
205
- firsts.collect! { |v| clean_column_value(v.to_label) }
205
+ firsts.collect! { |v| v.to_label }
206
206
  firsts[column.associated_limit] = '…' if value.size > column.associated_limit
207
207
  end
208
208
  if column.associated_limit == 0
209
209
  size if column.associated_number?
210
210
  else
211
- joined_associated = format_value(firsts.join(active_scaffold_config.list.association_join_text))
211
+ joined_associated = firsts.join(active_scaffold_config.list.association_join_text)
212
212
  joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit
213
213
  joined_associated
214
214
  end
@@ -256,14 +256,6 @@ module ActiveScaffold
256
256
  column.inplace_edit != :ajax and (override_form_field?(column) or column.form_ui or (column.column and override_input?(column.column.type)))
257
257
  end
258
258
 
259
- def format_inplace_edit_column(record,column)
260
- if column.list_ui == :checkbox
261
- active_scaffold_column_checkbox(column, record)
262
- else
263
- format_column_value(record, column)
264
- end
265
- end
266
-
267
259
  def active_scaffold_inplace_edit(record, column, options = {})
268
260
  formatted_column = options[:formatted_column] || format_column_value(record, column)
269
261
  id_options = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s}
@@ -119,7 +119,7 @@ module ActiveScaffold
119
119
  ## Overrides
120
120
  ##
121
121
  def active_scaffold_column_text(column, record)
122
- truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
122
+ clean_column_value(truncate(record.send(column.name), :length => column.options[:truncate] || 50))
123
123
  end
124
124
 
125
125
  def active_scaffold_column_checkbox(column, record)
@@ -190,25 +190,25 @@ module ActiveScaffold
190
190
  end
191
191
 
192
192
  def format_association_value(value, column, size)
193
- case column.association.macro
193
+ format_value case column.association.macro
194
194
  when :has_one, :belongs_to
195
195
  if column.polymorphic_association?
196
- format_value("#{value.class.model_name.human}: #{value.to_label}")
196
+ "#{value.class.model_name.human}: #{value.to_label}"
197
197
  else
198
- format_value(value.to_label)
198
+ value.to_label
199
199
  end
200
200
  when :has_many, :has_and_belongs_to_many
201
201
  if column.associated_limit.nil?
202
- firsts = value.collect { |v| clean_column_value(v.to_label) }
202
+ firsts = value.collect { |v| v.to_label }
203
203
  else
204
204
  firsts = value.first(column.associated_limit)
205
- firsts.collect! { |v| clean_column_value(v.to_label) }
205
+ firsts.collect! { |v| v.to_label }
206
206
  firsts[column.associated_limit] = '…' if value.size > column.associated_limit
207
207
  end
208
208
  if column.associated_limit == 0
209
209
  size if column.associated_number?
210
210
  else
211
- joined_associated = format_value(firsts.join(active_scaffold_config.list.association_join_text))
211
+ joined_associated = firsts.join(active_scaffold_config.list.association_join_text)
212
212
  joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit
213
213
  joined_associated
214
214
  end
@@ -279,7 +279,7 @@ module ActiveScaffold
279
279
  column = column.clone
280
280
  column.options = column.options.clone
281
281
  column.form_ui = :select if (column.association && column.form_ui.nil?)
282
- returning(content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class)) do
282
+ content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
283
283
  @record = old_record
284
284
  end
285
285
  end
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 8
5
+ PATCH = 9
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 8
10
- version: 3.1.8
9
+ - 9
10
+ version: 3.1.9
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-11-09 00:00:00 Z
18
+ date: 2011-11-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -205,6 +205,7 @@ files:
205
205
  - frontends/default/views/on_create.js.erb~
206
206
  - frontends/default/views/_horizontal_subform_record.html.erb~
207
207
  - frontends/default/views/_list_with_header.html.erb~
208
+ - frontends/default/views/_update_form.html.erb~
208
209
  - lib/active_scaffold.rb
209
210
  - lib/active_scaffold_env.rb
210
211
  - lib/active_scaffold/actions/core.rb