use tables to display clients

This commit is contained in:
Stefan Tollkühn
2025-07-23 17:33:01 +02:00
parent 8393202661
commit b366e5d0a1
4 changed files with 54 additions and 54 deletions

View File

@@ -2,4 +2,8 @@ module ClientsHelper
def client_form_fields def client_form_fields
[:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone] [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
end end
def client_view_fields
[:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
end
end end

View File

@@ -1,47 +1,14 @@
<div id="<%= dom_id client %>"> <% client_view_fields.each do |attrib| %>
<p> <td>
<strong>Company name:</strong> <% value = client.send(attrib) %>
<%= client.company_name %> <% if attrib == :company_name %>
</p> <%= link_to value, client_path(client) %>
<% elsif attrib == :email %>
<p> <%= mail_to value %>
<strong>Firstname:</strong> <% elsif attrib == :phone %>
<%= client.firstname %> <%= link_to value, "tel:#{value.strip.gsub(/\s+/, '')}" %>
</p> <% else %>
<%= value.is_a?(Date) ? l(value) : value %>
<p> <% end %>
<strong>Lastname:</strong> </td>
<%= client.lastname %> <% end %>
</p>
<p>
<strong>Streetname:</strong>
<%= client.streetname %>
</p>
<p>
<strong>Zipcode:</strong>
<%= client.zipcode %>
</p>
<p>
<strong>City:</strong>
<%= client.city %>
</p>
<p>
<strong>Country:</strong>
<%= client.country %>
</p>
<p>
<strong>Email:</strong>
<%= client.email %>
</p>
<p>
<strong>Phone:</strong>
<%= client.phone %>
</p>
</div>

View File

@@ -5,12 +5,22 @@
<h1>Clients</h1> <h1>Clients</h1>
<div id="clients"> <div id="clients">
<% @clients.each do |client| %> <table>
<%= render client %> <thead>
<p> <tr>
<%= link_to "Show this client", client %> <% client_view_fields.each do |attrib| %>
</p> <th><%= attrib.to_s.humanize %></th>
<% end %> <% end %>
</tr>
</thead>
<tbody>
<% @clients.each do |client| %>
<tr id="<%= dom_id client %>">
<%= render client %>
</tr>
<% end %>
</tbody>
</table>
</div> </div>
<%= link_to "New client", new_client_path %> <%= link_to "New client", new_client_path %>

View File

@@ -1,6 +1,25 @@
<p style="color: green"><%= notice %></p> <p style="color: green"><%= notice %></p>
<% content_for :title, "Client: #{@client.company_name}" %>
<h1>Client: <%= @client.company_name %></h1>
<div id="client">
<table>
<thead>
<tr>
<% client_view_fields.each do |attrib| %>
<th><%= attrib.to_s.humanize %></th>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<%= render @client %> <%= render @client %>
</tr>
</tbody>
</table>
</div>
<div> <div>
<%= link_to "Edit this client", edit_client_path(@client) %> | <%= link_to "Edit this client", edit_client_path(@client) %> |