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

Update Itemdate views to edtfdates (bugfix)

parent 28a26632
......@@ -22,6 +22,7 @@
class Itemdate < ApplicationRecord
# To play around we have this optional
belongs_to :dated, polymorphic: true, optional: true
# every dated should respond to title
attribute :edtfdate, :edtf
validates :edtfdate, presence: true
......
......@@ -12,23 +12,8 @@
<% end %>
<div class="field">
<%= form.label :value %>
<%= form.date_select :value %>
</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 %>
<%= form.label :date %>
<%= form.text_field :edtfdate, value: itemdate.edtfdate&.edtf %>
</div>
<div class="field">
......@@ -36,9 +21,8 @@
<%= form.text_area :description %>
</div>
<div class="field">
<%= form.label :dated_id %>
<%= form.text_field :dated_id %>
<div>
belongs to <%= itemdate.dated&.class %> <%= itemdate.dated&.title %>
</div>
<div class="actions">
......
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)
......@@ -5,10 +5,7 @@
<table>
<thead>
<tr>
<th>Value</th>
<th>Trunc</th>
<th>Datetext</th>
<th>Definitely</th>
<th>Date</th>
<th>Description</th>
<th>Dated</th>
<th colspan="3"></th>
......@@ -16,14 +13,13 @@
</thead>
<tbody>
<% @itemdates.each do |itemdate| %>
<% @itemdates.each do |itemdate|
dated = itemdate.dated
%>
<tr>
<td><%= itemdate.value %></td>
<td><%= itemdate.trunc %></td>
<td><%= itemdate.datetext %></td>
<td><%= itemdate.definitely %></td>
<td><%= itemdate.edtfdate&.edtf %></td>
<td><%= itemdate.description %></td>
<td><%= itemdate.dated_id %></td>
<td><%= dated&.class %> <%= dated&.title %></td>
<td><%= link_to 'Show', itemdate %></td>
<td><%= link_to 'Edit', edit_itemdate_path(itemdate) %></td>
<td><%= link_to 'Destroy', itemdate, method: :delete, data: { confirm: 'Are you sure?' } %></td>
......
<p id="notice"><%= notice %></p>
<p>
<strong>Value:</strong>
<%= @itemdate.value %>
<strong>Edtfdate:</strong>
<%= @itemdate.edtfdate&.edtf %>
</p>
<p>
<strong>Trunc:</strong>
<%= @itemdate.trunc %>
<strong>Description:</strong>
<%= @itemdate.description %>
</p>
<p>
<strong>Datetext:</strong>
<%= @itemdate.datetext %>
<strong>Value:</strong>
<%= @itemdate.value %>
</p>
<p>
<strong>Definitely:</strong>
<%= @itemdate.definitely %>
<strong>Trunc:</strong>
<%= @itemdate.trunc %>
</p>
<p>
<strong>Description:</strong>
<%= @itemdate.description %>
<strong>Definitely:</strong>
<%= @itemdate.definitely %>
</p>
<p>
<strong>Dated:</strong>
<%= @itemdate.dated_id %>
<%= @itemdate.dated&.class %><br />
<%= @itemdate.dated&.title %>
</p>
<%= 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