diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 0f4d59b..212d014 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -282,6 +282,30 @@ end end +<<<<<<< HEAD +======= + # GET /plans/[:plan_slug]/public_export + # ------------------------------------------------------------- + def public_export + @plan = Plan.find(params[:id]) + authorize @plan + # If the plan has multiple phases we should export each + @exported_plan = ExportedPlan.new.tap do |ep| + ep.plan = @plan + ep.phase_id = @plan.phases.first.id + ep.format = :pdf + plan_settings = @plan.settings(:export) + + Settings::Template::DEFAULT_SETTINGS.each do |key, value| + ep.settings(:export).send("#{key}=", plan_settings.send(key)) + end + end + # need to determine which phases to export + @a_q_ids = Answer.where(plan_id: @plan.id).pluck(:question_id).uniq + @a_s_ids = Question.where(id: @a_q_ids).pluck(:section_id).uniq + a_p_ids = Section.where(id: @a_s_ids).pluck(:phase_id).uniq + @phases = Phase.includes(sections: :questions).where(id: a_p_ids).order(:number) +>>>>>>> upstream/CDL-MVP def duplicate 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/policies/plan_policy.rb b/app/policies/plan_policy.rb index b3630bc..762b0b7 100644 --- a/app/policies/plan_policy.rb +++ b/app/policies/plan_policy.rb @@ -3,7 +3,7 @@ attr_reader :plan def initialize(user, plan) - raise Pundit::NotAuthorizedError, "must be logged in" unless user + raise Pundit::NotAuthorizedError, "must be logged in" unless user || plan.publicly_visible? @user = user @plan = plan end 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 bfe2220..d3f0e38 100644 --- a/lib/assets/stylesheets/dmproadmap/forms.scss +++ b/lib/assets/stylesheets/dmproadmap/forms.scss @@ -3,7 +3,7 @@ /* The top of this file is generic form styles and */ /* the bottom contains page specific changes to the generic */ /* ================================================ */ -textarea, +textarea, input[type="text"], input[type="email"], input[type="password"], input[type="search"], select { font-family: $font-family; @@ -67,7 +67,7 @@ div.under-input { display: block; margin: -5px 0 10px; - + label { font-weight: normal; } @@ -105,7 +105,7 @@ margin: 10px 5px 15px 15px; width: 70%; } - + label, input[type="checkbox"], .combobox-container, @@ -140,7 +140,7 @@ /* ------------------------------------------ */ fieldset.side-by-side { border: 0; - + .mce-tinymce { display: inline-block; margin-bottom: 15px; @@ -149,7 +149,7 @@ div.under-input { margin-left: 25%; - + label { width: auto; } @@ -204,17 +204,11 @@ float: left; /* positions the legend within the fieldset box */ border-bottom: none; } - - label:not(.regular-text) { - font-weight: bold; - } - label:not(.no-colon):not(.checkbox-label):after { - content: " :"; - } + label.required:before { content: "* "; } - + .form-input { clear: both; } @@ -293,7 +287,7 @@ position: absolute; z-index: 9; } - + .error-tooltip[role='alert']:before, .submit-tooltip[role='tooltip']:before { display: inline; position: absolute; @@ -303,7 +297,7 @@ color: $error-background; font-size: 44px; } - + .error-tooltip-top[role='alert'] { top: -35px; left: 0; @@ -406,15 +400,14 @@ /* Allows for an auto-complete box in a side-by-side form */ div.accessible-combobox-smaller { position: relative; - + .combobox-container { - width: 65%; + width: 30%; } .js-combobox { width: 95%; } .combobox-suggestions { - margin-left: 15px; width: 98% } } @@ -433,7 +426,7 @@ display: block; width: 100%; margin-bottom: 10px; - + .omniauth-login { display: inline-block; width: 90%; @@ -452,6 +445,7 @@ input[type="password"], #user_password, + #user_other_organisation, input[type="email"] { width: 90%; } @@ -482,7 +476,7 @@ float: right; } } - + .checkbox-right-side-by-side { width: 65%; } @@ -610,7 +604,7 @@ ul { top: 8px; left: 0; - + li a { text-decoration: none; } @@ -621,11 +615,11 @@ /* ------------------------------------------------ */ #create_plan { position: relative; - + fieldset { margin-bottom: 10px; } - + #plan_title { display: block; margin-bottom: 5px; @@ -679,21 +673,21 @@ vertical-align: top; display: inline-block; width: 35%; - + h2 { margin-top: 0; } - + ul { list-style: none; } - + .fa { vertical-align: top; font-size: 18px; margin-left: 5px; } - + fieldset.standard { label { margin-left: 0; @@ -706,7 +700,7 @@ #sections-accordion-controls { width: 55%; margin: 15px 0 15px 45px; - + a { text-decoration: none; } @@ -748,7 +742,7 @@ /* Section title / progress */ h2 { font-size: 18px; - + .section-title { color: $white; background-color: $primary-color; @@ -756,7 +750,7 @@ height: 100%; padding: 0 0 10px 10px; margin-bottom: -10px; - + .section-status { position: absolute; top: 10px; @@ -764,7 +758,7 @@ width: 55%; text-align: right; font-size: 16px; - + .fa { font-size: 14px; position: absolute; @@ -775,7 +769,7 @@ } } } - + .answer-unsaved { position: relative; right: -205px; @@ -785,7 +779,7 @@ padding: 5px 10px; border-radius: 3px; } - + .section-description { width: 60%; } @@ -797,7 +791,7 @@ border: 0.5px solid $light-grey; border-radius: 3px; padding: 5px 15px; - + .suggested-answer-intro { position: relative; top: -17px; @@ -810,7 +804,7 @@ margin-top: -20px; } } - + .form-input { margin-top: -10px; @@ -818,7 +812,7 @@ list-style: none; } } - + div.mce-tinymce { width: 84%; } @@ -834,18 +828,18 @@ min-height: auto; } } - + .comment-area { .div-table-content { - max-height: 200px; + max-height: 200px; overflow-y: auto; border-bottom: 1px solid $primary-color; - + .dmp_table { margin-top: 40px; border: none; border-top: 1px solid $primary-color; - + tr { border-bottom: 1px solid $light-grey; } @@ -868,11 +862,11 @@ label, div { vertical-align: top; } - + img { border: 1px dashed $medium-grey; } - + #logo-controls { width: 50%; label { @@ -909,4 +903,4 @@ display: inline-block; } } -} \ No newline at end of file +}