Commit b4b539e8 authored by Tugce Nur Tas's avatar Tugce Nur Tas

Merge branch 'features/add-notes-directly-on-spvindex' into 'develop'

features/add inplace fields to add notes on spvindex

See merge request !861
parents a81d9251 c78c2df8
Pipeline #31861 failed with stage
in 60 minutes
......@@ -7,6 +7,10 @@
width: 10%;
}
.limit-width-15 {
width: 15%;
}
.limit-width-40 {
width: 40%;
}
......
class SemesterProcessVolunteersController < ApplicationController
before_action :prepare_review, :initialize_nested_objects, only: [:review_semester, :submit_review]
before_action :set_semester_process_volunteer, only: [:show, :edit, :update, :take_responsibility, :mark_as_done]
before_action :set_semester_process_volunteer, only: [:show, :edit, :update, :take_responsibility, :mark_as_done, :update_notes]
before_action :set_semester, only: [:index]
include SemesterProcessVolunteerHelper
......@@ -88,6 +88,11 @@ class SemesterProcessVolunteersController < ApplicationController
end
end
def update_notes
updated_notes = semester_process_volunteer_params[:notes]
@spv.update_attribute(:notes, updated_notes)
end
private
def prepare_review
......@@ -149,6 +154,6 @@ class SemesterProcessVolunteersController < ApplicationController
end
def semester_process_volunteer_params
params.require(:semester_process_volunteer).permit(:semester)
params.require(:semester_process_volunteer).permit(:semester, :notes)
end
end
......@@ -18,4 +18,5 @@ class SemesterProcessVolunteerPolicy < ApplicationPolicy
alias_method :destroy?, :superadmin?
alias_method :take_responsibility?, :superadmin?
alias_method :mark_as_done?, :superadmin?
alias_method :update_notes?, :superadmin?
end
.inplace_field.update_notes
span.field_label
= spv.notes
- if(request.format.html? || request.format.js?)
- if spv.notes?
span.helper_label.hidden-print= " (Notiz manuell überschrieben)"
- else
span.helper_label.hidden-print= " (Neue Notiz hinzufügen)"
span.hidden-print =icon_span :edit
span.field_input= text_field_tag 'semester_process_volunteer[notes]',
spv.notes,
data: { remote: true, url: update_notes_semester_process_volunteer_path(spv), method: :put }
......@@ -17,11 +17,12 @@ h1= t_title(:index)
th Zukunft
th Bemerkungen
th Übernommen
th.limit-width-15 Notizen
th Quittiert
tbody
- @spvs.each do |spv|
tr
tr*{ data: { spv_id: spv.id } }
td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
= button_link icon_span(:journal), volunteer_journals_path(spv.volunteer), title: 'Journal'
......@@ -48,6 +49,7 @@ h1= t_title(:index)
= api_button('Übernehmen', subject: [spv],
action: :take_responsibility, extra_class: 'm-t-10',
template: 'Übernommen durch <a href="<%= data.link %>"><%= data.email %></a> am <%= data.at %>')
td= render 'update_notes_field', spv: spv
td.index-action-cell.hidden-print
- if spv.reviewed_by.present?
= 'Quittiert von '
......
$('tr[data-spv-id=<%=@spv.id%>] .update_notes').replaceWith('<%= j render 'semester_process_volunteers/update_notes_field', spv: @spv %>');
$('tr[data-spv-id=<%=@spv.id%>] .update_notes').parent().effect('highlight', { color: '#feffe6' }, 1000);
inplaceFields();
......@@ -101,6 +101,7 @@ Rails.application.routes.draw do
patch :submit_review, on: :member
put :take_responsibility, on: :member
put :mark_as_done, on: :member
put :update_notes, on: :member
end
resources :semester_processes, except: [:destroy]
......
......@@ -214,4 +214,14 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
assert_not page.has_text? @volunteer3.contact.full_name
end
end
test 'notes are editable' do
first('.update_notes .field_label').click
first('.update_notes .field_input').fill_in(with: 'notesnotesnotes')
first('div.wrapper').click
wait_for_ajax
@spv1.reload
assert page.has_text? 'notesnotesnotes'
assert_equal @spv1.notes,'notesnotesnotes'
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment