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

add inplace fields to add notes on spvindex

parent a81d9251
......@@ -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 }
......@@ -18,10 +18,11 @@ h1= t_title(:index)
th Bemerkungen
th Übernommen
th Quittiert
th.limit-width-15 Notizen
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'
......@@ -57,6 +58,7 @@ h1= t_title(:index)
= api_button('Quittieren', subject: [spv],
action: :mark_as_done, extra_class: 'm-t-10',
template: 'Quittiert von <a href="<%= data.link %>"><%= data.email %></a> am <%= data.at %>')
td= render 'update_notes_field', spv: spv
= bootstrap_paginate(@spvs)
......
$('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]
......
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