Sha256: cecd29edf2eb599eac2f65b26d13824e03988ee5634beee34b7d868af3bb718b

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

module Edgarj
  module Drawer
    # 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
    class Popup < Base
      def draw_row(record, &block)
        @vc.content_tag(:tr,
            class:  "list_line#{@line_color} edgarj_row edgarj_popup_list_row",
            data:   {id: record.id, name: record.name}) do
          yield
        end
      end

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

        @vc.content_tag(:table, width: '100%', class: 'list') do
          @vc.content_tag(: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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
edgarj-4.05.04 app/helpers/edgarj/drawer/popup.rb
edgarj-4.05.03 app/helpers/edgarj/drawer/popup.rb
edgarj-4.05.02 app/helpers/edgarj/drawer/popup.rb
edgarj-4.05.01 app/helpers/edgarj/drawer/popup.rb
edgarj-4.05.00 app/helpers/edgarj/drawer/popup.rb
edgarj-4.04.01 app/helpers/edgarj/drawer/popup.rb
edgarj-4.04.00 app/helpers/edgarj/drawer/popup.rb
edgarj-4.03.00 app/helpers/edgarj/drawer/popup.rb