forked from miguel456/rbrecruiter
Add ability to edit forms and add new fields
This commit adds the ability to edit and modify existing forms. On the technical side, it also adds a new reusable validation Facade which helps reduce duplicated code.
This commit is contained in:
103
resources/views/dashboard/administration/editform.blade.php
Normal file
103
resources/views/dashboard/administration/editform.blade.php
Normal file
@@ -0,0 +1,103 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('title', 'Raspberry Network | Edit From')
|
||||
|
||||
@section('content_header')
|
||||
|
||||
<h4>Administration / Forms / Editor</h4>
|
||||
|
||||
@stop
|
||||
|
||||
@section('js')
|
||||
|
||||
<script src="/js/formeditor.js"></script>
|
||||
<x-global-errors></x-global-errors>
|
||||
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="col">
|
||||
|
||||
</div>
|
||||
<div class="col text-center">
|
||||
|
||||
<img src="/img/editor.svg" width="250px" alt="Editor illustration" class="img-responsive" />
|
||||
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
<form id="editForm" method="POST" action="{{ route('updateForm', ['form' => $formID]) }}">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header">
|
||||
|
||||
<h4>Editing {{ $title }}...</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
@foreach($formStructure['fields'] as $fieldName => $field)
|
||||
|
||||
<div class="form-group mt-4 mb-4">
|
||||
|
||||
<input autocomplete="false" type="text" id="{{ $fieldName }}" class="form-control" name="{{ $fieldName }}[]" value="{{ $field['title'] }}" />
|
||||
|
||||
<select class="custom-select" id="{{ $fieldName }}-type" name="{{ $fieldName }}[]">
|
||||
|
||||
<option value="nil" disabled>Choose a type</option>
|
||||
<option value="textbox" {{ ($field['type'] == 'textbox' ? 'selected' : '') }}>Textbox</option>
|
||||
<option value="textarea" {{ ($field['type'] == 'textarea' ? 'selected' : '') }}>Multi line answer</option>
|
||||
<option value="checkbox" {{ ($field['type'] == 'checkbox' ? 'selected' : '') }}>Checkbox</option>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
|
||||
<div class="field-container mt-4 mb-4">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-footer text-center">
|
||||
|
||||
<button type="button" class="btn btn-warning ml-2" onclick="$('#editForm').submit()"><i class="fas fa-save"></i> Save & Quit</button>
|
||||
<button type="button" class="btn btn-primary ml-2" id="add"><i class="fas fa-plus"></i> New field</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@stop
|
@@ -66,8 +66,8 @@
|
||||
|
||||
<div class="card-footer text-center">
|
||||
|
||||
<button type="button" class="btn btn-success ml-2" onlick="window.location.href='{{ route('showForms') }}'"><i class="fas fa-chevron-left"></i> Go back</button>
|
||||
<button type="button" class="btn btn-warning ml-2"><i class="far fa-edit"></i> Edit</button>
|
||||
<button type="button" class="btn btn-success ml-2" onclick="window.location.href='{{ route('showForms') }}'"><i class="fas fa-chevron-left"></i> Go back</button>
|
||||
<button type="button" class="btn btn-warning ml-2" onclick="window.location.href='{{ route('editForm', ['form' => $formID]) }}'"><i class="far fa-edit"></i> Edit</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -38,6 +38,7 @@
|
||||
<th>#</th>
|
||||
<th>Form Title</th>
|
||||
<th>Created On</th>
|
||||
<th>Updated On</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
|
||||
@@ -51,6 +52,7 @@
|
||||
<td>{{$form->id}}</td>
|
||||
<td>{{$form->formName}}</td>
|
||||
<td>{{$form->created_at}}</td>
|
||||
<td>{{ $form->updated_at }}</td>
|
||||
<td>
|
||||
<form style="display: inline-block; white-space: nowrap" action="{{route('destroyForm', ['id' => $form->id])}}" method="POST">
|
||||
|
||||
|
@@ -75,6 +75,18 @@
|
||||
|
||||
@endhasrole
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
|
||||
<div class="alert alert-warning alert-dismissible">
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
<strong>Reminder:</strong> If this form has been updated, new fields and updated questions will not show up here!
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@@ -357,9 +369,9 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col">
|
||||
|
||||
|
||||
@if ($comments->isEmpty())
|
||||
|
||||
<div class="alert alert-warning">
|
||||
@@ -378,11 +390,11 @@
|
||||
|
||||
|
||||
@if (!$comments->isEmpty())
|
||||
|
||||
|
||||
@foreach($comments as $comment)
|
||||
<div class="row mt-3 mb-3">
|
||||
<div class="row mt-3 mb-3">
|
||||
<div class="col-md-2">
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@if($application->user->avatarPreference == 'gravatar')
|
||||
<img class="profile-user-img img-fluid img-circle" src="https://gravatar.com/avatar/{{md5($comment->user->email)}}" alt="User profile picture">
|
||||
@@ -394,24 +406,24 @@
|
||||
</div>
|
||||
|
||||
<div class="card comment">
|
||||
|
||||
|
||||
<div class="card-header comment-header">
|
||||
|
||||
<h1 class="commenter">{{$comment->user->name}} ● {{Carbon\Carbon::parse($comment->created_at)->diffForHumans()}}</h3>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
{{$comment->text}}
|
||||
|
||||
</div>
|
||||
|
||||
@if(Auth::user()->is($comment->user) || Auth::user()->hasRole('admin'))
|
||||
|
||||
|
||||
<div class="card-footer comment-footer">
|
||||
|
||||
|
||||
<form method="POST" id="deleteComment" action="{{route('deleteApplicationComment', ['comment' => $comment->id])}}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
@@ -434,7 +446,7 @@
|
||||
<div class="row mt-5">
|
||||
|
||||
<div class="col-md-2">
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@if($application->user->avatarPreference == 'gravatar')
|
||||
<img class="profile-user-img img-fluid img-circle" src="https://gravatar.com/avatar/{{md5(Auth::user()->email)}}" alt="User profile picture">
|
||||
@@ -443,15 +455,15 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="card border-top border-bottom">
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<form id="newComment" method="POST" action="{{route('addApplicationComment', ['application' => $application->id])}}">
|
||||
|
||||
|
||||
@csrf
|
||||
|
||||
<textarea id="comment" name="comment" class="form-control" id="commentText"></textarea>
|
||||
@@ -459,14 +471,14 @@
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col text-left">
|
||||
<p class="text-sm text-muted">Commenting as {{Auth::user()->name}}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col text-right">
|
||||
|
||||
|
||||
<p class="text-sm text-muted"><span id="charcount">0</span>/600 max characters</p>
|
||||
|
||||
</div>
|
||||
@@ -476,7 +488,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer text-right">
|
||||
|
||||
|
||||
<button type="button" id="submitComment" class="btn btn-sm btn-secondary">Post</button>
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user