Class: Glib::JsonUi::ViewBuilder::Panels::List

Inherits:
View show all
Defined in:
app/helpers/glib/json_ui/view_builder/panels.rb

Overview

List panel for displaying scrollable collections of items.

Lists can display data in various formats (cards, rows, etc.) with support for pagination, infinite scrolling, and drag-and-drop reordering.

Examples:

Basic list with items

panel.panels_list width: 'matchParent', firstSection: ->(section) do
  section.header childViews: ->(header) do
    header.h2 text: 'Products'
  end
  @products.each do |product|
    section.row childViews: ->(row) do
      row.label text: product.name
      row.label text: product.price
    end
  end
end

List with pagination

panel.panels_list \
  nextPage: { url: products_path(page: @page + 1) },
  prevPage: { url: products_path(page: @page - 1) },
  firstSection: ->(section) do
    # ... items
  end

Responsive grid list

panel.panels_list responsiveCols: 3, firstSection: ->(section) do
  @images.each do |image|
    section.row childViews: ->(row) do
      row.image url: image.url
    end
  end
end

Instance Attribute Summary

Attributes inherited from JsonUiElement

#json, #page

Instance Method Summary collapse

Methods inherited from View

component_name

Methods inherited from JsonUiElement

#initialize, #props

Constructor Details

This class inherits a constructor from Glib::JsonUi::JsonUiElement

Instance Method Details

#firstSection(block) ⇒ Object



392
393
394
395
396
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 392

def firstSection(block)
  json.sections [1] do
    block.call page.list_section_builder
  end
end

#sections(blocks) ⇒ Object



398
399
400
401
402
403
404
405
406
# File 'app/helpers/glib/json_ui/view_builder/panels.rb', line 398

def sections(blocks)
  json.sections do
    blocks.each do |block|
      json.child! do
        block.call page.list_section_builder
      end
    end
  end
end