Skip to content

Commit

Permalink
Backport the column icon fix from master
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <snipe@snipe.net>
  • Loading branch information
snipe committed Apr 24, 2020
1 parent bea3a7b commit 6847a33
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 89 deletions.
48 changes: 24 additions & 24 deletions app/Presenters/UserPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace App\Presenters;

use Illuminate\Support\Facades\Storage;
use App\Helpers\Helper;
use App\Models\Setting;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;

/**
* Class UserPresenter
Expand Down Expand Up @@ -168,39 +171,40 @@ public static function dataTableLayout()
"formatter" => "usersLinkObjFormatter"
],
[
"field" => "assets_count",
"searchable" => false,
"sortable" => true,
"switchable" => true,
"title" => ' <span class="hidden-md hidden-lg">Assets</span>'
.'<span class="hidden-xs"><i class="fa fa-barcode fa-lg"></i></span>',
"visible" => true,
'field' => 'assets_count',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'escape' => true,
'class' => 'css-barcode',
'title' => 'Assets',
'visible' => true,
],
[
"field" => "licenses_count",
"searchable" => false,
"sortable" => true,
"switchable" => true,
"title" => ' <span class="hidden-md hidden-lg">Licenses</span>'
.'<span class="hidden-xs"><i class="fa fa-floppy-o fa-lg"></i></span>',
'class' => 'css-license',
"title" => 'License',
"visible" => true,
],
[
"field" => "consumables_count",
"searchable" => false,
"sortable" => true,
"switchable" => true,
"title" => ' <span class="hidden-md hidden-lg">Consumables</span>'
.'<span class="hidden-xs"><i class="fa fa-tint fa-lg"></i></span>',
'class' => 'css-consumable',
"title" => 'Consumables',
"visible" => true,
],
[
"field" => "accessories_count",
"searchable" => false,
"sortable" => true,
"switchable" => true,
"title" => ' <span class="hidden-md hidden-lg">Accessories</span>'
.'<span class="hidden-xs"><i class="fa fa-keyboard-o fa-lg"></i></span>',
'class' => 'css-accessory',
"title" => 'Accessories',
"visible" => true,
],
[
Expand Down Expand Up @@ -317,20 +321,16 @@ public function gravatar()
{

if ($this->avatar) {
return Storage::disk('public')->url('avatars/'.$this->avatar, $this->avatar);
return config('app.url').'/uploads/avatars/'.$this->avatar;
}

if ($this->email != '') {
/**
* @see https://en.gravatar.com/site/implement/images/
* Return a default [Myster Person] gravatar if the user does not have one
*/
if ((Setting::getSettings()->load_remote=='1') && ($this->email!='')) {
$gravatar = md5(strtolower(trim($this->email)));
// return "//gravatar.com/avatar/".$gravatar.'?d=mp';
return "//gravatar.com/avatar/".$gravatar;
}

// Set a fun, gender-neutral default icon when there is no email
return url('/img/default-sm.png');
// Set a fun, gender-neutral default icon
return url('/').'/img/default-sm.png';

}

Expand All @@ -356,4 +356,4 @@ public function glyph()
{
return '<i class="fa fa-user" aria-hidden="true"></i>';
}
}
}
191 changes: 126 additions & 65 deletions resources/views/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,89 @@
{{-- Page title --}}
@section('title')

@if (Request::get('status')=='deleted')
{{ trans('general.deleted') }}
@else
{{ trans('general.current') }}
@endif
{{ trans('general.users') }}

@parent
@if (request('status')=='deleted')
{{ trans('general.deleted') }}
@else
{{ trans('general.current') }}
@endif
{{ trans('general.users') }}
@parent

@stop

@section('header_right')

<style>
/**
This is kind of weird, but it is necessary to prevent the column-selector code from barfing, since
any HTML used in the UserPresenter "title" attribute breaks the column selector HTML.
Instead, we use CSS to add the icon into the table header, which leaves the column selector
"title" text as-is.
See https://github.com/snipe/snipe-it/issues/7989
*/
th.css-barcode > .th-inner,
th.css-license > .th-inner,
th.css-consumable > .th-inner,
th.css-accessory > .th-inner
{
font-size: 0px;
line-height: 4!important;
text-align: left;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
th.css-barcode > .th-inner::before,
th.css-license > .th-inner::before,
th.css-consumable > .th-inner::before,
th.css-accessory > .th-inner::before
{
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: 20px;
}
th.css-barcode > .th-inner::before
{
content: "\f02a";
}
th.css-license > .th-inner::before
{
content: "\f0c7";
}
th.css-consumable > .th-inner::before
{
content: "\f043";
}
th.css-accessory > .th-inner::before
{
content: "\f11c";
}
</style>

@can('create', \App\Models\User::class)
@if ($snipeSettings->ldap_enabled == 1)
<a href="{{ route('ldap/user') }}" class="btn btn-default pull-right"><span class="fa fa-sitemap"></span> LDAP Sync</a>
@endif
<a href="{{ route('users.create') }}" class="btn btn-primary pull-right" style="margin-right: 5px;"> {{ trans('general.create') }}</a>
@if ($snipeSettings->ldap_enabled == 1)
<a href="{{ route('ldap/user') }}" class="btn btn-default pull-right"><span class="fa fa-sitemap"></span> LDAP Sync</a>
@endif
<a href="{{ route('users.create') }}" class="btn btn-primary pull-right" style="margin-right: 5px;"> {{ trans('general.create') }}</a>
@endcan

@if (Request::get('status')=='deleted')
<a class="btn btn-default pull-right" href="{{ route('users.index') }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_current') }}</a>
@if (request('status')=='deleted')
<a class="btn btn-default pull-right" href="{{ route('users.index') }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_current') }}</a>
@else
<a class="btn btn-default pull-right" href="{{ route('users.index', ['status' => 'deleted']) }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_deleted') }}</a>
<a class="btn btn-default pull-right" href="{{ route('users.index', ['status' => 'deleted']) }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_deleted') }}</a>
@endif
@can('view', \App\Models\User::class)
<a class="btn btn-default pull-right" href="{{ route('users.export') }}" style="margin-right: 5px;">Export</a>
Expand All @@ -34,65 +95,65 @@
{{-- Page content --}}
@section('content')

<div class="row">
<div class="col-md-12">
<div class="box box-default">
<div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}

@if (Request::get('status')!='deleted')
@can('delete', \App\Models\User::class)
<div id="toolbar">
<label for="bulk_actions" class="sr-only">Bulk Actions</label>
<select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
<option value="delete">Bulk Checkin &amp; Delete</option>
<option value="edit">Bulk Edit</option>
<option value="bulkpasswordreset">Send Password Reset</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>Go</button>
</div>
@endcan
@endif


<table
data-click-to-select="true"
data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
data-cookie-id-table="usersTable"
data-pagination="true"
data-id-table="usersTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-toolbar="#toolbar"
id="usersTable"
class="table table-striped snipe-table"
data-url="{{ route('api.users.index',
array('deleted'=> (Request::get('status')=='deleted') ? 'true' : 'false','company_id'=>e(Request::get('company_id')))) }}"
data-export-options='{
<div class="row">
<div class="col-md-12">
<div class="box box-default">
<div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}

@if (request('status')!='deleted')
@can('delete', \App\Models\User::class)
<div id="toolbar">
<label for="bulk_actions" class="sr-only">Bulk Actions</label>
<select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
<option value="delete">Bulk Checkin &amp; Delete</option>
<option value="edit">Bulk Edit</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>Go</button>
</div>
@endcan
@endif


<table
data-click-to-select="true"
data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
data-cookie-id-table="usersTable"
data-pagination="true"
data-id-table="usersTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-toolbar="#toolbar"
id="usersTable"
class="table table-striped snipe-table"
data-url="{{ route('api.users.index',
array('deleted'=> (request('status')=='deleted') ? 'true' : 'false','company_id'=>e(request('company_id')))) }}"
data-export-options='{
"fileName": "export-users-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</table>


{{ Form::close() }}
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
</div>
{{ Form::close() }}
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
</div>

@stop

@section('moar_scripts')

@include ('partials.bootstrap-table')


@stop
@stop

0 comments on commit 6847a33

Please sign in to comment.