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 -%} {%- if not user.state.arrived %} class="text-muted"{% endif -%}
> >
{{ _self.angel() }} {{ user.name }} {{ _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 %} and user.personalData.pronoun %}
({{ user.personalData.pronoun }}) ({{ user.personalData.pronoun }})
{% endif -%} {% endif -%}

View File

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

View File

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

View File

@ -36,7 +36,7 @@
{% for c in conversations %} {% for c in conversations %}
<tr> <tr>
<td> <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 %} {% if c.unread_messages > 0 %}
<span class="badge bg-danger">{{ c.unread_messages }}</span> <span class="badge bg-danger">{{ c.unread_messages }}</span>

View File

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

View File

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

View File

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

View File

@ -141,7 +141,7 @@ class MessagesControllerTest extends ControllerTest
$this->assertTrue($c['other_user'] instanceof User); $this->assertTrue($c['other_user'] instanceof User);
$this->assertTrue($c['latest_message'] instanceof Message); $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', $c['other_user']->name);
$this->assertEquals('b>a', $c['latest_message']->text); $this->assertEquals('b>a', $c['latest_message']->text);