Skip to content

Commit

Permalink
Merge branch 'master' into forum-timestamp-cast
Browse files Browse the repository at this point in the history
  • Loading branch information
notbakaneko authored Dec 18, 2024
2 parents 5f5cf92 + a32c9de commit 10fa4a7
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 106 deletions.
9 changes: 9 additions & 0 deletions app/Models/TeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}

public function userOrDeleted(): User
{
$user = $this->user;

return $user === null || $user->isRestricted()
? new DeletedUser(['user_id' => $this->user_id])
: $user;
}
}
6 changes: 4 additions & 2 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2128,8 +2128,10 @@ public static function attemptLogin($user, $password, $ip = null)

public static function findForLogin($username, $allowEmail = false)
{
if (!present($username)) {
return;
$username = trim($username ?? '');

if ($username === null) {
return null;
}

$query = static::where('username', $username);
Expand Down
12 changes: 12 additions & 0 deletions resources/css/bem/input-text.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@
padding: var(--input-padding);
box-shadow: inset 0 0 0 2px var(--input-border-colour);
border-radius: @border-radius-large;

&--bbcode {
.fancy-scrollbar();
display: grid;
grid-template-rows: 1fr auto;
gap: 5px;
}

&__bbcode-textarea {
.reset-input();
resize: none;
}
}
2 changes: 1 addition & 1 deletion resources/css/bem/team-settings-description-preview.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
.team-settings-description-preview {
padding: 0 var(--padding);
overflow-y: scroll;
max-height: calc(70 * var(--vh));
height: calc(70 * var(--vh));
}
11 changes: 7 additions & 4 deletions resources/views/teams/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ class="team-settings__image"
<span class="input-container__label">
{{ osu_trans('teams.edit.description.label') }}
</span>
<textarea
name="team[description]"
class="input-text js-post-preview--auto"
>{{ $team->description }}</textarea>
<div class="input-text input-text--bbcode">
<textarea
name="team[description]"
class="input-text__bbcode-textarea js-post-preview--auto js-bbcode-body"
>{{ $team->description }}</textarea>
@include('forum._post_toolbar')
</div>
</label>

<div class="team-settings__description-preview u-fancy-scrollbar">
Expand Down
13 changes: 8 additions & 5 deletions resources/views/teams/members/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,26 @@
<span>{{ osu_trans('teams.members.index.table.joined_at') }}</span>
<span></span>
@foreach ($team->members as $member)
@php
$user = $member->userOrDeleted();
@endphp
<li class="team-members-manage__item">
<span class="team-members-manage__avatar">
<span
class="avatar avatar--full avatar--guest"
{!! background_image($member->user->user_avatar) !!}
{!! background_image($user->user_avatar) !!}
></span>
</span>
<span>
{!! link_to_user($member->user, null, '', []) !!}
{!! link_to_user($user, null, '', []) !!}
</span>
<span>
{{ osu_trans('teams.members.index.status.status_'.(int) $member->user->isActive()) }}
@if ($member->user->isOnline())
{{ osu_trans('teams.members.index.status.status_'.(int) $user->isActive()) }}
@if ($user->isOnline())
<small>
({!! osu_trans('users.show.lastvisit_online') !!})
</small>
@elseif (($lastvisit = $member->user->displayed_last_visit) !== null)
@elseif (($lastvisit = $user->displayed_last_visit) !== null)
<small>
({!! osu_trans('users.show.lastvisit', ['date' => timeago($lastvisit)]) !!})
</small>
Expand Down
185 changes: 91 additions & 94 deletions resources/views/teams/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
See the LICENCE file in the repository root for full licence text.
--}}
@php
use App\Models\DeletedUser;
use App\Transformers\UserCompactTransformer;
$userTransformer = new UserCompactTransformer();
$toJson = fn ($users) => json_collection($users, $userTransformer, UserCompactTransformer::CARD_INCLUDES);
$teamMembers = array_map($toJson, $team->members->mapToGroups(fn ($member) => [
$member->user_id === $team->leader_id ? 'leader' : 'member' => $member->user,
$member->user_id === $team->leader_id ? 'leader' : 'member' => $member->userOrDeleted(),
])->all());
$teamMembers['member'] ??= [];
$teamMembers['leader'] ??= $toJson([$team->leader ?? new DeletedUser(['user_id' => $team->leader_id])]);
$teamMembers['leader'] ??= $toJson([$team->members()->make(['user_id' => $team->leader_id])->userOrDeleted()]);
$headerUrl = $team->header()->url();
@endphp

Expand All @@ -26,114 +25,112 @@
'backgroundImage' => $headerUrl,
]])

<div class="osu-layout osu-layout--full">
<div class="osu-page osu-page--generic-compact">
<div class="profile-info profile-info--cover profile-info--team">
<div
class="profile-info__bg profile-info__bg--team"
{!! background_image($headerUrl) !!}
>
@if (priv_check('TeamUpdate', $team)->can())
<div class="profile-page-cover-editor-button">
<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.members.index', $team) }}"
title="{{ osu_trans('teams.members.index.title') }}"
>
<span class="fa fa-users"></span>
</a>
<div class="osu-page osu-page--generic-compact">
<div class="profile-info profile-info--cover profile-info--team">
<div
class="profile-info__bg profile-info__bg--team"
{!! background_image($headerUrl) !!}
>
@if (priv_check('TeamUpdate', $team)->can())
<div class="profile-page-cover-editor-button">
<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.members.index', $team) }}"
title="{{ osu_trans('teams.members.index.title') }}"
>
<span class="fa fa-users"></span>
</a>

<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.edit', $team) }}"
title="{{ osu_trans('teams.edit.title') }}"
>
<span class="fa fa-wrench"></span>
</a>
</div>
@endif
</div>
<div class="profile-info__details">
<div class="profile-info__avatar">
@include('objects._flag_team', ['modifiers' => 'full', 'team' => $team])
<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.edit', $team) }}"
title="{{ osu_trans('teams.edit.title') }}"
>
<span class="fa fa-wrench"></span>
</a>
</div>
<div class="profile-info__info">
<h1 class="profile-info__name">
{{ $team->name }}
</h1>
<div class="profile-info__flags">
<p class="profile-info__flag">
[{{ $team->short_name }}]
</p>
</div>
@endif
</div>
<div class="profile-info__details">
<div class="profile-info__avatar">
@include('objects._flag_team', ['modifiers' => 'full', 'team' => $team])
</div>
<div class="profile-info__info">
<h1 class="profile-info__name">
{{ $team->name }}
</h1>
<div class="profile-info__flags">
<p class="profile-info__flag">
[{{ $team->short_name }}]
</p>
</div>
</div>
</div>
<div class="user-profile-pages user-profile-pages--no-tabs">
<div class="page-extra u-fancy-scrollbar">
<div class="team-summary">
<div class="team-summary__sidebar">
<h2 class="title title--page-extra-small title--page-extra-small-top">
{{ osu_trans('teams.show.sections.info') }}
</h2>
<div class="team-info-entries">
</div>
<div class="user-profile-pages user-profile-pages--no-tabs">
<div class="page-extra u-fancy-scrollbar">
<div class="team-summary">
<div class="team-summary__sidebar">
<h2 class="title title--page-extra-small title--page-extra-small-top">
{{ osu_trans('teams.show.sections.info') }}
</h2>
<div class="team-info-entries">
<div class="team-info-entry">
<div class="team-info-entry__title">{{ osu_trans('teams.show.info.created') }}</div>
<div class="team-info-entry__value">
{{ i18n_date($team->created_at, pattern: 'year_month') }}
</div>
</div>
@if (present($team->url))
<div class="team-info-entry">
<div class="team-info-entry__title">{{ osu_trans('teams.show.info.created') }}</div>
<div class="team-info-entry__title">{{ osu_trans('teams.show.info.website') }}</div>
<div class="team-info-entry__value">
{{ i18n_date($team->created_at, pattern: 'year_month') }}
<span class="u-ellipsis-overflow">
<a href="{{ $team->url }}">{{ $team->url }}</a>
</span>
</div>
</div>
@if (present($team->url))
<div class="team-info-entry">
<div class="team-info-entry__title">{{ osu_trans('teams.show.info.website') }}</div>
<div class="team-info-entry__value">
<span class="u-ellipsis-overflow">
<a href="{{ $team->url }}">{{ $team->url }}</a>
</span>
</div>
</div>
@endif
@endif
</div>
<h2 class="title title--page-extra-small title--page-extra-small-top">
{{ osu_trans('teams.show.sections.members') }}
</h2>
<div class="team-summary__members">
<div class="team-members team-members--owner">
<div class="team-members__meta">
{{ osu_trans('teams.show.members.owner') }}
</div>
<div
class="js-react--user-card u-contents"
data-user="{{ json_encode($teamMembers['leader'][0]) }}"
></div>
</div>
<h2 class="title title--page-extra-small title--page-extra-small-top">
{{ osu_trans('teams.show.sections.members') }}
</h2>
<div class="team-summary__members">
<div class="team-members team-members--owner">
<div class="team-members__meta">
{{ osu_trans('teams.show.members.owner') }}
</div>

<div class="team-members">
<div class="team-members__meta">
<span>
{{ osu_trans('teams.show.members.members') }}
</span>
<span>
{{ i18n_number_format(count($teamMembers['member'])) }}
</span>
</div>
@foreach ($teamMembers['member'] as $memberJson)
<div
class="js-react--user-card u-contents"
data-user="{{ json_encode($teamMembers['leader'][0]) }}"
data-user="{{ json_encode($memberJson) }}"
></div>
</div>

<div class="team-members">
<div class="team-members__meta">
<span>
{{ osu_trans('teams.show.members.members') }}
</span>
<span>
{{ i18n_number_format(count($teamMembers['member'])) }}
</span>
</div>
@foreach ($teamMembers['member'] as $memberJson)
<div
class="js-react--user-card u-contents"
data-user="{{ json_encode($memberJson) }}"
></div>
@endforeach
</div>
@endforeach
</div>
</div>
</div>

<div class="team-summary__sidebar team-summary__sidebar--separator"></div>
<div class="team-summary__sidebar team-summary__sidebar--separator"></div>

<div>
{!! $team->descriptionHtml() !!}
</div>
<div>
{!! $team->descriptionHtml() !!}
</div>
</div>
</div>
Expand Down

0 comments on commit 10fa4a7

Please sign in to comment.