Module: Tramway::Admin::RecordsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/tramway/admin/records_helper.rb
Instance Method Summary collapse
- #active_tab(tab, index) ⇒ Object
- #admin_index_path_of_model(model_class, tab = nil) ⇒ Object
-
#current_model_record_path(*args, **options) ⇒ Object
FIXME replace to module.
- #current_model_records_path(*args, **options) ⇒ Object
- #decorator_class ⇒ Object
- #edit_current_model_record_path(*args, **options) ⇒ Object
- #get_collection(model_class) ⇒ Object
- #model_class ⇒ Object
- #new_current_model_record_path(*args, **options) ⇒ Object
- #search_tab_title(count) ⇒ Object
- #searchable_model?(model_class) ⇒ Boolean
- #tab_title(model_class, tab, count, state_method = :state) ⇒ Object
- #to_path(constant) ⇒ Object
Instance Method Details
#active_tab(tab, index) ⇒ Object
62 63 64 65 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 62 def active_tab(tab, index) return :active if params[:scope].nil? && index == 0 return :active if params[:search].nil? && params[:scope].to_s == tab.to_s end |
#admin_index_path_of_model(model_class, tab = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 44 def admin_index_path_of_model(model_class, tab = nil) if tab records_path model: model_class, scope: tab else records_path model: model_class end end |
#current_model_record_path(*args, **options) ⇒ Object
FIXME replace to module
4 5 6 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 4 def current_model_record_path(*args, **) record_path args, .merge(model: params[:model]) end |
#current_model_records_path(*args, **options) ⇒ Object
16 17 18 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 16 def current_model_records_path(*args, **) records_path args, .merge(model: params[:model]) end |
#decorator_class ⇒ Object
24 25 26 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 24 def decorator_class "#{model_class}Decorator".constantize end |
#edit_current_model_record_path(*args, **options) ⇒ Object
8 9 10 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 8 def edit_current_model_record_path(*args, **) edit_record_path args, .merge(model: params[:model]) end |
#get_collection(model_class) ⇒ Object
28 29 30 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 28 def get_collection(model_class) decorator_class.collections end |
#model_class ⇒ Object
20 21 22 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 20 def model_class params[:model].constantize end |
#new_current_model_record_path(*args, **options) ⇒ Object
12 13 14 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 12 def new_current_model_record_path(*args, **) new_record_path args, .merge(model: params[:model]) end |
#search_tab_title(count) ⇒ Object
36 37 38 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 36 def search_tab_title(count) "#{t("helpers.found")} / #{count}" end |
#searchable_model?(model_class) ⇒ Boolean
40 41 42 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 40 def searchable_model?(model_class) model_class.methods.include?(:search) || model_class.methods.include?(:search_everywhere) end |
#tab_title(model_class, tab, count, state_method = :state) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 52 def tab_title(model_class, tab, count, state_method = :state) model = model_class.name.underscore name = if t("default.collections.#{tab}").include?('<span') t("collections.#{model}.#{tab}").pluralize(:ru) else t("default.collections.#{tab}") end "#{name} / #{count}" end |
#to_path(constant) ⇒ Object
32 33 34 |
# File 'app/helpers/tramway/admin/records_helper.rb', line 32 def to_path(constant) constant.name.underscore.gsub '/', '_' end |