active_scaffold 3.2.14 → 3.2.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,15 @@
1
- = 3.2.13 (not released yet)
1
+ = 3.2.15 (not released yet)
2
+ - Prepare to unify field overrides and list_ui method signatures
3
+ - Add :optional to update.persistent
4
+ - Add missing triggering of as:element_updated in new subform rows
5
+ - Fix conditions for :select in field_search
6
+ - Fix datetime field search
7
+ - Fix authorization checking in member action links
8
+
9
+ = 3.2.14
10
+ - Fix default sorting, it was broken in 3.2.13
11
+
12
+ = 3.2.13
2
13
  - Fix destroy action, was broken in 3.2.12
3
14
  - Remove default :method sorting for associations, it wasn't useful and can be slow
4
15
  - Rescue from ActiveScaffold::ActionNotAllowed and ActiveScaffold::RecordNotAllowed with 401 response, it can be overrided with deny_access method in ApplicationController.
@@ -72,7 +72,7 @@ jQuery(document).ready(function() {
72
72
 
73
73
  if (action_link) {
74
74
  var cancel_url = as_cancel.attr('href');
75
- var refresh_data = action_link.tag.data('cancel-refresh');
75
+ var refresh_data = action_link.tag.data('cancel-refresh') || as_cancel.data('refresh');
76
76
  if (!refresh_data || !cancel_url) {
77
77
  action_link.close();
78
78
  return false;
@@ -547,6 +547,7 @@ var ActiveScaffold = {
547
547
  } else {
548
548
  server_error.show();
549
549
  }
550
+ ActiveScaffold.scroll_to(server_error, ActiveScaffold.config.scroll_on_close == 'checkInViewport');
550
551
  },
551
552
 
552
553
  find_action_link: function(element) {
@@ -626,9 +627,11 @@ var ActiveScaffold = {
626
627
  create_associated_record_form: function(element, content, options) {
627
628
  if (typeof(element) == 'string') element = '#' + element;
628
629
  var element = jQuery(element);
630
+ content = jQuery(content);
629
631
  if (options.singular == false) {
630
632
  if (!(options.id && jQuery('#' + options.id).size() > 0)) {
631
- element.append(content);
633
+ var new_element = element.append(content);
634
+ content.trigger('as:element_updated');
632
635
  }
633
636
  } else {
634
637
  var current = jQuery('#' + element.attr('id') + ' .association-record')
@@ -636,6 +639,7 @@ var ActiveScaffold = {
636
639
  this.replace(current[0], content);
637
640
  } else {
638
641
  element.prepend(content);
642
+ content.trigger('as:element_updated');
639
643
  }
640
644
  }
641
645
  },
@@ -95,7 +95,7 @@ document.observe("dom:loaded", function() {
95
95
  var action_link = ActiveScaffold.find_action_link(as_cancel);
96
96
 
97
97
  if (action_link) {
98
- var refresh_data = action_link.readAttribute('data-cancel-refresh');
98
+ var refresh_data = action_link.readAttribute('data-cancel-refresh') || as_cancel.readAttribute('data-refresh');
99
99
  if (refresh_data && action_link.refresh_url) {
100
100
  event.memo.url = action_link.refresh_url;
101
101
  } else if (!refresh_data || as_cancel.readAttribute('href').blank()) {
@@ -6,6 +6,7 @@ de:
6
6
  add: 'Hinzufügen'
7
7
  add_existing: 'Existierenden Eintrag hinzufügen'
8
8
  add_existing_model: 'Existierende %{model} hinzufügen'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: 'Sind Sie sicher?'
10
11
  cancel: 'Abbrechen'
11
12
  click_to_edit: 'Zum Editieren anklicken'
@@ -6,6 +6,7 @@ en:
6
6
  add: 'Add'
7
7
  add_existing: 'Add Existing'
8
8
  add_existing_model: 'Add Existing %{model}'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: 'Are you sure you want to delete %{label}?'
10
11
  cancel: 'Cancel'
11
12
  click_to_edit: 'Click to edit'
@@ -6,6 +6,7 @@ es:
6
6
  add: 'Añadir'
7
7
  add_existing: 'Añadir Existente'
8
8
  add_existing_model: 'Añadir %{model} Existente'
9
+ apply: 'Aplicar'
9
10
  are_you_sure_to_delete: '¿Estás seguro de que quieres borrar %{label}?'
10
11
  cancel: 'Cancelar'
11
12
  click_to_edit: 'Pulsa para editar'
@@ -6,6 +6,7 @@ fr:
6
6
  add: 'Ajouter'
7
7
  add_existing: 'Ajouter un(e) existant(e)'
8
8
  add_existing_model: 'Ajouter un(e) %{model} existant(e)'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: 'Êtes vous sûr?'
10
11
  cancel: 'Annuler'
11
12
  click_to_edit: 'Cliquer pour éditer'
@@ -6,6 +6,7 @@ hu:
6
6
  add: 'Hozzáadás'
7
7
  add_existing: 'Meglevő hozzáadása'
8
8
  add_existing_model: 'Meglevő %{model} hozzáadása'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: 'Biztos vagy benne?'
10
11
  cancel: 'Mégse'
11
12
  click_to_edit: 'Kattints a szerkesztéshez'
@@ -6,6 +6,7 @@ ja:
6
6
  add: '追加'
7
7
  add_existing: '既存のものを追加'
8
8
  add_existing_model: '既存の%{model}を追加'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: '本当によいですか?'
10
11
  cancel: 'キャンセル'
11
12
  click_to_edit: 'クリックして編集'
@@ -6,6 +6,7 @@ ru:
6
6
  add: 'Добавить запись'
7
7
  add_existing: 'Добавить существующую запись'
8
8
  add_existing_model: '%{model}: добавить существующую запись'
9
+ apply: 'Apply'
9
10
  are_you_sure_to_delete: 'Удалить %{label}?'
10
11
  cancel: 'Отмена'
11
12
  click_to_edit: 'Нажмите для редактирования'
@@ -5,9 +5,11 @@
5
5
  if active_scaffold_config.actions.include? form_action
6
6
  multipart ||= active_scaffold_config.send(form_action).multipart?
7
7
  columns ||= active_scaffold_config.send(form_action).columns
8
+ persistent ||= active_scaffold_config.send(form_action).persistent
8
9
  else
9
10
  multipart ||= false
10
11
  columns ||= nil
12
+ persistent ||= false
11
13
  end
12
14
  method ||= :post
13
15
  cancel_link = true if cancel_link.nil?
@@ -40,7 +42,8 @@ end
40
42
  <%= render :partial => body_partial, :locals => { :columns => columns, :form_action => form_action, :scope => scope } %>
41
43
 
42
44
  <p class="form-footer">
43
- <%= submit_tag as_(submit_text), :class => "submit" %>
45
+ <%= submit_tag as_(submit_text), :class => "submit" if !persistent || persistent == :optional %>
46
+ <%= submit_tag as_(:apply), :class => "submit", :name => 'dont_close' if persistent %>
44
47
  <%= link_to(as_(:cancel), main_path_to_return, cancel_options) if cancel_link %>
45
48
  <%= loading_indicator_tag(:action => form_action, :id => params[:id]) %>
46
49
  <%= render :partial => footer_extension, :locals => { :form_action => form_action } if footer_extension %>
@@ -3,7 +3,12 @@ try {
3
3
  var action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
4
4
  action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'messages')) %>');
5
5
  <% if controller.send :successful? %>
6
- <% if !active_scaffold_config.update.persistent %>
6
+ <% if params[:dont_close] %>
7
+ <% row_selector = element_row_id(:action => :list, :id => @record.id) %>
8
+ ActiveScaffold.update_row('<%= row_selector %>', '<%= escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) %>');
9
+ <%= render :partial => 'update_calculations', :formats => [:js] %>
10
+ ActiveScaffold.scroll_to('<%= row_selector %>', true);
11
+ <% else %>
7
12
  <% if render_parent? %>
8
13
  <% if nested_singular_association? || render_parent_action == :row %>
9
14
  action_link.close(true);
@@ -13,8 +18,7 @@ action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'mes
13
18
  <% elsif update_refresh_list? %>
14
19
  <%= render :partial => 'refresh_list' %>
15
20
  <% else %>
16
- <% updated_row = render :partial => 'list_record', :locals => {:record => @record} %>
17
- action_link.close('<%= escape_javascript(updated_row) %>');
21
+ action_link.close('<%= escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) %>');
18
22
  <%= render :partial => 'update_calculations', :formats => [:js] %>
19
23
  <% end %>
20
24
  <% end %>
@@ -60,7 +60,7 @@ module ActiveScaffold::Actions
60
60
  # The default security delegates to ActiveRecordPermissions.
61
61
  # You may override the method to customize.
62
62
  def delete_authorized?(record = nil)
63
- (!nested? || !nested.readonly?) && authorized_for?(:crud_type => :delete)
63
+ (!nested? || !nested.readonly?) && (record || self).send(:authorized_for?, :crud_type => :delete)
64
64
  end
65
65
  private
66
66
  def delete_authorized_filter
@@ -56,6 +56,7 @@ module ActiveScaffold::Actions
56
56
 
57
57
  # The actual algorithm to prepare for the list view
58
58
  def set_includes_for_list_columns
59
+ @cache_associations = true
59
60
  includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
60
61
  self.active_scaffold_includes.concat includes_for_list_columns
61
62
  end
@@ -47,7 +47,7 @@ module ActiveScaffold::Actions
47
47
  # The default security delegates to ActiveRecordPermissions.
48
48
  # You may override the method to customize.
49
49
  def show_authorized?(record = nil)
50
- authorized_for?(:crud_type => :read)
50
+ (record || self).send(:authorized_for?, :crud_type => :read)
51
51
  end
52
52
  private
53
53
  def show_authorized_filter
@@ -139,7 +139,7 @@ module ActiveScaffold::Actions
139
139
  # The default security delegates to ActiveRecordPermissions.
140
140
  # You may override the method to customize.
141
141
  def update_authorized?(record = nil)
142
- (!nested? || !nested.readonly?) && authorized_for?(:crud_type => :update)
142
+ (!nested? || !nested.readonly?) && (record || self).send(:authorized_for?, :crud_type => :update)
143
143
  end
144
144
  private
145
145
  def update_authorized_filter
@@ -49,13 +49,15 @@ ActionView::Base.class_eval do
49
49
  end
50
50
  ActiveScaffold::Finder::ClassMethods.module_eval do
51
51
  include ActiveScaffold::Bridges::Shared::DateBridge::Finder::ClassMethods
52
- def datetime_conversion_for_condition(column)
52
+ def datetime_conversion_for_condition_with_datepicker(column)
53
53
  if column.search_ui == :date_picker
54
54
  :to_date
55
55
  else
56
- super
56
+ datetime_conversion_for_condition_without_datepicker
57
57
  end
58
58
  end
59
+ alias_method_chain :datetime_conversion_for_condition, :datepicker
60
+
59
61
  alias_method :condition_for_date_picker_type, :condition_for_date_bridge_type
60
62
  alias_method :condition_for_datetime_picker_type, :condition_for_date_picker_type
61
63
  end
@@ -123,7 +123,7 @@ module ActiveScaffold::DataStructures
123
123
  elsif controller.nil? || !skip_action_link(controller, link, *(Array(options[:for])))
124
124
  security_method = link.security_method_set? || controller.respond_to?(link.security_method)
125
125
  authorized = if security_method
126
- controller.send(link.security_method, *args)
126
+ controller.send(link.security_method, *(Array(options[:for])))
127
127
  else
128
128
  options[:for].nil? ? true : options[:for].authorized_for?(:crud_type => link.crud_type, :action => link.action)
129
129
  end
@@ -59,8 +59,8 @@ module ActiveScaffold
59
59
  condition_for_range(column, value, like_pattern)
60
60
  when :date, :time, :datetime, :timestamp
61
61
  condition_for_datetime(column, value)
62
- when :select, :multi_select, :country, :usa_state
63
- ["%{search_sql} in (?)", [Array(value)]]
62
+ when :select, :multi_select, :country, :usa_state, :chosen, :multi_chosen
63
+ ["%{search_sql} in (?)", Array(value)]
64
64
  else
65
65
  if column.column.nil? || column.column.text?
66
66
  ["%{search_sql} #{ActiveScaffold::Finder.like_operator} ?", like_pattern.sub('?', value)]
@@ -10,7 +10,12 @@ module ActiveScaffold
10
10
  # we only pass the record as the argument. we previously also passed the formatted_value,
11
11
  # but mike perham pointed out that prohibited the usage of overrides to improve on the
12
12
  # performance of our default formatting. see issue #138.
13
- send(method, record)
13
+ if method(method).arity == 1
14
+ ActiveSupport::Deprecation.warn("Add column argument to field override, signature is unified with list_ui")
15
+ send(method, record)
16
+ else
17
+ send(method, record, column)
18
+ end
14
19
  # second, check if the dev has specified a valid list_ui for this column
15
20
  elsif column.list_ui and (method = override_column_ui(column.list_ui))
16
21
  send(method, column, record)
@@ -236,7 +241,7 @@ module ActiveScaffold
236
241
  Rails.logger.warn "ActiveScaffold: Enable eager loading for #{column.name} association to reduce SQL queries"
237
242
  elsif column.associated_limit > 0
238
243
  value.target = value.find(:all, :limit => column.associated_limit + 1, :select => column.select_columns)
239
- else
244
+ elsif @cache_associations
240
245
  value.target = size.to_i.zero? ? [] : [nil]
241
246
  end
242
247
  end
@@ -8,7 +8,12 @@ module ActiveScaffold
8
8
  # we only pass the record as the argument. we previously also passed the formatted_value,
9
9
  # but mike perham pointed out that prohibited the usage of overrides to improve on the
10
10
  # performance of our default formatting. see issue #138.
11
- send(method, record)
11
+ if method(method).arity == 1
12
+ ActiveSupport::Deprecation.warn("Add column argument to field override, signature is unified with list_ui")
13
+ send(method, record)
14
+ else
15
+ send(method, record, column)
16
+ end
12
17
  # second, check if the dev has specified a valid list_ui for this column
13
18
  elsif column.list_ui and (method = override_show_column_ui(column.list_ui))
14
19
  send(method, column, record)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- PATCH = 14
5
+ PATCH = 15
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
  - 2
9
- - 14
10
- version: 3.2.14
9
+ - 15
10
+ version: 3.2.15
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: 2012-07-03 00:00:00 Z
18
+ date: 2012-08-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :development
@@ -29,8 +29,8 @@ dependencies:
29
29
  - 0
30
30
  version: "0"
31
31
  version_requirements: *id001
32
- name: shoulda
33
32
  prerelease: false
33
+ name: shoulda
34
34
  - !ruby/object:Gem::Dependency
35
35
  type: :development
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
@@ -45,8 +45,8 @@ dependencies:
45
45
  - 0
46
46
  version: 1.0.0
47
47
  version_requirements: *id002
48
- name: bundler
49
48
  prerelease: false
49
+ name: bundler
50
50
  - !ruby/object:Gem::Dependency
51
51
  type: :development
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
@@ -59,8 +59,8 @@ dependencies:
59
59
  - 0
60
60
  version: "0"
61
61
  version_requirements: *id003
62
- name: rcov
63
62
  prerelease: false
63
+ name: rcov
64
64
  - !ruby/object:Gem::Dependency
65
65
  type: :runtime
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
@@ -75,8 +75,8 @@ dependencies:
75
75
  - 3
76
76
  version: 3.1.3
77
77
  version_requirements: *id004
78
- name: rails
79
78
  prerelease: false
79
+ name: rails
80
80
  description: Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.
81
81
  email: activescaffold@googlegroups.com
82
82
  executables: []
@@ -443,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
443
443
  requirements: []
444
444
 
445
445
  rubyforge_project:
446
- rubygems_version: 1.8.10
446
+ rubygems_version: 1.8.23
447
447
  signing_key:
448
448
  specification_version: 3
449
449
  summary: Rails 3.1 Version of activescaffold supporting prototype and jquery