#9: Users management section now works with Bootstrap v4

This commit is contained in:
Andy Heathershaw 2017-03-26 21:29:10 +01:00
parent d15ff4ec6f
commit 00328c7ba2
5 changed files with 206 additions and 216 deletions

View File

@ -111,7 +111,7 @@ class UserController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit(Request $request, $id)
{ {
$this->authorize('admin-access'); $this->authorize('admin-access');
@ -128,6 +128,11 @@ class UserController extends Controller
$usersGroups[] = $group->id; $usersGroups[] = $group->id;
} }
if (!$request->session()->has('_old_input'))
{
$request->session()->flash('_old_input', $user->toArray());
}
return Theme::render('admin.edit_user', ['user' => $user, 'groups' => $groups, 'users_groups' => $usersGroups]); return Theme::render('admin.edit_user', ['user' => $user, 'groups' => $groups, 'users_groups' => $usersGroups]);
} }

View File

@ -2,50 +2,46 @@
@section('title', trans('admin.create_user')) @section('title', trans('admin.create_user'))
@section('breadcrumb') @section('breadcrumb')
<div class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<div class="container"> <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<ol class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li> <li class="breadcrumb-item active">@lang('navigation.breadcrumb.create_user')</li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li class="active">@lang('navigation.breadcrumb.create_user')</li>
</ol>
</div>
</div>
@endsection @endsection
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col">
<h1>@lang('admin.create_user_title')</h1> <h1>@lang('admin.create_user_title')</h1>
<p>@lang('admin.create_user_intro')</p> <p>@lang('admin.create_user_intro')</p>
<hr/> <hr/>
{!! Form::open(['route' => 'users.store', 'method' => 'POST']) !!} <form action="{{ route('users.store') }}" method="post">
{{ csrf_field() }}
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-name">@lang('forms.name_label')</label>
{!! Form::text('name', old('name'), ['class' => 'form-control']) !!} <input type="text" class="form-control" id="user-name" name="name" value="{{ old('name') }}">
@if ($errors->has('name')) @if ($errors->has('name'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('name') }}</strong> <strong>{{ $errors->first('name') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('email') ? ' has-danger' : '' }}">
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-email">@lang('forms.email_label')</label>
{!! Form::text('email', old('email'), ['class' => 'form-control']) !!} <input type="text" class="form-control" id="user-email" name="email" value="{{ old('email') }}">
@if ($errors->has('email')) @if ($errors->has('email'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong> <strong>{{ $errors->first('email') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
@ -53,51 +49,51 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password') ? ' has-danger' : '' }}">
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-password">@lang('forms.password_label')</label>
{!! Form::password('password', ['class' => 'form-control']) !!} <input type="password" class="form-control" id="user-password" name="password" value="{{ old('password') }}">
@if ($errors->has('password')) @if ($errors->has('password'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password') }}</strong> <strong>{{ $errors->first('password') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password_confirmation') ? ' has-danger' : '' }}">
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-password-confirm">@lang('forms.password_confirm_label')</label>
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} <input type="password" class="form-control" id="user-password-confirm" name="password_confirmation" value="{{ old('password_confirmation') }}">
@if ($errors->has('password_confirmation')) @if ($errors->has('password_confirmation'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password_confirmation') }}</strong> <strong>{{ $errors->first('password_confirmation') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
</div> </div>
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="is_admin"> <input class="form-check-input" type="checkbox" name="is_admin">
<strong>@lang('forms.admin_user_label')</strong> @lang('forms.admin_user_label')
</label> </label>
</div> </div>
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="can_create_albums"> <input class="form-check-input" type="checkbox" name="can_create_albums">
<strong>@lang('forms.can_create_albums_label')</strong> @lang('forms.can_create_albums_label')
</label> </label>
</div> </div>
<div class="form-actions"> <div class="text-right">
<a href="{{ route('users.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a> <a href="{{ route('users.index') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
<button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.create_action')</button> <button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.create_action')</button>
</div> </div>
{!! Form::close() !!} </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,32 +2,31 @@
@section('title', trans('admin.delete_user', ['name' => $user->name])) @section('title', trans('admin.delete_user', ['name' => $user->name]))
@section('breadcrumb') @section('breadcrumb')
<div class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<div class="container"> <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<ol class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li> <li class="breadcrumb-item active">@lang('navigation.breadcrumb.delete_user')</li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li class="active">@lang('navigation.breadcrumb.delete_user')</li>
</ol>
</div>
</div>
@endsection @endsection
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-md-8 offset-md-2">
<h1>@yield('title')</h1> <div class="card card-outline-danger">
<div class="card-header card-danger">@yield('title')</div>
<div class="card-block">
<p>@lang('admin.delete_user_confirm', ['name' => $user->name])</p> <p>@lang('admin.delete_user_confirm', ['name' => $user->name])</p>
<div class="alert alert-danger"> <p class="text-danger"><b>@lang('admin.delete_user_warning')</b></p>
@lang('admin.delete_user_warning')
</div> <div class="text-right">
<div class="form-actions"> <form action="{{ route('users.destroy', [$user->id]) }}" method="post">
{!! Form::open(['route' => ['users.destroy', $user->id], 'method' => 'DELETE']) !!} {{ csrf_field() }}
<a href="{{ route('users.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a> {{ method_field('DELETE') }}
<a href="{{ route('users.index') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
<button type="submit" class="btn btn-danger"><i class="fa fa-fw fa-trash"></i> @lang('forms.delete_action')</button> <button type="submit" class="btn btn-danger"><i class="fa fa-fw fa-trash"></i> @lang('forms.delete_action')</button>
{!! Form::close() !!} </form>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,27 +2,24 @@
@section('title', trans('admin.edit_user_title', ['name' => $user->name])) @section('title', trans('admin.edit_user_title', ['name' => $user->name]))
@section('breadcrumb') @section('breadcrumb')
<div class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<div class="container"> <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<ol class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li> <li class="breadcrumb-item active">@lang('navigation.breadcrumb.edit_user')</li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li><a href="{{ route('users.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li class="active">@lang('navigation.breadcrumb.edit_user')</li>
</ol>
</div>
</div>
@endsection @endsection
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col">
<h1>@yield('title')</h1> <h1>@yield('title')</h1>
<p>@lang('admin.edit_user_intro')</p> <p>@lang('admin.edit_user_intro')</p>
<hr/> <hr/>
{!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'PUT']) !!} <form action="{{ route('users.update', [$user->id]) }}" method="post">
{{ csrf_field() }}
{{ method_field('PUT') }}
<div> <div>
{{-- Nav tabs --}} {{-- Nav tabs --}}
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
@ -36,27 +33,27 @@
<div role="tabpanel" class="tab-pane active" id="details-tab"> <div role="tabpanel" class="tab-pane active" id="details-tab">
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-name">@lang('forms.name_label')</label>
{!! Form::text('name', old('name'), ['class' => 'form-control']) !!} <input type="text" class="form-control" id="user-name" name="name" value="{{ old('name') }}">
@if ($errors->has('name')) @if ($errors->has('name'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('name') }}</strong> <strong>{{ $errors->first('name') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('email') ? ' has-danger' : '' }}">
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-email">@lang('forms.email_label')</label>
{!! Form::text('email', old('email'), ['class' => 'form-control']) !!} <input type="text" class="form-control" id="user-email" name="email" value="{{ old('email') }}">
@if ($errors->has('email')) @if ($errors->has('email'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong> <strong>{{ $errors->first('email') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
@ -64,50 +61,50 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password') ? ' has-danger' : '' }}">
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-password">@lang('forms.password_label')</label>
{!! Form::password('password', ['class' => 'form-control']) !!} <input type="password" class="form-control" id="user-password" name="password" value="{{ old('password') }}">
@if ($errors->has('password')) @if ($errors->has('password'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password') }}</strong> <strong>{{ $errors->first('password') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password_confirmation') ? ' has-danger' : '' }}">
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} <label class="form-control-label" for="user-password-confirm">@lang('forms.password_confirm_label')</label>
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} <input type="password" class="form-control" id="user-password-confirm" name="password_confirmation" value="{{ old('password_confirmation') }}">
@if ($errors->has('password_confirmation')) @if ($errors->has('password_confirmation'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password_confirmation') }}</strong> <strong>{{ $errors->first('password_confirmation') }}</strong>
</span> </div>
@endif @endif
</div> </div>
</div> </div>
</div> </div>
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="is_admin"@if ($user->is_admin) checked="checked"@endif> <input class="form-check-input" type="checkbox" name="is_admin"@if ($user->is_admin) checked="checked"@endif>
<strong>@lang('forms.admin_user_label')</strong> @lang('forms.admin_user_label')
</label> </label>
</div> </div>
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="can_create_albums"@if ($user->can_create_albums) checked="checked"@endif> <input class="form-check-input" type="checkbox" name="can_create_albums"@if ($user->can_create_albums) checked="checked"@endif>
<strong>@lang('forms.can_create_albums_label')</strong> @lang('forms.can_create_albums_label')
</label> </label>
</div> </div>
@if (!$user->is_activated) @if (!$user->is_activated)
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="is_activated"> <input class="form-check-input" type="checkbox" name="is_activated">
<strong>@lang('forms.activate_user_label')</strong> <strong>@lang('forms.activate_user_label')</strong>
</label> </label>
</div> </div>
@ -120,10 +117,10 @@
<p style="margin-bottom: 20px;">@lang('admin.user_groups_list_select', ['name' => $user->name])</p> <p style="margin-bottom: 20px;">@lang('admin.user_groups_list_select', ['name' => $user->name])</p>
@foreach ($groups as $group) @foreach ($groups as $group)
<div class="checkbox"> <div class="form-check">
<label> <label class="form-check-label">
<input type="checkbox" name="user_group_id[]" value="{{ $group->id }}"@if (in_array($group->id, $users_groups)) checked="checked"@endif> <input class="form-check-input" type="checkbox" name="user_group_id[]" value="{{ $group->id }}"@if (in_array($group->id, $users_groups)) checked="checked"@endif>
<strong>{{ $group->name }}</strong> {{ $group->name }}
</label> </label>
</div> </div>
@endforeach @endforeach
@ -132,12 +129,12 @@
</div> </div>
</div> </div>
<div class="form-actions" style="margin-top: 20px;"> <div class="text-right" style="margin-top: 20px;">
<a href="{{ route('users.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a> <a href="{{ route('users.index') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
<button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.save_action')</button> <button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.save_action')</button>
</div> </div>
</div> </div>
{!! Form::close() !!} </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,21 +2,15 @@
@section('title', trans('admin.users_title')) @section('title', trans('admin.users_title'))
@section('breadcrumb') @section('breadcrumb')
<div class="breadcrumb"> <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<div class="container"> <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<ol class="breadcrumb"> <li class="breadcrumb-item active">@lang('navigation.breadcrumb.users')</li>
<li><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li class="active">@lang('navigation.breadcrumb.users')</li>
</ol>
</div>
</div>
@endsection @endsection
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col">
<h1>@lang('admin.list_users_title')</h1> <h1>@lang('admin.list_users_title')</h1>
<div class="alert alert-info" style="margin-bottom: 30px;"> <div class="alert alert-info" style="margin-bottom: 30px;">
<p><i class="fa fa-fw fa-info"></i> @lang('admin.list_users_intro')</p> <p><i class="fa fa-fw fa-info"></i> @lang('admin.list_users_intro')</p>
@ -27,8 +21,8 @@
@foreach ($users as $user) @foreach ($users as $user)
<tr> <tr>
<td> <td>
<span style="font-size: 1.3em;">{{ $user->name }}@if ($user->is_admin) <i class="fa fa-fw fa-cog"></i>@endif</span><br/> <span style="font-size: 1.3em;"><a href="{{ route('users.edit', ['id' => $user->id]) }}">{{ $user->name }}</a>@if ($user->is_admin) <i class="fa fa-fw fa-cog"></i>@endif</span><br/>
<a href="mailto:{{ $user->email }}">{{ $user->email }}</a> {{ $user->email }} <a href="mailto:{{ $user->email }}"><i class="fa fa-fw fa-mail-forward"></i></a>
</td> </td>
<td> <td>
@if (!$user->is_activated) @if (!$user->is_activated)
@ -36,7 +30,6 @@
@endif @endif
</td> </td>
<td class="text-right"> <td class="text-right">
<a href="{{ route('users.edit', ['id' => $user->id]) }}" class="btn btn-default">@lang('forms.edit_action')</a>
<a href="{{ route('users.delete', ['id' => $user->id]) }}" class="btn btn-danger">@lang('forms.delete_action')</a> <a href="{{ route('users.delete', ['id' => $user->id]) }}" class="btn btn-danger">@lang('forms.delete_action')</a>
</td> </td>
</tr> </tr>
@ -49,7 +42,7 @@
</div> </div>
<div class="pull-right" style="margin-top: 10px;"> <div class="pull-right" style="margin-top: 10px;">
<a href="{{ route('groups.index') }}" class="btn btn-default">@lang('admin.list_groups_title')</a> <a href="{{ route('groups.index') }}" class="btn btn-link">@lang('admin.list_groups_title')</a>
<a href="{{ route('users.create') }}" class="btn btn-success"><i class="fa fa-fw fa-plus"></i> @lang('admin.create_user')</a> <a href="{{ route('users.create') }}" class="btn btn-success"><i class="fa fa-fw fa-plus"></i> @lang('admin.create_user')</a>
</div> </div>
</div> </div>