diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb
index 75aa6dc..a693330 100644
--- a/app/controllers/plans_controller.rb
+++ b/app/controllers/plans_controller.rb
@@ -26,16 +26,9 @@
respond_to :html
end
-
- # GET /plans/possible_templates [JSON]
- # ------------------------------------------------------------------------------------
- def possible_templates
-
- end
-
# POST /plans
- # ------------------------------------------------------------------------------------
+ # -------------------------------------------------------------------
def create
@plan = Plan.new
authorize @plan
@@ -44,6 +37,13 @@
@plan.data_contact = current_user.email
@plan.funder_name = plan_params[:funder_name]
+ if plan_params[:title].blank?
+ @plan.title = current_user.firstname.blank? ? _('My Plan') :
+ current_user.firstname + "'s" + _(" Plan")
+ else
+ @plan.title = plan_params[:title]
+ end
+
# If a template hasn't been identified look for the available templates
if plan_params[:template_id].blank?
template_options(plan_params[:org_id], plan_params[:funder_id])
@@ -59,6 +59,10 @@
# Otherwise create the plan
else
@plan.template = Template.find(plan_params[:template_id])
+
+puts "CREATING"
+puts @plan.inspect
+
=begin
if @plan.save
@plan.assign_creator(current_user)
diff --git a/app/views/plans/new.html.erb b/app/views/plans/new.html.erb
index 92f3565..620c3dd 100644
--- a/app/views/plans/new.html.erb
+++ b/app/views/plans/new.html.erb
@@ -18,9 +18,9 @@
<%= _('Project title') %>
- <% default_name = (current_user.firstname.blank? ? _('My Plan') : current_user.firstname + _(' Plan')) %>
-
-
+ <% default_name = (current_user.firstname.blank? ? _('My Plan') : current_user.firstname + "'s" + _(" Plan")) %>
+
+
<%= _('If applying for funding, state the title exactly as in the proposal.') %>
diff --git a/app/views/shared/_accessible_combobox.html.erb b/app/views/shared/_accessible_combobox.html.erb
index 1d05151..b340883 100644
--- a/app/views/shared/_accessible_combobox.html.erb
+++ b/app/views/shared/_accessible_combobox.html.erb
@@ -20,6 +20,7 @@
" name="<%= name.gsub("_#{attribute}]", "_id]") %>"
value="<%= default_selection.id unless default_selection.nil? %>" />
+
<% else %>
<%= _('No items available.') %>
diff --git a/lib/assets/javascripts/new_plan.js b/lib/assets/javascripts/new_plan.js
index 5b3a6af..1b18bc2 100644
--- a/lib/assets/javascripts/new_plan.js
+++ b/lib/assets/javascripts/new_plan.js
@@ -3,21 +3,32 @@
$(".form-submit").prop("disabled", true);
$("#available-templates").hide();
+ // retrieve the template options and toggle the submit button on page reload
+ handleComboboxChange();
+ handleCheckboxClick("org", $("#plan_no_org").prop("checked"));
+ handleCheckboxClick("funder", $("#plan_no_funder").prop("checked"));
+
// When the hidden org and funder id fields change toogle the submit button
$("#plan_org_id, #plan_funder_id").change(function(){
- retrieveTemplateOptions();
+ handleComboboxChange();
});
-
- // If the user clicks the no Organisation checkbox disable the dropdown and hide clear button
+
+ $(".js-combobox").keyup(function(){
+ var whichOne = $(this).prop('id').split('_')[1];
+ $("#plan_no_" + whichOne).prop("checked", false);
+ });
+
+ // If the user clicks the no Org/Funder checkbox disable the dropdown
+ // and hide clear button
$("#plan_no_org, #plan_no_funder").click(function(){
- var whichOne = $(this).prop('id').split('_')[2];
- $("#plan_" + whichOne + "_name").prop("disabled", this.checked).val("").keyup();
+ var whichOne = $(this).prop('id').split('_')[2];
+ handleCheckboxClick(whichOne, this.checked);
});
});
// Only display the submit button if the user has made each decision
// -------------------------------------------------------------
-function retrieveTemplateOptions(){
+function handleComboboxChange(){
// If the (no_org checkbox is checked OR an org was selected) AND
// (no_funder checkbox is checked OR a funder was selected)
var retrieve = ($("#plan_no_org").prop("checked") ||
@@ -27,12 +38,29 @@
$("#available-templates").fadeOut();
$("#plan_template_id").val("");
- $(".form-submit").prop('disabled', true);
-
+
if(retrieve){
+ $(".form-submit").prop('disabled', false);
+
// If the templates section isn't available then submit the form to find the template options
if($("#available_templates").html() == undefined){
$("form").submit();
}
+
+ }else{
+ $(".form-submit").prop('disabled', true);
}
}
+
+// Clear the combobox and disable it if the box was checked
+// -------------------------------------------------------------
+function handleCheckboxClick(name, checked){
+ $("#plan_" + name + "_name").prop("disabled", checked);
+ if(checked){
+ $("#plan_" + name + "_name").val("");
+ $("#plan_" + name + "_id").val("").change();
+ $("#plan_" + name + "_name").siblings(".combobox-clear-button").hide();
+ }else{
+ $(".form-submit").prop('disabled', true);
+ }
+}
diff --git a/lib/assets/stylesheets/dmproadmap.scss b/lib/assets/stylesheets/dmproadmap.scss
index df80e0b..f858f4a 100644
--- a/lib/assets/stylesheets/dmproadmap.scss
+++ b/lib/assets/stylesheets/dmproadmap.scss
@@ -15,53 +15,55 @@
}
.main_header {
- margin-bottom: 20px;
+ margin-bottom: 20px;
}
.main {
-
- form {
-
- .white-fieldset {
- background-color: $white;
- padding: 0 25px 25px 25px;
- margin-bottom: 25px;
-
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
-
- label, input[type="checkbox"], .combobox-container {
- margin-left: 15px;
- }
-
- input[type="text"] {
- width: 450px;
- margin-bottom: 15px;
- margin-left: 15px;
- }
-
- input[type="checkbox"] {
- vertical-align: top;
- }
- }
-
- button.form-submit {
- background-color: $primary-color;
- color: $reverse-text;
- padding: 10px 30px;
- font-size: 12pt;
-
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- }
- button.form-submit:disabled {
- background-color: $disabled-button-color;
- }
-
- }
-
+
+ form {
+
+ .white-fieldset {
+ background-color: $white;
+ padding: 0 25px 25px 25px;
+ margin-bottom: 25px;
+
+ -webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
+ border-radius: 10px;
+
+ label,
+ input[type="checkbox"],
+ .combobox-container,
+ .combobox-like {
+ margin-left: 15px;
+ }
+
+ input[type="text"] {
+ width: 550px;
+ margin-bottom: 15px;
+ }
+
+ input[type="checkbox"] {
+ vertical-align: top;
+ }
+ }
+
+ input.form-submit {
+ background-color: $primary-color;
+ color: $reverse-text;
+ padding: 10px 30px;
+ font-size: 12pt;
+
+ -webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
+ border-radius: 10px;
+ }
+ input.form-submit:disabled {
+ background-color: $disabled-button-color;
+ }
+
+ }
+
}
/* Accessible JQuery combobox */
@@ -79,25 +81,25 @@
.combobox-container {
position: relative;
- max-width: 385px;
-
- font-family: $font-family;
+ max-width: 385px;
+
+ font-family: $font-family;
}
.combobox-suggestions {
position: absolute;
left: 0;
width: 362px;
- margin-top: -10px;
+ margin-top: -10px;
background: #fff;
- z-index: 99;
+ z-index: 99;
}
.combobox-suggestion {
color: #666;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
border-right: 1px solid #000;
- padding: 5px 10px 5px 10px;
+ padding: 5px 10px 5px 10px;
cursor: pointer;
text-align: left;
}
@@ -107,17 +109,17 @@
.combobox-suggestion:hover,
.combobox-suggestion:focus {
color: $white;
- background-color: $primary-color;
+ background-color: $primary-color;
}
.combobox-clear-button {
- @include icon(times-circle);
- display: inline;
+ @include icon(times-circle);
+ display: inline;
position: absolute;
- border: none;
- background: transparent;
- padding-top: 3px;
- font-size: 16pt;
+ border: none;
+ background: transparent;
+ padding-top: 3px;
+ font-size: 16pt;
}
/* http://geektnt.com/how-to-remove-x-from-search-input-field-on-chrome-and-ie.html */