Method: ModelModalHelper#dynamic_related_modal

Defined in:
app/helpers/model_modal_helper.rb

Only show the trigger with the edit path, let the rest be generated later



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/model_modal_helper.rb', line 23

def dynamic_related_modal(related_model, edit_path, _options = {})
  model_name = related_model.class.to_s.underscore
  datum = { view_url: edit_path.gsub('/edit', '') }
  anchor_id = "#{model_name}-#{related_model.id}"
  title = related_model.respond_to?(:short_name) ? related_model.short_name : related_model.name
  (:div) do
    concat((:a, href: "##{anchor_id}", class: 'modal-trigger') do
      concat((:span, title))
    end)
    concat((:div, id: anchor_id, class: 'modal', data: datum) do
      concat((:div, class: 'modal-content') do
        concat((:h2, class: 'center') do
          concat((:span, related_model.name))
        end)
        concat((:div, class: 'center-align') do
          concat((:div, class: 'progress red lighten-4') do
            tag(:div, class: 'indeterminate red')
          end)
        end)
      end)
      concat(model_modal_footer(related_model, edit_path))
    end)
  end
end