Custom user fields #711 (#772)

Custom user fields during registration and profile edit #711
This commit is contained in:
Nabeel S
2020-08-11 17:48:51 -04:00
committed by GitHub
parent 3739cc8e91
commit 3ebf4f2924
36 changed files with 740 additions and 107 deletions

View File

@@ -2,8 +2,7 @@
<div class="header">
@component('admin.components.info')
Flights fields that can be filled out. You can still add other custom fields
directly in the flight, but this provides a template for all flights.
These are fields that can be filled out by users
@endcomponent
</div>
@@ -17,8 +16,8 @@
<tr>
<td>{{ $field->name }}</td>
<td class="text-right">
{{ Form::open(['route' => ['admin.flightfields.destroy', $field->id], 'method' => 'delete']) }}
<a href="{{ route('admin.flightfields.edit', [$field->id]) }}"
{{ Form::open(['route' => ['admin.userfields.destroy', $field->id], 'method' => 'delete']) }}
<a href="{{ route('admin.userfields.edit', [$field->id]) }}"
class='btn btn-sm btn-success btn-icon'>
<i class="fas fa-pencil-alt"></i></a>

View File

@@ -0,0 +1,11 @@
@extends('admin.app')
@section('title', 'Adding Field')
@section('content')
<div class="card border-blue-bottom">
<div class="content">
{{ Form::open(['route' => 'admin.userfields.store']) }}
@include('admin.userfields.fields')
{{ Form::close() }}
</div>
</div>
@endsection

View File

@@ -0,0 +1,11 @@
@extends('admin.app')
@section('title', 'Editing ' . $field->name)
@section('content')
<div class="card border-blue-bottom">
<div class="content">
{{ Form::model($field, ['route' => ['admin.userfields.update', $field->id], 'method' => 'patch']) }}
@include('admin.userfields.fields')
{{ Form::close() }}
</div>
</div>
@endsection

View File

@@ -0,0 +1,64 @@
<div class="row">
<div class="form-group col-sm-6">
{{ Form::label('name', 'Name:') }}&nbsp;&nbsp;<span class="required">*</span>
{{ Form::text('name', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-6">
{{ Form::label('description', 'Description:') }}
{{ Form::text('description', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('description') }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label class="checkbox-inline">
{{ Form::label('required', 'Required:') }}
<input name="required" type="hidden" value="0" />
{{ Form::checkbox('required') }}
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label class="checkbox-inline">
{{ Form::label('show_on_registration', 'Show On Registration:') }}
<input name="show_on_registration" type="hidden" value="0" />
{{ Form::checkbox('show_on_registration') }}
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label class="checkbox-inline">
{{ Form::label('private', 'Private (only visible to admins):') }}
<input name="private" type="hidden" value="0" />
{{ Form::checkbox('private') }}
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label class="checkbox-inline">
{{ Form::label('active', 'Active:') }}
<input name="active" type="hidden" value="0" />
{{ Form::checkbox('active') }}
</label>
</div>
</div>
</div>
<div class="row">
<!-- Submit Field -->
<div class="form-group col-sm-12">
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
<a href="{{ route('admin.userfields.index') }}" class="btn btn-default">Cancel</a>
</div>
</div>

View File

@@ -0,0 +1,13 @@
@extends('admin.app')
@section('title', 'User Fields')
@section('actions')
<li><a href="{{ route('admin.userfields.create') }}"><i class="ti-plus"></i>Add Field</a></li>
@endsection
@section('content')
<div class="card border-blue-bottom">
<div class="content">
@include('admin.userfields.table')
</div>
</div>
@endsection

View File

@@ -0,0 +1,33 @@
<div class="content table-responsive table-full-width">
<div class="header">
@component('admin.components.info')
These are custom fields that can be filled out by a user
@endcomponent
</div>
<table class="table table-hover table-responsive" id="pirepFields-table">
<thead>
<th>Name</th>
<th></th>
</thead>
<tbody>
@foreach($fields as $field)
<tr>
<td>{{ $field->name }}</td>
<td class="text-right">
{{ Form::open(['route' => ['admin.userfields.destroy', $field->id], 'method' => 'delete']) }}
<a href="{{ route('admin.userfields.edit', [$field->id]) }}"
class='btn btn-sm btn-success btn-icon'>
<i class="fas fa-pencil-alt"></i></a>
{{ Form::button('<i class="fa fa-times"></i>',
['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon',
'onclick' => "return confirm('Are you sure?')"]) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>

View File

@@ -94,10 +94,11 @@
<div class="row">
<div class="form-group col-sm-12">
<table class="table table-hover">
{{--<tr>
<td>API Key</td>
<td>{{ $user->api_key }}</td>
</tr>--}}
<tr>
<td colspan="2">
<h5>User Details</h5>
</td>
</tr>
<tr>
<td>Total Flights</td>
<td>{{ $user->flights }}</td>
@@ -126,6 +127,22 @@
<td>@lang('profile.opt-in')</td>
<td>{{ $user->opt_in ? __('common.yes') : __('common.no') }}</td>
</tr>
@if($user->fields)
<tr>
<td colspan="2">
<h5>Custom Fields</h5>
</td>
</tr>
{{-- Custom Fields --}}
@foreach($user->fields as $field)
<tr>
<td>{{ $field->field->name }}</td>
<td>{{ $field->value }}</td>
</tr>
@endforeach
@endif
</table>
</div>
</div>

View File

@@ -2,6 +2,10 @@
@section('title', 'Users')
@section('actions')
<li><a href="{{ route('admin.userfields.index') }}">
<i class="ti-user"></i>Profile Fields</a>
</li>
<li><a href="{{ route('admin.users.index') }}?search=state:0">
<i class="ti-user"></i>@lang(UserState::label(UserState::PENDING))</a>
</li>

View File

@@ -85,6 +85,18 @@
<p class="text-danger">{{ $errors->first('password_confirmation') }}</p>
@endif
@if($userFields)
@foreach($userFields as $field)
<label for="field_{{ $field->slug }}" class="control-label">{{ $field->name }}</label>
<div class="input-group form-group-no-border {{ $errors->has('field_'.$field->slug) ? 'has-danger' : '' }}">
{{ Form::text('field_'.$field->slug, null, ['class' => 'form-control']) }}
</div>
@if ($errors->has('field_'.$field->slug))
<p class="text-danger">{{ $errors->first('field_'.$field->slug) }}</p>
@endif
@endforeach
@endif
@if(config('captcha.enabled'))
<label for="g-recaptcha-response" class="control-label">@lang('auth.fillcaptcha')</label>
<div

View File

@@ -16,6 +16,6 @@
{{ $field->value }}
@endif
</div>
<p class="text-danger">{{ $errors->first($field->slug) }}</p>
<p class="text-danger">{{ $errors->first('field_'.$field->slug) }}</p>
</td>
</tr>

View File

@@ -0,0 +1,16 @@
<tr>
<td>
{{ $field->field->name }}
@if($field->field->required === true)
<span class="text-danger">*</span>
@endif
</td>
<td>
<div class="input-group input-group-sm form-group">
{{ Form::text($field->field->slug, $field->value, [
'class' => 'form-control',
]) }}
</div>
<p class="text-danger">{{ $errors->first('field_'.$field->slug) }}</p>
</td>
</tr>

View File

@@ -108,6 +108,27 @@
@endif
</td>
</tr>
{{-- Custom fields --}}
@foreach($userFields as $field)
<tr>
<td>
{{ $field->name }}
@if($field->required === true)
<span class="text-danger">*</span>
@endif
</td>
<td>
<div class="input-group input-group-sm form-group">
{{ Form::text('field_'.$field->slug, $field->value, [
'class' => 'form-control',
]) }}
</div>
<p class="text-danger">{{ $errors->first('field_'.$field->slug) }}</p>
</td>
</tr>
@endforeach
<tr>
<td>@lang('profile.opt-in')</td>
<td>

View File

@@ -128,4 +128,20 @@
</div>
</div>
@endif
<div class="clearfix" style="height: 50px;"></div>
<div class="row">
<div class="col-sm-12">
<table class="table table-full-width">
@foreach($userFields as $field)
@if($field->public === true)
<tr>
<td>{{ $field->name }}</td>
<td>{{ $field->value }}</td>
</tr>
@endif
@endforeach
</table>
</div>
</div>
@endsection