Skip to content

Commit

Permalink
Added UNA date fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Simpson committed Feb 26, 2024
1 parent 6212ef5 commit f11327d
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/views/una/_date_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="form-group <%= "#{template}_date_#{date_type}" %>">
<label class="control-label" for="<%= "#{template}_date_#{date_type}" %>"><%= t("simple_form.labels.defaults.date_#{date_type}") %></label>
<span class="label label-info required-tag">required</span>
<p class="help-block"><%= t("simple_form.hints.defaults.date_#{date_type}") %></p>

<div class="form-inline <%= "date_#{date_type}" %>">

<% # The form-group class "#{template}_date_#{date_type}_..." is used for DOI auto population %>
<div class="form-group <%= "#{template}_date_#{date_type}_year" %>">
<%= select_year(f.object.model.send("date_#{date_type}").to_s.split('-')[0].to_i, {start_year: (Date.today.year + 6), end_year: 1750, prompt: "Select year"}, {id: "#{template}_date_#{date_type}__date_#{date_type}_year", name: "#{template}[date_#{date_type}][][date_#{date_type}_year]", class: "form-control ubiquity-date-#{date_type}-year ubiquity-date-input #{template}_date_#{date_type}_year", required: true}) %>
</div>
<div class="form-group <%= "#{template}_date_#{date_type}_month" %>">
<%= select_month(f.object.model.send("date_#{date_type}").to_s.split('-')[1].to_i, { use_two_digit_numbers: true, prompt: 'select month if available'}, {id: "#{template}_date_#{date_type}__date_#{date_type}_month", name: "#{template}[date_#{date_type}][][date_#{date_type}_month]", class: "form-control ubiquity-date-#{date_type}-month ubiquity-date-input #{template}_date_#{date_type}_month" }) %>
</div>
<div class="form-group <%= "#{template}_date_#{date_type}_day" %>">
<%= select_day(f.object.model.send("date_#{date_type}").to_s.split('-')[2].to_i, { use_two_digit_numbers: true, prompt: 'select day if available'}, {id: "#{template}_date_#{date_type}__date_#{date_type}_day", name: "#{template}[date_#{date_type}][][date_#{date_type}_day]", class: "form-control ubiquity-date-#{date_type}-day ubiquity-date-input #{template}_date_#{date_type}_day" }) %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
4 changes: 4 additions & 0 deletions app/views/una_articles/edit_fields/_date_published.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
4 changes: 4 additions & 0 deletions app/views/una_books/edit_fields/_date_published.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
4 changes: 4 additions & 0 deletions app/views/una_images/edit_fields/_date_published.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# see app/views/records/edit_fields/_date_published.html.erb %>
<% template = f.object.model.class.to_s.underscore %>

<%= render "una/date_fields", date_type: "published", template: template, f: f %>
6 changes: 6 additions & 0 deletions lib/hyku_knapsack/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module HykuKnapsack
class Engine < ::Rails::Engine
isolate_namespace HykuKnapsack

initializer "load_features" do
# Features from config/features.rb in your engine are merged with
# any application features.
Flipflop::FeatureLoader.current.append(self)
end

initializer :append_migrations do |app|
# only add the migrations if they are not already copied
# via the rake task. Allows gem to work both with the install:migrations
Expand Down

0 comments on commit f11327d

Please sign in to comment.