active_scaffold 3.2.4 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ = 3.2.5
2
+ - add outer window for pagination links
3
+ - workaround rails 3.2.3 bug in TimeWithZone#to_time
4
+ - fix date picker format for datetime fields
5
+ - fix bitfields bridge when some actions are not used
6
+ - use core config label when is set and STI is not used
7
+
1
8
  = 3.2.4
2
9
  - don't break on custom SQL sorting (e.g. sorting with functions)
3
10
  - fix cancel inplace edit with jquery
@@ -4,5 +4,5 @@
4
4
  :form_action => form_action,
5
5
  :method => method ||= :post,
6
6
  :cancel_link => cancel_link,
7
- :headline => headline ||= active_scaffold_config.send(form_action).label(active_scaffold_config.sti_create_links ? @record.class.model_name.human(:count => 1) : nil)} %>
7
+ :headline => headline ||= active_scaffold_config.send(form_action).label(active_scaffold_config.add_sti_create_links? ? @record.class.model_name.human(:count => 1) : nil)} %>
8
8
 
@@ -3,4 +3,4 @@
3
3
  :form_action => form_action ||= :create,
4
4
  :method => method ||= :post,
5
5
  :cancel_link => cancel_link,
6
- :headline => headline ||= active_scaffold_config.create.label(active_scaffold_config.sti_create_links ? @record.class.model_name.human(:count => 1) : nil)} %>
6
+ :headline => headline ||= active_scaffold_config.create.label(active_scaffold_config.add_sti_create_links? ? @record.class.model_name.human(:count => 1) : nil)} %>
@@ -4,6 +4,6 @@
4
4
 
5
5
  <%= loading_indicator_tag :action => :pagination %>
6
6
  <%= link_to as_(:previous), url_options.merge(:page => current_page.number - 1), options.merge(:class => "as_paginate previous") if current_page.prev? %>
7
- <%= pagination_ajax_links current_page, url_options, options, active_scaffold_config.list.page_links_window %>
7
+ <%= pagination_ajax_links current_page, url_options, options, active_scaffold_config.list.page_links_inner_window, active_scaffold_config.list.page_links_outer_window %>
8
8
  <%= link_to as_(:next), url_options.merge(:page => current_page.number + 1), options.merge(:class => "as_paginate next") if current_page.next? %>
9
9
  <% end -%>
@@ -19,7 +19,7 @@ module ActiveScaffold
19
19
  self.model.bitfields.each do |column_name, options|
20
20
  columns = options.keys.sort_by { |column| self.columns[column].weight }
21
21
  [:create, :update, :show, :subform].each do |action|
22
- self.send(action).columns.add_subgroup(column_name) { |group| group.add *columns }
22
+ self.send(action).columns.add_subgroup(column_name) { |group| group.add *columns } if self.actions.included? action
23
23
  end
24
24
  end if self.model.respond_to?(:bitfields) and self.model.bitfields.present?
25
25
 
@@ -16,7 +16,7 @@ ActiveScaffold::Config::Core.class_eval do
16
16
  # check to see if file column was used on the model
17
17
  return if date_picker_fields.empty?
18
18
 
19
- # automatically set the forum_ui to a file column
19
+ # automatically set the forum_ui to a date_picker or datetime_picker
20
20
  date_picker_fields.each{|field|
21
21
  col_config = self.columns[field[:name]]
22
22
  col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
@@ -158,7 +158,7 @@ module ActiveScaffold::Bridges
158
158
  options = active_scaffold_input_text_options(options.merge(column.options))
159
159
  options[:class] << " #{column.search_ui.to_s}"
160
160
  options[:style] = (options[:show].nil? || options[:show]) ? nil : "display: none"
161
- format = options.delete(:format) || :default
161
+ format = options.delete(:format) || column.form_ui == :date_picker ? :default : :picker
162
162
  datepicker_format_options(column, format, options)
163
163
  text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]"))
164
164
  end
@@ -169,7 +169,7 @@ module ActiveScaffold::Bridges
169
169
  options = active_scaffold_input_text_options(options.merge(column.options))
170
170
  options[:class] << " #{column.form_ui.to_s}"
171
171
  value = controller.class.condition_value_for_datetime(@record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
172
- format = options.delete(:format) || :default
172
+ format = options.delete(:format) || column.form_ui == :date_picker ? :default : :picker
173
173
  datepicker_format_options(column, format, options)
174
174
  options[:value] = (value ? l(value, :format => format) : nil)
175
175
  text_field(:record, column.name, options)
@@ -7,7 +7,8 @@ module ActiveScaffold::Config
7
7
  # inherit from global scope
8
8
  # full configuration path is: defaults => global table => local table
9
9
  @per_page = self.class.per_page
10
- @page_links_window = self.class.page_links_window
10
+ @page_links_inner_window = self.class.page_links_inner_window
11
+ @page_links_outer_window = self.class.page_links_outer_window
11
12
 
12
13
  # originates here
13
14
  @sorting = ActiveScaffold::DataStructures::Sorting.new(@core.columns)
@@ -28,8 +29,19 @@ module ActiveScaffold::Config
28
29
  @@per_page = 15
29
30
 
30
31
  # how many page links around current page to show
31
- cattr_accessor :page_links_window
32
- @@page_links_window = 2
32
+ cattr_accessor :page_links_inner_window
33
+ @@page_links_inner_window = 2
34
+
35
+ # how many page links around first and last page to show
36
+ cattr_accessor :page_links_outer_window
37
+ @@page_links_outer_window = 0
38
+
39
+ class << self
40
+ def page_links_window=(value)
41
+ ActiveSupport::Deprecation.warn("Use page_links_inner_window", caller(1))
42
+ self.page_links_inner_window = value
43
+ end
44
+ end
33
45
 
34
46
  # what string to use when a field is empty
35
47
  cattr_accessor :empty_field_text
@@ -64,7 +76,15 @@ module ActiveScaffold::Config
64
76
  attr_accessor :per_page
65
77
 
66
78
  # how many page links around current page to show
67
- attr_accessor :page_links_window
79
+ attr_accessor :page_links_inner_window
80
+
81
+ # how many page links around current page to show
82
+ attr_accessor :page_links_outer_window
83
+
84
+ def page_links_window=(value)
85
+ ActiveSupport::Deprecation.warn("Use page_links_inner_window", caller(1))
86
+ self.page_links_inner_window = value
87
+ end
68
88
 
69
89
  # What kind of pagination to use:
70
90
  # * true: The usual pagination
@@ -110,7 +110,13 @@ module ActiveScaffold
110
110
  if value.is_a? Hash
111
111
  Time.zone.local(*[:year, :month, :day, :hour, :minute, :second].collect {|part| value[part].to_i}) rescue nil
112
112
  elsif value.respond_to?(:strftime)
113
- value.send(conversion)
113
+ if conversion == :to_time
114
+ # Explicitly get the current zone, because TimeWithZone#to_time in rails 3.2.3 returns UTC.
115
+ # https://github.com/rails/rails/pull/2453
116
+ value.to_time.in_time_zone
117
+ else
118
+ value.send(conversion)
119
+ end
114
120
  elsif conversion == :to_date
115
121
  Date.strptime(value, I18n.t('date.formats.default')) rescue nil
116
122
  else
@@ -5,9 +5,9 @@ module ActiveScaffold
5
5
  link_to page_number, url_options.merge(:page => page_number), options.merge(:class => "as_paginate")
6
6
  end
7
7
 
8
- def pagination_ajax_links(current_page, url_options, options, window_size)
9
- start_number = current_page.number - window_size
10
- end_number = current_page.number + window_size
8
+ def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
9
+ start_number = current_page.number - inner_window
10
+ end_number = current_page.number + inner_window
11
11
  start_number = 1 if start_number <= 0
12
12
  if current_page.pager.infinite?
13
13
  offsets = [20, 100]
@@ -16,23 +16,24 @@ module ActiveScaffold
16
16
  end
17
17
 
18
18
  html = []
19
- unless start_number == 1
20
- last_page = 1
21
- html << pagination_ajax_link(last_page, url_options, options)
22
- if current_page.pager.infinite?
23
- offsets.reverse.each do |offset|
24
- page = current_page.number - offset
25
- if page < start_number && page > 1
26
- html << '..' if page > last_page + 1
27
- html << pagination_ajax_link(page, params)
28
- last_page = page
29
- end
19
+ last_page = 1
20
+ last_page.upto(last_page + outer_window) do |num|
21
+ html << pagination_ajax_link(num, url_options, options)
22
+ last_page = num
23
+ end
24
+ if current_page.pager.infinite?
25
+ offsets.reverse.each do |offset|
26
+ page = current_page.number - offset
27
+ if page < start_number && page > last_page
28
+ html << '..' if page > last_page + 1
29
+ html << pagination_ajax_link(page, params)
30
+ last_page = page
30
31
  end
31
32
  end
32
- html << ".." if start_number > last_page + 1
33
33
  end
34
+ html << ".." if start_number > last_page + 1
34
35
 
35
- start_number.upto(end_number) do |num|
36
+ [start_number, last_page + 1].max.upto(end_number) do |num|
36
37
  if current_page.number == num
37
38
  html << content_tag(:span, num.to_s, {:class => "as_paginate current"})
38
39
  else
@@ -45,8 +46,10 @@ module ActiveScaffold
45
46
  html << '..' << pagination_ajax_link(current_page.number + offset, url_options, options)
46
47
  end
47
48
  else
48
- html << ".." unless end_number >= current_page.pager.last.number - 1
49
- html << pagination_ajax_link(current_page.pager.last.number, url_options, options) unless end_number == current_page.pager.last.number
49
+ html << ".." unless end_number >= current_page.pager.last.number - outer_window - 1
50
+ [end_number + 1, current_page.pager.last.number - outer_window].max.upto(current_page.pager.last.number) do |num|
51
+ html << pagination_ajax_link(num, url_options, options)
52
+ end
50
53
  end
51
54
  html.join(' ').html_safe
52
55
  end
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- PATCH = 4
5
+ PATCH = 5
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
- - 4
10
- version: 3.2.4
9
+ - 5
10
+ version: 3.2.5
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-04-16 00:00:00 Z
18
+ date: 2012-05-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  version: "0"
30
- type: :development
31
30
  prerelease: false
31
+ type: :development
32
32
  requirement: *id001
33
33
  name: shoulda
34
34
  - !ruby/object:Gem::Dependency
@@ -43,8 +43,8 @@ dependencies:
43
43
  - 0
44
44
  - 0
45
45
  version: 1.0.0
46
- type: :development
47
46
  prerelease: false
47
+ type: :development
48
48
  requirement: *id002
49
49
  name: bundler
50
50
  - !ruby/object:Gem::Dependency
@@ -57,8 +57,8 @@ dependencies:
57
57
  segments:
58
58
  - 0
59
59
  version: "0"
60
- type: :development
61
60
  prerelease: false
61
+ type: :development
62
62
  requirement: *id003
63
63
  name: rcov
64
64
  - !ruby/object:Gem::Dependency
@@ -73,8 +73,8 @@ dependencies:
73
73
  - 1
74
74
  - 3
75
75
  version: 3.1.3
76
- type: :runtime
77
76
  prerelease: false
77
+ type: :runtime
78
78
  requirement: *id004
79
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.
@@ -437,7 +437,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
437
437
  requirements: []
438
438
 
439
439
  rubyforge_project:
440
- rubygems_version: 1.8.21
440
+ rubygems_version: 1.8.23
441
441
  signing_key:
442
442
  specification_version: 3
443
443
  summary: Rails 3.1 Version of activescaffold supporting prototype and jquery