Sha256: 2c1bb488d3cdadf4bce5f10d85a8a5b2155c9b7957602c0e042bfcb93fff5f9e

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 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 list_drawer_class
        Edgarj::ListDrawer::Normal
      end

      def draw_list(list)
        @line_color = 1
        d           = list_drawer_class.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

9 entries across 9 versions & 1 rubygems

Version Path
edgarj-4.06.10 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.09 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.07 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.05 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.04 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.03 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.02 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.01 app/helpers/edgarj/drawer/popup.rb
edgarj-4.06.00 app/helpers/edgarj/drawer/popup.rb