#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
* @return \Illuminate\Http\Response
*/
public function edit($id)
public function edit(Request $request, $id)
{
$this->authorize('admin-access');
@ -128,6 +128,11 @@ class UserController extends Controller
$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]);
}

View File

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

View File

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

View File

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

View File

@ -2,21 +2,15 @@
@section('title', trans('admin.users_title'))
@section('breadcrumb')
<div class="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<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>
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li class="breadcrumb-item active">@lang('navigation.breadcrumb.users')</li>
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="col">
<h1>@lang('admin.list_users_title')</h1>
<div class="alert alert-info" style="margin-bottom: 30px;">
<p><i class="fa fa-fw fa-info"></i> @lang('admin.list_users_intro')</p>
@ -27,8 +21,8 @@
@foreach ($users as $user)
<tr>
<td>
<span style="font-size: 1.3em;">{{ $user->name }}@if ($user->is_admin) <i class="fa fa-fw fa-cog"></i>@endif</span><br/>
<a href="mailto:{{ $user->email }}">{{ $user->email }}</a>
<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/>
{{ $user->email }} <a href="mailto:{{ $user->email }}"><i class="fa fa-fw fa-mail-forward"></i></a>
</td>
<td>
@if (!$user->is_activated)
@ -36,7 +30,6 @@
@endif
</td>
<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>
</td>
</tr>
@ -49,7 +42,7 @@
</div>
<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>
</div>
</div>