Skip to content

Commit

Permalink
Simplify the form view for entering institution data.
Browse files Browse the repository at this point in the history
  • Loading branch information
whomingbird committed Dec 13, 2024
1 parent dba83bf commit 6438f03
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 84 deletions.
11 changes: 3 additions & 8 deletions app/assets/javascripts/ror/institution-typeahead.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
var ROR_API_URL = "https://api.ror.org/organizations";

function extractRorId(rorUrl) {
// Define the regular expression to match the ROR ID
const regex = /https:\/\/ror\.org\/([^\/]+)/;

// Try to match the URL with the regex
const match = rorUrl.match(regex);

// If a match is found, return the extracted ROR ID
if (match) {
return match[1]; // Return the captured ID
return match[1];
} else {
return null; // Return null if no match is found
return null;
}
}

Expand Down Expand Up @@ -68,7 +63,7 @@ $j(document).ready(function() {
templates: {
pending: [
'<div class="empty-message">',
'Fetching organizations list',
'Fetching list ...',
'</div>'
].join('\n'),
suggestion: function (data) {
Expand Down
39 changes: 8 additions & 31 deletions app/views/institutions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
<%= f.error_messages -%>

<div class="form-group">
<%= f.label :title, 'Name', class: 'required' -%>
<%= f.text_field :title, :class=>"form-control" -%>
<div>
<div class="tab-pane fade active in" id="search-by-name-tab" role="tabpanel" aria-labelledby="search-by-name-tab">
<%= render partial: 'institution_fields', locals: {f:f, institution:institution} %>
</div>
</div>

<div class="form-group">
<%= f.label :ror_id, 'ROR ID' -%>
<%= f.text_field :ror_id, :class=>"form-control" -%>
<small class="form-text text-muted">
<em>The ROR ID (Research Organization Registry Identifier) is a unique 9-character alphanumeric code (e.g., 01f7bcy98).
Please do not include the prefix (e.g., https://ror.org/).</em>
</small>
</div>
<%= render :partial=> "assets/discussion_links_form", :locals=>{:resource => @institution} -%>

<div class="form-group">
<%= f.label :web_page -%>
<%= f.text_field :web_page, :class=>"form-control" -%>
</div>

<div class="form-group">
<%= f.label :address -%>
<%= f.text_area :address, :rows => 5, :class=>"form-control" -%>
</div>

<div class="form-group">
<%= f.label :city -%>
<%= f.text_field :city, :class=>"form-control" -%>
</div>

<div class="form-group">
<%= f.label :country -%>
<%= f.country_select :country, { include_blank: 'Please select...' }, class: 'form-control' -%>
</div>
<%= f.submit(institution ? "Update" : "Create",data: { disable_with: (institution ? "Updating..." : "Creating...") },
:class => 'btn btn-primary') -%> or
<%= cancel_button(institution ? institution_path(institution.id) : institutions_path) -%>

40 changes: 0 additions & 40 deletions app/views/institutions/_multi_tabs.erb

This file was deleted.

5 changes: 1 addition & 4 deletions app/views/institutions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

<div class="asset_form">
<%= form_for(@institution) do |f| %>
<%= render :partial => "form", :locals => { :f => f, :institution => @institution } -%>
<%= render :partial=> "assets/discussion_links_form", :locals=>{:resource => @institution} -%>
<%= f.submit("Update", data: { disable_with: ("Updating...") }, class: 'btn btn-primary') %> or
<%= cancel_button(institutions_path) %>
<%= render partial: "form", locals: { f:f, institution:@institution } -%>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/institutions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<div class="asset_form">
<%= form_for(@institution) do |f| %>
<%= render partial: 'multi_tabs', locals: {f:f, institution:nil } %>
<%= render partial: 'form', locals: { f:f, institution:nil } %>
<% end %>
</div>

0 comments on commit 6438f03

Please sign in to comment.