use tables to display clients
This commit is contained in:
@@ -2,4 +2,8 @@ module ClientsHelper
|
||||
def client_form_fields
|
||||
[:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
|
||||
end
|
||||
|
||||
def client_view_fields
|
||||
[:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,47 +1,14 @@
|
||||
<div id="<%= dom_id client %>">
|
||||
<p>
|
||||
<strong>Company name:</strong>
|
||||
<%= client.company_name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Firstname:</strong>
|
||||
<%= client.firstname %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Lastname:</strong>
|
||||
<%= client.lastname %>
|
||||
</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>
|
||||
<% client_view_fields.each do |attrib| %>
|
||||
<td>
|
||||
<% value = client.send(attrib) %>
|
||||
<% if attrib == :company_name %>
|
||||
<%= link_to value, client_path(client) %>
|
||||
<% elsif attrib == :email %>
|
||||
<%= mail_to value %>
|
||||
<% elsif attrib == :phone %>
|
||||
<%= link_to value, "tel:#{value.strip.gsub(/\s+/, '')}" %>
|
||||
<% else %>
|
||||
<%= value.is_a?(Date) ? l(value) : value %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
@@ -5,12 +5,22 @@
|
||||
<h1>Clients</h1>
|
||||
|
||||
<div id="clients">
|
||||
<% @clients.each do |client| %>
|
||||
<%= render client %>
|
||||
<p>
|
||||
<%= link_to "Show this client", client %>
|
||||
</p>
|
||||
<% end %>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<% client_view_fields.each do |attrib| %>
|
||||
<th><%= attrib.to_s.humanize %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @clients.each do |client| %>
|
||||
<tr id="<%= dom_id client %>">
|
||||
<%= render client %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%= link_to "New client", new_client_path %>
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @client %>
|
||||
<% 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 %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this client", edit_client_path(@client) %> |
|
||||
|
||||
Reference in New Issue
Block a user