Skip to content

Commit

Permalink
more javascript twist
Browse files Browse the repository at this point in the history
  • Loading branch information
whomingbird committed Jan 14, 2025
1 parent aff30dc commit 81dba73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/ror/institution-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ $j(document).ready(function () {
fetchRorData($j('#institution_ror_id').val());
});

// if the institution title is not selected from the local list or ROR, but entered manually by user
$j('#institution_name').on('change', function () {
const inputValue = $j(this).val();
$j('#institution_title').val(inputValue);
checkSubmitButtonEnabled();
});


$j('#combined_typeahead .typeahead').typeahead(
{
Expand Down
2 changes: 1 addition & 1 deletion app/views/institutions/_select_or_define.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>

<label class="control-label">Type the name of the <%= t('institution'.downcase) %> </label><span class="required">*</span>
<%= text_field_tag :search, nil, placeholder: "Search...", class: "form-control typeahead" %>
<%= text_field_tag :institution_name, nil, placeholder: "Search...", class: "form-control typeahead" %>
<small id="new_institution_reminder" style="display: none; color:darkseagreen; ">
This institution is not in <%= Seek::Config.instance_name %>. You will create this new institution along with your project.
</small>
Expand Down
8 changes: 4 additions & 4 deletions app/views/projects/guided_create.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@

function checkSubmitButtonEnabled() {
var progEnabled = <%= Seek::ProjectFormProgrammeOptions.show_programme_box? %>;
var enabled = $j('#institution_title').val()
&& !progEnabled || ($j('#programme_id').val() || $j('input#programme_title').val())
var enabled = $j('input#institution_name').val()
&& $j('input#project_title').val()
&& $j('input#institution_title').val();
&& $j('input#institution_title').val()
&& !progEnabled || ($j('#programme_id').val() || $j('input#programme_title').val());
$j('#submit-button').prop('disabled',!enabled);
}

Expand Down Expand Up @@ -104,7 +104,7 @@
checkSubmitButtonEnabled();
});

$j('input#project_title').on('input',function() {
$j('input#project_title').on('change',function() {
checkSubmitButtonEnabled();
});

Expand Down

0 comments on commit 81dba73

Please sign in to comment.