Class: Edgarj::Drawer::Popup

Inherits:
Base
  • Object
show all
Defined in:
app/helpers/edgarj/drawer/popup.rb

Overview

PopupDrawer is the same as Drawer to draw ‘belongs_to’ model to popup window.

For example, AuthorPopupDrawer is to draw Author popup, which is called from Book page.

  • options

    • list_drawer_options - options for Edgarj::ListDrawer::Normal

Instance Attribute Summary

Attributes inherited from Base

#model, #page_info, #params, #vc

Instance Method Summary collapse

Methods inherited from Base

#columns, #columns_for, #draw_form, #draw_search_form, #form_columns, #form_drawer_class, #fullname, #initialize, #list_columns, #list_drawer_class, #popup_path, #popup_path_on_search, #search_form_columns, #search_form_drawer_class, #url_for_show

Constructor Details

This class inherits a constructor from Edgarj::Drawer::Base

Instance Method Details

#draw_list(list) ⇒ Object



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

def draw_list(list)
  @line_color = 1
  d           = Edgarj::ListDrawer::Normal.new(
      self,
      @options[:list_drawer_options] || {})

  @vc.(:table, width: '100%', class: 'list') do
    @vc.(:tr) do
      ''.html_safe.tap do |result|
        for col in columns_for(list_columns) do
          result << d.draw_column_header(col, id_target: @params[:id_target])
        end
      end
    end +
    ''.html_safe.tap do |trs|
      for rec in list do
        @line_color = 1 - @line_color
        trs << draw_row(rec) do
          ''.html_safe.tap do |cols|
            for col in columns_for(list_columns) do
              cols << d.draw_column(rec, col)
            end
          end
        end
      end
    end
  end
end

#draw_row(record, &block) ⇒ Object



12
13
14
15
16
17
18
# File 'app/helpers/edgarj/drawer/popup.rb', line 12

def draw_row(record, &block)
  @vc.(:tr,
      class:  "list_line#{@line_color} edgarj_row edgarj_popup_list_row",
      data:   {id: record.id, name: record.name}) do
    yield
  end
end