diff --git a/README.md b/README.md index 0ae2435..470c7cd 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ * Rails >= 4.2 * MySql >= 5.0 OR PostgreSql -#### Migrating data from a running instance of DMPOnline_v4 or DMPTool -Migration instructions will be coming soon +Further detail on how to install Ruby on Rails applications are available from the Ruby on Rails site: http://rubyonrails.org Further details on how to install MySQL and create your first user and database. Be sure to follow the instructions for your particular environment. * Install: http://dev.mysql.com/downloads/mysql/ diff --git a/app/controllers/api/v0/guidance_groups_controller.rb b/app/controllers/api/v0/guidance_groups_controller.rb index ce2ac72..65899b9 100644 --- a/app/controllers/api/v0/guidance_groups_controller.rb +++ b/app/controllers/api/v0/guidance_groups_controller.rb @@ -4,12 +4,6 @@ before_action :authenticate #after_action :verify_authorized - def show - @guidance_group = GuidanceGroup.find(params[:id]) - raise Pundit::NotAuthorizedError unless Api::V0::GuidanceGroupPolicy.new(@user, @guidance_group).show? - respond_with @guidance_group - end - def index raise Pundit::NotAuthorizedError unless Api::V0::GuidanceGroupPolicy.new(@user, :guidance_group).index? @all_viewable_groups = GuidanceGroup.all_viewable(@user) diff --git a/app/controllers/api/v0/guidances_controller.rb b/app/controllers/api/v0/guidances_controller.rb deleted file mode 100644 index b6866d2..0000000 --- a/app/controllers/api/v0/guidances_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Api - module V0 - class GuidancesController < Api::V0::BaseController - before_action :authenticate - #after_action :verify_authorized - - ## - # returns the specified guidance - def show - @guidance = Guidance.find(params[:id]) - raise Pundit::NotAuthorizedError unless Api::V0::GuidancePolicy.new(@user, @guidance).show? - respond_with get_resource - end - - ## - # returns all guidances viewable to a user - def index - authorize Guidance - raise Pundit::NotAuthorizedError unless Api::V0::GuidancePolicy.new(@user, :guidance).index? - respond_with @all_viewable_guidances - end - - ## - # defines the default pundit user (overwrites current_user) - def pundit_user - @user - end - - - private - def query_params - params.permit(:id) - end - end - end -end diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 4519ea4..0a4ae70 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -282,7 +282,7 @@ begin @exported_plan.save! - file_name = @plan.title.gsub(/ /, "_") + file_name = @exported_plan.settings(:export)[:value]['title'].gsub(/ /, "_") respond_to do |format| format.html diff --git a/app/views/answers/_new_edit.html.erb b/app/views/answers/_new_edit.html.erb index 54fa9b4..2434033 100644 --- a/app/views/answers/_new_edit.html.erb +++ b/app/views/answers/_new_edit.html.erb @@ -2,7 +2,7 @@ This partial creates a form for each type of question. The local variables are: plan, answer, question, readonly --> <% q_format = question.question_format %> -<%= semantic_form_for answer, :url => {controller: :answers, action: :update }, html: {method: "put", class: "roadmap-form"}, remote: true do |f| %> +<%= semantic_form_for answer, :url => {controller: :answers, action: :update }, html: {method: "put", class: "roadmap-form", 'data-autosave': question.id }, remote: true do |f| %>
<% if !readonly %> <%= f.input :id, as: :hidden, input_html: { value: answer.id } %> @@ -74,7 +74,7 @@

<%= 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") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> <% end %> <%end%> <% end %> @@ -90,7 +90,7 @@

<%= 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") %> + <%= tinymce(selector: "#answer-text-#{question.id}", setup: "$.fn.tinymce_answer_events", content_css: asset_path('application.css')) %> <% end %> <% end %> diff --git a/app/views/api/v0/guidance_groups/show.json.jbuilder b/app/views/api/v0/guidance_groups/show.json.jbuilder deleted file mode 100644 index d1b0a2e..0000000 --- a/app/views/api/v0/guidance_groups/show.json.jbuilder +++ /dev/null @@ -1,14 +0,0 @@ -# builds a json response to api query for a list of guidance groups -json.prettify! - -json.guidance_group do - json.name @guidance_group.name - json.id @guidance_group.id - - json.guidances @guidance_group.guidances do |guidance| - json.text guidance.text - json.id guidance.id - end - json.optional @guidance_group.optional_subset - json.updated @guidance_group.updated_at -end diff --git a/app/views/api/v0/guidances/index.json.jbuilder b/app/views/api/v0/guidances/index.json.jbuilder deleted file mode 100644 index ac98f0a..0000000 --- a/app/views/api/v0/guidances/index.json.jbuilder +++ /dev/null @@ -1,22 +0,0 @@ -# builds a json response to api querry for all guidances - -json.prettify! - -json.guidance @all_viewable_guidances do |guidance| - json.id guidance.id - json.text guidance.text - json.updated_at guidance.updated_at - - # each guidance may be associated with many guidance groups - guidance_group = guidance.guidance_group - unless guidance_group.nil? - json.guidance_group do - json.name guidance_group.name - json.id guidance_group.id - - json.optional guidance_group.optional_subset - json.updated guidance_group.updated_at - end - end - -end diff --git a/app/views/api/v0/guidances/show.json.jbuilder b/app/views/api/v0/guidances/show.json.jbuilder deleted file mode 100644 index 67d3385..0000000 --- a/app/views/api/v0/guidances/show.json.jbuilder +++ /dev/null @@ -1,22 +0,0 @@ -# builds a json response to api querry for a specific guidance - -json.prettify! - -json.guidance do - json.id @guidance.id - json.text @guidance.text - json.updated_at @guidance.updated_at - - # each guidance may be associated with one guidance group - guidance_group = @guidance.guidance_group - - unless guidance_group.nil? - json.guidance_group do - json.name guidance_group.name - json.id guidance_group.id - - json.optional guidance_group.optional_subset - json.updated guidance_group.updated_at - end - end -end \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 8cb10ea..3db43de 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -46,4 +46,4 @@ <%= link_to 'Cancel', '#', style: 'text-decoration:none;' %> <% end %> - \ No newline at end of file + diff --git a/app/views/guidances/_add_guidance.html.erb b/app/views/guidances/_add_guidance.html.erb index da1d7ca..bd036d2 100644 --- a/app/views/guidances/_add_guidance.html.erb +++ b/app/views/guidances/_add_guidance.html.erb @@ -63,7 +63,7 @@
- <%= tinymce %> + <%= tinymce :content_css => asset_path('application.css') %> <% end %> diff --git a/app/views/guidances/admin_edit.html.erb b/app/views/guidances/admin_edit.html.erb index 4162018..bbf7cd9 100644 --- a/app/views/guidances/admin_edit.html.erb +++ b/app/views/guidances/admin_edit.html.erb @@ -81,7 +81,7 @@
- <%= tinymce %> + <%= tinymce :content_css => asset_path('application.css') %> <%end%> diff --git a/app/views/guidances/admin_new.html.erb b/app/views/guidances/admin_new.html.erb index cea5678..d6e7ded 100644 --- a/app/views/guidances/admin_new.html.erb +++ b/app/views/guidances/admin_new.html.erb @@ -78,7 +78,7 @@
- <%= tinymce %> + <%= tinymce :content_css => asset_path('application.css') %> <%end%> diff --git a/app/views/notes/_add.html.erb b/app/views/notes/_add.html.erb new file mode 100644 index 0000000..2817b90 --- /dev/null +++ b/app/views/notes/_add.html.erb @@ -0,0 +1,24 @@ + + +<% + new_note = Note.new + questionid = question.id +%> + +<%= form_for( :new_note, + url: notes_path, + remote: true, + html: {method: :post, class: "add_note_form roadmap-form"}, + id: "new_note_form_#{questionid}") do |f| %> + <%= f.hidden_field :user_id, value: current_user.id %> + <%= f.hidden_field :question_id, value: questionid %> + <%= f.hidden_field :answer_id, value: answer.id %> + <%= f.hidden_field :plan_id, value: plan_id %> + +
+ <%= 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') %> + +
+<% end %> diff --git a/app/views/notes/_archive.html.erb b/app/views/notes/_archive.html.erb new file mode 100644 index 0000000..eae2154 --- /dev/null +++ b/app/views/notes/_archive.html.erb @@ -0,0 +1,20 @@ +<%= form_for(note, + url: archive_note_path(note), + remote: true, + class: "archive_note_form", + id: "archive_note_form_#{note.id}") do |f| %> + + <%= f.hidden_field :id, :value => note.id %> + <%= f.hidden_field :archived_by, :value => current_user.id %> + + <%= render :partial => "/notes/view", locals: {note: note} %> + +

<%= _('Are you sure you want to remove this note?')%>

+ + +
+ <%= f.submit _('Remove'), onclick: "archive_note(#{note.id}, #{question_id})", :class => "btn btn-primary archive_comment_submit_button" %> + <%= link_to _('Cancel'), "#", onclick: "cancel_archive_note(#{note.id})", :class => "cancel_archive_comment btn cancel" %> +
+
+<% end %> diff --git a/app/views/notes/_edit.html.erb b/app/views/notes/_edit.html.erb new file mode 100644 index 0000000..17a75bc --- /dev/null +++ b/app/views/notes/_edit.html.erb @@ -0,0 +1,15 @@ + + +<%= form_for(note, + url: note_path(note), + remote: true, + html: {method: :put, class: "edit_note_form roadmap-form"}, + id: "edit_note_form_#{note.id}") do |f| %> + +
+ <%= f.hidden_field :id, :value => note.id %> + + <%= text_area_tag("#{note.id}_note_text".to_sym, note.text , class: "tinymce") %> + <%= f.submit _('Save'), :class => "form-submit edit_note_submit_button" %> +
+<%end%> diff --git a/app/views/notes/_list.html.erb b/app/views/notes/_list.html.erb new file mode 100644 index 0000000..daf6a20 --- /dev/null +++ b/app/views/notes/_list.html.erb @@ -0,0 +1,85 @@ + + +<% if notes.count > 1 then%> + <% style_to_add = "height:150px; overflow-y:auto;" %> +<%else%> + <% style_to_add = "" %> +<%end%> + +
+ +
+ + + <% notes.each do |note|%> + + + + + <%end%> + +
+ <% user = note.user.name %> + <%= user %>
+ (<%= l note.updated_at, format: :custom %>) +
+ + <% if note.archived %> + + <% if note.archived_by == current_user.id %> + <%= _('Note removed by you')%> + <% else %> + <% archived_by_user = User.find(note.archived_by) %> + <%= _('Note removed by')%> <%= archived_by_user.name %> + <%end%> + + <%else%> + + <%= link_to _('View'),"#question-form-#{question_id}", onclick: "view_note_button(#{note.id}, #{question_id})", :class => "dmp_table_link view_comment_button" %> + + <% if current_user.id == note.user_id %> + <%= link_to _('Edit'),"#question-form-#{question_id}", onclick: "edit_note(#{note.id}, #{question_id})", :class => "dmp_table_link edit_comment_button" %> + <%= link_to _('Remove'),"#question-form-#{question_id}", onclick: "archive_note(#{note.id}, #{question_id})", :class => "dmp_table_link archive_comment_button" %> + <% end%> + + <% if plan.administerable_by?(current_user.id) && current_user.id != note.user_id %> + <%= hidden_field_tag :note_id, note.id, :class => "comment_id" %> + <%= link_to _('Remove'),"#question-form-#{question_id}", onclick: "archive_note(#{note.id}, #{question_id})", :class => "dmp_table_link archive_comment_button" %> + <% end%> + <%end%> + +
+
+ +
+ + +<% notes_not_archived = notes.select { |n| n.archived.nil? } %> +<% latest_note = notes_not_archived.sort { |x,y| y.updated_at <=> x.updated_at }.first %> +<% if !latest_note.nil? then%> +
+ <%= render :partial => "/notes/view", locals: {note: latest_note} %> +
+
+<%end%> + +<%notes.each do |note|%> + + + + + + + + + +<%end%> diff --git a/app/views/notes/_view.html.erb b/app/views/notes/_view.html.erb new file mode 100644 index 0000000..0610f0c --- /dev/null +++ b/app/views/notes/_view.html.erb @@ -0,0 +1,11 @@ + +<% user = User.find(note.user_id) %> +
+
+
+ +
diff --git a/app/views/orgs/admin_edit.html.erb b/app/views/orgs/admin_edit.html.erb index 4530930..9cae8db 100644 --- a/app/views/orgs/admin_edit.html.erb +++ b/app/views/orgs/admin_edit.html.erb @@ -79,5 +79,5 @@ -<%= tinymce %> +<%= tinymce :content_css => asset_path('application.css') %> diff --git a/app/views/orgs/shibboleth_ds.html.erb b/app/views/orgs/shibboleth_ds.html.erb index 08d6005..6c443dd 100644 --- a/app/views/orgs/shibboleth_ds.html.erb +++ b/app/views/orgs/shibboleth_ds.html.erb @@ -48,9 +48,9 @@