#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,102 +2,98 @@
@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">
<div class="row"> {{ csrf_field() }}
<div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!}
{!! Form::text('name', old('name'), ['class' => 'form-control']) !!}
@if ($errors->has('name')) <div class="row">
<span class="help-block"> <div class="col-sm-6">
<strong>{{ $errors->first('name') }}</strong> <div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
</span> <label class="form-control-label" for="user-name">@lang('forms.name_label')</label>
@endif <input type="text" class="form-control" id="user-name" name="name" value="{{ old('name') }}">
@if ($errors->has('name'))
<div class="form-control-feedback">
<strong>{{ $errors->first('name') }}</strong>
</div>
@endif
</div>
</div>
<div class="col-sm-6">
<div class="form-group{{ $errors->has('email') ? ' has-danger' : '' }}">
<label class="form-control-label" for="user-email">@lang('forms.email_label')</label>
<input type="text" class="form-control" id="user-email" name="email" value="{{ old('email') }}">
@if ($errors->has('email'))
<div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong>
</div>
@endif
</div>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="row">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="col-sm-6">
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} <div class="form-group{{ $errors->has('password') ? ' has-danger' : '' }}">
{!! Form::text('email', old('email'), ['class' => 'form-control']) !!} <label class="form-control-label" for="user-password">@lang('forms.password_label')</label>
<input type="password" class="form-control" id="user-password" name="password" value="{{ old('password') }}">
@if ($errors->has('email')) @if ($errors->has('password'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong> <strong>{{ $errors->first('password') }}</strong>
</span> </div>
@endif @endif
</div>
</div> </div>
</div>
</div>
<div class="row"> <div class="col-sm-6">
<div class="col-sm-6"> <div class="form-group{{ $errors->has('password_confirmation') ? ' has-danger' : '' }}">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <label class="form-control-label" for="user-password-confirm">@lang('forms.password_confirm_label')</label>
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} <input type="password" class="form-control" id="user-password-confirm" name="password_confirmation" value="{{ old('password_confirmation') }}">
{!! Form::password('password', ['class' => 'form-control']) !!}
@if ($errors->has('password')) @if ($errors->has('password_confirmation'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password') }}</strong> <strong>{{ $errors->first('password_confirmation') }}</strong>
</span> </div>
@endif @endif
</div>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="form-check">
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <label class="form-check-label">
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} <input class="form-check-input" type="checkbox" name="is_admin">
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} @lang('forms.admin_user_label')
</label>
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</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="can_create_albums">
<strong>@lang('forms.admin_user_label')</strong> @lang('forms.can_create_albums_label')
</label> </label>
</div> </div>
<div class="checkbox"> <div class="text-right">
<label> <a href="{{ route('users.index') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
<input type="checkbox" name="can_create_albums"> <button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.create_action')</button>
<strong>@lang('forms.can_create_albums_label')</strong> </div>
</label> </form>
</div>
<div class="form-actions">
<a href="{{ route('users.index') }}" class="btn btn-default">@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>
</div>
{!! Form::close() !!}
</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">
<p>@lang('admin.delete_user_confirm', ['name' => $user->name])</p> <div class="card-header card-danger">@yield('title')</div>
<div class="alert alert-danger"> <div class="card-block">
@lang('admin.delete_user_warning') <p>@lang('admin.delete_user_confirm', ['name' => $user->name])</p>
</div> <p class="text-danger"><b>@lang('admin.delete_user_warning')</b></p>
<div class="form-actions">
{!! Form::open(['route' => ['users.destroy', $user->id], 'method' => 'DELETE']) !!} <div class="text-right">
<a href="{{ route('users.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a> <form action="{{ route('users.destroy', [$user->id]) }}" method="post">
<button type="submit" class="btn btn-danger"><i class="fa fa-fw fa-trash"></i> @lang('forms.delete_action')</button> {{ csrf_field() }}
{!! Form::close() !!} {{ 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>
</form>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,142 +2,139 @@
@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">
<div> {{ csrf_field() }}
{{-- Nav tabs --}} {{ method_field('PUT') }}
<ul class="nav nav-tabs" role="tablist">
@include(Theme::viewName('partials.tab'), ['active_tab' => 'details', 'tab_name' => 'details', 'tab_icon' => 'info-circle', 'tab_text' => trans('admin.user_details_tab')])
@include(Theme::viewName('partials.tab'), ['active_tab' => 'details', 'tab_name' => 'groups', 'tab_icon' => 'users', 'tab_text' => trans('admin.user_groups_tab')])
</ul>
{{-- Tab panes --}} <div>
<div class="tab-content"> {{-- Nav tabs --}}
{{-- Details --}} <ul class="nav nav-tabs" role="tablist">
<div role="tabpanel" class="tab-pane active" id="details-tab"> @include(Theme::viewName('partials.tab'), ['active_tab' => 'details', 'tab_name' => 'details', 'tab_icon' => 'info-circle', 'tab_text' => trans('admin.user_details_tab')])
<div class="row"> @include(Theme::viewName('partials.tab'), ['active_tab' => 'details', 'tab_name' => 'groups', 'tab_icon' => 'users', 'tab_text' => trans('admin.user_groups_tab')])
<div class="col-sm-6"> </ul>
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!}
{!! Form::text('name', old('name'), ['class' => 'form-control']) !!}
@if ($errors->has('name')) {{-- Tab panes --}}
<span class="help-block"> <div class="tab-content">
<strong>{{ $errors->first('name') }}</strong> {{-- Details --}}
</span> <div role="tabpanel" class="tab-pane active" id="details-tab">
@endif <div class="row">
<div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
<label class="form-control-label" for="user-name">@lang('forms.name_label')</label>
<input type="text" class="form-control" id="user-name" name="name" value="{{ old('name') }}">
@if ($errors->has('name'))
<div class="form-control-feedback">
<strong>{{ $errors->first('name') }}</strong>
</div>
@endif
</div>
</div>
<div class="col-sm-6">
<div class="form-group{{ $errors->has('email') ? ' has-danger' : '' }}">
<label class="form-control-label" for="user-email">@lang('forms.email_label')</label>
<input type="text" class="form-control" id="user-email" name="email" value="{{ old('email') }}">
@if ($errors->has('email'))
<div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong>
</div>
@endif
</div>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="row">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="col-sm-6">
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} <div class="form-group{{ $errors->has('password') ? ' has-danger' : '' }}">
{!! Form::text('email', old('email'), ['class' => 'form-control']) !!} <label class="form-control-label" for="user-password">@lang('forms.password_label')</label>
<input type="password" class="form-control" id="user-password" name="password" value="{{ old('password') }}">
@if ($errors->has('email')) @if ($errors->has('password'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('email') }}</strong> <strong>{{ $errors->first('password') }}</strong>
</span> </div>
@endif @endif
</div>
</div> </div>
</div>
</div>
<div class="row"> <div class="col-sm-6">
<div class="col-sm-6"> <div class="form-group{{ $errors->has('password_confirmation') ? ' has-danger' : '' }}">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <label class="form-control-label" for="user-password-confirm">@lang('forms.password_confirm_label')</label>
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} <input type="password" class="form-control" id="user-password-confirm" name="password_confirmation" value="{{ old('password_confirmation') }}">
{!! Form::password('password', ['class' => 'form-control']) !!}
@if ($errors->has('password')) @if ($errors->has('password_confirmation'))
<span class="help-block"> <div class="form-control-feedback">
<strong>{{ $errors->first('password') }}</strong> <strong>{{ $errors->first('password_confirmation') }}</strong>
</span> </div>
@endif @endif
</div>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="form-check">
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <label class="form-check-label">
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} <input class="form-check-input" type="checkbox" name="is_admin"@if ($user->is_admin) checked="checked"@endif>
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} @lang('forms.admin_user_label')
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
</div>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="is_admin"@if ($user->is_admin) checked="checked"@endif>
<strong>@lang('forms.admin_user_label')</strong>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="can_create_albums"@if ($user->can_create_albums) checked="checked"@endif>
<strong>@lang('forms.can_create_albums_label')</strong>
</label>
</div>
@if (!$user->is_activated)
<div class="checkbox">
<label>
<input type="checkbox" name="is_activated">
<strong>@lang('forms.activate_user_label')</strong>
</label> </label>
</div> </div>
@endif
</div>
{{-- Groups --}} <div class="form-check">
<div role="tabpanel" class="tab-pane" id="groups-tab"> <label class="form-check-label">
@if ($groups->count() > 0) <input class="form-check-input" type="checkbox" name="can_create_albums"@if ($user->can_create_albums) checked="checked"@endif>
<p style="margin-bottom: 20px;">@lang('admin.user_groups_list_select', ['name' => $user->name])</p> @lang('forms.can_create_albums_label')
</label>
</div>
@foreach ($groups as $group) @if (!$user->is_activated)
<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="is_activated">
<strong>{{ $group->name }}</strong> <strong>@lang('forms.activate_user_label')</strong>
</label> </label>
</div> </div>
@endforeach @endif
@else </div>
@endif
{{-- Groups --}}
<div role="tabpanel" class="tab-pane" id="groups-tab">
@if ($groups->count() > 0)
<p style="margin-bottom: 20px;">@lang('admin.user_groups_list_select', ['name' => $user->name])</p>
@foreach ($groups as $group)
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="user_group_id[]" value="{{ $group->id }}"@if (in_array($group->id, $users_groups)) checked="checked"@endif>
{{ $group->name }}
</label>
</div>
@endforeach
@else
@endif
</div>
</div>
<div class="text-right" style="margin-top: 20px;">
<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>
</div> </div>
</div> </div>
</form>
<div class="form-actions" style="margin-top: 20px;">
<a href="{{ route('users.index') }}" class="btn btn-default">@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>
</div>
</div>
{!! Form::close() !!}
</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>