Module: Gaku::FrontendHelper
Instance Method Summary
collapse
#edit_button, #guardian_icon, #name_label, #name_reading_label, #surname_label, #surname_reading_label
#student_chooser_modal
#can_edit?, #disabled?, #genders, #render_flash, #state_load
#big_person_caption_for, #gender, #name_and_ruby_for, #person_caption_for, #student_names
Methods included from ExamHelper
#exam_completion_info
#autocomplete_date_field, #autocomplete_select, #autocomplete_text_field
Instance Method Details
#ajax_link_to_search(text, resource, options = {}) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'app/helpers/gaku/frontend_helper.rb', line 23
def ajax_link_to_search(text, resource, options = {})
name = ("<span class='glyphicon glyphicon-search'></span> " + text).html_safe
attributes = {
remote: true,
class: 'btn btn-primary'
}.merge(options)
link_to name, resource, attributes
end
|
#badge_count(count, text, css_class) ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/helpers/gaku/frontend_helper.rb', line 15
def badge_count(count, text, css_class)
if count != 0
"#{text}<span class='badge pull-right #{css_class}'>#{count}</span>".html_safe
else
"#{text}<span class='badge pull-right #{css_class}'></span>".html_safe
end
end
|
45
46
47
|
# File 'app/helpers/gaku/frontend_helper.rb', line 45
def (grouped, resource)
grouped.map(&resource.to_sym)
end
|
#gradable_resource(gradable) ⇒ Object
11
12
13
|
# File 'app/helpers/gaku/frontend_helper.rb', line 11
def gradable_resource(gradable)
gradable.class.to_s.demodulize.underscore.dasherize
end
|
#prepare_resource_name(nested_resources, resource) ⇒ Object
41
42
43
|
# File 'app/helpers/gaku/frontend_helper.rb', line 41
def prepare_resource_name(nested_resources, resource)
@resource_name = [nested_resources.map { |r| r.is_a?(Symbol) ? r.to_s : get_class(r) }, resource.to_s].flatten.join '-'
end
|
#prepare_target(nested_resource, address) ⇒ Object
32
33
34
35
|
# File 'app/helpers/gaku/frontend_helper.rb', line 32
def prepare_target(nested_resource, address)
return nil if nested_resource.blank?
[nested_resource, address].flatten
end
|
#score_type_options ⇒ Object
61
62
63
64
65
|
# File 'app/helpers/gaku/frontend_helper.rb', line 61
def score_type_options
Gaku::ExamPortion.score_types.keys.map do |option|
[I18n.t("exam_portion.score_type.#{option}"), option]
end
end
|
#show_field?(field) ⇒ Boolean
37
38
39
|
# File 'app/helpers/gaku/frontend_helper.rb', line 37
def show_field?(field)
ActiveRecord::Type::Boolean.new.type_cast_from_database(field.to_i)
end
|
#sort_handler ⇒ Object
49
50
51
52
53
|
# File 'app/helpers/gaku/frontend_helper.rb', line 49
def sort_handler
content_tag :td, class: 'sort-handler' do
content_tag :i, nil, class: 'glyphicon glyphicon-move'
end
end
|
#sortable_tbody(path, &block) ⇒ Object
55
56
57
58
59
|
# File 'app/helpers/gaku/frontend_helper.rb', line 55
def sortable_tbody(path, &block)
content_tag(:tbody, class: 'sortable', data: { 'sort-url' => url_for(path) }) do
block.call
end
end
|