active_scaffold 3.4.3 → 3.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a8ff5ba84f3dc705d9828e90c74107b5d7956c0
4
- data.tar.gz: 83d93e5cfce76fc8b5ffa04a72114e88a39ee6b3
3
+ metadata.gz: e2ef74ce45fee06f01b9150802312b245e2eb226
4
+ data.tar.gz: 7be6ae4331a71c54488362305825ca222dc39d05
5
5
  SHA512:
6
- metadata.gz: 0a1018479c9bab0ef13fbfe281c20a1fec953bb91403c06c69b38a9220b78b7e7d55d39cd28f9fb5bf36ae742e5947034415478ff0fd9157c560fe73cbb2a23e
7
- data.tar.gz: d1b55a0ca9c756fd581aaaec5bdff972ad55942f8ea5d326e4e166dff35ea4c0ad4bebed3ff6df85275a7fb4872b1ebc4d7a2c8868b7bfb1954aa42ef7756dfb
6
+ metadata.gz: 7f30bfe3a5091311f0f03a0a9b74b2fdf92f0237bedd728020c32a818d6eb6fd5acb08c77ecbb948487bab097b79d5c17e7b8928021a72125531f086fd6f7041
7
+ data.tar.gz: a99a94a0321aaabda253e299d9eec2acc37ea7519db77ce8b1f3e843949b62316983d5523093b636b1dbd490e5b2ec970ba79c5cc6ce773472b3510657da596a
data/CHANGELOG CHANGED
@@ -1,6 +1,13 @@
1
+ = 3.4.4 (not released yet)
2
+ - Fix set_parent for render field on blank records added by default on subforms
3
+ - Enable sorting on selected draggable list, so it can be used on config_list
4
+ - Remove unfinished nested_auto_open feature, it was working only if render_component is used, which is not recommended way
5
+ - Allow to set sorting on multiple columns with a hash, ruby 1.9 hashes keep order so an array of hashes is not needed anymore, although it still works.
6
+ - Fix overriding default sorting (with config.list.user.sorting.set) without changing config.list.sorting
7
+
1
8
  = 3.4.3
2
9
  - default search columns doesn't include association columns (broken on 3.4.2), it slowing down search with no point (searching by association's primary key)
3
- - More unobtrusive html views
10
+ - More unobtrusive html views, activescaffold html views doesn't use javascript anymore so JS files can be loaded at page bottom
4
11
 
5
12
  = 3.4.2
6
13
  - fix tableless on latest rails4 versions
@@ -582,8 +582,7 @@ var ActiveScaffold = {
582
582
  if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','visible');
583
583
  jQuery('input[type=submit]', as_form).attr('disabled', 'disabled');
584
584
  jQuery('.sub-form a.destroy', as_form).addClass('disabled');
585
- if (jQuery.fn.draggable) jQuery('.draggable-item', as_form).draggable('disable');
586
- if (jQuery.fn.droppable) jQuery('.draggable-list', as_form).droppable('disable');
585
+ if (jQuery.fn.droppable) jQuery('.draggable-list', as_form).sortable('disable');
587
586
  // data-remote-disabled attr instead of set data because is used to in selector later
588
587
  jQuery("input:enabled,select:enabled,textarea:enabled", as_form).attr('disabled', 'disabled').attr('data-remove-disabled', true);
589
588
  },
@@ -595,8 +594,7 @@ var ActiveScaffold = {
595
594
  if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','hidden');
596
595
  jQuery('input[type=submit]', as_form).removeAttr('disabled');
597
596
  jQuery('.sub-form a.destroy.disabled', as_form).removeClass('disabled');
598
- if (jQuery.fn.draggable) jQuery('.draggable-item', as_form).draggable('enable');
599
- if (jQuery.fn.droppable) jQuery('.draggable-list', as_form).droppable('enable');
597
+ if (jQuery.fn.droppable) jQuery('.draggable-list', as_form).sortable('enable');
600
598
  jQuery("input[data-remove-disabled],select[data-remove-disabled],textarea[data-remove-disabled]", as_form).removeAttr('disabled data-remove-disabled');
601
599
  },
602
600
 
@@ -967,7 +965,7 @@ var ActiveScaffold = {
967
965
  draggable_lists: function(selector_or_elements, parent) {
968
966
  var elements;
969
967
  if (!jQuery.fn.draggableLists) return;
970
- if (typeof(selector_or_elements) == 'string') elements = jQuery('ul' + selector_or_elements, parent);
968
+ if (typeof(selector_or_elements) == 'string') elements = jQuery(selector_or_elements, parent);
971
969
  else elements = jQuery(selector_or_elements);
972
970
  elements.draggableLists();
973
971
  }
@@ -8,23 +8,18 @@
8
8
  var li = jQuery(item).closest('li').addClass('draggable-item');
9
9
  li.children('label').removeAttr('for');
10
10
  if (jQuery(item).is(':checked')) li.appendTo(list_selected);
11
- li.draggable({appendTo: 'body', helper: 'clone'});
12
11
  });
13
- jQuery([element, list_selected]).droppable({
12
+ var options = {
14
13
  hoverClass: 'hover',
15
- accept: function(draggable) {
16
- var parent_id = draggable.parent().attr('id'), id = jQuery(this).attr('id'),
17
- requested_id = jQuery(this).hasClass('selected') ? id.replace('_selected', '') : id + '_selected';
18
- return parent_id == requested_id;
19
- },
20
- drop: function(event, ui) {
21
- jQuery(this).append(ui.draggable);
22
- var input = jQuery('input:checkbox', ui.draggable);
14
+ containment: '',
15
+ receive: function(event, ui) {
16
+ var input = jQuery('input:checkbox', ui.item), selected = input.prop('checked');
23
17
  input.prop('checked', jQuery(this).hasClass('selected'));
24
- input.trigger('change');
25
- ui.draggable.css({left: '0px', top: '0px'});
18
+ if (selected != input.prop('checked')) input.trigger('change');
26
19
  }
27
- });
20
+ };
21
+ jQuery(element).sortable(jQuery.extend(options, {connectWith: '#'+list_selected.attr('id')}));
22
+ jQuery(list_selected).sortable(jQuery.extend(options, {connectWith: '#'+element.attr('id')}));
28
23
  return element;
29
24
  };
30
25
  jQuery.fn.draggableLists = function() {
@@ -803,7 +803,7 @@ var ActiveScaffold = {
803
803
 
804
804
  draggable_lists: function(selector_or_elements, parent) {
805
805
  var elements;
806
- if (typeof(selector_or_elements) == 'string') elements = $(parent).select('ul' + selector_or_elements);
806
+ if (typeof(selector_or_elements) == 'string') elements = $(parent).select(selector_or_elements);
807
807
  else elements = $A($(selector_or_elements));
808
808
  elements.each(function(item) {
809
809
  new DraggableLists(item);
@@ -23,7 +23,4 @@ data_refresh ||= record.to_param
23
23
  <%= display_action_links(action_links, record, :level_0_tag => :td, :for => record.persisted? ? record : record.class) %>
24
24
  </tr>
25
25
  </table></td>
26
-
27
-
28
- <%= render_nested_view(action_links, record) unless @nested_auto_open.nil? %>
29
26
  </tr>
@@ -83,7 +83,7 @@ module ActiveScaffold::Actions
83
83
  @record.send "#{@column.name}=", value
84
84
  @record.id = params[:id]
85
85
  end
86
- set_parent(@record) if @record.id.nil? && params[:parent_controller] && params[:child_association]
86
+ set_parent(@record) if @record.id.nil? && params[:parent_controller]
87
87
 
88
88
  after_render_field(@record, @column)
89
89
  end
@@ -91,7 +91,8 @@ module ActiveScaffold::Actions
91
91
 
92
92
  def set_parent(record)
93
93
  parent_model = params[:parent_controller].singularize.camelize.constantize
94
- association = parent_model.reflect_on_association(params[:child_association].to_sym).try(:reverse)
94
+ child_association = params[:child_association].presence || @scope.split(']').first.sub(/^\[/, '')
95
+ association = parent_model.reflect_on_association(child_association.to_sym).try(:reverse)
95
96
  if association
96
97
  parent = parent_model.new
97
98
  copy_attributes(parent_model.find(params[:parent_id]), parent) if params[:parent_id]
@@ -26,7 +26,6 @@ module ActiveScaffold::Actions
26
26
  else
27
27
  do_refresh_list
28
28
  end
29
- @nested_auto_open = active_scaffold_config.list.nested_auto_open
30
29
  respond_to_action(:list)
31
30
  end
32
31
 
@@ -152,11 +152,13 @@ module ActiveScaffold::Config
152
152
  # the ActionLink to reset search
153
153
  attr_reader :reset_link
154
154
 
155
- # the default sorting. should be an array of hashes of {column_name => direction}, e.g. [{:a => 'desc'}, {:b => 'asc'}]. to just sort on one column, you can simply provide a hash, though, e.g. {:a => 'desc'}.
155
+ # the default sorting.
156
+ # should be a hash of {column_name => direction}, e.g. {:a => 'desc', :b => 'asc'}.
157
+ # for backwards compatibility, it may be an array of hashes of {column_name => direction}, e.g. [{:a => 'desc'}, {:b => 'asc'}].
158
+ # to just sort on one column, you can simply provide a hash, e.g. {:a => 'desc'}.
156
159
  def sorting=(val)
157
160
  val = [val] if val.is_a? Hash
158
- sorting.clear
159
- val.each { |clause| sorting.add *Array(clause).first }
161
+ sorting.set *val
160
162
  end
161
163
  def sorting
162
164
  @sorting ||= ActiveScaffold::DataStructures::Sorting.new(@core.columns)
@@ -211,12 +213,6 @@ module ActiveScaffold::Config
211
213
  @hide_nested_column.nil? ? true : @hide_nested_column
212
214
  end
213
215
 
214
- # might be set to open nested_link automatically in view
215
- # conf.nested.add_link(:players)
216
- # conf.list.nested_auto_open = {:players => 2}
217
- # will open nested players view if there are 2 or less records in parent
218
- attr_accessor :nested_auto_open
219
-
220
216
  # wrap normal cells (not inplace editable columns or with link) with a tag
221
217
  # it allows for more css styling
222
218
  attr_accessor :wrap_tag
@@ -235,7 +231,7 @@ module ActiveScaffold::Config
235
231
  end
236
232
 
237
233
  attr_writer :label
238
- # This label has alread been localized.
234
+ # This label has already been localized.
239
235
  def label
240
236
  self['label'] || @label || @conf.label
241
237
  end
@@ -262,7 +258,7 @@ module ActiveScaffold::Config
262
258
  end
263
259
 
264
260
  def default_sorting
265
- nested_default_sorting.nil? ? @conf.sorting : nested_default_sorting
261
+ nested_default_sorting.nil? ? @conf.sorting.clone : nested_default_sorting
266
262
  end
267
263
 
268
264
  def user_sorting?
@@ -282,7 +278,6 @@ module ActiveScaffold::Config
282
278
  else
283
279
  @sorting = default_sorting
284
280
  if @conf.columns.constraint_columns.present?
285
- @sorting = @sorting.clone
286
281
  @sorting.constraint_columns = @conf.columns.constraint_columns
287
282
  end
288
283
  end
@@ -40,10 +40,10 @@ module ActiveScaffold
40
40
  # at some point we need to pass the session and params into config. we'll just take care of that before any particular action occurs by passing those hashes off to the UserSettings class of each action.
41
41
  def handle_user_settings
42
42
  if self.class.uses_active_scaffold?
43
+ storage = active_scaffold_config.store_user_settings ? active_scaffold_session_storage : {}
43
44
  active_scaffold_config.actions.each do |action_name|
44
45
  conf_instance = active_scaffold_config.send(action_name) rescue next
45
46
  next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it
46
- storage = active_scaffold_config.store_user_settings ? active_scaffold_session_storage : {}
47
47
  conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, storage, params)
48
48
  end
49
49
  end
@@ -49,9 +49,19 @@ module ActiveScaffold::DataStructures
49
49
  end
50
50
 
51
51
  # clears the sorting before setting to the given column/direction
52
+ # set(column, direction)
53
+ # set({column => direction, column => direction})
54
+ # set({column => direction}, {column => direction})
55
+ # set([column, direction], [column, direction])
52
56
  def set(*args)
53
57
  clear
54
- add(*args)
58
+ if args.first.is_a?(Enumerable)
59
+ args.each do |h|
60
+ h.is_a?(Hash) ? h.each { |c,d| add(c,d) } : add(*h)
61
+ end
62
+ else
63
+ add(*args)
64
+ end
55
65
  end
56
66
 
57
67
  # clears the sorting
@@ -329,18 +329,6 @@ module ActiveScaffold
329
329
  column.label
330
330
  end
331
331
 
332
- def render_nested_view(action_links, record)
333
- rendered = []
334
- action_links.member.each do |link|
335
- if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && controller.respond_to?(:render_component_into_view, true)
336
- link_url_options = {:adapter => '_list_inline_adapter', :format => :js}.merge(action_link_url_options(link, record))
337
- link_id = get_action_link_id(link, record)
338
- rendered << (controller.send(:render_component_into_view, link_url_options) + javascript_tag("ActiveScaffold.ActionLink.get('#{link_id}').set_opened();"))
339
- end
340
- end
341
- rendered.join(' ').html_safe
342
- end
343
-
344
332
  end
345
333
  end
346
334
  end
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 3
5
+ PATCH = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -65,11 +65,20 @@ module Config
65
65
  assert_equal 'DESC', @config.list.sorting.direction_of(:a)
66
66
  refute @config.list.sorting.sorts_on?(:id)
67
67
 
68
+ @config.list.sorting = {:c => :asc, :d => :desc}
69
+ assert @config.list.sorting.sorts_on?(:c)
70
+ assert_equal 'ASC', @config.list.sorting.direction_of(:c)
71
+ assert @config.list.sorting.sorts_on?(:d)
72
+ assert_equal 'DESC', @config.list.sorting.direction_of(:d)
73
+ refute @config.list.sorting.sorts_on?(:a)
74
+ refute @config.list.sorting.sorts_on?(:id)
75
+
68
76
  @config.list.sorting = [{:a => :asc}, {:b => :desc}]
69
77
  assert @config.list.sorting.sorts_on?(:a)
70
78
  assert_equal 'ASC', @config.list.sorting.direction_of(:a)
71
79
  assert @config.list.sorting.sorts_on?(:b)
72
80
  assert_equal 'DESC', @config.list.sorting.direction_of(:b)
81
+ refute @config.list.sorting.sorts_on?(:c)
73
82
  refute @config.list.sorting.sorts_on?(:id)
74
83
  end
75
84
 
@@ -56,6 +56,20 @@ class SortingTest < MiniTest::Test
56
56
  refute @sorting.sorts_on?(:a)
57
57
  assert @sorting.sorts_on?(:b)
58
58
  assert_equal 'DESC', @sorting.direction_of(:b)
59
+
60
+ @sorting.set :a => 'DESC', :b => 'ASC'
61
+ assert @sorting.instance_variable_get('@clauses').size == 2
62
+ assert @sorting.sorts_on?(:a)
63
+ assert_equal 'DESC', @sorting.direction_of(:a)
64
+ assert @sorting.sorts_on?(:b)
65
+ assert_equal 'ASC', @sorting.direction_of(:b)
66
+
67
+ @sorting.set [:a, 'DESC'], [:b, 'ASC']
68
+ assert @sorting.instance_variable_get('@clauses').size == 2
69
+ assert @sorting.sorts_on?(:a)
70
+ assert_equal 'DESC', @sorting.direction_of(:a)
71
+ assert @sorting.sorts_on?(:b)
72
+ assert_equal 'ASC', @sorting.direction_of(:b)
59
73
  end
60
74
 
61
75
  def test_sorts_on
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.3
4
+ version: 3.4.4
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-08-29 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda