From 0004821afbacd91fa746f19ed9d8fbe16fe53b01 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Mon, 27 Nov 2023 16:14:02 +0100 Subject: [PATCH] Allow columns to be defined as simple symbols When both the header and the data are defaulting to an AR attribute passing just the symbol should suffice. --- admin/app/components/solidus_admin/ui/table/component.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 88546843299..f25a4549f55 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -11,7 +11,9 @@ class Data < Struct.new(:rows, :class, :url, :prev, :next, :columns, :fade, :bat def initialize(**args) super - self.columns = columns.map { |column| Column.new(wrap: false, **column) } + self.columns = columns.map do |column| + column.is_a?(Symbol) ? Column.new(wrap: false, header: column, data: column) : Column.new(wrap: false, **column) + end self.batch_actions = batch_actions.to_a.map { |action| BatchAction.new(**action) } end