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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions app/views/shared/_register_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
<%= f.hidden_field "user_identifiers[#{scheme}]", value: resource.user_identifiers.first.identifier%>
<% end %>
<li>
<%= collection_select(:user, :org_id, Org.where("parent_id IS NULL").order("sort_name ASC, name ASC"), :id, :name, {include_blank: _('Organisation')}, { :class => 'typeahead org_sign_up' }) %>
<%= collection_select(:user, :org_id, Org.where("parent_id IS NULL").order("sort_name ASC, name ASC"), :id, :name, {include_blank: _('Organisation')}, { :class => 'typeahead org_sign_up', 'data-allow-clear': false }) %>
</li>
<div id="other-org-link"><a href="#"><%= _("My organisation isn't listed.") %></a></div>
<% other_organisations = Array.new %>
<% Org.where("parent_id IS ? AND is_other = ?", nil, true).each do |org| %>
<% other_organisations << org.id %>
<% end %>
<li id="other-organisation-name" style="display:none" data-orgs="<%= other_organisations.join(',') %>">
<div id="other-org-link"><a href="#"><%= _("My organisation isn't listed.") %></a></div>
<% other_organisations = Org.where("parent_id IS ? AND is_other = ?", nil, true).pluck(:id) %>
<li id="other-org-name" style="display:none" data-orgs="<%= other_organisations.join(',') %>">
<%= f.text_field :other_organisation, placeholder: ( _('Organisation name') + ' *'), :as => :string , :autocomplete => "off", :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Please enter the name of your organisation.') %>
</li>
<li>
Expand Down
22 changes: 18 additions & 4 deletions lib/assets/javascripts/shared/register_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@ $(document).ready(function() {
allowClear: true
});
// TODO removing once the new create account functionality is in place
$('#user_org_id').on("change", function(e) {
e.preventDefault();
var selected_org = $(this).select2("val");
var other_orgs = $("#other-org-name").attr("data-orgs").split(",");
var index = $.inArray(selected_org, other_orgs);
if (index > -1) {
$("#other-org-name").show();
$("#user_other_organisation").focus();
}
else {
$("#other-org-name").hide();
$("#user_other_organisation").val("");
}
});
$("#other-org-link > a").click(function(e){
e.preventDefault();
var other_org = $("#other-organisation-name").attr("data-orgs").split(",");
$("#user_organisation_id").select2("val", other_org);
$("#other-org-link").hide();
$("#user_organisation_id").change();
var other_org = $("#other-org-name").attr("data-orgs").split(",");
$("#user_org_id").select2("val", other_org);
$("#user_org_id").change();
//$("#other-org-link").hide();
});
$("#user_email.text_field.reg-input").change(function(){
if (email_regex.test($(this).val())) {
Expand Down