forked from miguel456/rbrecruiter
Added view forms
This commit is contained in:
parent
f52b249834
commit
290104eea7
|
@ -11,7 +11,8 @@ class FormController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
return view('dashboard.administration.forms')
|
||||
->with('forms', Form::all());
|
||||
}
|
||||
|
||||
public function showFormBuilder()
|
||||
|
@ -60,11 +61,30 @@ class FormController extends Controller
|
|||
);
|
||||
|
||||
$request->session()->flash('success', 'Form created! You can now link this form to a vacancy.');
|
||||
return redirect()->back();
|
||||
return redirect()->to(route('showForms'));
|
||||
}
|
||||
|
||||
$request->session()->flash('errors', $validation->errors()->getMessages());
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
|
||||
$form = Form::find($id);
|
||||
|
||||
// TODO: Check if form is linked to vacancies before allowing deletion
|
||||
if (!is_null($form))
|
||||
{
|
||||
$form->delete();
|
||||
|
||||
$request->session()->flash('success', 'Form deleted successfully.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$request->session()->flash('error', 'The form you\'re trying to delete does not exist.');
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
@foreach(session('error') as $error)
|
||||
|
||||
<script>
|
||||
toastr.error("{{$error}}")
|
||||
toastr.error("{{session('error')}}")
|
||||
</script>
|
||||
|
||||
@endforeach
|
||||
|
@ -53,17 +53,13 @@
|
|||
|
||||
</form>
|
||||
|
||||
<div class="mt-4">
|
||||
<input type="button" value="New Field" class="add btn btn-success" id="add" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-footer text-center">
|
||||
|
||||
<button onclick="save()" type="button" class="btn btn-success">Save Form</button>
|
||||
<button type="button" class="btn btn-info">Form List</button>
|
||||
<input type="button" value="New Field" class="add btn btn-info ml-3" id="add" />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
@extends('adminlte::page')
|
||||
|
||||
@section('title', 'Raspberry Network | Application Form Management Tool')
|
||||
|
||||
@section('content_header')
|
||||
|
||||
<h4>Administration / Forms</h4>
|
||||
|
||||
@stop
|
||||
|
||||
@section('js')
|
||||
|
||||
@if (session()->has('success'))
|
||||
|
||||
<script>
|
||||
toastr.success("{{session('success')}}")
|
||||
</script>
|
||||
|
||||
@elseif(session()->has('error'))
|
||||
|
||||
<script>
|
||||
toastr.error("{{session('error')}}")
|
||||
</script>
|
||||
|
||||
|
||||
@endif
|
||||
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
|
||||
<div class="card bg-gray-dark">
|
||||
|
||||
<div class="card-header bg-indigo">
|
||||
<div class="card-title"><h4 class="text-bold">Available Forms</h4></div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
@if(!$forms->isEmpty())
|
||||
|
||||
<table class="table table-active table-borderless" style="white-space: nowrap">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Form Title</th>
|
||||
<th>Created On</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
@foreach($forms as $form)
|
||||
|
||||
<tr>
|
||||
<td>{{$form->id}}</td>
|
||||
<td>{{$form->formName}}</td>
|
||||
<td>{{$form->created_at}}</td>
|
||||
<td>
|
||||
<form style="display: inline-block; white-space: nowrap" action="{{route('destroyForm', ['id' => $form->id])}}" method="POST">
|
||||
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
|
||||
<button type="submit" class="btn btn-sm btn-danger mr-2"><i class="fa fa-trash"></i> Delete</button>
|
||||
</form>
|
||||
<button type="button" class="btn btn-sm btn-success"><i class="fa fa-eye"></i> Preview</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
@else
|
||||
|
||||
<div class="alert alert-warning">
|
||||
|
||||
Nothing to see here! Please add some forms first.
|
||||
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
|
||||
<button type="button" class="btn btn-outline-primary" onclick="window.location.href='{{route('showFormBuilder')}}'">NEW FORM</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@stop
|
|
@ -78,7 +78,7 @@
|
|||
|
||||
<div class="card-footer">
|
||||
|
||||
<button type="button" class="btn btn-outline-primary">MANAGE APPLICATION FORMS</button>
|
||||
<button type="button" class="btn btn-outline-primary" onclick="window.location.href='{{route('showForms')}}'">MANAGE APPLICATION FORMS</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -73,6 +73,9 @@ Route::group(['middleware' => 'auth'], function(){
|
|||
Route::post('forms/save', 'FormController@saveForm')
|
||||
->name('saveForm');
|
||||
|
||||
Route::delete('forms/destroy/{id}', 'FormController@destroy')
|
||||
->name('destroyForm');
|
||||
|
||||
Route::get('forms', 'FormController@index')
|
||||
->name('showForms');
|
||||
|
||||
|
|
Loading…
Reference in New Issue