diff --git a/admin/app/components/solidus_admin/ui/table/component.html.erb b/admin/app/components/solidus_admin/ui/table/component.html.erb index 69a155cd66d..9e685cbcbf2 100644 --- a/admin/app/components/solidus_admin/ui/table/component.html.erb +++ b/admin/app/components/solidus_admin/ui/table/component.html.erb @@ -138,15 +138,11 @@ > <% @data.rows.each do |row| %> - data-action="click-><%= stimulus_id %>#rowClicked" - data-<%= stimulus_id %>-url-param="<%= @data.url.call(row) %>" - <%= "data-sortable-url=#{@sortable.url.call(row)}" if @sortable&.url %> - <% end %> + class="border-b border-gray-100 last:border-0 hover:bg-gray-50 <%= 'bg-gray-15 text-gray-700' if @data.fade&.call(row) %>" + <%= "data-sortable-url=#{@sortable.url.call(row)}" if @sortable&.url %> > <% @data.columns.each do |column| %> - <%= render_data_cell(column, row) %> + <%= render_data_cell(column, row, @data.url&.call(row)) %> <% end %> <% end %> diff --git a/admin/app/components/solidus_admin/ui/table/component.js b/admin/app/components/solidus_admin/ui/table/component.js index 66837d4ce75..f0277eef3ec 100644 --- a/admin/app/components/solidus_admin/ui/table/component.js +++ b/admin/app/components/solidus_admin/ui/table/component.js @@ -97,25 +97,6 @@ export default class extends Controller { this.render() } - rowClicked(event) { - // If the user clicked on a link, button, input or summary, skip the row url visit - if (event.target.closest("td").contains(event.target.closest("a,select,textarea,button,input,summary"))) return - - if (this.modeValue === "batch") { - this.toggleCheckbox(event.currentTarget) - } else { - const url = new URL(event.params.url, "http://dummy.com") - const params = new URLSearchParams(url.search) - const frameId = params.get('_turbo_frame') - const frame = frameId ? { frame: frameId } : {} - // remove the custom _turbo_frame param from url search: - params.delete('_turbo_frame') - url.search = params.toString() - - window.Turbo.visit(url.pathname + url.search, frame) - } - } - toggleCheckbox(row) { const checkbox = this.checkboxTargets.find(selection => row.contains(selection)) diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 79e08f9d494..b41c505c0c5 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -158,10 +158,10 @@ def render_header_cell(cell, **attrs) }, **attrs) end - def render_data_cell(column, data) + def render_data_cell(column, data, url = nil) cell = column.data cell = cell.call(data) if cell.respond_to?(:call) - cell = data.public_send(cell) if cell.is_a?(Symbol) + cell = link_to data.public_send(cell), url, class: "underline cursor-pointer" if cell.is_a?(Symbol) cell = cell.render_in(self) if cell.respond_to?(:render_in) cell = tag.div(cell, class: "flex items-center gap-1.5 justify-start overflow-x-hidden") if column.wrap