diff --git a/app/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb index a262cb3..e83366b 100644 --- a/app/controllers/annotations_controller.rb +++ b/app/controllers/annotations_controller.rb @@ -4,18 +4,36 @@ #create annotations def admin_create - @example_answer = Annotation.new(params[:annotation]) - authorize @example_answer - if @example_answer.save - redirect_to admin_show_phase_path(id: @example_answer.question.section.phase_id, section_id: @example_answer.question.section_id, question_id: @example_answer.question.id, edit: 'true'), notice: _('Information was successfully created.') + # authorize the question (includes to reduce queries) + @question = Question.includes(section: { phase: :template}).find(params[:question_id]) + authorize @question + if params[:example_answer_text].present? + example_answer = init_annotation(params[:example_answer_text], @question, current_user.org, Annotation.types[:example_answer]) + end + if params[:guidance_text].present? + guidance = init_annotation(params[:guidance_text], @question, current_user.org, Annotation.types[:guidance]) + end + # if they dont exist, no requirement for them to be saved + ex_save = example_answer.present? ? example_answer.save : true + guid_save = guidance.present? ? guidance.save : true + + if ex_save && guid_save + redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: _('Information was successfully created.') else - @section = @example_answer.question.section + @section = @question.section @phase = @section.phase @open = true @sections = @phase.sections @section_id = @section.id @question_id = @example_answer.question - flash[:notice] = failed_create_error(@example_answer, _('example answer')) + if !ex_save && !guid_save + flash[:notice] = failed_create_error(example_answer, _('example answer')) + '\n' + + failed_create_error(gudiance, _('guidance')) + elsif !guid_save + flash[:notice] = failed_create_error(gudiance, _('guidance')) + elsif !ex_save + flash[:notice] = failed_create_error(example_answer, _('example answer')) + end render "phases/admin_show" end end @@ -23,15 +41,49 @@ #update a example answer of a template def admin_update - @example_answer = Annotation.includes(question: { section: {phase: :template}}).find(params[:id]) - authorize @example_answer #.question.section.phase.template - @question = @example_answer.question + @question = Question.includes(section: { phase: :template}).find(params[:question_id]) + if params[:guidance_id].present? + guidance = Annotation.includes(question: {section: {phase: :template}}).find(params[:guidance_id]) + authorize guidance + end + if params[:example_answer_id].present? + example_answer = Annotation.includes(question: {section: {phase: :template}}).find(params[:example_answer_id]) + authorize example_answer + end + verify_authorized + # if guidance present, update + if params[:guidance_text].present? + if guidance.present? + guidance.text = params[:guidance_text] + else + guidance = init_annotation(params[:guidance_text], @question, current_user.org, Annotation.types[:guidance]) + end + end + # if example answer present, update + if params[:example_answer_text].present? + if example_answer.present? + example_answer.text = params[:example_answer_text] + else + example_answer = init_annotation(params[:example_answer_text], @question, current_user.org, Annotation.types[:example_answer]) + end + end + # only required to save if we updated/created one + ex_save = example_answer.present? ? example_answer.save : true + guid_save = guidance.present? ? guidance.save : true + @section = @question.section @phase = @section.phase - if @example_answer.update_attributes(params[:annotation]) + if ex_save && guid_save redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, edit: 'true'), notice: _('Information was successfully updated.') else - flash[:notice] = failed_update_error(@example_answer, _('example answer')) + if !ex_save && !guid_save + flash[:notice] = failed_create_error(example_answer, _('example answer')) + '\n' + + failed_create_error(gudiance, _('guidance')) + elsif !guid_save + flash[:notice] = failed_create_error(gudiance, _('guidance')) + elsif !ex_save + flash[:notice] = failed_create_error(example_answer, _('example answer')) + end render action: "phases/admin_show" end end @@ -50,4 +102,15 @@ end end + private + + def init_annotation(text, question, org, type) + annotation = Annotation.new + annotation.org = org + annotation.question = question + annotation.text = text + annotation.type = type + return annotation + end + end \ No newline at end of file diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 51f76b2..7d48ddf 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -2,95 +2,54 @@ after_action :verify_authorized respond_to :html - # PUT/PATCH /[:locale]/answer/[:id] + # PUT/PATCH /answers/[:id] def update - question_id = params[:answer][:question_id] - plan_id = params[:answer][:plan_id] - @question = Question.find(question_id); - # If an answer id is present load that answer otherwise load by plan/question - @answer = Answer.find_by(plan_id: plan_id, question_id: question_id) - - @old_answer = nil - @timestamp = nil - - if @answer.nil? # If there is no answer for plan/question - @answer = Answer.new(permitted_params) - @answer.text = params["answer-text-#{@answer.question_id}".to_sym] - - authorize @answer - - if @answer.save - @timestamp = @answer.updated_at.iso8601 - end - @lock_version = @answer.lock_version - elsif params[:answer][:id].blank? # Someone else already added an answer while the user was working - @old_answer = Marshal::load(Marshal.dump(@answer)) - @answer.text = params["answer-text-#{@answer.question_id}".to_sym] - - authorize @answer - - @lock_version = @answer.lock_version - else # We're about updating an answer (let ActiveRecord check for a race condition) - @old_answer = Marshal::load(Marshal.dump(@answer)) - @answer.text = params["answer-text-#{@answer.question_id}".to_sym] - - authorize @answer - - if @answer.update(permitted_params) - @answer.touch # Saves the record with the updated_at set to the current time. Needed if only answer.question_options is updated - @timestamp = @answer.updated_at.iso8601 - end - @lock_version = @answer.lock_version - @old_answer = nil - end - - @section_id = @answer.question.section.id - @username = @answer.user.name - - @nquestions = 0 - @nanswers = 0 - @n_section_questions = 0 - @n_section_answers = 0 - - plan = Plan.find(plan_id) - # Problem of N+1 queries below - plan.template.phases.each do |phase| - phase.sections.each do |section| - section.questions.each do |question| - @nquestions += 1 - if section.id == @section_id - @n_section_questions += 1 - end - question.answers = question.answers.to_a.select {|answer| answer.plan_id == plan.id} - if question.answers.present? && question.answers.first.text.present? - @nanswers += 1 - if section.id == @section_id - @n_section_answers += 1 - end - end + p_params = permitted_params() + @answer = Answer.find_by({plan_id: p_params[:plan_id], question_id: p_params[:question_id], }) + begin + if @answer + authorize @answer + @answer.update(p_params) + if p_params[:question_option_ids].present? + @answer.touch() # Saves the record with the updated_at set to the current time. Needed if only answer.question_options is updated end + else + @answer = Answer.new(p_params) + @answer.lock_version = 1 + authorize @answer + @answer.save() # NOTE, there is a chance to create multiple answer associated for a plan/question (IF any concurrent thread) INSERTS an answer after checking the existence of an answer (Line 8) + # In order to avoid that edge-case, it is recommended to create answers whenever a new plan is created (e.g. after_create callback) end + rescue ActiveRecord::StaleObjectError + @stale_answer = @answer + @answer = Answer.find_by({plan_id: p_params[:plan_id], question_id: p_params[:question_id]}) end + + @plan = Plan.includes({ + sections: { + questions: [ + :answers, + :question_format + ] + } + }).find(p_params[:plan_id]) + @question = @answer.question + @section = @plan.get_section(@question.section_id) respond_to do |format| format.js {} end - - rescue ActiveRecord::StaleObjectError - @username = @old_answer.user.name - @lock_version = @old_answer.lock_version - respond_to do |format| - format.js {} - end - end # End update private def permitted_params - permitted = params.require(:answer).permit(:id, :plan_id, :user_id, :question_id, :lock_version, :question_option_ids => []) - if !permitted[:question_option_ids].present? #If question_option_ids has been filtered out because it was a scalar value (e.g. radiobutton answer) + permitted = params.require(:answer).permit(:id, :text, :plan_id, :user_id, :question_id, :lock_version, :question_option_ids => []) + if !params[:answer][:question_option_ids].nil? && !permitted[:question_option_ids].present? #If question_option_ids has been filtered out because it was a scalar value (e.g. radiobutton answer) permitted[:question_option_ids] = [params[:answer][:question_option_ids]] # then convert to an Array end + if !permitted[:id].present? + permitted.delete(:id) + end return permitted end # End permitted_params end diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index 99406e9..b9d9685 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -15,24 +15,6 @@ @phase = @plan.template.phases.select {|p| p.id == phase_id}.first @readonly = !@plan.editable_by?(current_user.id) - # the eager_load pulls in ALL answers - # need to restrict to just ones for this plan - # at the same time count the questions and answers for the status - @nquestions = 0 - @nanswers = 0 - - @plan.template.phases.each do |phase| - phase.sections.each do |section| - section.questions.each do |question| - @nquestions += 1 - question.answers = question.answers.to_a.select {|answer| answer.plan_id == @plan.id} - if question.answers.present? && question.answers.first.text.present? - @nanswers += 1 - end - end - end - end - # Now we need to get all the themed guidance for the plan. # TODO: think this through again, there may be a better way to do this. # diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index b17e7b7..b0f3465 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -18,7 +18,7 @@ authorize @plan # Get all of the available funders and non-funder orgs - @funders = Org.funders.sort{|x,y| x.name <=> y.name } + @funders = Org.funders.joins(:templates).where(templates: {published: true}).uniq.sort{|x,y| x.name <=> y.name } @orgs = (Org.institutions + Org.managing_orgs).flatten.uniq.sort{|x,y| x.name <=> y.name } # Get the current user's org @@ -125,7 +125,7 @@ @all_ggs_grouped_by_org = @all_ggs_grouped_by_org.sort_by {|org,gg| org.name} @selected_guidance_groups = @plan.guidance_groups.pluck(:id) - @based_on = (@plan.template.customization_of.nil? ? @plan.template : Template.live(@plan.template.customization_of)) + @based_on = (@plan.template.customization_of.nil? ? @plan.template : Template.where(dmptemplate: @plan.template.customization_of).first) respond_to :html end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 14a6d21..2beb963 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -4,38 +4,36 @@ #create a question def admin_create - @question = Question.new(params[:question]) - authorize @question - example = @question.annotations.first - if example.present? - example.org_id = current_user.org_id - example.example_answer! - end - if params["new-question-guidance"].present? - guidance = @question.annotations.build - guidance.text = params["new-question-guidance"] - guidance.org_id = current_user.org_id - guidance.guidance! - guidance.save - end - @question.default_value = params["new-question-default-value"] - @question.modifiable = true - if @question.save - @question.section.phase.template.dirty = true - @question.section.phase.template.save! + begin + @question = Question.new(question_params) + authorize @question + @question.modifiable = true + if @question.save + @question.section.phase.template.dirty = true + @question.section.phase.template.save! + if params[:example_answer].present? + example_answer = Annotation.new({question_id: @question.id, org_id: current_user.org_id, text: params[:example_answer], type: Annotation.types[:example_answer]}) + example_answer.save + end + if params[:guidance].present? + guidance = Annotation.new({question_id: @question.id, org_id: current_user.org_id, text: params[:guidance], type: Annotation.types[:guidance]}) + guidance.save + end + redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: _('Information was successfully created.') + else + @edit = (@question.section.phase.template.org == current_user.org) + @open = true + @phase = @question.section.phase + @section = @question.section + @sections = @phase.sections + @section_id = @question.section.id + @question_id = @question.id - redirect_to admin_show_phase_path(id: @question.section.phase_id, section_id: @question.section_id, question_id: @question.id, edit: 'true'), notice: _('Information was successfully created.') - else - @edit = (@question.section.phase.template.org == current_user.org) - @open = true - @phase = @question.section.phase - @section = @question.section - @sections = @phase.sections - @section_id = @question.section.id - @question_id = @question.id - - flash[:notice] = failed_create_error(@question, _('question')) - render template: 'phases/admin_show' + flash[:notice] = failed_create_error(@question, _('question')) + render template: 'phases/admin_show' + end + rescue ActionController::ParameterMissing => e + flash[:notice] = e.message end end @@ -89,4 +87,18 @@ end end + private + # Filters the valid attributes for a question according to each type. + # Note, that params[:question] and params[:question][:question_format_id] are required and their absence raises ActionController::ParameterMissing + def question_params + permitted = params.require(:question).except(:created_at, :updated_at).tap do |question_params| + question_params.require(:question_format_id) + q_format = QuestionFormat.find(question_params[:question_format_id]) + if q_format.option_based + question_params.delete(:default_value) + else + question_params.delete(:question_options_attributes) + end + end + end end \ No newline at end of file diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index bcaf9b9..a628929 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -72,6 +72,7 @@ def update if user_signed_in? then @orgs = Org.where(parent_id: nil).order("name") + @default_org = current_user.org @other_organisations = Org.where(parent_id: nil, is_other: true).pluck(:id) @identifier_schemes = IdentifierScheme.where(active: true).order(:name) @languages = Language.sorted_by_abbreviation @@ -91,30 +92,53 @@ end def do_update(require_password = true, confirm = false) - if require_password # user is changing email or password - if current_user.email != params[:user][:email] # if user is changing email - if params[:user][:current_password].blank? # password needs to be present - message = _('Please enter your password to change email address.') - successfully_updated = false - else + mandatory_params = true + message = _('Save Unsuccessful.') + ' ' # added to by below, overwritten otherwise + # ensure that the required fields are present + if params[:user][:email].blank? + message +=_('Please enter an email address.') + ' ' + mandatory_params &&= false + end + if params[:user][:firstname].blank? + message +=_('Please enter a First name.') + ' ' + mandatory_params &&= false + end + if params[:user][:surname].blank? + message +=_('Please enter a Last name.') + ' ' + mandatory_params &&= false + end + if params[:user][:org_id].blank? + message += _('Please select an organisation, or select Other.') + mandatory_params &&= false + end + if mandatory_params # has the user entered all the details + if require_password # user is changing email or password + if current_user.email != params[:user][:email] # if user is changing email + if params[:user][:current_password].blank? # password needs to be present + message = _('Please enter your password to change email address.') + successfully_updated = false + else + successfully_updated = current_user.update_with_password(password_update) + end + elsif params[:user][:password].present? # if user is changing password + successfully_updated = false # shared across first 3 conditions + if params[:user][:current_password].blank? + message = _('Please enter your current password') + elsif params[:user][:password_confirmation].blank? + message = _('Please enter a password confirmation') + elsif params[:user][:password] != params[:user][:password_confirmation] + message = _('Password and comfirmation must match') + else + successfully_updated = current_user.update_with_password(password_update) + end + else # potentially unreachable... but I dont like to leave off the else successfully_updated = current_user.update_with_password(password_update) end - elsif params[:user][:password].present? # if user is changing password - successfully_updated = false # shared across first 3 conditions - if params[:user][:current_password].blank? - message = _('Please enter your current password') - elsif params[:user][:password_confirmation].blank? - message = _('Please enter a password confirmation') - elsif params[:user][:password] != params[:user][:password_confirmation] - message = _('Password and comfirmation must match') - else - successfully_updated = current_user.update_with_password(password_update) - end - else # potentially unreachable... but I dont like to leave off the else - successfully_updated = current_user.update_with_password(password_update) + else # password not required + successfully_updated = current_user.update_without_password(update_params) end - else # password not required - successfully_updated = current_user.update_without_password(update_params) + else + successfully_updated = false end #unlink shibboleth from user's details diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 76d55a5..c1ea7e8 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -50,7 +50,7 @@ } end - # PUT /org/admin/templates/:id/admin_customize + # GET /org/admin/templates/:id/admin_customize # ----------------------------------------------------- def admin_customize @template = Template.find(params[:id]) diff --git a/app/models/answer.rb b/app/models/answer.rb index 8267948..d46ad59 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -42,4 +42,18 @@ def has_question_option(option_id) self.question_option_ids.include?(option_id) end + + # Returns true if the answer is valid and false otherwise. If the answer's question is option_based, it is checked if exist + # any question_option selected. For non option_based (e.g. textarea or textfield), it is checked the presence of text + def is_valid? + if self.question.present? + if self.question.question_format.option_based? + return !self.question_options.empty? + else # (e.g. textarea or textfield question formats) + return self.text.present? + end + else + return false + end + end end diff --git a/app/models/org.rb b/app/models/org.rb index 348a7d1..bb45c32 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -22,11 +22,11 @@ ## # Possibly needed for active_admin # -relies on protected_attributes gem as syntax depricated in rails 4.2 -# attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, -# :logo_file_name, :name, :target_url, -# :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, -# :token_permission_type_ids, :language_id, :contact_email, -# :language, :org_type, :region, :token_permission_types + attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, + :logo_file_name, :name, :target_url, + :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, + :token_permission_type_ids, :language_id, :contact_email, + :language, :org_type, :region, :token_permission_types ## # Validators diff --git a/app/models/phase.rb b/app/models/phase.rb index a316416..5c2323f 100644 --- a/app/models/phase.rb +++ b/app/models/phase.rb @@ -4,6 +4,12 @@ # [+Created:+] 03/09/2014 # [+Copyright:+] Digital Curation Centre and University of California Curation Center class Phase < ActiveRecord::Base + + ## + # Sort order: Number ASC + default_scope { order(number: :asc) } + + # extend FriendlyId ## # Associations diff --git a/app/models/plan.rb b/app/models/plan.rb index 549b4fe..5db4cde 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -949,8 +949,29 @@ end =end + # Returns the number of answered questions from the entire plan + def num_answered_questions + n = 0 + self.sections.each do |s| + n+= s.num_answered_questions(self.id) + end + return n + end + # Returns a section given its id or nil if does not exist for the current plan + def get_section(section_id) + self.sections.find { |s| s.id == section_id } + end + # Returns the number of questions for a plan. Note, this method becomes useful + # for when sections and their questions are eager loaded so that avoids SQL queries. + def num_questions + n = 0 + self.sections.each do |s| + n+= s.questions.size() + end + return n + end # the following two methods are for eager loading. One gets used for the plan/show # page and the oter for the plan/edit. The difference is just that one pulls in more than # the other. diff --git a/app/models/question.rb b/app/models/question.rb index 10efc8b..0a3e947 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,8 +1,13 @@ class Question < ActiveRecord::Base + + ## + # Sort order: Number ASC + default_scope { order(number: :asc) } + ## # Associations has_many :answers, :dependent => :destroy - has_many :question_options, :dependent => :destroy + has_many :question_options, :dependent => :destroy, :inverse_of => :question # inverse_of needed for nester forms has_many :annotations, :dependent => :destroy has_and_belongs_to_many :themes, join_table: "questions_themes" belongs_to :section diff --git a/app/models/question_format.rb b/app/models/question_format.rb index 061961a..b7d6afc 100644 --- a/app/models/question_format.rb +++ b/app/models/question_format.rb @@ -14,6 +14,9 @@ # -relies on protected_attributes gem as syntax depricated in rails 4.2 attr_accessible :title, :description, :option_based, :questions, :as => [:default, :admin] + # Retrieves the id for a given formattype passed + scope :id_for, -> (formattype) { where(formattype: formattype).pluck(:id).first } + ## # Define Bit Field Values so we can test a format without doing string comps # Column type diff --git a/app/models/section.rb b/app/models/section.rb index abf1327..4d4562b 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -23,10 +23,11 @@ "#{title}" end + # Returns the number of answered questions for a given plan id def num_answered_questions(plan_id) n = 0 self.questions.each do |question| - n += question.plan_answers(plan_id).select{|answer| answer.text.present?}.count + n += question.plan_answers(plan_id).select{|answer| answer.is_valid?}.count end return n end diff --git a/app/models/template.rb b/app/models/template.rb index b10daa4..f0fdc00 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -19,7 +19,7 @@ # -relies on protected_attributes gem as syntax depricated in rails 4.2 attr_accessible :id, :org_id, :description, :published, :title, :locale, :customization_of, :is_default, :guidance_group_ids, :org, :plans, :phases, :dmptemplate_id, - :version, :visibility, :published, :as => [:default, :admin] + :migrated, :version, :visibility, :published, :as => [:default, :admin] # defines the export setting for a template object has_settings :export, class_name: 'Settings::Template' do |s| diff --git a/app/models/user.rb b/app/models/user.rb index 8ea0608..c1350f6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -263,6 +263,14 @@ end end + ## + # Override devise_invitable email title + # -------------------------------------------------------------- + def deliver_invitation(options = {}) + super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]})) + end + + # TODO: Remove this, its never called. # this generates a reset password link for a given user # which can then be sent to them with the appropriate host diff --git a/app/policies/annotation_policy.rb b/app/policies/annotation_policy.rb index cf63f42..a426546 100644 --- a/app/policies/annotation_policy.rb +++ b/app/policies/annotation_policy.rb @@ -14,11 +14,12 @@ ## def admin_create? - user.can_modify_templates? && (annotation.question.section.phase.template.org_id == user.org_id) + # here we pass through a question instead of an annotation object + user.can_modify_templates? && (annotation.section.phase.template.org_id == user.org_id) end def admin_update? - user.can_modify_templates? && (annotation.question.section.phase.template.org_id == user.org_id) + user.can_modify_templates? && (annotation.question.section.phase.template.org_id == user.org_id) && annotation.org_id == user.org_id end def admin_destroy? diff --git a/app/views/annotations/_add_annotation.html.erb b/app/views/annotations/_add_annotation.html.erb index 8cf9113..8add942 100644 --- a/app/views/annotations/_add_annotation.html.erb +++ b/app/views/annotations/_add_annotation.html.erb @@ -1,15 +1,21 @@ -<%= form_for :annotation, url: admin_create_annotation_path do |f| %> - <%= f.hidden_field :org_id, value: current_user.org_id %> - <%= f.hidden_field :question_id, value: question.id %> - <%= f.hidden_field :type, value: Annotation.types[:example_answer] %> - +

<%= _('Add Annotations') %>

+<%= form_tag admin_create_annotation_path , class: 'add_annotation_form' do %> + + + + @@ -19,7 +25,8 @@
- <%= f.submit _('Save'), class: "btn btn-primary" %> - <%= link_to _('Cancel'), "#", id: "cancel_suugested_answer", class: "btn cancel" %> + <%= submit_tag _('Save'), class: "btn btn-primary" %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to _('Cancel'), "#", class: "btn cancel cancel_add_annotations" %>
<%end%> diff --git a/app/views/annotations/_edit_annotation.html.erb b/app/views/annotations/_edit_annotation.html.erb index 6fa1e35..3a59362 100644 --- a/app/views/annotations/_edit_annotation.html.erb +++ b/app/views/annotations/_edit_annotation.html.erb @@ -1,25 +1,43 @@ -<%= form_for( annotation, url: admin_update_annotation_path(annotation.id), html: { method: :put}) do |f| %> - <%= f.hidden_field :org_id, value: current_user.org_id %> +<%= form_tag admin_update_annotation_path, method: :put do %> + <% example_answer_text = example_answer.present? ? example_answer.text : '' %> + <% guidance_text = guidance.present? ? guidance.text : '' %> + <%= hidden_field_tag :example_answer_id, example_answer.present? ? example_answer.id : nil %> + <%= hidden_field_tag :guidance_id, guidance.present? ? guidance.id : nil %>
<%= _('Example Answer')%>
    -
  • <%= f.text_area :text, rows: 5 %> +
  • <%= text_area_tag :example_answer_text, nil, rows: 5 %> +
  • +
+
<%= _('Guidance')%> +
    +
  • <%= text_area_tag :guidance_text, nil, rows: 5 %>
- + + + + +
<%= _('Example of Answer')%><%= _('Example Answer')%>
    -
  • <%= f.text_area :text, rows: 5 %>
  • +
  • <%= text_area_tag :example_answer_text, example_answer_text, rows: 5 %>
  • +
+
<%= _('Guidance')%> +
    +
  • <%= text_area_tag :guidance_text, guidance_text, rows: 5 %>

- +
- <%= f.submit _('Save'), class: 'btn btn-primary' %> - <%= link_to _('Delete'), admin_destroy_annotation_path(id: annotation.id), - confirm: _("You are about to delete an example answer for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%> + <%= submit_tag _('Save'), class: 'btn btn-primary' %> + <% if example_answer.present? %> + <%= link_to _('Delete Example Answer'), admin_destroy_annotation_path(id: example_answer.id), + confirm: _("You are about to delete an example answer for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%> + <% end %> + <% if guidance.present? %> + <%= link_to _('Delete Example Answer'), admin_destroy_annotation_path(id: guidance.id), + confirm: _("You are about to delete a guidance for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%> + <% end %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <%= link_to _('Cancel'), '#', class: 'btn cancel cancel_edit_suggested_answer' %> + <%= link_to _('Cancel'), '#', class: 'btn cancel cancel_edit_annotations' %>
<% end %> diff --git a/app/views/annotations/_show_annotation.html.erb b/app/views/annotations/_show_annotation.html.erb index 9cc93de..a790d70 100644 --- a/app/views/annotations/_show_annotation.html.erb +++ b/app/views/annotations/_show_annotation.html.erb @@ -1,15 +1,26 @@ +

<%= _('Annotations') %>

- - - - + <% if example_answer.present? %> + + + + + <% end %> + <% if guidance.present? %> + + + + + <% end %>
- <%= _('Example of answer')%> - <%= raw annotation.text %>
+ <%= _('Example Answer')%> + <%= raw example_answer.text %>
+ <%= _('Guidance')%> + <%= raw guidance.text %>

<%= hidden_field_tag :question_id, question.id, class: "question_id" %> - <%= link_to _('Edit Example of Answer'), '# ', class: "btn btn-primary edit_form_for_suggested_answer"%> + <%= link_to _('Edit Annotations'), '# ', class: "btn btn-primary edit_form_for_annotations"%>
diff --git a/app/views/answers/_form_fields.html.erb b/app/views/answers/_form_fields.html.erb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/views/answers/_form_fields.html.erb diff --git a/app/views/answers/_locking.html.erb b/app/views/answers/_locking.html.erb new file mode 100644 index 0000000..40a3d90 --- /dev/null +++ b/app/views/answers/_locking.html.erb @@ -0,0 +1,5 @@ +
+

<%= _('The following answer cannot be saved') %>

+ <%= render partial: '/answers/new_edit', locals: { question: question, answer: answer, readonly: true } %> +

<%= _('since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again.') % { name: user.name} %>

+
diff --git a/app/views/answers/_new_edit.html.erb b/app/views/answers/_new_edit.html.erb new file mode 100644 index 0000000..54fa9b4 --- /dev/null +++ b/app/views/answers/_new_edit.html.erb @@ -0,0 +1,101 @@ + +<% q_format = question.question_format %> +<%= semantic_form_for answer, :url => {controller: :answers, action: :update }, html: {method: "put", class: "roadmap-form"}, remote: true do |f| %> +
+ <% if !readonly %> + <%= f.input :id, as: :hidden, input_html: { value: answer.id } %> + <%= f.input :plan_id, as: :hidden, input_html: { value: answer.plan_id } %> + <%= f.input :user_id, as: :hidden, input_html: { value: answer.user_id } %> + <%= f.input :question_id, as: :hidden, input_html: { value: answer.question_id } %> + <%= f.input :lock_version, as: :hidden, input_html: { value: answer.lock_version } %> + <% end %> + + +

+ <%= raw question.text %> +

+ + + <% if !readonly && question.annotations.where(type: Annotation.types[:example_answer]).any? %> + <% annotation = question.annotations.where(type: Annotation.types[:example_answer]).order(:created_at).first %> + <% if annotation.text.present? %> +
+ + <%="#{annotation.org.abbreviation} "%> <%=_('Example of answer')%> + + +
+

+ <%= raw annotation.text %> +

+
+
+ <% end %> + <% end %> + + <% if question.option_based? %> + <% options = question.question_options.by_number %> + <% if q_format.checkbox? %> +
    + <% options.each do |op| %> +
  1. + <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id), disabled: readonly }, op.id, nil) %> + <%= raw op.text %> +
  2. + <% end %> +
+ <% elsif q_format.radiobuttons? %> +
    + <% options.each do |op| %> +
  1. + <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}", disabled: readonly } %> + <%= raw op.text %> +
  2. + <% end %> +
+ <% elsif q_format.dropdown? || q_format.multiselectbox? %> + <% + options_html = "" + options.each do |op| + options_html += answer.has_question_option(op.id) ? + "" : + "" + end + %> + <%= select_tag('answer[question_option_ids]', raw(options_html), + {multiple: q_format.multiselectbox?, include_blank: q_format.dropdown?, disabled: readonly }) %> + <% end %> + + <% if question.option_comment_display == true %> + <%= label_tag('answer[text]', _('Comment')) %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.change_answer") %> + <% end %> + <%end%> + <% end %> + + <% if q_format.textfield? %> + <% if readonly %> +

<%= strip_tags(answer.text) %>

+ <% else %> + <%= text_field_tag('answer[text]', strip_tags(answer.text)) %> + <% end %> + <% elsif q_format.textarea? %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.change_answer") %> + <% end %> + <% end %> + + <% if !readonly %> + + <% end %> +
+ <% end %> \ No newline at end of file diff --git a/app/views/answers/_status.html.erb b/app/views/answers/_status.html.erb index e1c8d8b..ddf8dcf 100644 --- a/app/views/answers/_status.html.erb +++ b/app/views/answers/_status.html.erb @@ -3,7 +3,7 @@
<% if answer.updated_at.blank? %> - <%= _('Not answered yet') %> + <%= _('Not answered yet') %> <% else %> <%= _('Answered')%> <%= answer.updated_at.iso8601 %><%= _(' by')%> <%= answer.user.name %> <% end %> \ No newline at end of file diff --git a/app/views/answers/update.js.erb b/app/views/answers/update.js.erb index ec06441..2290a67 100644 --- a/app/views/answers/update.js.erb +++ b/app/views/answers/update.js.erb @@ -1,29 +1,26 @@ -// after saving the answer (and possibly getting a conflict) -// set the message div about the answer. -// On success this will be "" on error it will be the -// conflicting answer - -<% if @old_answer %> - $("#answer_notice_<%=@question.id%>").html("<%= escape_javascript(render partial: '/phases/answer', locals: { question: @question, answer: @old_answer}) %>"); +// partial /answers/locking +<% if @stale_answer %> + $("#answer-locking-<%= @question.id%>") + .html("<%= escape_javascript(render partial: '/answers/locking', locals: { question: @question, answer: @stale_answer, user: @answer.user }) %>"); <% else %> - $("#answer_notice_<%=@question.id%>").html(""); + $("#answer-locking-<%= @question.id%>").html(""); <% end %> -// have to update the lock_version on success or failure -// so that the next save can work. If you don't do -// this it will fail forever. Also update the answer id +// partial /answer/new_edit +if(tinymce) + tinymce.remove("#answer-text-<%= @question.id %>"); +$("#answer-form-<%= @question.id%>") + .html("<%= escape_javascript(render partial: '/answers/new_edit', locals: { question: @question, answer: @answer, readonly: false }) %>"); -$("#answer_lock_version-<%=@question.id%>").val(<%= @lock_version %>); -$("#question-form-<%= @question.id %> #answer_id").val(<%= @answer.id %>); - -// update the answer status +// partial /answer/status $("#answer-status-<%= @question.id %>") - .html("<%= escape_javascript(render partial: '/answers/status', locals: { question_id: @question.id, answer: @answer}) %>"); + .html("<%= escape_javascript(render partial: '/answers/status', locals: { answer: @answer}) %>"); if($.fn.init_answer_status) $.fn.init_answer_status(); -// update plan progress bar -$(".progress").html("<%= escape_javascript(render :partial => '/plans/progress', locals: {nquestions: @nquestions, nanswers: @nanswers}) %>"); +// partial /plans/progress +$(".progress").html("<%= escape_javascript(render :partial => '/plans/progress', locals: { plan: @plan }) %>"); -// update the section progress message -$("#<%=@section_id%>-status").html("(<%=@n_section_questions%> <%= _('questions') %>, <%=@n_section_answers%> <%= _('answered') %>)") +// partial /sections/progress +$("#section-progress-<%= @section.id %>") + .html("<%= escape_javascript(render partial: '/sections/progress', locals: { section: @section, plan: @plan }) %>"); \ No newline at end of file diff --git a/app/views/guidance_groups/admin_edit.html.erb b/app/views/guidance_groups/admin_edit.html.erb index 006318b..77146d5 100644 --- a/app/views/guidance_groups/admin_edit.html.erb +++ b/app/views/guidance_groups/admin_edit.html.erb @@ -29,7 +29,7 @@
- <%= link_to(image_tag('help_button.png'), '#', class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'")) %> + <%= link_to(image_tag('help_button.png'), '#', class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. "[guidance group name]: guidance on data sharing" so we suggest you just use the institution or department name.')) %>
@@ -75,4 +75,4 @@
<% end %> - \ No newline at end of file + diff --git a/app/views/guidance_groups/admin_new.html.erb b/app/views/guidance_groups/admin_new.html.erb index faf81f8..8ea92b8 100644 --- a/app/views/guidance_groups/admin_new.html.erb +++ b/app/views/guidance_groups/admin_new.html.erb @@ -25,7 +25,7 @@ <%= f.text_field :name, as: :string, class: "text_field" %>
- <%= link_to( image_tag("help_button.png"), "#", class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"))%> + <%= link_to( image_tag("help_button.png"), "#", class: 'guidance_group_title_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. "[guidance group name]: guidance on data sharing" so we suggest you just use the institution or department name.'))%>
diff --git a/app/views/guidances/_add_guidance.html.erb b/app/views/guidances/_add_guidance.html.erb index 28f75f6..da1d7ca 100644 --- a/app/views/guidances/_add_guidance.html.erb +++ b/app/views/guidances/_add_guidance.html.erb @@ -63,7 +63,7 @@
- <%= tinymce content_css: asset_path("application.css") %> + <%= tinymce %> <% end %> diff --git a/app/views/guidances/_edit_guidance.html.erb b/app/views/guidances/_edit_guidance.html.erb index 7138ceb..ffae58d 100644 --- a/app/views/guidances/_edit_guidance.html.erb +++ b/app/views/guidances/_edit_guidance.html.erb @@ -7,7 +7,7 @@ <%= _('Suggested answer/ Example')%> diff --git a/app/views/guidances/admin_edit.html.erb b/app/views/guidances/admin_edit.html.erb index 7b43313..1a04cc8 100644 --- a/app/views/guidances/admin_edit.html.erb +++ b/app/views/guidances/admin_edit.html.erb @@ -82,7 +82,7 @@
- <%= tinymce content_css: asset_path('application.css') %> + <%= tinymce %> <%end%> diff --git a/app/views/guidances/admin_new.html.erb b/app/views/guidances/admin_new.html.erb index 95239c0..f77a3f6 100644 --- a/app/views/guidances/admin_new.html.erb +++ b/app/views/guidances/admin_new.html.erb @@ -79,7 +79,7 @@
- <%= tinymce content_css: asset_path('application.css') %> + <%= tinymce %> <%end%> diff --git a/app/views/orgs/admin_edit.html.erb b/app/views/orgs/admin_edit.html.erb index 58ac1fd..adbc664 100644 --- a/app/views/orgs/admin_edit.html.erb +++ b/app/views/orgs/admin_edit.html.erb @@ -79,5 +79,5 @@ -<%= tinymce content_css: asset_path('application.css') %> +<%= tinymce %> diff --git a/app/views/phases/_add_note.html.erb b/app/views/phases/_add_note.html.erb index 51e81e2..5a20c05 100644 --- a/app/views/phases/_add_note.html.erb +++ b/app/views/phases/_add_note.html.erb @@ -18,7 +18,7 @@
<%= label_tag "#{questionid}new_note_text", _('Share note with collaborators') %> <%= text_area_tag "#{questionid}new_note_text", nil, class: "tinymce" %> - <%= tinymce :content_css => asset_path("application.css"), :setup => "function(editor){editor.on('change', function(e){$.fn.check_textarea(editor)});}" %> + <%= tinymce %>
<% end %> diff --git a/app/views/phases/_answer.html.erb b/app/views/phases/_answer.html.erb deleted file mode 100644 index 1b3106c..0000000 --- a/app/views/phases/_answer.html.erb +++ /dev/null @@ -1,77 +0,0 @@ - - -<% qformat = question.question_format %> - - - -

<%= _("While you were editing ") + answer.user.name + _(" saved the following answer:") %>

- -<%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, :remote => true do |af| %> - <%= af.inputs do %> - - - <% if question.option_based? %> - <% options = question.options.order("number") %> - - - <% if qformat.checkbox? %> - <%= af.input :options, - :as => :check_boxes, - :collection => options, - :label => false, - :input_html => { :disabled => :true } - %> - <% elsif qformat.multiselectbox? %> - <%= af.input :options, - :as => :select, - :collection => options, - :label => false, - :input_html => { :multiple => true , :disabled => :true } %> - <% elsif qformat.radiobuttons?%> -
    - <% options.each do |op| %> -
  1. - <% checked = (answer.option_ids[0] == op.id) %> - <%= af.radio_button :option_ids, op.id, :checked => checked, id: "answer_option_ids_#{op.id}"%> - <%= raw op.text %> -
  2. - <% end %> -
- <% elsif qformat.dropdown? %> - <%= af.input :options, - :as => :select, - :collection => options, - :label => false, - :input_html => { :multiple => false, :disabled => :true } - %> - <% end %> - - - <% if question.option_comment_display %> - <%= label_tag("answer-text-Ans#{question.id}".to_sym, _('Comment')) %> - <%= text_area_tag("answer-text-Ans#{question.id}".to_sym, answer.text, class: "tinymce answer-notice") %> - <%end%> - <% end %> - - <% if qformat.textfield? %> - <%= text_field_tag("answer-text-Ans#{question.id}".to_sym, strip_tags(answer.text), class: "question_text_field", disabled: true) %> - <% elsif qformat.textarea? %> - <%= text_area_tag("answer-text-Ans#{question["id"]}".to_sym, strip_tags(answer.text), class: "tinymce answer-notice", disabled: true) %> - <% end %> - - <% end %> -<% end %> - -

<%= _('Combine their changes with your answer below and then save the answer again.') %>
<%= _('The edits in the box below will overwrite the existing answer from ') + answer.user.name + _(' once you click save!')%>

- - diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb index aba7c44..334c057 100644 --- a/app/views/phases/_answer_form.html.erb +++ b/app/views/phases/_answer_form.html.erb @@ -6,134 +6,37 @@ -->
- <% answers = question.plan_answers(plan.id) if answers.present? answer = answers.first else - answer = Answer.new + answer = Answer.new({ plan_id: plan.id, question_id: question.id, user_id: current_user.id }) + if question.default_value.present? + answer.text = question.default_value + end end - question_id = question.id - q_format = question.question_format %> - -
- <%= semantic_form_for answer, :url => {controller: :answers, action: :update }, html: {method: "put", class: "roadmap-form"}, remote: true do |f| %> -
- <%= f.input :id, as: :hidden, input_html: { value: answer.id } %> - <%= f.input :plan_id, as: :hidden, input_html: { value: @plan.id } %> - <%= f.input :user_id, as: :hidden, input_html: { value: current_user.id } %> - <%= f.input :question_id, as: :hidden, input_html: { value: question_id, class: "question_id" } %> - <%= f.hidden_field :lock_version, id: "answer_lock_version-#{question_id}" %> - - - - <%= raw question.text %> - - - <% if question.annotations.where(type: Annotation.types[:example_answer]).any? %> - <% annotation = question.annotations.where(type: Annotation.types[:example_answer]).order(:created_at).first %> - <% if annotation.text.present? %> -
- - <%="#{annotation.org.abbreviation} "%> <%=_('Example of answer')%> - - -
-

- <%= raw annotation.text %> -

-
-
- <% end %> - <% end %> - - -
- - - <% if question.option_based? %> - <% options = question.question_options.by_number %> - - - <% if q_format.checkbox? %> -
    - <% options.each do |op| %> -
  1. - <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id), disabled: readonly }, op.id, nil) %> - <%= raw op.text %> -
  2. - <% end %> -
- <% elsif q_format.radiobuttons? %> -
    - <% options.each do |op| %> -
  1. - <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}", disabled: readonly } %> - <%= raw op.text %> -
  2. - <% end %> -
- <% elsif q_format.dropdown? || q_format.multiselectbox? %> - <% - options_html = "" - options.each do |op| - options_html += answer.has_question_option(op.id) ? - "" : - "" - end - %> - <%= select_tag('answer[question_option_ids]', raw(options_html), - {multiple: q_format.multiselectbox?, include_blank: q_format.dropdown?, disabled: readonly }) %> - <% end %> - - - - <% if question.option_comment_display == true %> - <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %> - <% if readonly %> -

<%= raw(answer.text) %>

- <% else %> - <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> - <% end %> - <%end%> - <% end %> - - <% if q_format.textfield? %> - <% if readonly %> -

<%= strip_tags(answer.text) %>

- <% else %> - <%= text_field_tag("answer-text-#{question_id}".to_sym, strip_tags(answer.text), { class: "question_text_field" }) %> - <% end %> - <% elsif q_format.textarea? %> - <% if readonly %> -

<%= raw(answer.text) %>

- <% else %> - <%= text_area_tag("answer-text-#{question_id}".to_sym, answer.text, class: "tinymce") %> - <% end %> - <% end %> - - <% if !readonly %> - - <% end %> -
-
"> - <%= render(partial: 'answers/status', locals: { question_id: question_id, answer: answer }) %> -
- <% end %> +
+
">
+
"> + <%= render(partial: 'answers/new_edit', locals: { question: question, answer: answer, readonly: readonly }) %> +
+
" class="answer-status"> + <%= render(partial: 'answers/status', locals: { answer: answer }) %> +
-
+
<% comments = answer.notes.all %> - <%= hidden_field_tag :question_id, question_id, class: "question_id" %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
    - <% annotations = question.annotations.where("type <> ?", Annotation.types[:guidance]) %> - <% if annotations.present? || question_guidances[question_id] %> + <% annotations = question.annotations.where(type: Annotation.types[:guidance]) %> + <% if annotations.present? || question_guidances[question.id] %> <% css_style_comment_div = "display: none;"%> <% css_style_guidance_div = ""%> @@ -143,9 +46,9 @@
  • <% if comments.count > 0%> <% comments_label_with_count = "#{_('Notes')} (#{comments.count})"%> - <%= link_to comments_label_with_count , "#", id: "notes_number_#{question_id}", class: "comments_accordion_button" %> + <%= link_to comments_label_with_count , "#", id: "notes_number_#{question.id}", class: "comments_accordion_button" %> <% else %> - <%= link_to _('Share note'), "#", id: "notes_number_#{question_id}", class: "comments_accordion_button" %> + <%= link_to _('Share note'), "#", id: "notes_number_#{question.id}", class: "comments_accordion_button" %> <% end %>
  • <% else %> @@ -155,9 +58,9 @@
  • <% if comments.count > 0 %> <% comments_label_with_count = "#{_('Notes')} (#{comments.count})"%> -

    <%= comments_label_with_count %>

    +

    <%= comments_label_with_count %>

    <% else %> -

    <%= _('Share note') %>

    +

    <%= _('Share note') %>

    <% end %>
  • <% end %> @@ -166,10 +69,11 @@ -
    -
    +
    +
    + <% num_annotations = 0 %> <% if annotations.present? %> <% annotations.each do |annotation| %> @@ -177,7 +81,9 @@ -
    +
    <%= raw annotation.text %>
    - + <% num_annotations += 1%>
    <% end %> <% end %> - <% guidance_accordion_id = 0 %> + <% guidance_accordion_id = num_annotations %> <% question_guidances.each_pair do |theme, group| %> <% group.each do |gobj| %>
    -
    +
    <%= raw gobj[:text] %>
    <% guidance_accordion_id += 1 %> @@ -216,13 +122,13 @@
    -
    +
    <%= render partial: "note", locals: {question: question, answer: answer, plan: plan, suffix: "" }%>
    -<% if last_question_id == question_id then %> +<% if last_question_id == question.id then %>
    <% else %>
    diff --git a/app/views/phases/_edit_phase.html.erb b/app/views/phases/_edit_phase.html.erb index edbfd90..de7b425 100644 --- a/app/views/phases/_edit_phase.html.erb +++ b/app/views/phases/_edit_phase.html.erb @@ -23,14 +23,15 @@ <%= f.number_field :number, in: 0..5, class: "number_field has-tooltip", 'data-toggle' => "tooltip", 'title' => _('This allows you to order the phases of your template.') %> - <%= _('Description') %> - + <%= _('Description') %> +
    <%= text_area_tag("phase-desc", phase.description, class: "tinymce") %>
    <%= link_to( image_tag('help_button.png'), '#', class: 'phase_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("Enter a basic description. This will be presented to users on the 'Admin Plan' tab, above the summary of the sections and questions which they will be asked to answer."))%>
    +
    diff --git a/app/views/phases/admin_add.html.erb b/app/views/phases/admin_add.html.erb index a5141aa..72a9a66 100644 --- a/app/views/phases/admin_add.html.erb +++ b/app/views/phases/admin_add.html.erb @@ -47,9 +47,10 @@ <%= _('Description') %> - +
    <%= text_area_tag("phase-desc","" , class: "tinymce") %> + <%= tinymce %>
    <%= link_to( image_tag("help_button.png"), "#", class: "phase_desc_popover", rel: "popover", "data-html" => "true", "data-content" => _("Enter a basic description. This will be presented to users on the 'Admin Plan' tab, above the summary of the sections and questions which they will be asked to answer."))%> @@ -70,6 +71,4 @@
    -
    - -<%= tinymce content_css: asset_path("application.css") %> \ No newline at end of file +
    \ No newline at end of file diff --git a/app/views/phases/admin_show.html.erb b/app/views/phases/admin_show.html.erb index e27f41e..321ac60 100644 --- a/app/views/phases/admin_show.html.erb +++ b/app/views/phases/admin_show.html.erb @@ -2,7 +2,7 @@ <%= stylesheet_link_tag "admin" %> <% javascript 'admin.js' %> -<%= tinymce content_css: asset_path('application.css') %> +<%= tinymce %>

    <%= @phase.template.title %> diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index 9c73d91..8ddbcc2 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -11,7 +11,7 @@
    - <%= render :partial => "/plans/progress", locals: {nquestions: @nquestions, nanswers: @nanswers} %> + <%= render :partial => "/plans/progress", locals: { plan: @plan } %>
    @@ -34,26 +34,11 @@ <% end%>
    - - - <% num_section_questions = section.questions.to_a.count %> - <% num_section_answers = section.num_answered_questions(@plan.id) %> - <% question_word = "questions" %> - <% if num_section_questions == 1 then %> - <% question_word = "question" %> - <% end %> - <% section_status = "#{num_section_questions} #{question_word}, #{num_section_answers} answered" %> -
    -
    - <%= section.title %> - <% if num_section_questions.to_i > num_section_answers.to_i then %> - (<%= section_status %>) - <% else %> - (<%= section_status %>) - <% end %> +
    + <%= render :partial => "/sections/progress", locals: { section: section, plan: @plan } %>
    @@ -88,11 +73,10 @@
    <% guidances = @question_guidance[question.id] %> - + <%= render partial: 'answer_form', locals: { plan: @plan, - phase_id: @phase.id, question: question, question_guidances: guidances, last_question_id: section.questions.last.id, @@ -132,8 +116,6 @@ <% end %>
    - - <%= tinymce :content_css => asset_path("application.css"), :setup => "function(editor){editor.on('change', function(e){$.fn.check_textarea(editor)});}" %>
    diff --git a/app/views/plans/_plan_details.html.erb b/app/views/plans/_plan_details.html.erb index 2ce0220..ee420d1 100644 --- a/app/views/plans/_plan_details.html.erb +++ b/app/views/plans/_plan_details.html.erb @@ -220,9 +220,9 @@

    <% if based_on.org != plan.template.org %> - <%= _('A version of ') %> "<%= based_on.title %>" <%= based_on.title.downcase.include?(_('template')) ? '' : _('template') %><%= _(' that has been customised by ') %> <%= plan.template.org.name %> + <%= _('A version of ') %> "<%= based_on.title %>" <%= based_on.title.downcase.include?(_('template')) ? '' : _('template') %><%= _(' that has been customised by ') %> <%= plan.template.org.name %>. <% else %> - <%= _('The')%> "<%= plan.template.title %>" <%= (plan.template.is_default ? _('generic template') : plan.template.title.downcase.include?(_('template')) ? '' : _('template')) %> <%= _(' provided by ') %><%= plan.template.org.name %> + <%= _('The')%> "<%= plan.template.title %>" <%= (plan.template.is_default ? _('generic template') : plan.template.title.downcase.include?(_('template')) ? '' : _('template')) %> <%= _(' provided by ') %><%= plan.template.org.name %>. <% end %>

    @@ -231,6 +231,9 @@ <% phases = plan.template.phases %> <% if phases.count == 1 %> +
    + <%= raw plan.template.description %> +
    <% phases.each do |phase| %>
    <%= link_to _('Answer questions'), edit_plan_phase_path(plan,phase), :class => 'btn btn-primary' %> diff --git a/app/views/plans/_progress.html.erb b/app/views/plans/_progress.html.erb index 9a2fa84..256c00e 100644 --- a/app/views/plans/_progress.html.erb +++ b/app/views/plans/_progress.html.erb @@ -1,3 +1,7 @@ +<% + nanswers = plan.num_answered_questions() + nquestions = plan.num_questions() +%> <% answered = %(#{nanswers}/#{nquestions})%>
    <%= answered -%> <%= _('questions answered')%> diff --git a/app/views/plans/edit.html.erb b/app/views/plans/edit.html.erb index 57a7d38..44393fa 100644 --- a/app/views/plans/edit.html.erb +++ b/app/views/plans/edit.html.erb @@ -143,7 +143,7 @@
    <% end %>
    - <%= tinymce :content_css => asset_path("application.css"), :setup => "function(editor){editor.on('change', function(e){$.fn.check_textarea(editor)});}" %> + <%= tinymce %>
    <%= _('Export') %> diff --git a/app/views/questions/_add_question.html.erb b/app/views/questions/_add_question.html.erb index 9ca04bf..9e20de0 100644 --- a/app/views/questions/_add_question.html.erb +++ b/app/views/questions/_add_question.html.erb @@ -35,20 +35,19 @@ <%= _('Answer format')%> <%= f.hidden_field :section_id, value: section.id, class: "section_id" %> -
    +
    <%= f.select :question_format_id, - options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.find_by_title(_('Text area')).id), - {}, id: "new-select-format-#{section.id}"%> + options_from_collection_for_select(QuestionFormat.all.order("title"), :id, :title, QuestionFormat.id_for(QuestionFormat.formattypes[:textarea])), + {}, class: "question_format" %>
    <%= link_to( image_tag("help_button.png"), "#", class: "question_format_popover", rel: "popover", "data-html" => "true", "data-content" => _("You can choose from:
    • - text area (large box for paragraphs);
    • - text field (for a short answer);
    • - checkboxes where options are presented in a list and multiple values can be selected;
    • - radio buttons where options are presented in a list but only one can be selected;
    • - dropdown like this box - only one option can be selected;
    • - multiple select box allows users to select several options from a scrollable list, using the CTRL key;
    "))%>
    -
    -

diff --git a/app/views/templates/_edit_annotations.html.erb b/app/views/templates/_edit_annotations.html.erb index 443f6cb..8273f4d 100644 --- a/app/views/templates/_edit_annotations.html.erb +++ b/app/views/templates/_edit_annotations.html.erb @@ -44,7 +44,7 @@ - <%= _('Example of Answer')%> + <%= _('example answer')%>
<% annotations = question.annotations.where(org_id: current_user.org_id).where(type: Annotation.types[:example_answer]).order(:created_at).first %> diff --git a/app/views/templates/_edit_template.html.erb b/app/views/templates/_edit_template.html.erb index b1656c0..a660e7b 100644 --- a/app/views/templates/_edit_template.html.erb +++ b/app/views/templates/_edit_template.html.erb @@ -10,12 +10,14 @@ <%= _('Description') %> -
+ +
<%= text_area_tag("template-desc", template.description, class: "tinymce") %>
<%= link_to( image_tag('help_button.png'), '#', class: 'template_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => _('Enter a description that helps you to differentiate between templates e.g. if you have ones for different audiences'))%>
+
diff --git a/app/views/templates/_show_template.html.erb b/app/views/templates/_show_template.html.erb index 423dc5f..fed7740 100644 --- a/app/views/templates/_show_template.html.erb +++ b/app/views/templates/_show_template.html.erb @@ -2,9 +2,11 @@ <% if template == current then %>

+ <% if template.customization_of.nil? %>
<%= link_to _('Edit template details'), '# ', class: "btn btn-primary", id: "edit_template_button"%>
+ <% end %>

<% end %>
diff --git a/app/views/templates/admin_index.html.erb b/app/views/templates/admin_index.html.erb index 71ee063..37e6b6a 100644 --- a/app/views/templates/admin_index.html.erb +++ b/app/views/templates/admin_index.html.erb @@ -139,7 +139,7 @@ <% if hash[:current].customization_of.nil? %> <% b_label = _('Customise') %> - <%= link_to b_label, admin_customize_template_path(hash[:current]), method: :put, class: "dmp_table_link" %> + <%= link_to b_label, admin_customize_template_path(hash[:current]), method: :get, class: "dmp_table_link" %> <% else %> <% b_label = _('Edit customisation') %> <%= link_to b_label, admin_template_template_path(hash[:current]), class: "dmp_table_link" %> diff --git a/app/views/templates/admin_new.html.erb b/app/views/templates/admin_new.html.erb index ed39d22..e180b4a 100644 --- a/app/views/templates/admin_new.html.erb +++ b/app/views/templates/admin_new.html.erb @@ -25,7 +25,8 @@ <%= _('Description') %> -
+ +
<%= text_area_tag("template-desc", "", class: "tinymce") %>
@@ -44,4 +45,4 @@ <% end %>
-<%= tinymce content_css: asset_path("application.css") %> \ No newline at end of file +<%= tinymce %> \ No newline at end of file diff --git a/app/views/templates/admin_template.html.erb b/app/views/templates/admin_template.html.erb index afac069..77b956a 100644 --- a/app/views/templates/admin_template.html.erb +++ b/app/views/templates/admin_template.html.erb @@ -19,7 +19,7 @@
- <% if @template == @current %> + <% if @template == @current && @template.customization_of.nil? %> @@ -59,4 +59,4 @@ <% end %>
-<%= tinymce content_css: asset_path('application.css') %> +<%= tinymce %> diff --git a/config/locale/app.pot b/config/locale/app.pot index 1e57dc4..1520d3f 100644 --- a/config/locale/app.pot +++ b/config/locale/app.pot @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: app 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-26 15:50+0100\n" -"PO-Revision-Date: 2017-05-26 15:50+0100\n" +"POT-Creation-Date: 2017-06-08 13:02+0100\n" +"PO-Revision-Date: 2017-06-08 13:02+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -57,9 +57,6 @@ msgid " on " msgstr "" -msgid " once you click save!" -msgstr "" - msgid " or " msgstr "" @@ -69,9 +66,6 @@ msgid " provided by " msgstr "" -msgid " saved the following answer:" -msgstr "" - msgid " team" msgstr "" @@ -213,6 +207,9 @@ "

Email %{organisation_email}

" msgstr "" +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "" + msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "" @@ -249,15 +246,15 @@ msgid "Actions" msgstr "" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" +msgid "Add Annotations" +msgstr "" + +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." msgstr "" msgid "Add collaborator" msgstr "" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "" @@ -306,6 +303,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + msgid "Answer" msgstr "" @@ -408,9 +408,6 @@ msgid "Collaborators" msgstr "" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "" @@ -465,6 +462,9 @@ msgid "Delete" msgstr "" +msgid "Delete Example Answer" +msgstr "" + msgid "Delete question" msgstr "" @@ -501,7 +501,7 @@ msgid "Edit" msgstr "" -msgid "Edit Example of Answer" +msgid "Edit Annotations" msgstr "" msgid "Edit User Privileges" @@ -567,9 +567,6 @@ msgid "Example Answer" msgstr "" -msgid "Example of Answer" -msgstr "" - msgid "Example of answer" msgstr "" @@ -969,6 +966,12 @@ msgid "Plan was successfully updated." msgstr "" +msgid "Please enter a First name." +msgstr "" + +msgid "Please enter a Last name." +msgstr "" + msgid "Please enter a password confirmation" msgstr "" @@ -981,6 +984,9 @@ msgid "Please enter an email address" msgstr "" +msgid "Please enter an email address." +msgstr "" + msgid "Please enter the name of your organisation." msgstr "" @@ -1017,6 +1023,9 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +msgid "Please select an organisation, or select Other." +msgstr "" + msgid "Please select one" msgstr "" @@ -1122,6 +1131,9 @@ msgid "Save" msgstr "" +msgid "Save Unsuccessful." +msgstr "" + msgid "Saving..." msgstr "" @@ -1251,10 +1263,10 @@ msgid "The " msgstr "" -msgid "The edits in the box below will overwrite the existing answer from " +msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "" -msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." +msgid "The following answer cannot be saved" msgstr "" msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." @@ -1410,9 +1422,6 @@ msgid "Which DMP template would you like to use?" msgstr "" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "" @@ -1434,6 +1443,9 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "" +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "" @@ -1569,15 +1581,9 @@ msgid "ago" msgstr "" -msgid "answered" -msgstr "" - msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "" -msgid "by" -msgstr "" - msgid "by " msgstr "" @@ -1665,9 +1671,6 @@ msgid "question" msgstr "" -msgid "questions" -msgstr "" - msgid "questions answered" msgstr "" @@ -1683,6 +1686,9 @@ msgid "select at least one theme" msgstr "" +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr "" + msgid "template" msgstr "" diff --git a/config/locale/de/app.po b/config/locale/de/app.po index 7251de4..8146f34 100644 --- a/config/locale/de/app.po +++ b/config/locale/de/app.po @@ -61,9 +61,6 @@ msgid " on " msgstr "" -msgid " once you click save!" -msgstr "" - msgid " or " msgstr "" @@ -75,9 +72,6 @@ msgid " provided by " msgstr " von " -msgid " saved the following answer:" -msgstr "" - #, fuzzy msgid " team" msgstr "am" @@ -230,6 +224,10 @@ msgstr "DMPonline" #, fuzzy +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "DMPonline" + +#, fuzzy msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "A colleague has invited you to contribute to their Data Management Plan at" @@ -266,15 +264,16 @@ msgid "Actions" msgstr "Aktionen" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" -msgstr "Geben Sie einen geeigneten Namen für Ihre Hilfestellungsgruppe ein, wie z.B. 'CAU Hilfestellungen'. Dieser Name soll den Nutzern vermitteln, woher die Hilfestellung kommt, z.B. 'CAU Hilfestellung zu Metadaten'" +msgid "Add Annotations" +msgstr "" + +#, fuzzy +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." +msgstr "Hilfestellungsgruppe" msgid "Add collaborator" msgstr "Mitarbeitende(n) hinzufügen" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "Hilfestellung hinzufügen" @@ -327,6 +326,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + #, fuzzy msgid "Answer" msgstr "Antworten" @@ -438,9 +440,6 @@ msgid "Collaborators" msgstr "Mitarbeitende" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "Kommentar" @@ -498,6 +497,10 @@ msgid "Delete" msgstr "Löschen" +#, fuzzy +msgid "Delete Example Answer" +msgstr "Beispielantwort" + msgid "Delete question" msgstr "Frage löschen" @@ -535,8 +538,8 @@ msgstr "Bearbeiten" #, fuzzy -msgid "Edit Example of Answer" -msgstr "Beispielantwort" +msgid "Edit Annotations" +msgstr "Bearbeiten" msgid "Edit User Privileges" msgstr "Bearbeiten Benutzerberechtigungen" @@ -604,9 +607,6 @@ msgstr "Beispielantwort" #, fuzzy -msgid "Example of Answer" -msgstr "Beispielantwort" - msgid "Example of answer" msgstr "Beispielantwort" @@ -1022,6 +1022,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Bitte geben Sie ihren Vornamen ein." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Bitte geben Sie ihren Vornamen ein." + msgid "Please enter a password confirmation" msgstr "" @@ -1034,6 +1042,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Bitte prüfen Sie die Korrektheit ihrer Web-Adresse." + msgid "Please enter the name of your organisation." msgstr "Bitte geben Sie den Namen Ihrer Organisation an." @@ -1071,6 +1083,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organisation" + msgid "Please select one" msgstr "" @@ -1178,6 +1194,10 @@ msgid "Save" msgstr "Speichern" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Speichern" + msgid "Saving..." msgstr "Speichere..." @@ -1313,12 +1333,12 @@ msgid "The " msgstr "" -msgid "The edits in the box below will overwrite the existing answer from " -msgstr "" - msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "Die E-Mail -Adresse des Administrators in Ihrer Org. Ihre Benutzer werden diese Adresse verwenden, wenn sie Fragen haben." +msgid "The following answer cannot be saved" +msgstr "" + msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." msgstr "Die hier ausgewählten Einträge werden in der Tabelle unten angezeigt. Sie können die Daten durch jeden ihrer Tabellenköpfe sortieren oder filtern, indem Sie eine Zeichenkette in der Suchbox eingeben." @@ -1481,9 +1501,6 @@ msgid "Which DMP template would you like to use?" msgstr "templates" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "Wollen Sie sie jetzt sichern?" @@ -1505,6 +1522,10 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "Sie sind dabei '%{section_title}' zu entfernen. Das wird Auswirkungen auf die Fragen haben, die mit diesem Abschnitt verbunden sind. Sind Sie sicher?" +#, fuzzy +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "Sie sind dabei den Antwortvorschlag / das Beispiel für '%{question_text}' zu löschen. Sind Sie sicher?" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "Sie sind dabei den Antwortvorschlag / das Beispiel für '%{question_text}' zu löschen. Sind Sie sicher?" @@ -1665,16 +1686,9 @@ msgstr "" #, fuzzy -msgid "answered" -msgstr "Beantwortet " - -#, fuzzy msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "annährend %{space_used}% des verfügbaren Platzes wird verwendet (max. %{num_pages} Seiten)" -msgid "by" -msgstr "" - #, fuzzy msgid "by " msgstr " von " @@ -1776,10 +1790,6 @@ msgid "question" msgstr "Frage" -#, fuzzy -msgid "questions" -msgstr "Fragen" - msgid "questions answered" msgstr "Fragen beantwortet" @@ -1797,6 +1807,9 @@ msgid "select at least one theme" msgstr "select at least one theme" +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr "" + #, fuzzy msgid "template" msgstr "templates" diff --git a/config/locale/en_GB/app.po b/config/locale/en_GB/app.po index 244d1d9..d0ebad7 100644 --- a/config/locale/en_GB/app.po +++ b/config/locale/en_GB/app.po @@ -60,9 +60,6 @@ msgid " on " msgstr " on " -msgid " once you click save!" -msgstr " once you click save!" - #, fuzzy msgid " or " msgstr " on " @@ -74,9 +71,6 @@ msgid " provided by " msgstr " by " -msgid " saved the following answer:" -msgstr " saved the following answer:" - msgid " team" msgstr " team" @@ -222,6 +216,10 @@ "

Email %{organisation_email}

" msgstr "%{application_name}" +#, fuzzy +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "%{application_name}" + msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "A colleague has invited you to contribute to their Data Management Plan at " @@ -258,15 +256,16 @@ msgid "Actions" msgstr "Actions" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" -msgstr "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" +msgid "Add Annotations" +msgstr "" + +#, fuzzy +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." +msgstr "guidance group" msgid "Add collaborator" msgstr "Add collaborator" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "Add guidance" @@ -319,6 +318,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + msgid "Answer" msgstr "Answer" @@ -424,9 +426,6 @@ msgid "Collaborators" msgstr "Collaborators" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "Comment" @@ -482,6 +481,10 @@ msgid "Delete" msgstr "Delete" +#, fuzzy +msgid "Delete Example Answer" +msgstr "Example of answer" + msgid "Delete question" msgstr "Delete question" @@ -519,8 +522,8 @@ msgstr "Edit" #, fuzzy -msgid "Edit Example of Answer" -msgstr "Example of answer" +msgid "Edit Annotations" +msgstr "Edit" msgid "Edit User Privileges" msgstr "Edit User Privileges" @@ -587,9 +590,6 @@ msgstr "Example of answer" #, fuzzy -msgid "Example of Answer" -msgstr "Example of answer" - msgid "Example of answer" msgstr "Example of answer" @@ -1001,6 +1001,14 @@ msgid "Plan was successfully updated." msgstr "Plan was successfully updated." +#, fuzzy +msgid "Please enter a First name." +msgstr "Please enter your first name." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Please enter your first name." + msgid "Please enter a password confirmation" msgstr "" @@ -1013,6 +1021,10 @@ msgid "Please enter an email address" msgstr "Please enter an email address" +#, fuzzy +msgid "Please enter an email address." +msgstr "Please enter an email address" + msgid "Please enter the name of your organisation." msgstr "Please enter the name of your organisation." @@ -1050,6 +1062,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "organisation" + msgid "Please select one" msgstr "" @@ -1157,6 +1173,10 @@ msgid "Save" msgstr "Save" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Save" + msgid "Saving..." msgstr "Saving..." @@ -1290,12 +1310,13 @@ msgid "The " msgstr "The " -msgid "The edits in the box below will overwrite the existing answer from " -msgstr "The edits in the box below will overwrite the existing answer from " - msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "The email address of an administrator at your organisation. Your users will use this address if they have questions." +#, fuzzy +msgid "The following answer cannot be saved" +msgstr "The " + msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." msgstr "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." @@ -1455,9 +1476,6 @@ msgid "Which DMP template would you like to use?" msgstr "template" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "Would you like to save them now?" @@ -1479,6 +1497,10 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" +#, fuzzy +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" @@ -1620,15 +1642,9 @@ msgid "ago" msgstr "ago" -msgid "answered" -msgstr "answered" - msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "approx. %{space_used}%% of available space used (max %{num_pages} pages)" -msgid "by" -msgstr "" - #, fuzzy msgid "by " msgstr " by " @@ -1720,9 +1736,6 @@ msgid "question" msgstr "question" -msgid "questions" -msgstr "questions" - msgid "questions answered" msgstr "questions answered" @@ -1738,6 +1751,10 @@ msgid "select at least one theme" msgstr "select at least one theme" +#, fuzzy +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr " on " + msgid "template" msgstr "template" diff --git a/config/locale/en_US/app.po b/config/locale/en_US/app.po index dbb07f4..4cb0fb5 100644 --- a/config/locale/en_US/app.po +++ b/config/locale/en_US/app.po @@ -60,9 +60,6 @@ msgid " on " msgstr " on " -msgid " once you click save!" -msgstr " once you click save!" - #, fuzzy msgid " or " msgstr " on " @@ -74,9 +71,6 @@ msgid " provided by " msgstr " by " -msgid " saved the following answer:" -msgstr " saved the following answer:" - msgid " team" msgstr " team" @@ -222,6 +216,10 @@ "

Email %{organisation_email}

" msgstr "%{application_name}" +#, fuzzy +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "%{application_name}" + msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "A colleague has invited you to contribute to their Data Management Plan at " @@ -258,15 +256,16 @@ msgid "Actions" msgstr "Actions" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" -msgstr "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" +msgid "Add Annotations" +msgstr "" + +#, fuzzy +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." +msgstr "guidance group" msgid "Add collaborator" msgstr "Add collaborator" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "Add guidance" @@ -319,6 +318,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + msgid "Answer" msgstr "Answer" @@ -424,9 +426,6 @@ msgid "Collaborators" msgstr "Collaborators" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "Comment" @@ -482,6 +481,10 @@ msgid "Delete" msgstr "Delete" +#, fuzzy +msgid "Delete Example Answer" +msgstr "Example of answer" + msgid "Delete question" msgstr "Delete question" @@ -519,8 +522,8 @@ msgstr "Edit" #, fuzzy -msgid "Edit Example of Answer" -msgstr "Example of answer" +msgid "Edit Annotations" +msgstr "Edit" msgid "Edit User Privileges" msgstr "Edit User Permissions" @@ -587,9 +590,6 @@ msgstr "Example of answer" #, fuzzy -msgid "Example of Answer" -msgstr "Example of answer" - msgid "Example of answer" msgstr "Example of answer" @@ -1001,6 +1001,14 @@ msgid "Plan was successfully updated." msgstr "Plan was successfully updated." +#, fuzzy +msgid "Please enter a First name." +msgstr "Please enter your first name." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Please enter your first name." + msgid "Please enter a password confirmation" msgstr "" @@ -1013,6 +1021,10 @@ msgid "Please enter an email address" msgstr "Please enter an email address" +#, fuzzy +msgid "Please enter an email address." +msgstr "Please enter an email address" + msgid "Please enter the name of your organisation." msgstr "Please enter the name of your organization." @@ -1050,6 +1062,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "organization" + msgid "Please select one" msgstr "" @@ -1157,6 +1173,10 @@ msgid "Save" msgstr "Save" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Save" + msgid "Saving..." msgstr "Saving..." @@ -1290,12 +1310,13 @@ msgid "The " msgstr "The " -msgid "The edits in the box below will overwrite the existing answer from " -msgstr "The edits in the box below will overwrite the existing answer from " - msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "The email address of an administrator at your organization. Your users will use this address if they have questions." +#, fuzzy +msgid "The following answer cannot be saved" +msgstr "The " + msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." msgstr "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." @@ -1455,9 +1476,6 @@ msgid "Which DMP template would you like to use?" msgstr "template" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "Would you like to save them now?" @@ -1479,6 +1497,10 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" +#, fuzzy +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" @@ -1620,15 +1642,9 @@ msgid "ago" msgstr "ago" -msgid "answered" -msgstr "answered" - msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "approx. %{space_used}%% of available space used (max %{num_pages} pages)" -msgid "by" -msgstr "" - #, fuzzy msgid "by " msgstr " by " @@ -1720,9 +1736,6 @@ msgid "question" msgstr "question" -msgid "questions" -msgstr "questions" - msgid "questions answered" msgstr "questions answered" @@ -1738,6 +1751,10 @@ msgid "select at least one theme" msgstr "select at least one theme" +#, fuzzy +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr " on " + msgid "template" msgstr "template" diff --git a/config/locale/es/app.po b/config/locale/es/app.po index c7cfe48..25d8f59 100644 --- a/config/locale/es/app.po +++ b/config/locale/es/app.po @@ -60,9 +60,6 @@ msgid " on " msgstr "" -msgid " once you click save!" -msgstr "" - msgid " or " msgstr "" @@ -73,9 +70,6 @@ msgid " provided by " msgstr " por " -msgid " saved the following answer:" -msgstr "" - #, fuzzy msgid " team" msgstr "am" @@ -226,6 +220,10 @@ "

Email %{organisation_email}

" msgstr "DMPonline" +#, fuzzy +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "DMPonline" + msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "" @@ -262,15 +260,16 @@ msgid "Actions" msgstr "Acciones" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" -msgstr "Añada un nombre adecuado para el grupo de su guía (Ej: Guía de Glasgow). Este nombre se usará para indicar a los usuarios finales la procedencia de la guía (Ej: 'Guía de metadatos de Glasgow')" +msgid "Add Annotations" +msgstr "" + +#, fuzzy +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." +msgstr "Grupo de orientación" msgid "Add collaborator" msgstr "Añadir colaborador" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "Añadir orientación" @@ -323,6 +322,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + #, fuzzy msgid "Answer" msgstr "Respuestas" @@ -434,9 +436,6 @@ msgid "Collaborators" msgstr "Colaboradores" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "Comentario" @@ -494,6 +493,10 @@ msgid "Delete" msgstr "Borrar" +#, fuzzy +msgid "Delete Example Answer" +msgstr "Respuesta de ejemplo" + msgid "Delete question" msgstr "Borrar la pregunta" @@ -531,8 +534,8 @@ msgstr "Editar" #, fuzzy -msgid "Edit Example of Answer" -msgstr "Respuesta de ejemplo" +msgid "Edit Annotations" +msgstr "Editar" msgid "Edit User Privileges" msgstr "" @@ -600,9 +603,6 @@ msgstr "Respuesta de ejemplo" #, fuzzy -msgid "Example of Answer" -msgstr "Respuesta de ejemplo" - msgid "Example of answer" msgstr "Respuesta de ejemplo" @@ -1017,6 +1017,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Por favor, introduzca su nombre." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Por favor, introduzca su nombre." + msgid "Please enter a password confirmation" msgstr "" @@ -1029,6 +1037,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Por favor, introduzca una dirección web válida." + msgid "Please enter the name of your organisation." msgstr "Por favor, introduzca el nombre de su entidad." @@ -1066,6 +1078,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organización" + msgid "Please select one" msgstr "" @@ -1173,6 +1189,10 @@ msgid "Save" msgstr "Guardar" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Guardar" + msgid "Saving..." msgstr "Guardando..." @@ -1306,10 +1326,10 @@ msgid "The " msgstr "" -msgid "The edits in the box below will overwrite the existing answer from " +msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "" -msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." +msgid "The following answer cannot be saved" msgstr "" msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." @@ -1474,9 +1494,6 @@ msgid "Which DMP template would you like to use?" msgstr "templates" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "¿Quere grabar los cambios ahora?" @@ -1498,6 +1515,10 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "Va a borrar '%{section_title}'. Esta acción afectará las preguntas enlazadas con esta sección. ¿Está seguro?" +#, fuzzy +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "Va a eliminar una respuesta sugerida / ejemplo de '%{question_text}'. ¿Está seguro?" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "Va a eliminar una respuesta sugerida / ejemplo de '%{question_text}'. ¿Está seguro?" @@ -1650,16 +1671,9 @@ msgstr "" #, fuzzy -msgid "answered" -msgstr "Contestado " - -#, fuzzy msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "aprox. %{space_used}% de disponibilidad del espacio usado (máx. %{num_pages} páginas)" -msgid "by" -msgstr "" - #, fuzzy msgid "by " msgstr " por " @@ -1759,10 +1773,6 @@ msgid "question" msgstr "Pregunta" -#, fuzzy -msgid "questions" -msgstr "Preguntas" - msgid "questions answered" msgstr "preguntas respondidas" @@ -1780,6 +1790,9 @@ msgid "select at least one theme" msgstr "" +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr "" + #, fuzzy msgid "template" msgstr "templates" diff --git a/config/locale/fr/app.po b/config/locale/fr/app.po index fc41878..1bc520c 100644 --- a/config/locale/fr/app.po +++ b/config/locale/fr/app.po @@ -60,9 +60,6 @@ msgid " on " msgstr "" -msgid " once you click save!" -msgstr "" - msgid " or " msgstr "" @@ -73,9 +70,6 @@ msgid " provided by " msgstr " par " -msgid " saved the following answer:" -msgstr "" - #, fuzzy msgid " team" msgstr "am" @@ -225,6 +219,10 @@ "

Email %{organisation_email}

" msgstr "DMPonline" +#, fuzzy +msgid "A Data Management Plan in %{application_name} has been shared with you" +msgstr "DMPonline" + msgid "A colleague has invited you to contribute to their Data Management Plan at " msgstr "" @@ -261,15 +259,16 @@ msgid "Actions" msgstr "Actions" -msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'" -msgstr "Ajoutez un nom adéquat à votre groupe de conseils, par ex. : Conseils de Glasgow. Ce nom sera utilié pour indiquer à lutilisateur final lorigine des conseils, par ex. : Glasgow Guidance on Metadata" +msgid "Add Annotations" +msgstr "" + +#, fuzzy +msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name." +msgstr "Groupe de conseils" msgid "Add collaborator" msgstr "Ajouter le collaborateur" -msgid "Add example answer" -msgstr "" - msgid "Add guidance" msgstr "Ajoutez des conseils" @@ -322,6 +321,9 @@ msgid "An error has occurred while saving/resetting your export settings." msgstr "" +msgid "Annotations" +msgstr "" + #, fuzzy msgid "Answer" msgstr "Réponses" @@ -432,9 +434,6 @@ msgid "Collaborators" msgstr "Collaborateurs" -msgid "Combine their changes with your answer below and then save the answer again." -msgstr "" - msgid "Comment" msgstr "Commentaire" @@ -492,6 +491,10 @@ msgid "Delete" msgstr "Effacer" +#, fuzzy +msgid "Delete Example Answer" +msgstr "Exemple de réponse" + msgid "Delete question" msgstr "Supprimer la question" @@ -529,8 +532,8 @@ msgstr "Modifier" #, fuzzy -msgid "Edit Example of Answer" -msgstr "Exemple de réponse" +msgid "Edit Annotations" +msgstr "Modifier" msgid "Edit User Privileges" msgstr "" @@ -598,9 +601,6 @@ msgstr "Exemple de réponse" #, fuzzy -msgid "Example of Answer" -msgstr "Exemple de réponse" - msgid "Example of answer" msgstr "Exemple de réponse" @@ -1014,6 +1014,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Entrez votre prénom, svp." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Entrez votre prénom, svp." + msgid "Please enter a password confirmation" msgstr "" @@ -1026,6 +1034,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Formation à la rédaction de documents scientifiques en anglais une adresse web valide." + msgid "Please enter the name of your organisation." msgstr "Veuillez saisir le nom de votre organisme.." @@ -1063,6 +1075,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organisation" + msgid "Please select one" msgstr "" @@ -1170,6 +1186,10 @@ msgid "Save" msgstr "Enregistrer" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Enregistrer" + msgid "Saving..." msgstr "Enregistrement en cours..." @@ -1303,10 +1323,10 @@ msgid "The " msgstr "" -msgid "The edits in the box below will overwrite the existing answer from " +msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." msgstr "" -msgid "The email address of an administrator at your organisation. Your users will use this address if they have questions." +msgid "The following answer cannot be saved" msgstr "" msgid "The items you select here will be displayed in the table below. You can sort the data by each of these headings or filter by entering a text string in the search box." @@ -1471,9 +1491,6 @@ msgid "Which DMP template would you like to use?" msgstr "templates" -msgid "While you were editing " -msgstr "" - msgid "Would you like to save them now?" msgstr "Voulez-vous faire la sauvegarde maintenant?" @@ -1495,6 +1512,10 @@ msgid "You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?" msgstr "Vous allez supprimer %{section_title}. Cette opération affectera les questions liées à cette phase. En êtes-vous sûr?" +#, fuzzy +msgid "You are about to delete a guidance for '%{question_text}'. Are you sure?" +msgstr "Vous allez supprimer la suggestion/lexemple de réponse à la questioo : %{question_text}. En êtes-vous sûr ?" + msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?" msgstr "Vous allez supprimer la suggestion/lexemple de réponse à la questioo : %{question_text}. En êtes-vous sûr ?" @@ -1647,16 +1668,9 @@ msgstr "" #, fuzzy -msgid "answered" -msgstr "Réponse " - -#, fuzzy msgid "approx. %{space_used}%% of available space used (max %{num_pages} pages)" msgstr "env. %{space_used}% despace disponible utilisé (%{num_pages} pages maxi)" -msgid "by" -msgstr "" - #, fuzzy msgid "by " msgstr " par " @@ -1756,10 +1770,6 @@ msgid "question" msgstr "Question" -#, fuzzy -msgid "questions" -msgstr "Questions" - msgid "questions answered" msgstr "questions avec réponses" @@ -1777,6 +1787,9 @@ msgid "select at least one theme" msgstr "" +msgid "since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again." +msgstr "" + #, fuzzy msgid "template" msgstr "templates" diff --git a/config/routes.rb b/config/routes.rb index 8fee9ee..4591fc9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,10 +125,10 @@ get 'admin_template' get 'admin_new' get 'admin_template_history' + get 'admin_customize' delete 'admin_destroy' post 'admin_create' put 'admin_update' - put 'admin_customize' put 'admin_publish' put 'admin_unpublish' end diff --git a/config/tinymce.yml b/config/tinymce.yml index bc00326..2b2bb03 100644 --- a/config/tinymce.yml +++ b/config/tinymce.yml @@ -1,3 +1,5 @@ +content_css: /assets/application.css +selector: 'textarea.tinymce' statusbar: false menubar: false toolbar: bold italic | bullist numlist | link | table diff --git a/lib/assets/javascripts/admin.js b/lib/assets/javascripts/admin.js index 5997e27..7b47b6b 100644 --- a/lib/assets/javascripts/admin.js +++ b/lib/assets/javascripts/admin.js @@ -30,147 +30,28 @@ e.preventDefault(); }).popover(); - //show or hide divs based on what the user selects from the question format. New question - $('.ques_format').on("change", function(e) { - var s_id = $(this).prev(".section_id").val(); - - var selected_format = $('#new-select-format-'+ s_id).val(); - - //text area - if (selected_format == 1){ - $("#new-options-"+ s_id).hide(); - $("#new-default-text-field-"+ s_id).hide(); - $("#new-default-text-area-"+ s_id).show(); - $("#new-default-value-field-"+ s_id).show(); - } - //text field - else if (selected_format == 2){ - $("#new-options-"+ s_id).hide(); - $("#new-default-text-field-"+ s_id).show(); - $("#new-default-value-field-"+ s_id).show(); - $("#new-default-text-area-"+ s_id).hide(); - } - //checkbox,radio button, dropdown, multi select - else if (selected_format == 3 ||selected_format == 4 || selected_format == 5 || selected_format == 6){ - $("#new-options-"+ s_id).show(); - $("#new-default-text-field-"+ s_id).hide(); - $("#new-default-text-area-"+ s_id).hide(); - $("#new-default-value-field-"+ s_id).hide(); - } - delete selected_format; - }).trigger('change'); - - - //show or hide divs based on what the user selects from the question format - $('.ques_format').on("change", function(e) { - var q_id = $(this).find('.quest_id').val(); - - var selected_format = $('#'+ q_id +'-select-format').val(); - //text area - if (selected_format == 1){ - $("#options-"+ q_id).hide(); - $("#default-text-field-"+ q_id).hide(); - $("#default-text-area-"+ q_id).show(); - $("#default-value-field-"+ q_id).show(); - } - //text field - else if (selected_format == 2){ - $("#options-"+ q_id).hide(); - $("#default-text-field-"+ q_id).show(); - $("#default-value-field-"+ q_id).show(); - $("#default-text-area-"+ q_id).hide(); - } - //checkbox,radio button, dropdown, multi select - else if (selected_format == 3 ||selected_format == 4 || selected_format == 5 || selected_format == 6){ - $("#options-"+ q_id).show(); - $("#default-text-field-"+ q_id).hide(); - $("#default-text-area-"+ q_id).hide(); - $("#default-value-field-"+ q_id).hide(); - } - delete selected_format; - delete q_id; - }).trigger('change'); - - - //Code to show/hide divs on new guidance (by themes or by question) -/* $('#g_options').on("change", function (){ - var g_t_q = $(this).val(); - - e_g_q_f = $("#edit_guid_ques_flag").val(); - - if (g_t_q == 1){ - $(".guindace_by_question").hide(); - $(".guindance_by_theme").show(); - } - else if (g_t_q == 2){ - $(".guindace_by_question").show(); - $(".guindance_by_theme").hide(); - } - - }).trigger('change'); -*/ - - //filter from template to question 5 dropdowns -/* $('#templates_select').change(function() { - $.ajax({ - type: 'GET', - url: "update_phases", - dataType: 'script', - data: { - dmptemplate_id : $('#templates_select').val() - } - }); - $('#phases_select').show(); - //$('#versions_select').hide(); - //$('#sections_select').hide(); - //$('#questions_select').hide(); - return false; - }); - $('#phases_select').change(function() { - $.ajax({ - type: 'GET', - url: "update_versions", - dataType: 'script', - data: { - phase_id : $('#phases_select').val() - } - }); - //$('#phases_select').show(); - $('#versions_select').show(); - //$('#sections_select').hide(); - //$('#questions_select').hide(); - return false; - }); - $('#versions_select').change(function() { - $.ajax({ - type: 'GET', - url: "update_sections", - dataType: 'script', - data: { - version_id : $('#versions_select').val() - } - }); - //$('#phases_select').show(); - //$('#versions_select').show(); - $('#sections_select').show(); - //$('#questions_select').show(); - return false; - }); - $('#sections_select').change(function() { - $.ajax({ - type: 'GET', - url: "update_questions", - dataType: 'script', - data: { - section_id : $('#sections_select').val() - } - }); - //$('#phases_select').show(); - //$('#versions_select').show(); - //$('#sections_select').show(); - $('#questions_select').show(); - }); -*/ + // This handler serves to display/hide default_answer field as well as to display/hide question_options fields + // depending on the question_format selected + $('.question_format').change(function(){ + var selected = $(this).val(); + var question_div = $(this).closest('.question-div'); + if(selected === '1' || selected === '2') { + question_div.find('.ques_format_option').hide(); + question_div.find('.default_answer').show(); + if(selected === '1') { //textarea + question_div.find('.default_answer_textfield').hide(); + question_div.find('.default_answer_textarea').prev().show() + } + else { //textfield + question_div.find('.default_answer_textarea').prev().hide(); + question_div.find('.default_answer_textfield').show(); + } + } + else if(selected === '3' || selected === '4' || selected === '5' || selected === '6') { // option_based + question_div.find('.default_answer').hide(); + question_div.find('.ques_format_option').show(); + } + }); //action for show or hide template editing display $('#edit_template_button').click(function(e){ @@ -255,33 +136,40 @@ e.preventDefault(); }); - //SUGGESTED ANSWERS - //action for adding a new suggested answer - $('.add_suggested_answer_button').click(function(e){ + //ANNOTATIONS + //action for adding a new annotation + $('.add_annotations_button').click(function(e){ var q_id = $(this).prev(".question_id").val(); - - $('#add_suggested_answer_block_'+ q_id).show(); - $('#add_suggested_answer_button_'+ q_id).hide(); + $('#add_annotations_block_'+ q_id).show(); + $('#add_annotations_button_'+ q_id).hide(); e.preventDefault(); }); - //cancelling edit of a suggested answer - $(".cancel_edit_suggested_answer").click(function(e){ + //cancelling edit of an annotation + $(".cancel_edit_annotations").click(function(e){ var q_id = $(this).prev(".question_id").val(); - $('#edit_suggested_answer_div_'+ q_id).hide(); - $('#show_suggested_answer_div_'+ q_id).show(); + $('#edit_annotations_div_'+ q_id).hide(); + $('#show_annotations_div_'+ q_id).show(); e.preventDefault(); }); - //edit a suggested answer - $('.edit_form_for_suggested_answer').click(function(e){ + //cancelling addition of an annotation + $(".cancel_add_annotations").click(function(e){ + var q_id = $(this).prev(".question_id").val(); + $('#add_annotations_block_'+ q_id).hide(); + $('#add_annotations_button_'+ q_id).show(); + e.preventDefault(); + }); + + //edit an annotation + $('.edit_form_for_annotations').click(function(e){ var q_id = $(this).prev(".question_id").val(); - $('#edit_suggested_answer_div_'+ q_id).show(); - $('#show_suggested_answer_div_'+ q_id).hide(); + $('#edit_annotations_div_'+ q_id).show(); + $('#show_annotations_div_'+ q_id).hide(); e.preventDefault(); }); - //GUIDANCE + //GUIDANCE //action for adding a new guidance next to the question $('.add_guidance_button').click(function(e){ var q_id = $(this).prev(".question_id").val(); diff --git a/lib/assets/javascripts/answers/status.js b/lib/assets/javascripts/answers/status.js index 3358bd9..ebf5165 100644 --- a/lib/assets/javascripts/answers/status.js +++ b/lib/assets/javascripts/answers/status.js @@ -2,14 +2,24 @@ $(document).ready(function(){ $("form.answer").submit(function(){ - var saving = $(this).find('.saving-message'); + var container = $(this).closest('.question-form'); + var saving = container.find('.saving-message'); saving.show(); }); $("form.answer fieldset input, form.answer fieldset select").change(function(){ - var unsaved = $(this).closest('form.answer').find('.answer-unsaved'); + var unsaved = $(this).closest('.question-form').find('.answer-unsaved'); unsaved.show(); + var notAnswered = $(this).closest('.question-form').find('.not-answered'); + notAnswered.hide(); }); - // TODO An adequate listener for textarea (e.g. tinymce) that triggers unsaved.show(). Temporary workaround defined at $.fn.toggle_dirty (plans.js) + $.fn.change_answer = function(editor){ + editor.on('change', function(event){ + var unsaved = $('#'+editor.id).closest('.question-form').find('.answer-unsaved'); + unsaved.show(); + var notAnswered = $('#'+editor.id).closest('.question-form').find('.not-answered'); + notAnswered.hide(); + }); + } $.fn.init_answer_status = function() { $('abbr.timeago').timeago(); } diff --git a/lib/assets/javascripts/plans.js b/lib/assets/javascripts/plans.js index 86acb77..5837312 100644 --- a/lib/assets/javascripts/plans.js +++ b/lib/assets/javascripts/plans.js @@ -353,6 +353,7 @@ }; $.fn.toggle_dirty = function(question_id, is_dirty) { + console.log($(this)); section_id = $(this).attr("id").split('-')[0]; if (dirty[section_id] == null) { dirty[section_id] = {}; @@ -360,17 +361,8 @@ dirty[section_id][question_id] = is_dirty; if (is_dirty) { $("#"+question_id+"-unsaved").show(); - $("#answer-status-"+question_id).find('.answer-unsaved').show(); // Temporary workaround ONLY triggered when textarea format type changes } else { $("#"+question_id+"-unsaved").hide(); } }; - - - - -// this is the function used to hanndle the interface between tinymce and the Dirty stuff -$.fn.check_textarea = function(editor) { - $("#"+editor.id).closest(".accordion-group").find(".section-status:first").toggle_dirty(editor.id.split('-')[2], editor.isDirty()); -}; diff --git a/lib/assets/stylesheets/admin.css.less b/lib/assets/stylesheets/admin.css.less index 075941e..30da02c 100644 --- a/lib/assets/stylesheets/admin.css.less +++ b/lib/assets/stylesheets/admin.css.less @@ -1186,7 +1186,7 @@ } table.dmp_details_table tr td.tinymce{ - min-width: 370px; + min-width: 400px; } table.dmp_details_table .text_area{ diff --git a/lib/assets/stylesheets/bootstrap_and_overrides.css.less b/lib/assets/stylesheets/bootstrap_and_overrides.css.less index f083ce1..11fcd58 100644 --- a/lib/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/lib/assets/stylesheets/bootstrap_and_overrides.css.less @@ -474,6 +474,7 @@ div.answer_notice { background-color: #fee; margin-bottom: 4px; + padding: 5px; } diff --git a/lib/assets/stylesheets/roadmap-form.scss b/lib/assets/stylesheets/roadmap-form.scss index 72345a1..5a860ae 100644 --- a/lib/assets/stylesheets/roadmap-form.scss +++ b/lib/assets/stylesheets/roadmap-form.scss @@ -45,6 +45,7 @@ /* Fieldset with labels over inputs */ fieldset.standard { + padding: 5px; background-color: $white; margin-bottom: 25px; diff --git a/public/shib_logo.png b/public/shib_logo.png deleted file mode 100644 index 191b508..0000000 --- a/public/shib_logo.png +++ /dev/null Binary files differ diff --git a/test/functional/annotations_controller_test.rb b/test/functional/annotations_controller_test.rb index 8615d16..67c7756 100644 --- a/test/functional/annotations_controller_test.rb +++ b/test/functional/annotations_controller_test.rb @@ -36,59 +36,72 @@ # POST /org/admin/templates/suggested_answers/:id/admin_create (admin_create_annotation_path) # ---------------------------------------------------------- test "create a new annotation" do - params = {org_id: @user.org.id, question_id: @question.id, text: "Here's a suggestion"} + params_guid = {question_id: @question.id, guidance_text: "some guidance text"} + params_example = {question_id: @question.id, example_answer_text: "example answer text"} + params_both = {question_id: @question.id, example_answer_text: "example answer text", guidance_text: "some guidance text"} # Should redirect user to the root path if they are not logged in! - post admin_create_annotation_path(@question.id), {annotation: params} + post admin_create_annotation_path(id: Annotation.first.id), params_both assert_unauthorized_redirect_to_root_path sign_in @user - post admin_create_annotation_path(@question.id), {annotation: params} + # both + post admin_create_annotation_path(id: Annotation.first.id), params_both assert_response :redirect assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" assert_equal _('Information was successfully created.'), flash[:notice] - assert_equal "Here's a suggestion", Annotation.last.text, "expected the record to have been created!" - assert assigns(:example_answer) + assert_equal "some guidance text", Annotation.last.text, "expected the guidance to have been created!" + assert_equal "example answer text", Annotation.all[-2].text, "expected the example answer to have been created" + # just an example answer + post admin_create_annotation_path(id: Annotation.first.id), params_example + assert_response :redirect + assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" + assert_equal _('Information was successfully created.'), flash[:notice] + assert_equal "example answer text", Annotation.last.text, "expected the record to have been created!" + # just some guidance + post admin_create_annotation_path(id: Annotation.first.id), params_guid + assert_response :redirect + assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" + assert_equal _('Information was successfully created.'), flash[:notice] + assert_equal "some guidance text", Annotation.last.text, "expected the record to have been created!" - # Invalid object - post admin_create_annotation_path(@question.id), {annotation: {question_id: @question.id}} - assert flash[:notice].starts_with?(_('Could not create your')) - assert_response :success - assert assigns(:example_answer) end # PUT /org/admin/templates/suggested_answers/:id/admin_update (admin_update_suggested_answer_path) # ---------------------------------------------------------- test "update the annotation" do - params = {text: 'UPDATE'} + q = Annotation.first.question + params_guid = {question_id: q.id, guidance_id: Annotation.first.id ,guidance_text: 'UPDATE'} + params_example = {question_id: q.id, example_answer_id: Annotation.first.id, example_answer_text: 'UPDATE'} + params_both = {question_id: q.id, guidance_id: Annotation.first.id ,guidance_text: 'gUPDATE',example_answer_id: Annotation.last.id, example_answer_text: 'eUPDATE'} # Should redirect user to the root path if they are not logged in! - put admin_update_annotation_path(Annotation.first), {annotation: params} + put admin_update_annotation_path(id: Annotation.first.id), params_guid assert_unauthorized_redirect_to_root_path sign_in @user - # Valid save - put admin_update_annotation_path(Annotation.first), {annotation: params} + # Valid save for guidance only + put admin_update_annotation_path(id: Annotation.first.id), params_guid assert_equal _('Information was successfully updated.'), flash[:notice] assert_response :redirect assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" - assert assigns(:example_answer) - assert assigns(:question) - assert assigns(:section) - assert assigns(:phase) assert_equal 'UPDATE', Annotation.first.text, "expected the record to have been updated" + # valid save for example only + put admin_update_annotation_path(id: Annotation.first.id), params_example + assert_equal _('Information was successfully updated.'), flash[:notice] + assert_response :redirect + assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" + assert_equal 'UPDATE', Annotation.first.text, "expected the record to have been updated" + # valid save for both example answer and guidance + put admin_update_annotation_path(id: Annotation.first.id), params_both + assert_equal _('Information was successfully updated.'), flash[:notice] + assert_response :redirect + assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}" + assert_equal 'gUPDATE', Annotation.first.text, "expected the record to have been updated" + assert_equal 'eUPDATE', Annotation.last.text, "expected the record to have been updated" -# TODO: We need to add in validation checks on the model and reactivate this test - # Invalid save -# put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: {text: nil}} -# assert flash[:notice].starts_with?(_('Could not update your')) -# assert_response :success -# assert assigns(:suggested_answer) -# assert assigns(:question) -# assert assigns(:section) -# assert assigns(:phase) end # DELETE /org/admin/templates/suggested_answers/:id/admin_destroy (admin_destroy_suggested_answer_path) diff --git a/test/functional/answers_controller_test.rb b/test/functional/answers_controller_test.rb index 1d5a3eb..a659295 100644 --- a/test/functional/answers_controller_test.rb +++ b/test/functional/answers_controller_test.rb @@ -27,30 +27,33 @@ plan.reload referrer = "/#{FastGettext.locale}/plans/#{plan.id}/phases/#{question.section.phase.id}/edit" - - answer = Answer.create(user: @user, plan: plan, question: question, - text: "#{format.title} Tester") if format.option_based else # Try creating one first - form_attributes = {"answer-text-#{question.id}": "#{format.title} Tester", - answer: {user_id: @user.id, plan_id: plan.id, - question_id: question.id}} + form_attributes = { + answer: {user_id: @user.id, + plan_id: plan.id, + question_id: question.id, + text: "#{format.title} Tester", + lock_version: 0} + } - put_answer(answer, form_attributes, referrer) + put_answer(Answer.new(), form_attributes, referrer) answer = Answer.find_by(user: @user, plan: plan, question: question) assert_not answer.id.nil?, "expected the answer to have been created and for an id to be present after creating a #{format.title} question!" # Try editing it - form_attributes = {"answer-text-#{question.id}": "Tested", + form_attributes = { answer: {id: answer.id, user_id: answer.user.id, plan_id: answer.plan.id, question_id: answer.question.id, - lock_version: answer.lock_version}} + text: "Tested", + lock_version: answer.lock_version} + } put_answer(answer, form_attributes, referrer) @@ -71,7 +74,6 @@ assert_response :success assert_equal "text/javascript", @response.content_type - # last line of JS updates section status with X questions, Y answered - assert_match /status"\).html\("\([0-9]+ questions, [0-9]+ answered/, @response.body + assert_match(/[^\$]*\$\("#answer-locking-[0-9]+"\).html\(""\);[^\$]*\$\("#answer-form-[0-9]+"\)[^\.]*.html\(".+"\);[^\$]*\$\("#answer-status-[0-9]+"\)[^.]*.html\(".+"\);[^\$]*\$.[^$]*\$.[^\$]*\$\(".progress"\).html\(".+"\);[^\$]*\$\("#section-progress-[0-9]+"\)[^.]*.html\(".+"\);/, @response.body) end end diff --git a/test/functional/questions_controller_test.rb b/test/functional/questions_controller_test.rb index 9a156f5..ce6414c 100644 --- a/test/functional/questions_controller_test.rb +++ b/test/functional/questions_controller_test.rb @@ -8,7 +8,7 @@ scaffold_template @section = @template.phases.first.sections.first - # Get the first Org Admin + # Get the first Org Admin scaffold_org_admin(@template.org) @question_format = QuestionFormat.where(option_based: false).first @@ -38,8 +38,8 @@ # POST /org/admin/templates/questions/:id/admin_create (admin_create_question_path) # ---------------------------------------------------------- test "create a new question" do - params = {section_id: @section.id, text: 'Test Question', number: 9, question_format_id: @question_format.id, annotations_attributes: {0 => {text: "some text", org_id: Org.first.id}}} - + params = {section_id: @section.id, text: 'Test Question', number: 9, question_format_id: @question_format.id} + @section.phase.template.dirty = false @section.phase.template.save! @@ -64,7 +64,7 @@ assert @section.phase.template.reload.dirty?, "expected the templates dirty flag to be true" # Invalid object - post admin_create_question_path(@section), {question: {section_id: @section.id, text: nil}} + post admin_create_question_path(@section), {question: {section_id: @section.id, text: nil, question_format_id: @question_format.id}} assert flash[:notice].starts_with?(_('Could not create your')) assert_response :success assert assigns(:question) diff --git a/test/functional/registrations_controller_test.rb b/test/functional/registrations_controller_test.rb index 8976103..ef0079b 100644 --- a/test/functional/registrations_controller_test.rb +++ b/test/functional/registrations_controller_test.rb @@ -87,13 +87,13 @@ sign_in @user # Change name - put user_registration_path, {user: {email: @user.email, firstname: 'Testing', surname: 'UPDATE'}} + put user_registration_path, {user: {email: @user.email, firstname: 'Testing', surname: 'UPDATE', org_id: Org.first.id}} assert_equal _('Details successfully updated.'), flash[:notice] assert_response :redirect assert_redirected_to edit_user_registration_url # Change email but didn't provide password - put user_registration_path, {user: {email: 'something@else.org', firstname: @user.firstname, surname: @user.surname}} + put user_registration_path, {user: {email: 'something@else.org', firstname: @user.firstname, surname: @user.surname, org_id: Org.first.id}} assert_response :success assert_equal _('Please enter your password to change email address.'), flash[:notice] diff --git a/test/functional/templates_controller_test.rb b/test/functional/templates_controller_test.rb index 70e6edd..0987259 100644 --- a/test/functional/templates_controller_test.rb +++ b/test/functional/templates_controller_test.rb @@ -211,7 +211,7 @@ # ---------------------------------------------------------- test "customize a funder template" do # Make sure we are redirected if we're not logged in - put admin_customize_template_path(@template) + get admin_customize_template_path(@template) assert_unauthorized_redirect_to_root_path funder_template = Template.create(org: Org.funders.first, title: 'Testing integration') @@ -228,7 +228,7 @@ template = Template.live(funder_template.dmptemplate_id) - put admin_customize_template_path(template) + get admin_customize_template_path(template) customization = Template.where(customization_of: template.dmptemplate_id).last diff --git a/test/integration/answer_locking_test.rb b/test/integration/answer_locking_test.rb index e083dda..0c0bb0f 100644 --- a/test/integration/answer_locking_test.rb +++ b/test/integration/answer_locking_test.rb @@ -33,10 +33,10 @@ assert_equal "Initial answer - by UserA", updated.text assert_equal @plan.owner.id, updated.user_id - # Make sure the answer-notice is NOT displayed - assert_not @response.body.include?(_('Combine their changes with your answer below and then save the answer again.')), "expected there to be no lock error messaging" - assert @response.body.include?("#{_('by')} #{@plan.owner.name}"), "expected the messaging to say the plan was updated by the plan owner" - assert @response.body.include?(_('answered')), "expected the messaging to include the status" + # Make sure the answers/locking partial is NOT displayed + assert_not @response.body.include?(_('The following answer cannot be saved')), "expected there to be no lock error messaging" + assert @response.body.include?(_('Answered')) + assert @response.body.include?("#{_(' by')} #{@plan.owner.name}"), "expected the messaging to say the plan was updated by the plan owner" # Signin as UserB and try to insert the new answer but fail sign_in @collaborator @@ -48,9 +48,9 @@ assert_equal @plan.owner.id, updated.user_id # Make sure the answer-notice IS displayed - assert @response.body.include?(_('Combine their changes with your answer below and then save the answer again.')), "expected there to be lock error messaging" - assert @response.body.include?("#{_('by')} #{@plan.owner.name}"), "expected the messaging to STILL say the plan was updated by the plan owner" - assert @response.body.include?(_('answered')), "expected the messaging to include the status" + assert @response.body.include?(_('The following answer cannot be saved')), "expected there to be lock error messaging" + assert @response.body.include?(_('since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again.') % { name: @plan.owner.name}), "expected the messaging to STILL say the plan was updated by the plan owner" + assert @response.body.include?(_('Answered')), "expected the messaging to include the status" end # ---------------------------------------------------------- @@ -70,10 +70,10 @@ assert_equal "Initial answer - by UserA - Updated by userA", updated.text assert_equal @plan.owner.id, updated.user_id - # Make sure the answer-notice is NOT displayed - assert_not @response.body.include?(_('Combine their changes with your answer below and then save the answer again.')), "expected there to be no lock error messaging" - assert @response.body.include?("#{_('by')} #{@plan.owner.name}"), "expected the messaging to say the plan was updated by the plan owner" - assert @response.body.include?(_('answered')), "expected the messaging to include the status" + # Make sure the answers/locking partial is NOT displayed + assert_not @response.body.include?(_('The following answer cannot be saved')), "expected there to be no lock error messaging" + assert @response.body.include?(_('Answered')) + assert @response.body.include?("#{_(' by')} #{@plan.owner.name}"), "expected the messaging to say the plan was updated by the plan owner" # Signin as UserB and try to insert the new answer but fail sign_in @collaborator @@ -87,19 +87,20 @@ assert_equal @plan.owner.id, updated.user_id # Make sure the answer-notice IS displayed - assert @response.body.include?(_('Combine their changes with your answer below and then save the answer again.')), "expected there to be lock error messaging" - assert @response.body.include?("#{_('by')} #{@plan.owner.name}"), "expected the messaging to STILL say the plan was updated by the plan owner" - assert @response.body.include?(_('answered')), "expected the messaging to include the status" + assert @response.body.include?(_('The following answer cannot be saved')), "expected there to be lock error messaging" + assert @response.body.include?(_('since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again.') % { name: @plan.owner.name}), "expected the messaging to STILL say the plan was updated by the plan owner" + assert @response.body.include?(_('Answered')), "expected the messaging to include the status" end # ---------------------------------------------------------- private def obj_to_params(attributes) - {"answer-text-#{attributes['question_id']}": "#{attributes['text']}", + { answer: {id: attributes['id'], user_id: attributes['user_id'], plan_id: attributes['plan_id'], question_id: attributes['question_id'], + text: attributes['text'], lock_version: attributes['lock_version']} } end diff --git a/test/test_helper.rb b/test/test_helper.rb index b33f296..ec8cda5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -55,21 +55,22 @@ template.phases << Phase.new(title: 'Test phase', description: 'My test phase', - number: 1) + number: 1, template: template) - section = Section.new(title: 'Test section', + template.phases.first.sections << Section.new(title: 'Test section', description: 'My test section', number: 99, phase: template.phases.first) + section = template.phases.first.sections.first i = 1 # Add each type of Question to the new section QuestionFormat.all.each do |frmt| question = Question.new(text: "Test question - #{frmt.title}", number: i, - question_format: frmt) + question_format: frmt, section: section) if frmt.option_based? 3.times do |j| - question.question_options << QuestionOption.new(text: "Option #{j}", number: j) + question.question_options << QuestionOption.new(text: "Option #{j}", number: j, question: question) end end @@ -77,11 +78,8 @@ i += 1 end - template.phases.first.sections << section - template.save! assert template.valid?, "unable to create new Template: #{template.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}" - @template = template.reload end