Skip to content

Commit 78dad98

Browse files
Add text field to add a member as reservist to an activity (Requested by Olivier)
1 parent d05c09a commit 78dad98

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

app/controllers/admin/participants_controller.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ class Admin::ParticipantsController < ApplicationController
33
def create
44
@participant = Participant.new(
55
member: Member.find_by(id: params[:member]),
6-
activity: Activity.find_by(id: params[:activity_id])
6+
activity: Activity.find_by(id: params[:activity_id]),
7+
reservist: params[:reservist] || false,
78
)
89

910
impressionist(@participant) if @participant.save

app/javascript/src/admin/activities.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,13 @@ var participant = {
358358
});
359359
},
360360

361-
enroll(activity_id, member_id) {
361+
enroll(activity_id, member_id, reservist = false) {
362362
$.ajax({
363363
url: "/activities/" + activity_id + "/participants",
364364
type: "POST",
365365
data: {
366366
member: member_id,
367+
reservist: reservist,
367368
},
368369
})
369370
.done(function (data) {
@@ -389,7 +390,15 @@ $(document).on("ready page:load turbolinks:load", function () {
389390
participant.enroll($("#participants-table").attr("data-id"), id);
390391
});
391392

393+
$("#participants")
394+
.find("input#participant-reservist")
395+
.search()
396+
.on("selected", function (event, id) {
397+
participant.enroll($("#reservists-table").attr("data-id"), id, true);
398+
});
399+
392400
posterHandlers();
401+
393402
if (window.location.href.indexOf("summary_only") !== -1) {
394403
makeTableCollapsable();
395404
addCopyTableCallBack();

app/views/admin/activities/show.html.haml

+13-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
%span#pricesum= " / €"+(number_with_precision(@activity.price_sum, :precision => 2) || 0)
3232
%span#paidsum= ""+(number_with_precision(@activity.paid_sum, :precision => 2) || 0)
3333

34-
3534
%template#attendee-table-row
3635
= render 'admin/activities/partials/attendee_table_row', participant: Participant.new(activity: @activity, member: Member.new)
3736
%table#participants-table.table.table-striped.table-linked{ :data => { 'id' => @activity.id }}
@@ -50,7 +49,7 @@
5049
= I18n.t('activerecord.attributes.activity.member_is_spare')
5150
%tbody
5251
- [@attendees.map {|participant| {"entity" => participant, "is_reservist" => false}},
53-
@reservists.map{| reservist | {"entity" => reservist, "is_reservist" => true}}].reduce([], :concat).each do |member|
52+
@reservists.map{|reservist| {"entity" => reservist, "is_reservist" => true}}].reduce([], :concat).each do |member|
5453
- if !@is_summarized.nil?
5554
= render 'admin/activities/partials/attendee_table_row_summary', member: member
5655
- elsif !member["is_reservist"]
@@ -124,3 +123,15 @@
124123
%i.fa.fa-fw.fa-plus
125124
%button.btn.btn-default.destroy
126125
%i.fa.fa-fw.fa-trash
126+
%tr
127+
128+
-# Add member to reservist participants
129+
%tr
130+
%td{ :style => 'position: relative;'}
131+
%input#participant-reservist.col-md-11{ :style => 'margin-left: -3px;', :tabindex => '-1' }
132+
%ul.dropdown-menu.col-md-11
133+
%td{ :style => 'text-align: left;' }
134+
135+
%span= number_to_currency(@activity.price, :unit => '€')
136+
%td
137+

0 commit comments

Comments
 (0)