From 9e5f0ff8546049c2ac623b37631be2f203d36206 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 6 Jun 2022 13:00:37 +0200 Subject: [PATCH] Use pronoun for other pages too, a bit more cleanup --- resources/views/macros/base.twig | 2 +- resources/views/pages/design.twig | 7 ++++-- .../views/pages/messages/conversation.twig | 24 +++++++++---------- resources/views/pages/messages/overview.twig | 2 +- resources/views/pages/news/news.twig | 2 +- resources/views/pages/questions/overview.twig | 4 ++-- src/Controllers/DesignController.php | 4 ++++ .../Controllers/MessagesControllerTest.php | 2 +- 8 files changed, 26 insertions(+), 21 deletions(-) diff --git a/resources/views/macros/base.twig b/resources/views/macros/base.twig index 3d46ff81..b6dfb19e 100644 --- a/resources/views/macros/base.twig +++ b/resources/views/macros/base.twig @@ -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 -%} diff --git a/resources/views/pages/design.twig b/resources/views/pages/design.twig index dd3b8c99..439532a2 100644 --- a/resources/views/pages/design.twig +++ b/resources/views/pages/design.twig @@ -317,8 +317,11 @@

{{ m.alert('Test content', 'info') }}

-

user(user)

-

{{ m.user(demo_user) }}
{{ m.user(demo_user_2) }}

+

user(user, opt)

+

+ {{ m.user(demo_user) }}
+ {{ m.user(demo_user_2, {'pronoun': true}) }} +

button(label, url, type, size)

diff --git a/resources/views/pages/messages/conversation.twig b/resources/views/pages/messages/conversation.twig index a0b576db..7e1bcb40 100644 --- a/resources/views/pages/messages/conversation.twig +++ b/resources/views/pages/messages/conversation.twig @@ -8,7 +8,7 @@
@@ -17,16 +17,16 @@
{% for msg in messages %} {% if msg.user_id == user.id %} -
+
-
{{ msg.text | nl2br }}
+

{{ msg.text | nl2br }}

-
+ enctype="multipart/form-data" method="post" + > {{ csrf() }} - {{ msg.created_at }} + {{ msg.created_at.format(__('Y-m-d H:i')) }} {{ f.submit(m.icon('trash'), {'btn_type': 'primary', 'size': 'sm'}) }}
@@ -34,31 +34,29 @@
{% else %} -
+
{{ msg.text | nl2br }}
- {{ msg.created_at.format(__('Y-m-d H:i')) }} + {{ msg.created_at.format(__('Y-m-d H:i')) }}
{% if msg.read == false %} - + {% endif %}
{% endif %} {% endfor %} -
{# id for scrolling to the newest messages #}
{{ csrf() }}
- + + {{ f.submit(m.icon('send-fill')) }}
diff --git a/resources/views/pages/messages/overview.twig b/resources/views/pages/messages/overview.twig index 09cfdc7b..f11c9d94 100644 --- a/resources/views/pages/messages/overview.twig +++ b/resources/views/pages/messages/overview.twig @@ -36,7 +36,7 @@ {% for c in conversations %} - {{ 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 %} {{ c.unread_messages }} diff --git a/resources/views/pages/news/news.twig b/resources/views/pages/news/news.twig index 3829b879..f604deaa 100644 --- a/resources/views/pages/news/news.twig +++ b/resources/views/pages/news/news.twig @@ -22,7 +22,7 @@ {{ m.icon('clock') }} {{ comment.created_at.format(__('Y-m-d H:i')) }}
- {{ 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') %}
diff --git a/resources/views/pages/questions/overview.twig b/resources/views/pages/questions/overview.twig index e9dcdab8..ecaf3dd3 100644 --- a/resources/views/pages/questions/overview.twig +++ b/resources/views/pages/questions/overview.twig @@ -44,7 +44,7 @@
{% if has_permission_to('question.edit') %} - {{ m.user(question.user) }} + {{ m.user(question.user, {'pronoun': true}) }}
{% endif %} @@ -78,7 +78,7 @@
{{ m.icon('clock') }} {{ question.updated_at.format(__('Y-m-d H:i')) }}
- {{ m.user(question.answerer) }} + {{ m.user(question.answerer, {'pronoun': true}) }}
diff --git a/src/Controllers/DesignController.php b/src/Controllers/DesignController.php index d0420fd3..4df6e7a2 100644 --- a/src/Controllers/DesignController.php +++ b/src/Controllers/DesignController.php @@ -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 = [ diff --git a/tests/Unit/Controllers/MessagesControllerTest.php b/tests/Unit/Controllers/MessagesControllerTest.php index 4c199723..81243b03 100644 --- a/tests/Unit/Controllers/MessagesControllerTest.php +++ b/tests/Unit/Controllers/MessagesControllerTest.php @@ -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);