active_scaffold 3.1.6 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -503,9 +503,15 @@ var ActiveScaffold = {
503
503
  record = $(record);
504
504
  var errors = record.prev();
505
505
  if (errors.hasClass('association-record-errors')) {
506
- this.replace_html(errors, '');
506
+ this.remove(errors);
507
507
  }
508
+ var associated = $(record).next();
508
509
  this.remove(record);
510
+ while (associated.hasClass('associated-record')) {
511
+ record = associated;
512
+ associated = $(record).next();
513
+ this.remove(record);
514
+ }
509
515
  },
510
516
 
511
517
  report_500_response: function(active_scaffold_id) {
@@ -503,9 +503,15 @@ var ActiveScaffold = {
503
503
  record = $(record);
504
504
  var errors = record.prev();
505
505
  if (errors.hasClass('association-record-errors')) {
506
- this.replace_html(errors, '');
506
+ this.remove(errors);
507
507
  }
508
+ var associated = $(record).next();
508
509
  this.remove(record);
510
+ while (associated && associated.hasClassName('associated-record')) {
511
+ record = associated;
512
+ associated = $(record).next();
513
+ this.remove(record);
514
+ }
509
515
  },
510
516
 
511
517
  report_500_response: function(active_scaffold_id) {
@@ -765,7 +771,7 @@ var ActiveScaffold = {
765
771
  },
766
772
 
767
773
  draggable_lists: function(element) {
768
- $(element).draggable_lists();
774
+ $('#' + element).draggable_lists();
769
775
  }
770
776
  }
771
777
 
@@ -456,9 +456,15 @@ var ActiveScaffold = {
456
456
  delete_subform_record: function(record) {
457
457
  var errors = $(record).previous();
458
458
  if (errors.hasClassName('association-record-errors')) {
459
- this.replace_html(errors, '');
459
+ this.remove(errors);
460
460
  }
461
+ var associated = $(record).next();
461
462
  this.remove(record);
463
+ while (associated && associated.hasClassName('associated-record')) {
464
+ record = associated;
465
+ associated = $(record).next();
466
+ this.remove(record);
467
+ }
462
468
  },
463
469
 
464
470
  report_500_response: function(active_scaffold_id) {
@@ -456,7 +456,7 @@ var ActiveScaffold = {
456
456
  delete_subform_record: function(record) {
457
457
  var errors = $(record).previous();
458
458
  if (errors.hasClassName('association-record-errors')) {
459
- this.replace_html(errors, '');
459
+ this.remove(errors);
460
460
  }
461
461
  this.remove(record);
462
462
  },
@@ -626,6 +626,10 @@ var ActiveScaffold = {
626
626
  }
627
627
  }
628
628
  });
629
+ },
630
+
631
+ draggable_lists: function(element) {
632
+ new DraggableLists(element);
629
633
  }
630
634
  }
631
635
 
@@ -84,8 +84,8 @@ ru:
84
84
  this_year: 'В этом году'
85
85
  prev_year: 'В прошлом году'
86
86
  next_year: 'В следующем году'
87
- past: 'Прошлое'
88
- future: 'Будущее'
87
+ past: 'Прошедшие'
88
+ future: 'Будущие'
89
89
  range: 'Интервал'
90
90
  seconds: 'секунд'
91
91
  minutes: 'минут'
@@ -102,10 +102,9 @@ ru:
102
102
  firstDay: 1
103
103
  isRTL: false
104
104
  showMonthAfterYear: false
105
+
105
106
  datetime_picker_options:
106
- timeText: 'Время'
107
- currentText: 'Сегодня'
108
- closeText: 'Закрыть'
107
+
109
108
  errors:
110
109
  template:
111
110
  header:
@@ -117,6 +116,8 @@ ru:
117
116
 
118
117
  # error_messages
119
118
  cant_destroy_record: 'Запись %{record} не может быть удалена'
120
- failed_to_save_record: 'Запись не может быть сохранена из-за неизвестной ошибки'
121
119
  internal_error: '500 Внутренняя ошибка сервера'
122
120
  version_inconsistency: 'Эта запись была обновлена с того момента, как вы начали ее редактировать'
121
+ record_not_saved: 'Запись не может быть сохранена из-за неизвестной ошибки'
122
+ no_authorization_for_action: 'Нет прав на выполнение действия "%{action}"'
123
+
@@ -5,6 +5,7 @@
5
5
  <table cellpadding="0" cellspacing="0">
6
6
  <tbody class="before-header" id="<%= before_header_id -%>">
7
7
  <% if active_scaffold_config.list.always_show_search %>
8
+ <% old_record, @record = @record, new_model %>
8
9
  <tr>
9
10
  <td>
10
11
  <div class="active-scaffold show_search-view <%= "#{params[:controller]}-view" %> view">
@@ -12,10 +13,12 @@
12
13
  </div>
13
14
  </td>
14
15
  </tr>
16
+ <% @record = old_record %>
15
17
  <% else %>
16
18
  <tr><td></td></tr>
17
19
  <% end %>
18
20
  <% if !nested? && active_scaffold_config.list.always_show_create %>
21
+ <% old_record, @record = @record, new_model %>
19
22
  <tr>
20
23
  <td>
21
24
  <div class="active-scaffold create-view <%= "#{params[:controller]}-view" %> view">
@@ -23,6 +26,7 @@
23
26
  </div>
24
27
  </td>
25
28
  </tr>
29
+ <% @record = old_record %>
26
30
  <% end %>
27
31
  </tbody>
28
32
  </table>
@@ -0,0 +1,32 @@
1
+ <div id="<%= active_scaffold_id -%>" class="<%= as_main_div_class %>" <%= "data-eid=#{id_from_controller(params[:eid])}" if params[:eid]%>>
2
+ <div class="active-scaffold-header">
3
+ <%= render :partial => 'list_header' %>
4
+ </div>
5
+ <table cellpadding="0" cellspacing="0">
6
+ <tbody class="before-header" id="<%= before_header_id -%>">
7
+ <% if active_scaffold_config.list.always_show_search %>
8
+ <tr>
9
+ <td>
10
+ <div class="active-scaffold show_search-view <%= "#{params[:controller]}-view" %> view">
11
+ <%= render :partial => active_scaffold_config.list.search_partial %>
12
+ </div>
13
+ </td>
14
+ </tr>
15
+ <% else %>
16
+ <tr><td></td></tr>
17
+ <% end %>
18
+ <% if !nested? && active_scaffold_config.list.always_show_create %>
19
+ <tr>
20
+ <td>
21
+ <div class="active-scaffold create-view <%= "#{params[:controller]}-view" %> view">
22
+ <%= render :partial => 'create_form_on_list' %>
23
+ </div>
24
+ </td>
25
+ </tr>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ <div id="<%= active_scaffold_content_id-%>" class="as_content">
30
+ <%= render :partial => 'list' %>
31
+ </div>
32
+ </div>
@@ -16,9 +16,11 @@ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'mess
16
16
  <% end %>
17
17
  action_link.close();
18
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?}%>
19
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
20
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
21
+ <% end %>
20
22
  <% elsif (active_scaffold_config.create.refresh_list) %>
21
- ActiveScaffold.replace_html(<%= active_scaffold_content_id%>, <%= escape_javascript(render(:partial => 'list', :layout => false)) %>);
23
+ ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%= escape_javascript(render(:partial => 'list', :layout => false)) %>');
22
24
  <% elsif params[:parent_controller].nil? %>
23
25
  <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
24
26
  ActiveScaffold.create_record_row(action_link.scaffold(),'<%=escape_javascript(new_row)%>', <%={:insert_at => insert_at}.to_json.html_safe%>);
@@ -1,14 +1,14 @@
1
- <% column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column])%>
1
+ <% @column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column]) %>
2
2
  <% unless controller.send :successful?%>
3
3
  alert('<%= escape_javascript(@record.errors.full_messages.join("\n"))%>');
4
4
  <% @record.reload%>
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))%>');
@@ -0,0 +1,16 @@
1
+ <% @column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column]) %>
2
+ <% unless controller.send :successful?%>
3
+ alert('<%= escape_javascript(@record.errors.full_messages.join("\n"))%>');
4
+ <% @record.reload%>
5
+ <% end%>
6
+ <% column = active_scaffold_config.columns[params[:column]]%>
7
+ <% if column.inplace_edit%>
8
+ ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
9
+ <% else%>
10
+ <% formatted_value = get_column_value(@record, column)%>
11
+ ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(formatted_value)%>');
12
+ <% end%>
13
+ <% if column.calculation?%>
14
+ ActiveScaffold.replace_html('<%=active_scaffold_calculations_id(column)%>', '<%=escape_javascript(render_column_calculation(column))%>');
15
+ <% end%>
16
+
@@ -17,8 +17,6 @@ module ActiveScaffold::Actions
17
17
 
18
18
  def list
19
19
  do_list
20
- do_new if active_scaffold_config.list.always_show_create
21
- @record ||= new_model if active_scaffold_config.list.always_show_search
22
20
  @nested_auto_open = active_scaffold_config.list.nested_auto_open
23
21
  respond_to_action(:list)
24
22
  end
@@ -175,7 +175,9 @@ module ActiveScaffold::Actions
175
175
  end
176
176
  alias_method :index_formats, :list_formats
177
177
 
178
- alias_method :row_formats, :list_formats
178
+ def row_formats
179
+ ([:html] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
180
+ end
179
181
 
180
182
  def action_update_formats
181
183
  (default_formats + active_scaffold_config.formats).uniq
@@ -18,7 +18,7 @@ module ActiveScaffold::Actions
18
18
  # for inline (inlist) editing
19
19
  def update_column
20
20
  do_update_column
21
- render :action => 'update_column', :locals => {:column_span_id => params[:editor_id] || params[:editorId]}
21
+ @column_span_id = params[:editor_id] || params[:editorId]
22
22
  end
23
23
 
24
24
  protected
@@ -82,7 +82,6 @@ module ActiveScaffold::Actions
82
82
  @record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record]) unless options[:no_record_param_update]
83
83
  before_update_save(@record)
84
84
  self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
85
- debugger
86
85
  if successful?
87
86
  @record.save! and @record.save_associated!
88
87
  after_update_save(@record)
@@ -275,11 +275,13 @@ module ActiveScaffold
275
275
 
276
276
  def inplace_edit_control(column)
277
277
  if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
278
- @record = new_model
278
+ old_record, @record = @record, new_model
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
- content_tag(:div, active_scaffold_input_for(column), {:style => "display:none;", :class => inplace_edit_control_css_class})
282
+ content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
283
+ @record = old_record
284
+ end
283
285
  end
284
286
  end
285
287
 
@@ -84,7 +84,7 @@ module ActiveScaffold
84
84
  link.action = 'index'
85
85
  link.crud_type = :read
86
86
  end
87
- link if link.crud_type.present?
87
+ link if link.action.present?
88
88
  end
89
89
 
90
90
  def column_link_authorized?(link, column, record, associated)
@@ -275,11 +275,13 @@ module ActiveScaffold
275
275
 
276
276
  def inplace_edit_control(column)
277
277
  if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
278
- @record = new_model
278
+ old_record, @record = @record, new_model
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
- content_tag(:div, active_scaffold_input_for(column), {:style => "display:none;", :class => inplace_edit_control_css_class})
282
+ returning(content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class)) do
283
+ @record = old_record
284
+ end
283
285
  end
284
286
  end
285
287
 
@@ -265,7 +265,7 @@ module ActiveScaffold
265
265
 
266
266
  def render_column_calculation(column)
267
267
  calculation = column_calculation(column)
268
- override_formatter = "render_#{column.name}_#{column.calculate}"
268
+ override_formatter = "render_#{column.name}_#{column.calculate.is_a?(Proc) ? :calculate : column.calculate}"
269
269
  calculation = send(override_formatter, calculation) if respond_to? override_formatter
270
270
 
271
271
  "#{"#{as_(column.calculate)}: " unless column.calculate.is_a? Proc}#{format_column_value nil, column, calculation}"
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 6
5
+ PATCH = 7
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 6
10
- version: 3.1.6
9
+ - 7
10
+ version: 3.1.7
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-20 00:00:00 Z
18
+ date: 2011-10-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -186,6 +186,7 @@ files:
186
186
  - frontends/default/views/_form.html.erb~
187
187
  - frontends/default/views/_row.html.erb~
188
188
  - frontends/default/views/render_field.js.erb~
189
+ - frontends/default/views/update_column.js.erb~
189
190
  - frontends/default/views/_form_association_footer.html.erb~
190
191
  - frontends/default/views/edit_associated.js.erb~
191
192
  - frontends/default/views/_list_inline_adapter.html.erb~
@@ -203,6 +204,7 @@ files:
203
204
  - frontends/default/views/on_update.js.erb~
204
205
  - frontends/default/views/on_create.js.erb~
205
206
  - frontends/default/views/_horizontal_subform_record.html.erb~
207
+ - frontends/default/views/_list_with_header.html.erb~
206
208
  - lib/active_scaffold.rb
207
209
  - lib/active_scaffold_env.rb
208
210
  - lib/active_scaffold/actions/core.rb