active_scaffold 3.1.20 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/app/assets/javascripts/jquery/active_scaffold.js +4 -1
  2. data/app/assets/javascripts/prototype/active_scaffold.js +4 -1
  3. data/app/assets/stylesheets/{active_scaffold.scss~ → active_scaffold.css.scss} +5 -2
  4. data/app/assets/stylesheets/{active_scaffold_colors.scss → active_scaffold_colors.css.scss} +4 -0
  5. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +2 -0
  6. data/app/assets/stylesheets/active_scaffold_images.css.scss +43 -0
  7. data/lib/active_scaffold/actions/core.rb +1 -0
  8. data/lib/active_scaffold/actions/nested.rb +0 -1
  9. data/lib/active_scaffold/extensions/action_view_rendering.rb +1 -1
  10. data/lib/active_scaffold/helpers/form_column_helpers.rb +1 -0
  11. data/lib/active_scaffold/version.rb +2 -2
  12. data/test/mock_app/.gitignore +2 -0
  13. metadata +86 -164
  14. data/app/assets/javascripts/active_scaffold.js.erb~ +0 -16
  15. data/app/assets/javascripts/jquery/active_scaffold.js~ +0 -1053
  16. data/app/assets/javascripts/jquery/draggable_lists.js~ +0 -27
  17. data/app/assets/javascripts/prototype/active_scaffold.js~ +0 -1037
  18. data/app/assets/stylesheets/active_scaffold.css.erb +0 -11
  19. data/app/assets/stylesheets/active_scaffold.css.erb~ +0 -11
  20. data/app/assets/stylesheets/active_scaffold.css.scss.erb~ +0 -1120
  21. data/app/assets/stylesheets/active_scaffold.css.scss~ +0 -11
  22. data/app/assets/stylesheets/active_scaffold.css~ +0 -11
  23. data/app/assets/stylesheets/active_scaffold_colors.css +0 -244
  24. data/app/assets/stylesheets/active_scaffold_colors.css.scss~ +0 -481
  25. data/app/assets/stylesheets/active_scaffold_default.css.erb +0 -47
  26. data/app/assets/stylesheets/active_scaffold_default.css.erb~ +0 -57
  27. data/app/assets/stylesheets/active_scaffold_default.css.scss~ +0 -1092
  28. data/app/assets/stylesheets/active_scaffold_default.css~ +0 -923
  29. data/app/assets/stylesheets/active_scaffold_layout.css~ +0 -922
  30. data/app/assets/stylesheets/blue-theme.css~ +0 -1150
  31. data/config/locales/es.yml~ +0 -120
  32. data/frontends/default/views/_action_group.html.erb~ +0 -24
  33. data/frontends/default/views/_base_form.html.erb~ +0 -42
  34. data/frontends/default/views/_form.html.erb~ +0 -26
  35. data/frontends/default/views/_form_association.html.erb~ +0 -19
  36. data/frontends/default/views/_form_association_footer.html.erb~ +0 -48
  37. data/frontends/default/views/_horizontal_subform.html.erb~ +0 -32
  38. data/frontends/default/views/_horizontal_subform_header.html.erb~ +0 -11
  39. data/frontends/default/views/_horizontal_subform_record.html.erb~ +0 -38
  40. data/frontends/default/views/_list_actions.html.erb~ +0 -15
  41. data/frontends/default/views/_list_inline_adapter.html.erb~ +0 -10
  42. data/frontends/default/views/_list_messages.html.erb~ +0 -30
  43. data/frontends/default/views/_list_pagination.html.erb~ +0 -11
  44. data/frontends/default/views/_list_pagination_links.html.erb~ +0 -0
  45. data/frontends/default/views/_list_with_header.html.erb~ +0 -36
  46. data/frontends/default/views/_render_field.js.erb~ +0 -23
  47. data/frontends/default/views/_row.html.erb~ +0 -6
  48. data/frontends/default/views/_show.html.erb~ +0 -8
  49. data/frontends/default/views/_update_form.html.erb~ +0 -6
  50. data/frontends/default/views/_vertical_subform.html.erb~ +0 -12
  51. data/frontends/default/views/add_existing.js.erb~ +0 -18
  52. data/frontends/default/views/add_existing_form.html.erb~ +0 -5
  53. data/frontends/default/views/create.html.erb~ +0 -5
  54. data/frontends/default/views/edit_associated.js.erb~ +0 -13
  55. data/frontends/default/views/on_create.js.erb~ +0 -45
  56. data/frontends/default/views/on_update.js.erb~ +0 -31
  57. data/frontends/default/views/render_field.js.erb~ +0 -1
  58. data/frontends/default/views/search.html.erb~ +0 -5
  59. data/frontends/default/views/show.html.erb~ +0 -5
  60. data/frontends/default/views/update.html.erb~ +0 -8
  61. data/frontends/default/views/update_column.js.erb~ +0 -16
  62. data/lib/active_scaffold.rb~ +0 -373
  63. data/lib/active_scaffold/actions/core.rb~ +0 -203
  64. data/lib/active_scaffold/actions/create.rb~ +0 -148
  65. data/lib/active_scaffold/actions/list.rb~ +0 -196
  66. data/lib/active_scaffold/actions/nested.rb~ +0 -247
  67. data/lib/active_scaffold/actions/search.rb~ +0 -49
  68. data/lib/active_scaffold/actions/subform.rb~ +0 -27
  69. data/lib/active_scaffold/actions/update.rb~ +0 -150
  70. data/lib/active_scaffold/attribute_params.rb~ +0 -203
  71. data/lib/active_scaffold/bridges/date_picker/helper.rb~ +0 -180
  72. data/lib/active_scaffold/bridges/record_select/helpers.rb~ +0 -86
  73. data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
  74. data/lib/active_scaffold/config/base.rb~ +0 -72
  75. data/lib/active_scaffold/config/list.rb~ +0 -195
  76. data/lib/active_scaffold/config/nested.rb~ +0 -41
  77. data/lib/active_scaffold/config/search.rb~ +0 -74
  78. data/lib/active_scaffold/constraints.rb~ +0 -186
  79. data/lib/active_scaffold/data_structures/action_columns.rb~ +0 -140
  80. data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
  81. data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -147
  82. data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +0 -22
  83. data/lib/active_scaffold/extensions/action_view_rendering.rb~ +0 -120
  84. data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
  85. data/lib/active_scaffold/extensions/cache_association.rb~ +0 -12
  86. data/lib/active_scaffold/extensions/reverse_associations.rb~ +0 -64
  87. data/lib/active_scaffold/extensions/routing_mapper.rb~ +0 -48
  88. data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
  89. data/lib/active_scaffold/finder.rb~ +0 -370
  90. data/lib/active_scaffold/helpers/controller_helpers.rb~ +0 -92
  91. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +0 -320
  92. data/lib/active_scaffold/helpers/id_helpers.rb~ +0 -123
  93. data/lib/active_scaffold/helpers/list_column_helpers.rb~ +0 -370
  94. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +0 -263
  95. data/lib/active_scaffold/helpers/view_helpers.rb~ +0 -350
@@ -1,209 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Shared
4
- module DateBridge
5
- module SearchColumnHelpers
6
- def active_scaffold_search_date_bridge(column, options)
7
- current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN',
8
- 'number' => 1, 'unit' => 'DAYS', 'range' => nil}
9
- current_search.merge!(options[:value]) unless options[:value].nil?
10
- tags = []
11
- tags << active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
12
- tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
13
- tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
14
- tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
15
- tags.join("&nbsp;").html_safe
16
- end
17
-
18
- def active_scaffold_search_date_bridge_comparator_options(column)
19
- select_options = ActiveScaffold::Finder::DateComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
20
- select_options + ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
21
- end
22
-
23
- def active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
24
- select_tag("#{options[:name]}[opt]", options_for_select(active_scaffold_search_date_bridge_comparator_options(column),current_search['opt']), :id => "#{options[:id]}_opt", :class => "as_search_range_option as_search_date_time_option")
25
- end
26
-
27
- def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
28
- numeric_controls = "" <<
29
- active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
30
- content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
31
- :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => "display:#{current_search['opt'] == 'BETWEEN' ? '' : 'none'}")
32
- content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => "display:#{ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? '' : 'none'}")
33
- end
34
-
35
- def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
36
- active_scaffold_date_bridge_trend_tag(column, options,
37
- {:name_prefix => 'search',
38
- :number_value => current_search['number'],
39
- :unit_value => current_search["unit"],
40
- :show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')})
41
- end
42
-
43
- def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
44
- trend_controls = text_field_tag("#{trend_options[:name_prefix]}[#{column.name}][number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " <<
45
- select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
46
- options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
47
- :class => 'text-input')
48
- content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => "display:#{trend_options[:show] ? '' : 'none'}")
49
- end
50
-
51
- def active_scaffold_search_date_bridge_trend_units(column)
52
- options = ActiveScaffold::Finder::DateUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]}
53
- options = ActiveScaffold::Finder::TimeUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} + options if column_datetime?(column)
54
- options
55
- end
56
-
57
- def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
58
- range_controls = select_tag("search[#{column.name}][range]",
59
- options_for_select( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]),
60
- :class => 'text-input')
61
- content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => "display:#{(current_search['opt'] == 'RANGE') ? '' : 'none'}")
62
- end
63
-
64
- def column_datetime?(column)
65
- (!column.column.nil? && [:datetime, :time].include?(column.column.type))
66
- end
67
- end
68
-
69
- module HumanConditionHelpers
70
- def active_scaffold_human_condition_date_bridge(column, value)
71
- case value[:opt]
72
- when 'RANGE'
73
- range_type, range = value[:range].downcase.split('_')
74
- format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
75
- from, to = controller.class.date_bridge_from_to(column, value)
76
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
77
- when 'PAST', 'FUTURE'
78
- from, to = controller.class.date_bridge_from_to(column, value)
79
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
80
- else
81
- from, to = controller.class.date_bridge_from_to(column, value)
82
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
83
- end
84
- end
85
-
86
- def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
87
- case range
88
- when 'week'
89
- first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
90
- if first_day_of_week == 1
91
- '%W %Y'
92
- else
93
- '%U %Y'
94
- end
95
- when 'month'
96
- '%b %Y'
97
- when 'year'
98
- '%Y'
99
- else
100
- I18n.translate 'date.formats.default'
101
- end
102
- end
103
- end
104
-
105
- module Finder
106
- module ClassMethods
107
- def condition_for_date_bridge_type(column, value, like_pattern)
108
- operator = ActiveScaffold::Finder::NumericComparators.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
109
- from_value, to_value = date_bridge_from_to(column, value)
110
-
111
- if column.search_sql.is_a? Proc
112
- column.search_sql.call(from_value, to_value, operator)
113
- else
114
- unless operator.nil?
115
- ["#{column.search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
116
- else
117
- ["#{column.search_sql} BETWEEN ? AND ?", from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? && to_value.nil?
118
- end
119
- end
120
- end
121
-
122
- def date_bridge_from_to(column, value)
123
- conversion = column.column.type == :date ? :to_date : :to_time
124
- case value[:opt]
125
- when 'RANGE'
126
- date_bridge_from_to_for_range(column, value).collect(&conversion)
127
- when 'PAST', 'FUTURE'
128
- date_bridge_from_to_for_trend(column, value).collect(&conversion)
129
- else
130
- ['from', 'to'].collect { |field| condition_value_for_datetime(value[field], conversion)}
131
- end
132
- end
133
-
134
- def date_bridge_now
135
- Time.zone.now
136
- end
137
-
138
- def date_bridge_from_to_for_trend(column, value)
139
- case value['opt']
140
- when "PAST"
141
- trend_number = [value['number'].to_i, 1].max
142
- now = date_bridge_now
143
- if date_bridge_column_date?(column)
144
- from = now.beginning_of_day.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
145
- to = now.end_of_day
146
- else
147
- from = now.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
148
- to = now
149
- end
150
- return from, to
151
- when "FUTURE"
152
- trend_number = [value['number'].to_i, 1].max
153
- now = date_bridge_now
154
- if date_bridge_column_date?(column)
155
- from = now.beginning_of_day
156
- to = now.end_of_day.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
157
- else
158
- from = now
159
- to = now.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
160
- end
161
- return from, to
162
- end
163
- end
164
-
165
- def date_bridge_from_to_for_range(column, value)
166
- case value[:range]
167
- when 'TODAY'
168
- return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
169
- when 'YESTERDAY'
170
- return date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day
171
- when 'TOMORROW'
172
- return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
173
- else
174
- range_type, range = value[:range].downcase.split('_')
175
- raise ArgumentError unless ['week', 'month', 'year'].include?(range)
176
- case range_type
177
- when 'this'
178
- return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
179
- when 'prev'
180
- return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
181
- when 'next'
182
- return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
183
- else
184
- return nil, nil
185
- end
186
- end
187
- end
188
-
189
- def date_bridge_column_date?(column)
190
- if [:date_picker, :datetime_picker].include? column.form_ui
191
- column.form_ui == :date_picker
192
- else
193
- (!column.column.nil? && [:date].include?(column.column.type))
194
- end
195
- end
196
- end
197
- end
198
- end
199
- end
200
- end
201
- end
202
-
203
- ActiveScaffold::Finder.const_set('DateComparators', ["PAST", "FUTURE", "RANGE"])
204
- ActiveScaffold::Finder.const_set('DateUnits', ["DAYS", "WEEKS", "MONTHS", "YEARS"])
205
- ActiveScaffold::Finder.const_set('TimeUnits', ["SECONDS", "MINUTES", "HOURS"])
206
- ActiveScaffold::Finder.const_set('DateRanges', ["TODAY", "YESTERDAY", "TOMORROW",
207
- "THIS_WEEK", "PREV_WEEK", "NEXT_WEEK",
208
- "THIS_MONTH", "PREV_MONTH", "NEXT_MONTH",
209
- "THIS_YEAR", "PREV_YEAR", "NEXT_YEAR"])
@@ -1,72 +0,0 @@
1
- module ActiveScaffold::Config
2
- class Base
3
- include ActiveScaffold::Configurable
4
- extend ActiveScaffold::Configurable
5
-
6
- def initialize(core_config)
7
- @core = core_config
8
- end
9
-
10
- def self.inherited(subclass)
11
- class << subclass
12
- # the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
13
- # this is not a setting for the developer. it's self-description for the actions.
14
- def crud_type; @crud_type; end
15
-
16
- protected
17
-
18
- def crud_type=(val)
19
- raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
20
- @crud_type = val.to_sym
21
- end
22
- end
23
- end
24
-
25
- # delegate
26
- def crud_type; self.class.crud_type end
27
-
28
- def label(model = nil)
29
- model ||= @core.label(:count => 1)
30
- @label.nil? ? model : as_(@label, :model => model)
31
- end
32
-
33
- # the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
34
- attr_accessor :user
35
-
36
- # define a default action_group for this action
37
- # e.g. 'members.crud'
38
- class_attribute :action_group
39
-
40
- # action_group this action should belong to
41
- attr_accessor :action_group
42
-
43
- class UserSettings
44
- def initialize(conf, storage, params)
45
- # the session hash relevant to this action
46
- @session = storage
47
- debugger
48
- # all the request params
49
- @params = params
50
- # the configuration object for this action
51
- @conf = conf
52
- end
53
- end
54
-
55
- def formats
56
- @formats ||= []
57
- end
58
-
59
- def formats=(val)
60
- @formats=val
61
- end
62
-
63
- private
64
-
65
- def columns=(val)
66
- @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
67
- @columns.action = self
68
- @columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
69
- @columns
70
- end
71
- end
72
- end
@@ -1,195 +0,0 @@
1
- module ActiveScaffold::Config
2
- class List < Base
3
- self.crud_type = :read
4
-
5
- def initialize(core_config)
6
- super
7
- # inherit from global scope
8
- # full configuration path is: defaults => global table => local table
9
- @per_page = self.class.per_page
10
- @page_links_window = self.class.page_links_window
11
-
12
- # originates here
13
- @sorting = ActiveScaffold::DataStructures::Sorting.new(@core.columns)
14
- @sorting.set_default_sorting(@core.model)
15
-
16
- # inherit from global scope
17
- @empty_field_text = self.class.empty_field_text
18
- @association_join_text = self.class.association_join_text
19
- @pagination = self.class.pagination
20
- @show_search_reset = true
21
- @mark_records = self.class.mark_records
22
- end
23
-
24
- # global level configuration
25
- # --------------------------
26
- # how many records to show per page
27
- cattr_accessor :per_page
28
- @@per_page = 15
29
-
30
- # how many page links around current page to show
31
- cattr_accessor :page_links_window
32
- @@page_links_window = 2
33
-
34
- # what string to use when a field is empty
35
- cattr_accessor :empty_field_text
36
- @@empty_field_text = '-'
37
-
38
- # what string to use to join records from plural associations
39
- cattr_accessor :association_join_text
40
- @@association_join_text = ', '
41
-
42
- # What kind of pagination to use:
43
- # * true: The usual pagination
44
- # * :infinite: Treat the source as having an infinite number of pages (i.e. don't count the records; useful for large tables where counting is slow and we don't really care anyway)
45
- # * false: Disable pagination
46
- cattr_accessor :pagination
47
- @@pagination = true
48
-
49
- # Add a checkbox in front of each record to mark them and use them with a batch action later
50
- cattr_accessor :mark_records
51
-
52
- # instance-level configuration
53
- # ----------------------------
54
-
55
- # provides access to the list of columns specifically meant for the Table to use
56
- def columns
57
- self.columns = @core.columns._inheritable unless @columns # lazy evaluation
58
- @columns
59
- end
60
-
61
- public :columns=
62
-
63
- # how many rows to show at once
64
- attr_accessor :per_page
65
-
66
- # how many page links around current page to show
67
- attr_accessor :page_links_window
68
-
69
- # What kind of pagination to use:
70
- # * true: The usual pagination
71
- # * :infinite: Treat the source as having an infinite number of pages (i.e. don't count the records; useful for large tables where counting is slow and we don't really care anyway)
72
- # * false: Disable pagination
73
- attr_accessor :pagination
74
-
75
- # what string to use when a field is empty
76
- attr_accessor :empty_field_text
77
-
78
- # what string to use to join records from plural associations
79
- attr_accessor :association_join_text
80
-
81
- # show a link to reset the search next to filtered message
82
- attr_accessor :show_search_reset
83
-
84
- # Add a checkbox in front of each record to mark them and use them with a batch action later
85
- attr_accessor :mark_records
86
-
87
- # 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'}.
88
- def sorting=(val)
89
- val = [val] if val.is_a? Hash
90
- sorting.clear
91
- val.each { |clause| sorting.add *Array(clause).first }
92
- end
93
- def sorting
94
- @sorting ||= ActiveScaffold::DataStructures::Sorting.new(@core.columns)
95
- end
96
-
97
- # overwrite the includes used for the count sql query
98
- attr_accessor :count_includes
99
-
100
- # the label for this List action. used for the header.
101
- attr_writer :label
102
- def label
103
- @label ? as_(@label, :count => 2) : @core.label(:count => 2)
104
- end
105
-
106
- attr_writer :no_entries_message
107
- def no_entries_message
108
- @no_entries_message ? @no_entries_message : :no_entries
109
- end
110
-
111
- attr_writer :filtered_message
112
- def filtered_message
113
- @filtered_message ? @filtered_message : :filtered
114
- end
115
-
116
- attr_writer :always_show_search
117
- def always_show_search
118
- @always_show_search && !search_partial.blank?
119
- end
120
-
121
- def search_partial
122
- return "search" if @core.actions.include?(:search)
123
- return "field_search" if @core.actions.include?(:field_search)
124
- end
125
-
126
- # always show create
127
- attr_writer :always_show_create
128
- def always_show_create
129
- @always_show_create && @core.actions.include?(:create)
130
- end
131
-
132
- # if list view is nested hide nested_column
133
- attr_writer :hide_nested_column
134
- def hide_nested_column
135
- @hide_nested_column.nil? ? true : @hide_nested_column
136
- end
137
-
138
- # might be set to open nested_link automatically in view
139
- # conf.nested.add_link(:players)
140
- # conf.list.nested_auto_open = {:players => 2}
141
- # will open nested players view if there are 2 or less records in parent
142
- attr_accessor :nested_auto_open
143
-
144
- class UserSettings < UserSettings
145
- # This label has alread been localized.
146
- def label
147
- @session[:label] ? @session[:label] : @conf.label
148
- end
149
-
150
- def per_page
151
- @session['per_page'] = @params['limit'].to_i if @params.has_key? 'limit'
152
- @session['per_page'] || @conf.per_page
153
- end
154
-
155
- def page
156
- @session['page'] = @params['page'] if @params.has_key? 'page'
157
- @session['page'] || 1
158
- end
159
-
160
- def page=(value = nil)
161
- @session['page'] = value
162
- end
163
-
164
- attr_reader :nested_default_sorting
165
-
166
- def nested_default_sorting=(options)
167
- @nested_default_sorting ||= @conf.sorting.clone
168
- @nested_default_sorting.set_nested_sorting(options[:table_name], options[:default_sorting])
169
- end
170
-
171
- def default_sorting
172
- nested_default_sorting.nil? ? @conf.sorting : nested_default_sorting
173
- end
174
-
175
- def sorting
176
- # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
177
- debugger
178
- @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
179
- @session['sort'] = nil if @params['sort_direction'] == 'reset'
180
-
181
- if @session['sort']
182
- sorting = @conf.sorting.clone
183
- sorting.set(*@session['sort'])
184
- return sorting
185
- else
186
- return default_sorting
187
- end
188
- end
189
-
190
- def count_includes
191
- @conf.count_includes
192
- end
193
- end
194
- end
195
- end