Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/assets/javascripts/student_thesis_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ function conditionalLicenseField() {
var value = $("select#thesis_copyright_id option:selected").text();
if ('I hold copyright' == value) {
$("div.thesis_license").show();
$("select#thesis_license_id").prop('required', true);
} else {
$("div.thesis_license").hide();
$("select#thesis_license_id")[0].value = "";
$("select#thesis_license_id").prop('required', false);
}
};

Expand Down
1 change: 1 addition & 0 deletions app/models/thesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Thesis < ApplicationRecord

VALIDATION_MSGS = {
copyright: 'Required - Please identify the copyright holder.',
license: 'Required - Please identify the license type.',
graduation_year: 'Required - Please input your year of graduation.',
graduation_month: 'Required - Please select your month of graduation.',
departments: 'Required - Please select your primary department.',
Expand Down
6 changes: 4 additions & 2 deletions app/views/thesis/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
</div>

<%= f.association :copyright, as: :select,
selected: @thesis.copyright.present? ? @thesis.copyright.id : 2,
required: true,
collection: Copyright.display_to_author,
validate: { present: true },
Expand All @@ -142,12 +143,13 @@

<%= f.association :license, as: :select,
include_hidden: false,
label: 'License (if you retain copyright)',
label: 'License (if you retain copyright) *',
label_method: :display_description,
label_html: { class: 'col1q' },
wrapper_html: { class: 'field-row select layout-1q3q layout-band' },
input_html: { class: 'field field-select col3q', multiple: false,
aria: { describedby: 'thesis_license-hint' } },
aria: { describedby: 'thesis_license-hint' },
data: { msg: Thesis::VALIDATION_MSGS[:license] } },
hint: 'Not sure what to select? Learn more about <a href="https://chooser-beta.creativecommons.org/" target="_blank">Creative Commons licenses</a>.'.html_safe,
hint_html: { class: 'col3q', id: 'thesis_license-hint' } %>

Expand Down
6 changes: 4 additions & 2 deletions app/views/thesis/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
</div>

<%= f.association :copyright, as: :select,
selected: 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if for the edit view we can do something like selected: 2 if license.nil? (not real code). My reasoning is that because of the registrar data load pre-creating theses, I think most users hit the edit form and not the new form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. I'll see what options we have there.

required: true,
collection: Copyright.display_to_author,
validate: { presence: true },
Expand All @@ -140,12 +141,13 @@

<%= f.association :license, as: :select,
include_hidden: false,
label: 'License (if you retain copyright)',
label: 'License (if you retain copyright) *',
label_method: :display_description,
label_html: { class: 'col1q' },
wrapper_html: { class: 'field-row select layout-1q3q layout-band' },
input_html: { class: 'field field-select col3q', multiple: false,
aria: { describedby: 'thesis_license-hint' } },
aria: { describedby: 'thesis_license-hint' },
data: { msg: Thesis::VALIDATION_MSGS[:license] } },
hint: 'Not sure what to select? Learn more about <a href="https://chooser-beta.creativecommons.org/" target="_blank">Creative Commons licenses</a>.'.html_safe,
hint_html: { class: 'col3q', id: 'thesis_license-hint' } %>

Expand Down