diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 0a2c03b..1c1160a 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -38,10 +38,9 @@
# POST /resource
def create
#logger.debug "#{sign_up_params}"
- if sign_up_params[:accept_terms] != "on" then
+ if !sign_up_params[:accept_terms] then
redirect_to after_sign_up_error_path_for(resource), alert: _('You must accept the terms and conditions to register.')
else
- sign_up_params[:accept_terms] = "1" # Convert the html 'on' to '1'
existing_user = User.find_by_email(sign_up_params[:email])
if !existing_user.nil? # If email exists
if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? # If user has not accepted invitation yet
@@ -115,7 +114,7 @@
message +=_('Please enter a Last name.') + ' '
mandatory_params &&= false
end
- if params[:user][:org_id].blank?
+ if params[:user][:org_id].blank? && params[:user][:other_organisation].blank?
message += _('Please select an organisation, or select Other.')
mandatory_params &&= false
end
@@ -188,7 +187,7 @@
def sign_up_params
params.require(:user).permit(:email, :password, :password_confirmation,
:firstname, :surname, :recovery_email,
- :accept_terms, :other_organisation)
+ :accept_terms, :org_id, :other_organisation)
end
def update_params
diff --git a/app/views/devise/registrations/_personal_details.html.erb b/app/views/devise/registrations/_personal_details.html.erb
index 4437580..ee0941f 100644
--- a/app/views/devise/registrations/_personal_details.html.erb
+++ b/app/views/devise/registrations/_personal_details.html.erb
@@ -56,7 +56,16 @@
default_selection: @default_org,
models: @orgs,
attribute: 'name',
- classes: 'left-indent'} %>
+ classes: 'left-indent input-medium'} %>
+
+ <% other_organisations = Org.where("parent_id IS ? AND is_other = ?", nil, true).pluck(:id) %>
+
+ <%= f.label _('Organisation Name'), for: :other_organisation %>
+ <%= f.text_field :other_organisation, :autocomplete => "off", :class => 'left-indent input-medium has-tooltip', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Please enter the name of your organisation.') %>
+
<% if MANY_LANGUAGES %>
diff --git a/app/views/shared/_register_form.html.erb b/app/views/shared/_register_form.html.erb
index 081a0a4..9783973 100644
--- a/app/views/shared/_register_form.html.erb
+++ b/app/views/shared/_register_form.html.erb
@@ -22,16 +22,24 @@
+
- <%= 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 }) %>
-
-
- <% other_organisations = Org.where("parent_id IS ? AND is_other = ?", nil, true).pluck(:id) %>
-
diff --git a/lib/assets/javascripts/views/devise/registrations/edit.js b/lib/assets/javascripts/views/devise/registrations/edit.js
index ce67491..9d1eabb 100644
--- a/lib/assets/javascripts/views/devise/registrations/edit.js
+++ b/lib/assets/javascripts/views/devise/registrations/edit.js
@@ -30,6 +30,28 @@
// Make sure the show password checkbox is unchecked on load
$("#password_show").attr("checked", false);
+ $('#user_org_name').on("change", function(e) {
+ e.preventDefault();
+ var selected_org = $(this).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-org-name").attr("data-orgs").split(",");
+ $("#user_org_name").val("");
+ $("#user_org_id").val("");
+ $("#user_org_name").change();
+ });
+
toggleSubmit();
function validateEmailsDoNotMatch(){
diff --git a/lib/assets/javascripts/views/shared/register_form.js b/lib/assets/javascripts/views/shared/register_form.js
index d5b3416..6262248 100644
--- a/lib/assets/javascripts/views/shared/register_form.js
+++ b/lib/assets/javascripts/views/shared/register_form.js
@@ -26,9 +26,9 @@
$("form.register-form #user_password").attr('type', (typ === 'password' ? 'text' : 'password'));
});
- $('#user_org_id').on("change", function(e) {
+ $('#user_org_name').on("change", function(e) {
e.preventDefault();
- var selected_org = $(this).select2("val");
+ var selected_org = $(this).val();
var other_orgs = $("#other-org-name").attr("data-orgs").split(",");
var index = $.inArray(selected_org, other_orgs);
if (index > -1) {
@@ -43,9 +43,9 @@
$("#other-org-link > a").click(function(e){
e.preventDefault();
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_org_name").val("");
+ $("#user_org_id").val("");
+ $("#user_org_name").change();
});
// Run the validations in case the page was refreshed
diff --git a/lib/assets/stylesheets/dmproadmap/forms.scss b/lib/assets/stylesheets/dmproadmap/forms.scss
index 90aac1e..d3f0e38 100644
--- a/lib/assets/stylesheets/dmproadmap/forms.scss
+++ b/lib/assets/stylesheets/dmproadmap/forms.scss
@@ -402,13 +402,12 @@
position: relative;
.combobox-container {
- width: 65%;
+ width: 30%;
}
.js-combobox {
width: 95%;
}
.combobox-suggestions {
- margin-left: 15px;
width: 98%
}
}
@@ -446,6 +445,7 @@
input[type="password"],
#user_password,
+ #user_other_organisation,
input[type="email"] {
width: 90%;
}