Work on attendee questions backend design
This commit is contained in:
parent
637d8265ee
commit
0ca9e2e1be
|
|
@ -31,7 +31,7 @@ class EventQuestionsController extends MyBaseController
|
|||
],
|
||||
];
|
||||
|
||||
return view('ManageEvent.Modals.EditQuestion', [
|
||||
return view('ManageEvent.Modals.CreateQuestion', [
|
||||
'form_url' => route('event.question.store', [
|
||||
'event_id' => $event_id,
|
||||
]),
|
||||
|
|
@ -99,6 +99,28 @@ class EventQuestionsController extends MyBaseController
|
|||
]);
|
||||
}
|
||||
|
||||
|
||||
public function showEditEventQuestion(Request $request, $event_id, $question_id)
|
||||
{
|
||||
$question = Question::findOrFail($question_id);
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$data = [
|
||||
'question' => $question,
|
||||
'event' => $event,
|
||||
'question_types' => QuestionType::all(),
|
||||
'modal_id' => $request->get('modal_id'),
|
||||
];
|
||||
|
||||
return view('ManageEvent.Modals.EditQuestion', $data);
|
||||
}
|
||||
|
||||
|
||||
public function postEditEventQuestion(Request $request, $event_id, $question_id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -380,6 +380,16 @@ Route::group(['middleware' => ['auth', 'first.run']], function () {
|
|||
*/
|
||||
Route::resource('question', 'EventQuestionsController');
|
||||
|
||||
Route::get('{event_id}/question/{question_id}', [
|
||||
'as' => 'showEditEventQuestion',
|
||||
'uses' => 'EventQuestionsController@showEditEventQuestion'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/question/{question_id}', [
|
||||
'as' => 'postEditEventQuestion',
|
||||
'uses' => 'EventQuestionsController@postEditEventQuestion'
|
||||
]);
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Attendees
|
||||
|
|
|
|||
|
|
@ -568,7 +568,8 @@
|
|||
{{implode(', ', array_column($question->tickets->toArray(), 'title'))}}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="btn btn-xs btn-primary loadModal">
|
||||
<a class="btn btn-xs btn-primary loadModal" data-modal-id="EditQuestion" href="javascript:void(0);"
|
||||
data-href="{{route('showEditEventQuestion', ['event_id' => $event->id, 'question_id' => $question->id])}}">
|
||||
Edit
|
||||
</a>
|
||||
<a href="#" class="btn btn-xs btn-danger loadModal">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
|
||||
<div role="dialog" id="{{ $modal_id }}" class="modal fade" style="display: none;">
|
||||
<script id="question-option-template" type="text/template">
|
||||
<tr>
|
||||
<td><input class="form-control" name="option[]" type="text"></td>
|
||||
<td width="50">
|
||||
<i class="btn btn-danger ico-remove" onclick="removeQuestionOption(this);"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header text-center">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h3 class="modal-title">
|
||||
<i class="ico-question"></i>
|
||||
Create Question</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="panel panel-default">
|
||||
{!! Form::model($question, ['url' => $form_url, 'id' => 'edit-question-form', 'class' => 'ajax']) !!}
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label for="question-title" class="required">
|
||||
Question
|
||||
</label>
|
||||
{!! Form::text('title', '', [
|
||||
'id' => 'question-title',
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'e.g.: What is your name?',
|
||||
]) !!}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="question-type">
|
||||
Question Type
|
||||
</label>
|
||||
|
||||
<select id="question-type" class="form-control" name="question_type_id" onchange="changeQuestionType(this);">
|
||||
@foreach ($question_types as $question_type)
|
||||
<option data-has-options="{{$question_type->has_options}}" value="{{$question_type->id}}">
|
||||
{{$question_type->name}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="question-instructions">
|
||||
Instructions
|
||||
</label>
|
||||
{!! Form::text('instructions', null, [
|
||||
'id' => 'question-instructions',
|
||||
'class' => 'form-control',
|
||||
]) !!}
|
||||
</div>
|
||||
<fieldset id="question-options" {!! empty($question->has_options) ? ' class="hide"' : '' !!}>
|
||||
<legend>Question Options</legend>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Option name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($question_options as $question_option)
|
||||
<tr>
|
||||
<td><input class="form-control" name="option[]" type="text" value="{{ $question_option->name }}"></td>
|
||||
<td width="50">
|
||||
<i class="btn btn-danger ico-remove" onclick="removeQuestionOption(this);"></i>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<span id="add-question-option" class="btn btn-success btn-xs" onclick="addQuestionOption();">
|
||||
<i class="ico-plus"></i>
|
||||
Add another option
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<div class="form-group">
|
||||
{!! Form::checkbox('is_required', 1, null, ['id' => 'is_required']) !!}
|
||||
{!! Form::label('is_required', 'Make this a required question') !!}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>
|
||||
Require this question for ticket(s):
|
||||
</label>
|
||||
|
||||
@foreach ($event->tickets as $ticket)
|
||||
<br>
|
||||
<input id="ticket_{{ $ticket->id }}" name="tickets[]" type="checkbox" value="{{ $ticket->id }}">
|
||||
<label for="ticket_{{ $ticket->id }}"> {{ $ticket->title }}</label>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div> <!-- /end modal body-->
|
||||
<div class="modal-footer">
|
||||
<a href="" class="btn btn-danger" data-dismiss="modal">
|
||||
Close
|
||||
</a>
|
||||
<a class="btn btn-success" href="javascript:void(0);" onclick="submitQuestionForm();">
|
||||
Create Question
|
||||
</a>
|
||||
</div>
|
||||
</div><!-- /end modal content-->
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,33 +1,29 @@
|
|||
<script id="question-option-template" type="text/template">
|
||||
<tr>
|
||||
<td><input class="form-control" name="option[]" type="text"></td>
|
||||
<td width="50">
|
||||
<i class="btn btn-danger ico-remove" onclick="removeQuestionOption(this);"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
<div role="dialog" id="{{ $modal_id }}" class="modal fade" style="display: none;">
|
||||
<script id="question-option-template" type="text/template">
|
||||
<tr>
|
||||
<td><input class="form-control" name="option[]" type="text"></td>
|
||||
<td width="50">
|
||||
<i class="btn btn-danger ico-remove" onclick="removeQuestionOption(this);"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header text-center">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h3 class="modal-title">
|
||||
<i class="ico-question"></i>
|
||||
Questions</h3>
|
||||
Edit Question</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h3>
|
||||
Existing Questions
|
||||
</h3>
|
||||
|
||||
<div class="panel panel-default">
|
||||
{!! Form::model($question, ['url' => $form_url, 'id' => 'edit-question-form', 'class' => 'ajax']) !!}
|
||||
{!! Form::model($question, ['url' => route('postEditEventQuestion', ['event_id' => $event->id, 'question_id' => $question->id]), 'id' => 'edit-question-form', 'class' => 'ajax']) !!}
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label for="question-title" class="required">
|
||||
Question
|
||||
</label>
|
||||
{!! Form::text('title', '', [
|
||||
{!! Form::text('title', $question->title, [
|
||||
'id' => 'question-title',
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'e.g.: What is your name?',
|
||||
|
|
@ -40,7 +36,7 @@
|
|||
|
||||
<select id="question-type" class="form-control" name="question_type_id" onchange="changeQuestionType(this);">
|
||||
@foreach ($question_types as $question_type)
|
||||
<option data-has-options="{{$question_type->has_options}}" value="{{$question_type->id}}">
|
||||
<option {{$question->question_type_id == $question_type->id ? 'selected' : ''}} data-has-options="{{$question_type->has_options}}" value="{{$question_type->id}}">
|
||||
{{$question_type->name}}
|
||||
</option>
|
||||
@endforeach
|
||||
|
|
@ -50,7 +46,7 @@
|
|||
<label for="question-instructions">
|
||||
Instructions
|
||||
</label>
|
||||
{!! Form::text('instructions', null, [
|
||||
{!! Form::text('instructions', $question->instructions, [
|
||||
'id' => 'question-instructions',
|
||||
'class' => 'form-control',
|
||||
]) !!}
|
||||
|
|
@ -64,7 +60,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($question_options as $question_option)
|
||||
@foreach ($question->options as $question_option)
|
||||
<tr>
|
||||
<td><input class="form-control" name="option[]" type="text" value="{{ $question_option->name }}"></td>
|
||||
<td width="50">
|
||||
|
|
@ -112,7 +108,7 @@
|
|||
Close
|
||||
</a>
|
||||
<a class="btn btn-success" href="javascript:void(0);" onclick="submitQuestionForm();">
|
||||
Create Question
|
||||
Save Question
|
||||
</a>
|
||||
</div>
|
||||
</div><!-- /end modal content-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue