#19: Added a check for the user.enable_profile_page column when viewing the profile page. Added link to user's profile page (if enabled) in album footers. Tooltips are now enabled globally. Child album's footer now shows the details as tooltips.

This commit is contained in:
Andy Heathershaw 2018-08-11 09:20:40 +01:00
parent 7e721966e9
commit a22ce0c57a
10 changed files with 62 additions and 64 deletions

View File

@ -174,6 +174,8 @@ class Album extends Model
return $this->hasMany(Photo::class);
}
public function redirects()
{
return $this->hasMany(AlbumRedirect::class);
@ -231,6 +233,11 @@ class Album extends Model
return route('viewAlbum', $this->url_path);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function userPermissions()
{
return $this->belongsToMany(Permission::class, 'album_user_permissions');

View File

@ -31,7 +31,6 @@ class UserPolicy
public function view(User $user, User $userBeingAccessed)
{
// TODO per-user setting that determines if the page is available
return true;
return $userBeingAccessed->enable_profile_page;
}
}

View File

@ -16,7 +16,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'is_admin', 'is_activated', 'activation_token'
'name', 'email', 'password', 'is_admin', 'is_activated', 'activation_token', 'profile_alias'
];
/**
@ -64,4 +64,16 @@ class User extends Authenticatable
{
return $this->id == -1 && $this->name == 'Anonymous';
}
public function profileUrl()
{
return route('viewUser', [
'idOrAlias' => (!empty($this->profile_alias) ? trim(strtolower($this->profile_alias)) : $this->id)
]);
}
public function publicDisplayName()
{
return trim(!empty($this->profile_alias) ? $this->profile_alias : $this->name);
}
}

View File

@ -57,23 +57,7 @@
<div class="row">
@foreach ($child_albums as $childAlbum)
<div class="col-6 col-sm-4 col-md-3 text-left" style="max-width: 250px;">
<div class="card mb-3">
<img class="card-img-top" src="{{ $childAlbum->thumbnailUrl('preview') }}" style="max-height: 120px;"/>
<div class="card-body">
<h5 class="card-title"><a href="{{ $childAlbum->url() }}">{{ $childAlbum->name }}</a></h5>
</div>
<div class="card-footer">
<small class="text-muted">
<i class="fa fa-fw fa-photo"></i> {{ number_format($childAlbum->photos_count) }} {{ trans_choice('gallery.photos', $childAlbum->photos_count) }}
@if ($childAlbum->children_count > 0)
<i class="fa fa-fw fa-book ml-3"></i> {{ number_format($childAlbum->children_count) }} {{ trans_choice('gallery.child_albums', $childAlbum->children_count) }}
@endif
</small>
</div>
</div>
</div>
@include(Theme::viewName('partials.gallery_child_album'));
@endforeach
</div>
</div>

View File

@ -32,23 +32,7 @@
<div class="row">
@foreach ($child_albums as $childAlbum)
<div class="col-6 col-sm-4 col-md-3 text-left" style="max-width: 250px;">
<div class="card mb-3">
<img class="card-img-top" src="{{ $childAlbum->thumbnailUrl('preview') }}" style="max-height: 120px;"/>
<div class="card-body">
<h5 class="card-title"><a href="{{ $childAlbum->url() }}">{{ $childAlbum->name }}</a></h5>
</div>
<div class="card-footer">
<small class="text-muted">
<i class="fa fa-fw fa-photo"></i> {{ number_format($childAlbum->photos_count) }} {{ trans_choice('gallery.photos', $childAlbum->photos_count) }}
@if ($childAlbum->children_count > 0)
<i class="fa fa-fw fa-book ml-3"></i> {{ number_format($childAlbum->children_count) }} {{ trans_choice('gallery.child_albums', $childAlbum->children_count) }}
@endif
</small>
</div>
</div>
</div>
@include(Theme::viewName('partials.gallery_child_album'));
@endforeach
</div>
@endif

View File

@ -64,23 +64,7 @@
<div class="row">
@foreach ($child_albums as $childAlbum)
<div class="col-6 col-sm-4 col-md-3 text-left" style="max-width: 250px;">
<div class="card mb-3">
<img class="card-img-top" src="{{ $childAlbum->thumbnailUrl('preview') }}" style="max-height: 120px;"/>
<div class="card-body">
<h5 class="card-title"><a href="{{ $childAlbum->url() }}">{{ $childAlbum->name }}</a></h5>
</div>
<div class="card-footer">
<small class="text-muted">
<i class="fa fa-fw fa-photo"></i> {{ number_format($childAlbum->photos_count) }} {{ trans_choice('gallery.photos', $childAlbum->photos_count) }}
@if ($childAlbum->children_count > 0)
<i class="fa fa-fw fa-book ml-3"></i> {{ number_format($childAlbum->children_count) }} {{ trans_choice('gallery.child_albums', $childAlbum->children_count) }}
@endif
</small>
</div>
</div>
</div>
@include(Theme::viewName('partials.gallery_child_album'));
@endforeach
</div>
</div>

View File

@ -24,7 +24,16 @@
<i class="fa fa-fw fa-photo"></i> {{ number_format($album->photos_count) }} {{ trans_choice('gallery.photos', $album->photos_count) }}
@if ($album->children_count > 0)
<i class="fa fa-fw fa-book ml-3"></i> {{ number_format($album->children_count) }} {{ trans_choice('gallery.child_albums', $album->children_count) }}
<i class="fa fa-fw fa-book ml-2"></i> {{ number_format($album->children_count) }} {{ trans_choice('gallery.child_albums', $album->children_count) }}
@endif
@if (UserConfig::get('social_user_profiles'))
<i class="fa fa-fw fa-user ml-2"></i>
@can('view', $album->user)
<a href="{{ $album->user->profileUrl() }}">{{ $album->user->publicDisplayName() }}</a>
@else
{{ $album->user->publicDisplayName() }}
@endif
@endif
</small>
</div>

View File

@ -104,12 +104,4 @@
</div>
</div>
</div>
@endsection
@push ('scripts')
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
</script>
@endpush
@endsection

View File

@ -126,6 +126,8 @@
{
$('.modal-footer', '#quick-upload-modal').html('<center><img src="{{ asset('ripple.svg') }}"/></center>');
});
$('[data-toggle="tooltip"]').tooltip();
});
</script>
@stack('scripts')

View File

@ -0,0 +1,25 @@
<div class="col-6 col-sm-4 col-md-3 text-left" style="max-width: 250px;">
<div class="card mb-3">
<img class="card-img-top" src="{{ $childAlbum->thumbnailUrl('preview') }}" style="max-height: 120px;"/>
<div class="card-body">
<h5 class="card-title"><a href="{{ $childAlbum->url() }}">{{ $childAlbum->name }}</a></h5>
</div>
<div class="card-footer">
<small class="text-muted">
<i class="fa fa-fw fa-photo" data-toggle="tooltip" data-placement="top" title="{{ number_format($childAlbum->photos_count) }} {{ trans_choice('gallery.photos', $childAlbum->photos_count) }}"></i>
@if ($childAlbum->children_count > 0)
<i class="fa fa-fw fa-book ml-3" data-toggle="tooltip" data-placement="top" title="{{ number_format($childAlbum->children_count) }} {{ trans_choice('gallery.child_albums', $childAlbum->children_count) }}"></i>
@endif
@if (UserConfig::get('social_user_profiles'))
@can('view', $childAlbum->user)
<a href="{{ $childAlbum->user->profileUrl() }}" data-toggle="tooltip" data-placement="top" title="{{ $childAlbum->user->publicDisplayName() }}"><i class="fa fa-fw fa-user ml-2"></i></a>
@else
<i class="fa fa-fw fa-user ml-2" data-toggle="tooltip" data-placement="top" title="{{ $childAlbum->user->publicDisplayName() }}"></i>
@endif
@endif
</small>
</div>
</div>
</div>