Commit 341e2716 authored by Klaus Stein's avatar Klaus Stein
Browse files

Update Itemdate views to edtfdates (bugfix)

parent 28a26632
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
class Itemdate < ApplicationRecord class Itemdate < ApplicationRecord
# To play around we have this optional # To play around we have this optional
belongs_to :dated, polymorphic: true, optional: true belongs_to :dated, polymorphic: true, optional: true
# every dated should respond to title
attribute :edtfdate, :edtf attribute :edtfdate, :edtf
validates :edtfdate, presence: true validates :edtfdate, presence: true
......
...@@ -12,23 +12,8 @@ ...@@ -12,23 +12,8 @@
<% end %> <% end %>
<div class="field"> <div class="field">
<%= form.label :value %> <%= form.label :date %>
<%= form.date_select :value %> <%= form.text_field :edtfdate, value: itemdate.edtfdate&.edtf %>
</div>
<div class="field">
<%= form.label :trunc %>
<%= form.text_field :trunc %>
</div>
<div class="field">
<%= form.label :datetext %>
<%= form.text_field :datetext %>
</div>
<div class="field">
<%= form.label :definitely %>
<%= form.check_box :definitely %>
</div> </div>
<div class="field"> <div class="field">
...@@ -36,10 +21,9 @@ ...@@ -36,10 +21,9 @@
<%= form.text_area :description %> <%= form.text_area :description %>
</div> </div>
<div class="field"> <div>
<%= form.label :dated_id %> belongs to <%= itemdate.dated&.class %> <%= itemdate.dated&.title %>
<%= form.text_field :dated_id %> </div>
</div>
<div class="actions"> <div class="actions">
<%= form.submit %> <%= form.submit %>
......
json.extract! itemdate, :id, :value, :trunc, :datetext, :definitely, :description, :dated_id, :dated_type, :created_at, :updated_at json.extract! itemdate, :id, :definitely, :description, :dated_id, :dated_type, :created_at, :updated_at
json.edtfdate itemdate.edtfdate&.edtf
json.url itemdate_url(itemdate, format: :json) json.url itemdate_url(itemdate, format: :json)
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Value</th> <th>Date</th>
<th>Trunc</th>
<th>Datetext</th>
<th>Definitely</th>
<th>Description</th> <th>Description</th>
<th>Dated</th> <th>Dated</th>
<th colspan="3"></th> <th colspan="3"></th>
...@@ -16,14 +13,13 @@ ...@@ -16,14 +13,13 @@
</thead> </thead>
<tbody> <tbody>
<% @itemdates.each do |itemdate| %> <% @itemdates.each do |itemdate|
dated = itemdate.dated
%>
<tr> <tr>
<td><%= itemdate.value %></td> <td><%= itemdate.edtfdate&.edtf %></td>
<td><%= itemdate.trunc %></td> <td><%= itemdate.description %></td>
<td><%= itemdate.datetext %></td> <td><%= dated&.class %> <%= dated&.title %></td>
<td><%= itemdate.definitely %></td>
<td><%= itemdate.description %></td>
<td><%= itemdate.dated_id %></td>
<td><%= link_to 'Show', itemdate %></td> <td><%= link_to 'Show', itemdate %></td>
<td><%= link_to 'Edit', edit_itemdate_path(itemdate) %></td> <td><%= link_to 'Edit', edit_itemdate_path(itemdate) %></td>
<td><%= link_to 'Destroy', itemdate, method: :delete, data: { confirm: 'Are you sure?' } %></td> <td><%= link_to 'Destroy', itemdate, method: :delete, data: { confirm: 'Are you sure?' } %></td>
......
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<p> <p>
<strong>Value:</strong> <strong>Edtfdate:</strong>
<%= @itemdate.value %> <%= @itemdate.edtfdate&.edtf %>
</p> </p>
<p> <p>
<strong>Trunc:</strong> <strong>Description:</strong>
<%= @itemdate.trunc %> <%= @itemdate.description %>
</p> </p>
<p> <p>
<strong>Datetext:</strong> <strong>Value:</strong>
<%= @itemdate.datetext %> <%= @itemdate.value %>
</p> </p>
<p> <p>
<strong>Definitely:</strong> <strong>Trunc:</strong>
<%= @itemdate.definitely %> <%= @itemdate.trunc %>
</p> </p>
<p> <p>
<strong>Description:</strong> <strong>Definitely:</strong>
<%= @itemdate.description %> <%= @itemdate.definitely %>
</p> </p>
<p> <p>
<strong>Dated:</strong> <strong>Dated:</strong>
<%= @itemdate.dated_id %> <%= @itemdate.dated&.class %><br />
<%= @itemdate.dated&.title %>
</p> </p>
<%= link_to 'Edit', edit_itemdate_path(@itemdate) %> | <%= link_to 'Edit', edit_itemdate_path(@itemdate) %> |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment