andrewroth_activeadmin 0.3.4 → 0.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +159 -3
- data/CONTRIBUTING.md +113 -0
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js +9 -0
- data/app/assets/javascripts/active_admin/base.js +4 -12
- data/app/assets/stylesheets/active_admin/_base.css.scss +16 -340
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -7
- data/app/assets/stylesheets/active_admin/_header.css.scss +23 -4
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +2 -0
- data/app/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/app/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/app/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +101 -0
- data/app/assets/stylesheets/active_admin/mixins/_all.css.scss +2 -1
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +50 -13
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +7 -5
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/active_admin/page/index.html.arb +1 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +3 -2
- data/docs/1-general-configuration.md +46 -10
- data/docs/6-show-screens.md +7 -0
- data/docs/8-custom-actions.md +12 -2
- data/docs/9-custom-pages.md +84 -0
- data/features/belongs_to.feature +27 -0
- data/features/comments/commenting.feature +3 -2
- data/features/dashboard.feature +18 -0
- data/features/development_reloading.feature +19 -0
- data/features/index/filter_with_check_boxes.feature +25 -0
- data/features/index/index_as_table.feature +14 -0
- data/features/index/index_scopes.feature +42 -0
- data/features/index/pagination.feature +19 -1
- data/features/menu.feature +22 -2
- data/features/registering_assets.feature +2 -2
- data/features/registering_pages.feature +66 -0
- data/features/specifying_actions.feature +5 -0
- data/features/step_definitions/action_item_steps.rb +2 -6
- data/features/step_definitions/action_link_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +8 -0
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/configuration_steps.rb +56 -8
- data/features/step_definitions/dashboard_steps.rb +5 -1
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +16 -4
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +25 -10
- data/lib/active_admin/application.rb +63 -20
- data/lib/active_admin/arbre/html/element.rb +10 -0
- data/lib/active_admin/asset_registration.rb +15 -2
- data/lib/active_admin/base_controller.rb +61 -0
- data/lib/active_admin/{resource_controller → base_controller}/menu.rb +1 -1
- data/lib/active_admin/comments.rb +48 -54
- data/lib/active_admin/comments/comment.rb +13 -2
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +7 -3
- data/lib/active_admin/dashboards.rb +4 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +20 -4
- data/lib/active_admin/dsl.rb +6 -159
- data/lib/active_admin/event.rb +5 -3
- data/lib/active_admin/filter_form_builder.rb +53 -0
- data/lib/active_admin/form_builder.rb +25 -19
- data/lib/active_admin/inputs.rb +14 -0
- data/lib/active_admin/inputs/datepicker_input.rb +11 -0
- data/lib/active_admin/inputs/filter_base.rb +46 -0
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +40 -0
- data/lib/active_admin/inputs/filter_date_range_input.rb +34 -0
- data/lib/active_admin/inputs/filter_numeric_input.rb +55 -0
- data/lib/active_admin/inputs/filter_select_input.rb +23 -0
- data/lib/active_admin/inputs/filter_string_input.rb +22 -0
- data/lib/active_admin/locales/ca.yml +44 -0
- data/lib/active_admin/locales/cs.yml +14 -10
- data/lib/active_admin/locales/de.yml +43 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/ko.yml +40 -0
- data/lib/active_admin/locales/lv.yml +43 -0
- data/lib/active_admin/locales/nl.yml +40 -0
- data/lib/active_admin/locales/no-NB.yml +40 -0
- data/lib/active_admin/locales/pl.yml +7 -1
- data/lib/active_admin/locales/pt-BR.yml +6 -2
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +54 -0
- data/lib/active_admin/page_controller.rb +15 -0
- data/lib/active_admin/page_dsl.rb +21 -0
- data/lib/active_admin/page_presenter.rb +30 -0
- data/lib/active_admin/resource.rb +38 -44
- data/lib/active_admin/resource/action_items.rb +5 -0
- data/lib/active_admin/resource/belongs_to.rb +4 -2
- data/lib/active_admin/resource/controllers.rb +35 -0
- data/lib/active_admin/resource/menu.rb +1 -2
- data/lib/active_admin/resource/naming.rb +43 -31
- data/lib/active_admin/resource/page_presenters.rb +28 -0
- data/lib/active_admin/resource/scopes.rb +16 -3
- data/lib/active_admin/resource/sidebars.rb +4 -0
- data/lib/active_admin/resource_collection.rb +88 -0
- data/lib/active_admin/resource_controller.rb +18 -54
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +1 -1
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +8 -4
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/resource_class_methods.rb +24 -0
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +157 -0
- data/lib/active_admin/router.rb +21 -14
- data/lib/active_admin/scope.rb +15 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +4 -3
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -10
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +25 -21
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -150
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/scopes.rb +17 -17
- data/lib/active_admin/views/components/status_tag.rb +6 -5
- data/lib/active_admin/views/components/table_for.rb +6 -2
- data/lib/active_admin/views/header_renderer.rb +31 -12
- data/lib/active_admin/views/index_as_block.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +3 -3
- data/lib/active_admin/views/index_as_grid.rb +4 -4
- data/lib/active_admin/views/index_as_table.rb +13 -6
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/form.rb +49 -0
- data/lib/active_admin/views/pages/index.rb +18 -6
- data/lib/active_admin/views/pages/page.rb +24 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +19 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +38 -12
- data/lib/generators/active_admin/install/templates/dashboards.rb +6 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/templates/cucumber_with_reloading.rb +5 -0
- data/spec/unit/active_admin_spec.rb +8 -0
- data/spec/unit/application_spec.rb +48 -2
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/asset_registration_spec.rb +9 -3
- data/spec/unit/auto_link_spec.rb +2 -2
- data/spec/unit/base_controller_shared_examples.rb +28 -0
- data/spec/unit/base_controller_spec.rb +8 -0
- data/spec/unit/belongs_to_spec.rb +30 -33
- data/spec/unit/comments_spec.rb +45 -15
- data/spec/unit/config_shared_examples.rb +108 -0
- data/spec/unit/dashboard_controller_spec.rb +44 -0
- data/spec/unit/event_spec.rb +6 -0
- data/spec/unit/filter_form_builder_spec.rb +9 -0
- data/spec/unit/form_builder_spec.rb +8 -14
- data/spec/unit/namespace/register_page_spec.rb +102 -0
- data/spec/unit/namespace/register_resource_spec.rb +188 -0
- data/spec/unit/namespace_spec.rb +11 -183
- data/spec/unit/page_controller_spec.rb +8 -0
- data/spec/unit/page_spec.rb +60 -0
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +24 -19
- data/spec/unit/resource/page_presenters_spec.rb +32 -0
- data/spec/unit/resource/scopes_spec.rb +13 -0
- data/spec/unit/resource_collection_spec.rb +101 -0
- data/spec/unit/resource_controller_spec.rb +40 -32
- data/spec/unit/{registration_spec.rb → resource_registration_spec.rb} +0 -0
- data/spec/unit/resource_spec.rb +8 -24
- data/spec/unit/routing_spec.rb +50 -1
- data/spec/unit/scope_spec.rb +18 -4
- data/spec/unit/views/components/paginated_collection_spec.rb +150 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/tasks/test.rake +43 -27
- metadata +140 -31
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/comments/configuration.rb +0 -18
- data/lib/active_admin/page_config.rb +0 -15
- data/lib/active_admin/resource_controller/form.rb +0 -42
- data/lib/active_admin/resource_controller/page_configurations.rb +0 -53
- data/lib/active_admin/views/pages/edit.rb +0 -28
- data/lib/active_admin/views/pages/new.rb +0 -28
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +0 -427
- data/spec/integration/belongs_to_spec.rb +0 -42
data/lib/active_admin/event.rb
CHANGED
@@ -9,9 +9,11 @@ module ActiveAdmin
|
|
9
9
|
@events = {}
|
10
10
|
end
|
11
11
|
|
12
|
-
def subscribe(
|
13
|
-
|
14
|
-
|
12
|
+
def subscribe(*event_names, &block)
|
13
|
+
event_names.each do |event|
|
14
|
+
@events[event] ||= []
|
15
|
+
@events[event] << block
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def subscribers(event)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
# This form builder defines methods to build filter forms such
|
3
|
+
# as the one found in the sidebar of the index page of a standard resource.
|
4
|
+
class FilterFormBuilder < FormBuilder
|
5
|
+
|
6
|
+
def filter(method, options = {})
|
7
|
+
return "" if method.nil? || method == ""
|
8
|
+
options[:as] ||= default_input_type(method)
|
9
|
+
return "" unless options[:as]
|
10
|
+
content = input(method, options)
|
11
|
+
form_buffers.last << content.html_safe if content
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
# Returns the default filter type for a given attribute
|
17
|
+
def default_input_type(method, options = {})
|
18
|
+
if column = column_for(method)
|
19
|
+
case column.type
|
20
|
+
when :date, :datetime
|
21
|
+
return :date_range
|
22
|
+
when :string, :text
|
23
|
+
return :string
|
24
|
+
when :integer
|
25
|
+
return :select if reflection_for(method.to_s.gsub('_id','').to_sym)
|
26
|
+
return :numeric
|
27
|
+
when :float, :decimal
|
28
|
+
return :numeric
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if reflection = reflection_for(method)
|
33
|
+
return :select if reflection.macro == :belongs_to && !reflection.options[:polymorphic]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def custom_input_class_name(as)
|
38
|
+
"ActiveAdmin::Inputs::Filter#{as.to_s.camelize}Input"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns the column for an attribute on the object being searched
|
42
|
+
# if it exists. Otherwise returns nil
|
43
|
+
def column_for(method)
|
44
|
+
@object.base.columns_hash[method.to_s] if @object.base.respond_to?(:columns_hash)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the association reflection for the method if it exists
|
48
|
+
def reflection_for(method)
|
49
|
+
@object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
|
-
require 'formtastic'
|
2
|
-
|
3
1
|
module ActiveAdmin
|
4
|
-
class FormBuilder < ::Formtastic::
|
2
|
+
class FormBuilder < ::Formtastic::FormBuilder
|
5
3
|
|
6
4
|
attr_reader :form_buffers
|
7
5
|
|
@@ -21,8 +19,6 @@ module ActiveAdmin
|
|
21
19
|
# its contents, so we want to skip the internal buffering
|
22
20
|
# while building up its contents
|
23
21
|
def input(method, *args)
|
24
|
-
return if polymorphic_belongs_to_association?(method)
|
25
|
-
|
26
22
|
content = with_new_form_buffer { super }
|
27
23
|
return content.html_safe unless @inputs_with_block
|
28
24
|
form_buffers.last << content.html_safe
|
@@ -52,14 +48,6 @@ module ActiveAdmin
|
|
52
48
|
content << cancel_link
|
53
49
|
end
|
54
50
|
|
55
|
-
def datepicker_input(method, options)
|
56
|
-
options = options.dup
|
57
|
-
options[:input_html] ||= {}
|
58
|
-
options[:input_html][:class] = [options[:input_html][:class], "datepicker"].compact.join(' ')
|
59
|
-
options[:input_html][:size] ||= "10"
|
60
|
-
string_input(method, options)
|
61
|
-
end
|
62
|
-
|
63
51
|
def has_many(association, options = {}, &block)
|
64
52
|
options = { :for => association }.merge(options)
|
65
53
|
options[:class] ||= ""
|
@@ -98,15 +86,33 @@ module ActiveAdmin
|
|
98
86
|
form_buffers.last << content.html_safe
|
99
87
|
end
|
100
88
|
|
101
|
-
|
89
|
+
protected
|
102
90
|
|
103
|
-
|
104
|
-
|
105
|
-
reflection = reflection_for(method)
|
106
|
-
|
107
|
-
reflection && reflection.macro == :belongs_to && reflection.options[:polymorphic]
|
91
|
+
def active_admin_input_class_name(as)
|
92
|
+
"ActiveAdmin::Inputs::#{as.to_s.camelize}Input"
|
108
93
|
end
|
109
94
|
|
95
|
+
def input_class(as)
|
96
|
+
@input_classes_cache ||= {}
|
97
|
+
@input_classes_cache[as] ||= begin
|
98
|
+
begin
|
99
|
+
begin
|
100
|
+
custom_input_class_name(as).constantize
|
101
|
+
rescue NameError
|
102
|
+
begin
|
103
|
+
active_admin_input_class_name(as).constantize
|
104
|
+
rescue NameError
|
105
|
+
standard_input_class_name(as).constantize
|
106
|
+
end
|
107
|
+
end
|
108
|
+
rescue NameError
|
109
|
+
raise Formtastic::UnknownInputError
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
110
116
|
def with_new_form_buffer
|
111
117
|
form_buffers << "".html_safe
|
112
118
|
return_value = yield
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
extend ActiveSupport::Autoload
|
4
|
+
|
5
|
+
autoload :DatepickerInput
|
6
|
+
|
7
|
+
autoload :FilterBase
|
8
|
+
autoload :FilterStringInput
|
9
|
+
autoload :FilterDateRangeInput
|
10
|
+
autoload :FilterNumericInput
|
11
|
+
autoload :FilterSelectInput
|
12
|
+
autoload :FilterCheckBoxesInput
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
module FilterBase
|
4
|
+
include ::Formtastic::Inputs::Base
|
5
|
+
|
6
|
+
def input_wrapping(&block)
|
7
|
+
template.content_tag(:div,
|
8
|
+
template.capture(&block),
|
9
|
+
wrapper_html_options
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def required?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def wrapper_html_options
|
18
|
+
{ :class => "filter_form_field #{as}" }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Override the standard finder to accept a proc
|
22
|
+
def collection_from_options
|
23
|
+
if options[:collection].is_a?(Proc)
|
24
|
+
options[:collection].call
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the default label for a given attribute
|
31
|
+
# Will use ActiveModel I18n if possible
|
32
|
+
def humanized_method_name
|
33
|
+
if object.base.respond_to?(:human_attribute_name)
|
34
|
+
object.base.human_attribute_name(method)
|
35
|
+
else
|
36
|
+
method.to_s.send(builder.label_str_method)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns the association reflection for the method if it exists
|
41
|
+
def reflection_for(method)
|
42
|
+
@object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterCheckBoxesInput < ::Formtastic::Inputs::CheckBoxesInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def input_name
|
7
|
+
"#{object_name}[#{association_primary_key || method}_in][]"
|
8
|
+
end
|
9
|
+
|
10
|
+
def selected_values
|
11
|
+
@object.send("#{association_primary_key || method}_in") || []
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add whitespace before label
|
15
|
+
def choice_label(choice)
|
16
|
+
" #{super(choice)}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Don't wrap in UL tag
|
20
|
+
def choices_group_wrapping(&block)
|
21
|
+
template.capture(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Don't wrap in LI tag
|
25
|
+
def choice_wrapping(html_options, &block)
|
26
|
+
template.capture(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Don't render hidden fields
|
30
|
+
def hidden_field_for_all
|
31
|
+
""
|
32
|
+
end
|
33
|
+
|
34
|
+
# Don't render hidden fields
|
35
|
+
def hidden_fields?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterDateRangeInput < ::Formtastic::Inputs::StringInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def to_html
|
7
|
+
input_wrapping do
|
8
|
+
[ label_html,
|
9
|
+
builder.text_field(gt_input_name, input_html_options(gt_input_name)),
|
10
|
+
template.content_tag(:span, "-", :class => "seperator"),
|
11
|
+
builder.text_field(lt_input_name, input_html_options(lt_input_name)),
|
12
|
+
].join("\n").html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def gt_input_name
|
17
|
+
"#{method}_gte"
|
18
|
+
end
|
19
|
+
alias :input_name :gt_input_name
|
20
|
+
|
21
|
+
def lt_input_name
|
22
|
+
"#{method}_lte"
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_html_options(input_name = gt_input_name)
|
26
|
+
current_value = @object.send(input_name)
|
27
|
+
{ :size => 12,
|
28
|
+
:class => "datepicker",
|
29
|
+
:max => 10,
|
30
|
+
:value => current_value.respond_to?(:strftime) ? current_value.strftime("%Y-%m-%d") : "" }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterNumericInput < ::Formtastic::Inputs::NumberInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def to_html
|
7
|
+
input_wrapping do
|
8
|
+
[ label_html,
|
9
|
+
select_html,
|
10
|
+
" ",
|
11
|
+
input_html
|
12
|
+
].join("\n").html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def input_html
|
17
|
+
builder.text_field current_filter, input_html_options
|
18
|
+
end
|
19
|
+
|
20
|
+
def input_html_options
|
21
|
+
{ :size => 10, :id => "#{method}_numeric" }
|
22
|
+
end
|
23
|
+
|
24
|
+
def select_html
|
25
|
+
template.select_tag '', select_options, select_html_options
|
26
|
+
end
|
27
|
+
|
28
|
+
def select_options
|
29
|
+
template.options_for_select(filters, current_filter)
|
30
|
+
end
|
31
|
+
|
32
|
+
def select_html_options
|
33
|
+
{ :onchange => "document.getElementById('#{method}_numeric').name = 'q[' + this.value + ']';" }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the scope for which we are currently searching. If no search is available
|
37
|
+
# it returns the first scope
|
38
|
+
def current_filter
|
39
|
+
filters[1..-1].inject(filters.first){|a,b| @object.send(b[1].to_sym) ? b : a }[1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def filters
|
43
|
+
(options[:filters] || default_filters).collect do |scope|
|
44
|
+
[scope[0], [method, scope[1]].join("_")]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_filters
|
49
|
+
[ [I18n.t('active_admin.equal_to'), 'eq'],
|
50
|
+
[I18n.t('active_admin.greater_than'), 'gt'],
|
51
|
+
[I18n.t('active_admin.less_than'), 'lt'] ]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterSelectInput < ::Formtastic::Inputs::SelectInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def input_name
|
7
|
+
"#{super}_eq"
|
8
|
+
end
|
9
|
+
|
10
|
+
def input_options
|
11
|
+
super.merge(:include_blank => I18n.t('active_admin.any'))
|
12
|
+
end
|
13
|
+
|
14
|
+
def method
|
15
|
+
super.to_s.gsub('_id','').to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
def extra_input_html_options
|
19
|
+
{}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterStringInput < ::Formtastic::Inputs::StringInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def to_html
|
7
|
+
input_wrapping do
|
8
|
+
label_html <<
|
9
|
+
builder.text_field(input_name, input_html_options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def label_text
|
14
|
+
I18n.t('active_admin.search_field', :field => super)
|
15
|
+
end
|
16
|
+
|
17
|
+
def input_name
|
18
|
+
"#{super}_contains"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
ca:
|
3
|
+
active_admin:
|
4
|
+
dashboard: Tauler
|
5
|
+
dashboard_welcome:
|
6
|
+
welcome: "Benvingut a Active Admin. Aquest és el tauler per defecte."
|
7
|
+
call_to_action: "Mira l'arxiu 'app/admin/dashboards.rb' per afegir seccions al tauler"
|
8
|
+
view: "Mostra"
|
9
|
+
edit: "Edita"
|
10
|
+
delete: "Elimina"
|
11
|
+
delete_confirmation: "Segur que vols eliminar-ho?"
|
12
|
+
new_model: "Crear %{model}"
|
13
|
+
edit_model: "Editar %{model}"
|
14
|
+
delete_model: "eliminar %{model}"
|
15
|
+
details: "Detalls de %{model}"
|
16
|
+
cancel: "Cancel·lar"
|
17
|
+
empty: "Buit"
|
18
|
+
previous: "Anterior"
|
19
|
+
next: "Següent"
|
20
|
+
download: "Descarregar:"
|
21
|
+
has_many_new: "Afegir %{model}"
|
22
|
+
has_many_delete: "Eliminar"
|
23
|
+
filter: "Filtrar"
|
24
|
+
clear_filters: "Treure filtres"
|
25
|
+
search_field: "Cercar %{field}"
|
26
|
+
equal_to: "Igual a"
|
27
|
+
greater_than: "Més gran que"
|
28
|
+
less_than: "Més petit que"
|
29
|
+
main_content: "Implementa %{model}#main_content per mostrar contingut."
|
30
|
+
logout: "Desconnecta't"
|
31
|
+
sidebars:
|
32
|
+
filters: "Filtres"
|
33
|
+
pagination:
|
34
|
+
empty: "No hi ha %{model}"
|
35
|
+
one: "S'està mostrant <b>1</b> %{model}"
|
36
|
+
one_page: "S'estan mostrant <b>tots %{n}</b> %{model}"
|
37
|
+
multiple: "S'estan mostrant %{model} <b>%{from} - %{to}</b> de <b>%{total}</b> en total"
|
38
|
+
entry:
|
39
|
+
one: "entrada"
|
40
|
+
other: "entrades"
|
41
|
+
any: "Qualsevol"
|
42
|
+
blank_slate:
|
43
|
+
content: "Encara no hi ha cap %{resource_name}."
|
44
|
+
link: "Crea'n un/a"
|