From f11327dbbccbcea9607d7e9811ecfbf11509f76d Mon Sep 17 00:00:00 2001 From: Martin Simpson Date: Mon, 26 Feb 2024 14:59:04 +0700 Subject: [PATCH] Added UNA date fields --- app/views/una/_date_fields.html.erb | 19 +++++++++++++++++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ .../edit_fields/_date_published.html.erb | 4 ++++ lib/hyku_knapsack/engine.rb | 6 ++++++ 10 files changed, 57 insertions(+) create mode 100644 app/views/una/_date_fields.html.erb create mode 100644 app/views/una_archival_items/edit_fields/_date_published.html.erb create mode 100644 app/views/una_articles/edit_fields/_date_published.html.erb create mode 100644 app/views/una_books/edit_fields/_date_published.html.erb create mode 100644 app/views/una_chapters_and_book_sections/edit_fields/_date_published.html.erb create mode 100644 app/views/una_images/edit_fields/_date_published.html.erb create mode 100644 app/views/una_presentations/edit_fields/_date_published.html.erb create mode 100644 app/views/una_thesis_or_dissertations/edit_fields/_date_published.html.erb create mode 100644 app/views/una_time_based_medias/edit_fields/_date_published.html.erb diff --git a/app/views/una/_date_fields.html.erb b/app/views/una/_date_fields.html.erb new file mode 100644 index 0000000..46595e1 --- /dev/null +++ b/app/views/una/_date_fields.html.erb @@ -0,0 +1,19 @@ +
"> + + required +

<%= t("simple_form.hints.defaults.date_#{date_type}") %>

+ +
"> + + <% # The form-group class "#{template}_date_#{date_type}_..." is used for DOI auto population %> +
"> + <%= 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}) %> +
+
"> + <%= 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" }) %> +
+
"> + <%= 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" }) %> +
+
+
diff --git a/app/views/una_archival_items/edit_fields/_date_published.html.erb b/app/views/una_archival_items/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_archival_items/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_articles/edit_fields/_date_published.html.erb b/app/views/una_articles/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_articles/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_books/edit_fields/_date_published.html.erb b/app/views/una_books/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_books/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_chapters_and_book_sections/edit_fields/_date_published.html.erb b/app/views/una_chapters_and_book_sections/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_chapters_and_book_sections/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_images/edit_fields/_date_published.html.erb b/app/views/una_images/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_images/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_presentations/edit_fields/_date_published.html.erb b/app/views/una_presentations/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_presentations/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_thesis_or_dissertations/edit_fields/_date_published.html.erb b/app/views/una_thesis_or_dissertations/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_thesis_or_dissertations/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/app/views/una_time_based_medias/edit_fields/_date_published.html.erb b/app/views/una_time_based_medias/edit_fields/_date_published.html.erb new file mode 100644 index 0000000..1810d2f --- /dev/null +++ b/app/views/una_time_based_medias/edit_fields/_date_published.html.erb @@ -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 %> diff --git a/lib/hyku_knapsack/engine.rb b/lib/hyku_knapsack/engine.rb index 1ba2361..322f175 100644 --- a/lib/hyku_knapsack/engine.rb +++ b/lib/hyku_knapsack/engine.rb @@ -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