Current section

Files

Jump to
dumper priv templates dumper_html table_records.html.heex
Raw

priv/templates/dumper_html/table_records.html.heex

<%#
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
%>
<p :if={Enum.empty?(@records)} class="italic">
No records
</p>
<table :if={!Enum.empty?(@records)}>
<thead class="sticky top-0 bg-slate-100">
<tr>
<th
:for={field <- fields(@records)}
:if={field not in embeds(@records)}
class="px-3 py-1 border border-slate-300"
>
<%= field %>
</th>
</tr>
</thead>
<tbody>
<tr :for={record <- @records}>
<td :for={field <- fields(@records)} :if={field not in embeds(@records)} class="px-3 py-1 border border-slate-300">
<%= if field == :id do %>
<a href={"/dumper/#{Macro.underscore(record.__struct__)}/#{record.id}"} class="text-blue-600">
<%= record.id %>
</a>
<% else %>
<.value
module={record.__struct__}
field={field}
resource={record}
value={Map.get(record, field)}
type={record.__struct__.__schema__(:type, field)}
redacted={field in redacted_fields(record)}
/>
<% end %>
</td>
</tr>
</tbody>
</table>