Use pronoun for other pages too, a bit more cleanup

This commit is contained in:
Igor Scheller 2022-06-06 13:00:37 +02:00
parent 7acd34ba74
commit 9e5f0ff854
8 changed files with 26 additions and 21 deletions

View File

@ -21,7 +21,7 @@
{%- if not user.state.arrived %} class="text-muted"{% endif -%}
>
{{ _self.angel() }} {{ user.name }}
{%- if opt.show_pronoun_if_configured|default(false) and config('enable_pronoun')
{%- if opt.pronoun|default(false) and config('enable_pronoun')
and user.personalData.pronoun %}
({{ user.personalData.pronoun }})
{% endif -%}

View File

@ -317,8 +317,11 @@
<p>{{ m.alert('Test content', 'info') }}</p>
</div>
<div class="col-md-3">
<h4><code>user(user)</code></h4>
<p>{{ m.user(demo_user) }}<br>{{ m.user(demo_user_2) }}</p>
<h4><code>user(user, opt)</code></h4>
<p>
{{ m.user(demo_user) }}<br>
{{ m.user(demo_user_2, {'pronoun': true}) }}
</p>
</div>
<div class="col-md-3">
<h4><code>button(label, url, type, size)</code></h4>

View File

@ -8,7 +8,7 @@
<div class="container">
<div class="page-header">
<h1>
{{ __('message.title') }}: {{ m.user(other_user, {'show_pronoun_if_configured': true}) }}
{{ __('message.title') }}: {{ m.user(other_user, {'pronoun': true}) }}
</h1>
</div>
@ -17,16 +17,16 @@
<div class="row conversation">
{% for msg in messages %}
{% if msg.user_id == user.id %}
<div class="col-12">
<div class="col-12"{% if loop.last %} id="newest"{% endif %}>
<div class="d-flex justify-content-end">
<div class="message alert alert-primary">
<div>{{ msg.text | nl2br }}</div>
<p>{{ msg.text | nl2br }}</p>
<div class="text-end">
<form action="{{ url('/messages/' ~ other_user.id ~ '/' ~ msg.id) }}"
enctype="multipart/form-data" method="post">
enctype="multipart/form-data" method="post"
>
{{ csrf() }}
<small class="opacity-75">{{ msg.created_at }}</small>
<small class="opacity-75">{{ msg.created_at.format(__('Y-m-d H:i')) }}</small>
{{ f.submit(m.icon('trash'), {'btn_type': 'primary', 'size': 'sm'}) }}
</form>
</div>
@ -34,31 +34,29 @@
</div>
</div>
{% else %}
<div class="col-12">
<div class="col-12"{% if loop.last %} id="newest"{% endif %}>
<div>
<div class="message alert alert-secondary position-relative">
<div>{{ msg.text | nl2br }}</div>
<div class="text-end">
<small
class="opacity-75">{{ msg.created_at.format(__('Y-m-d H:i')) }}</small>
<small class="opacity-75">{{ msg.created_at.format(__('Y-m-d H:i')) }}</small>
</div>
{% if msg.read == false %}
<span class="position-absolute top-0 start-100 translate-middle-x p-2
bg-danger rounded-circle"></span>
<span class="position-absolute top-0 start-100 translate-middle-x p-2 bg-danger rounded-circle"></span>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endfor %}
<div id="newest">{# id for scrolling to the newest messages #}</div>
</div>
<form action="" enctype="multipart/form-data" method="post">
{{ csrf() }}
<div class="input-group">
<textarea class="form-control" id="text" name="text" required="" rows="2"></textarea>
<label for="message" class="visually-hidden">{{ __('message.message') }}</label>
<textarea class="form-control" id="message" name="text" required="" rows="2"></textarea>
{{ f.submit(m.icon('send-fill')) }}
</div>
</form>

View File

@ -36,7 +36,7 @@
{% for c in conversations %}
<tr>
<td>
{{ m.user(c.other_user, {'show_pronoun_if_configured': true, 'url': url('messages/' ~ c.other_user.id ~ '#newest')}) }}
{{ m.user(c.other_user, {'pronoun': true, 'url': url('messages/' ~ c.other_user.id ~ '#newest')}) }}
{% if c.unread_messages > 0 %}
<span class="badge bg-danger">{{ c.unread_messages }}</span>

View File

@ -22,7 +22,7 @@
{{ m.icon('clock') }}
{{ comment.created_at.format(__('Y-m-d H:i')) }}
</div>
{{ m.user(comment.user) }}
{{ m.user(comment.user, {'pronoun': true}) }}
{% if comment.user.id == user.id or has_permission_to('admin_news') or has_permission_to('comment.delete') %}
<div class="ms-auto">

View File

@ -44,7 +44,7 @@
</div>
{% if has_permission_to('question.edit') %}
{{ m.user(question.user) }}
{{ m.user(question.user, {'pronoun': true}) }}
<div class="d-flex ms-auto">
{% endif %}
@ -78,7 +78,7 @@
<div class="me-3">
{{ m.icon('clock') }} {{ question.updated_at.format(__('Y-m-d H:i')) }}
</div>
{{ m.user(question.answerer) }}
{{ m.user(question.answerer, {'pronoun': true}) }}
</div>
</div>
</div>

View File

@ -4,6 +4,7 @@ namespace Engelsystem\Controllers;
use Engelsystem\Config\Config;
use Engelsystem\Http\Response;
use Engelsystem\Models\User\PersonalData;
use Engelsystem\Models\User\State;
use Engelsystem\Models\User\User;
@ -48,6 +49,9 @@ class DesignController extends BaseController
'user_id' => 1337,
'arrived' => false,
]));
$demoUser2->__set('personalData', (new PersonalData())->forceFill([
'pronoun' => 'it/its',
]));
$themes = $this->config->get('themes');
$data = [

View File

@ -141,7 +141,7 @@ class MessagesControllerTest extends ControllerTest
$this->assertTrue($c['other_user'] instanceof User);
$this->assertTrue($c['latest_message'] instanceof Message);
$this->assertEquals('string', gettype($c['unread_messages']));
$this->assertIsNumeric($c['unread_messages']);
$this->assertEquals('b', $c['other_user']->name);
$this->assertEquals('b>a', $c['latest_message']->text);