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, #initialize, #list_columns, #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



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 24

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

  @vc.(:table, width: '100%', class: 'list') do
    @vc.(:tr) do
      for col in columns_for(list_columns, :list) do
        @vc.concat d.draw_column_header(col, id_target: @params[:id_target])
      end
    end +
    @vc.capture do
      for rec in list do
        @line_color = 1 - @line_color
        @vc.concat(draw_row(rec) do
          for col in columns_for(list_columns, :list) do
            @vc.concat d.draw_column(rec, col)
          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

#list_drawer_classObject



20
21
22
# File 'app/helpers/edgarj/drawer/popup.rb', line 20

def list_drawer_class
  Edgarj::ListDrawer::Normal
end