rename is_important to is_highlighted (#1215)
This commit is contained in:
parent
383f8ebde5
commit
8ebaffd71a
|
@ -20,7 +20,7 @@ class NewsFactory extends Factory
|
||||||
'text' => $this->faker->realText(),
|
'text' => $this->faker->realText(),
|
||||||
'is_meeting' => $this->faker->boolean(),
|
'is_meeting' => $this->faker->boolean(),
|
||||||
'is_pinned' => $this->faker->boolean(.1),
|
'is_pinned' => $this->faker->boolean(.1),
|
||||||
'is_important' => $this->faker->boolean(.1),
|
'is_highlighted' => $this->faker->boolean(.1),
|
||||||
'user_id' => User::factory(),
|
'user_id' => User::factory(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Engelsystem\Migrations;
|
||||||
|
|
||||||
|
use Engelsystem\Database\Migration\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
|
class NewsRenameImportantToHighlight extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migration
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->schema->table('news', function (Blueprint $table): void {
|
||||||
|
$table->renameColumn('is_important', 'is_highlighted');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->schema->getConnection()
|
||||||
|
->table('privileges')
|
||||||
|
->where('name', 'news.important')
|
||||||
|
->update(['name' => 'news.highlight', 'description' => 'Highlight News']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migration
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$this->schema->table('news', function (Blueprint $table): void {
|
||||||
|
$table->renameColumn('is_highlighted', 'is_important');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->schema->getConnection()
|
||||||
|
->table('privileges')
|
||||||
|
->where('name', 'news.highlight')
|
||||||
|
->update(['name' => 'news.important', 'description' => 'Make News Important']);
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,14 +57,14 @@ function public_dashboard_controller()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$important_news = News::whereIsImportant(true)
|
$highlighted_news = News::whereIsHighlighted(true)
|
||||||
->orderBy('updated_at')
|
->orderBy('updated_at')
|
||||||
->limit(1)
|
->limit(1)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
__('Public Dashboard'),
|
__('Public Dashboard'),
|
||||||
public_dashboard_view($stats, $free_shifts, $important_news),
|
public_dashboard_view($stats, $free_shifts, $highlighted_news),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,15 @@ use Illuminate\Support\Collection;
|
||||||
*
|
*
|
||||||
* @param array $stats
|
* @param array $stats
|
||||||
* @param array[] $free_shifts
|
* @param array[] $free_shifts
|
||||||
* @param News[]|Collection $important_news
|
* @param News[]|Collection $highlighted_news
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function public_dashboard_view($stats, $free_shifts, $important_news)
|
function public_dashboard_view($stats, $free_shifts, $highlighted_news)
|
||||||
{
|
{
|
||||||
$needed_angels = '';
|
$needed_angels = '';
|
||||||
$news = '';
|
$news = '';
|
||||||
if ($important_news->isNotEmpty()) {
|
if ($highlighted_news->isNotEmpty()) {
|
||||||
$first_news = $important_news->first();
|
$first_news = $highlighted_news->first();
|
||||||
$news = div('alert alert-warning text-center', [
|
$news = div('alert alert-warning text-center', [
|
||||||
'<a href="' . url('/news/' . $first_news->id) . '"><strong>' . $first_news->title . '</strong></a>',
|
'<a href="' . url('/news/' . $first_news->id) . '"><strong>' . $first_news->title . '</strong></a>',
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -2050,8 +2050,8 @@ msgstr "+"
|
||||||
msgid "news.is_meeting"
|
msgid "news.is_meeting"
|
||||||
msgstr "[Treffen]"
|
msgstr "[Treffen]"
|
||||||
|
|
||||||
msgid "news.edit.is_important"
|
msgid "news.edit.is_highlighted"
|
||||||
msgstr "Wichtig"
|
msgstr "Hervorgehoben"
|
||||||
|
|
||||||
msgid "news.read_more"
|
msgid "news.read_more"
|
||||||
msgstr "Weiterlesen"
|
msgstr "Weiterlesen"
|
||||||
|
|
|
@ -193,8 +193,8 @@ msgstr "Subject"
|
||||||
msgid "news.edit.is_meeting"
|
msgid "news.edit.is_meeting"
|
||||||
msgstr "Meeting"
|
msgstr "Meeting"
|
||||||
|
|
||||||
msgid "news.edit.is_important"
|
msgid "news.edit.is_highlighted"
|
||||||
msgstr "Important"
|
msgstr "Highlighted"
|
||||||
|
|
||||||
msgid "news.edit.is_pinned"
|
msgid "news.edit.is_pinned"
|
||||||
msgstr "Pin to top"
|
msgstr "Pin to top"
|
||||||
|
|
|
@ -49,9 +49,9 @@
|
||||||
{{ f.checkbox('is_pinned', __('news.edit.is_pinned'), {
|
{{ f.checkbox('is_pinned', __('news.edit.is_pinned'), {
|
||||||
'checked': is_pinned,
|
'checked': is_pinned,
|
||||||
}) }}
|
}) }}
|
||||||
{% if has_permission_to('news.important') %}
|
{% if has_permission_to('news.highlight') %}
|
||||||
{{ f.checkbox('is_important', __('news.edit.is_important'), {
|
{{ f.checkbox('is_highlighted', __('news.edit.is_highlighted'), {
|
||||||
'checked': is_important,
|
'checked': is_highlighted,
|
||||||
}) }}
|
}) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h2>{{ __('form.preview') }}</h2>
|
<h2>{{ __('form.preview') }}</h2>
|
||||||
|
|
||||||
<div class="card {% if news.is_important %}bg-warning{% elseif news.is_meeting %}bg-info{% elseif theme.type =='light' %}bg-light{% else %}bg-secondary{% endif %} mb-4">
|
<div class="card {% if news.is_highlighted %}bg-warning{% elseif news.is_meeting %}bg-info{% elseif theme.type =='light' %}bg-light{% else %}bg-secondary{% endif %} mb-4">
|
||||||
<div class="card-header {% if news.is_meeting and theme.type == 'dark' %}text-white{% endif %}">
|
<div class="card-header {% if news.is_meeting and theme.type == 'dark' %}text-white{% endif %}">
|
||||||
{% if news.is_meeting %}{{ __('news.is_meeting') }}{% endif %}
|
{% if news.is_meeting %}{{ __('news.is_meeting') }}{% endif %}
|
||||||
{{ news.title }}
|
{{ news.title }}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro news(news, show_comments_link, is_overview) %}
|
{% macro news(news, show_comments_link, is_overview) %}
|
||||||
<div class="card {% if news.is_important %}bg-warning{% elseif news.is_meeting %}bg-info{% elseif theme.type =='light' %}bg-light{% else %}bg-dark{% endif %} mb-4">
|
<div class="card {% if news.is_highlighted %}bg-warning{% elseif news.is_meeting %}bg-info{% elseif theme.type =='light' %}bg-light{% else %}bg-dark{% endif %} mb-4">
|
||||||
{% if is_overview|default(false) %}
|
{% if is_overview|default(false) %}
|
||||||
<div class="card-header {% if news.is_meeting and theme.type == 'dark' %}text-white{% endif %}">
|
<div class="card-header {% if news.is_meeting and theme.type == 'dark' %}text-white{% endif %}">
|
||||||
<a href="{{ url('news/' ~ news.id) }}" class="text-inherit">
|
<a href="{{ url('news/' ~ news.id) }}" class="text-inherit">
|
||||||
|
|
|
@ -50,7 +50,7 @@ class NewsController extends BaseController
|
||||||
'news' => $news,
|
'news' => $news,
|
||||||
'is_meeting' => $news ? $news->is_meeting : $isMeetingDefault,
|
'is_meeting' => $news ? $news->is_meeting : $isMeetingDefault,
|
||||||
'is_pinned' => $news ? $news->is_pinned : false,
|
'is_pinned' => $news ? $news->is_pinned : false,
|
||||||
'is_important' => $news ? $news->is_important : false,
|
'is_highlighted' => $news ? $news->is_highlighted : false,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class NewsController extends BaseController
|
||||||
'text' => 'required',
|
'text' => 'required',
|
||||||
'is_meeting' => 'optional|checked',
|
'is_meeting' => 'optional|checked',
|
||||||
'is_pinned' => 'optional|checked',
|
'is_pinned' => 'optional|checked',
|
||||||
'is_important' => 'optional|checked',
|
'is_highlighted' => 'optional|checked',
|
||||||
'delete' => 'optional|checked',
|
'delete' => 'optional|checked',
|
||||||
'preview' => 'optional|checked',
|
'preview' => 'optional|checked',
|
||||||
]);
|
]);
|
||||||
|
@ -96,8 +96,8 @@ class NewsController extends BaseController
|
||||||
$news->is_meeting = !is_null($data['is_meeting']);
|
$news->is_meeting = !is_null($data['is_meeting']);
|
||||||
$news->is_pinned = !is_null($data['is_pinned']);
|
$news->is_pinned = !is_null($data['is_pinned']);
|
||||||
|
|
||||||
if ($this->auth->can('news.important')) {
|
if ($this->auth->can('news.highlight')) {
|
||||||
$news->is_important = !is_null($data['is_important']);
|
$news->is_highlighted = !is_null($data['is_highlighted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($data['preview'])) {
|
if (!is_null($data['preview'])) {
|
||||||
|
@ -119,7 +119,7 @@ class NewsController extends BaseController
|
||||||
'Updated {pinned}{type} "{news}": {text}',
|
'Updated {pinned}{type} "{news}": {text}',
|
||||||
[
|
[
|
||||||
'pinned' => $news->is_pinned ? 'pinned ' : '',
|
'pinned' => $news->is_pinned ? 'pinned ' : '',
|
||||||
'important' => $news->is_important ? 'important ' : '',
|
'highlighted' => $news->is_highlighted ? 'highlighted ' : '',
|
||||||
'type' => $news->is_meeting ? 'meeting' : 'news',
|
'type' => $news->is_meeting ? 'meeting' : 'news',
|
||||||
'news' => $news->title,
|
'news' => $news->title,
|
||||||
'text' => $news->text,
|
'text' => $news->text,
|
||||||
|
|
|
@ -138,7 +138,7 @@ class NewsController extends BaseController
|
||||||
->with('user')
|
->with('user')
|
||||||
->withCount('comments')
|
->withCount('comments')
|
||||||
->orderByDesc('is_pinned')
|
->orderByDesc('is_pinned')
|
||||||
->orderByDesc('is_important')
|
->orderByDesc('is_highlighted')
|
||||||
->orderByDesc('updated_at')
|
->orderByDesc('updated_at')
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->limit($perPage)
|
->limit($perPage)
|
||||||
|
|
|
@ -16,9 +16,9 @@ use Illuminate\Support\Str;
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $text
|
* @property string $text
|
||||||
|
* @property bool $is_highlighted
|
||||||
* @property bool $is_meeting
|
* @property bool $is_meeting
|
||||||
* @property bool $is_pinned
|
* @property bool $is_pinned
|
||||||
* @property bool $is_important
|
|
||||||
* @property Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,7 @@ use Illuminate\Support\Str;
|
||||||
* @method static QueryBuilder|News[] whereText($value)
|
* @method static QueryBuilder|News[] whereText($value)
|
||||||
* @method static QueryBuilder|News[] whereIsMeeting($value)
|
* @method static QueryBuilder|News[] whereIsMeeting($value)
|
||||||
* @method static QueryBuilder|News[] whereIsPinned($value)
|
* @method static QueryBuilder|News[] whereIsPinned($value)
|
||||||
* @method static QueryBuilder|News[] whereIsImportant($value)
|
* @method static QueryBuilder|News[] whereIsHighlighted($value)
|
||||||
* @method static QueryBuilder|News[] whereCreatedAt($value)
|
* @method static QueryBuilder|News[] whereCreatedAt($value)
|
||||||
* @method static QueryBuilder|News[] whereUpdatedAt($value)
|
* @method static QueryBuilder|News[] whereUpdatedAt($value)
|
||||||
*/
|
*/
|
||||||
|
@ -47,14 +47,14 @@ class News extends BaseModel
|
||||||
'user_id' => 'integer',
|
'user_id' => 'integer',
|
||||||
'is_meeting' => 'boolean',
|
'is_meeting' => 'boolean',
|
||||||
'is_pinned' => 'boolean',
|
'is_pinned' => 'boolean',
|
||||||
'is_important' => 'boolean',
|
'is_highlighted' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<string, bool> Default attributes */
|
/** @var array<string, bool> Default attributes */
|
||||||
protected $attributes = [ // phpcs:ignore
|
protected $attributes = [ // phpcs:ignore
|
||||||
'is_meeting' => false,
|
'is_meeting' => false,
|
||||||
'is_pinned' => false,
|
'is_pinned' => false,
|
||||||
'is_important' => false,
|
'is_highlighted' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<string> */
|
/** @var array<string> */
|
||||||
|
@ -63,7 +63,7 @@ class News extends BaseModel
|
||||||
'text',
|
'text',
|
||||||
'is_meeting',
|
'is_meeting',
|
||||||
'is_pinned',
|
'is_pinned',
|
||||||
'is_important',
|
'is_highlighted',
|
||||||
'user_id',
|
'user_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ class NewsControllerTest extends ControllerTest
|
||||||
'text' => 'New text',
|
'text' => 'New text',
|
||||||
'is_meeting' => '1',
|
'is_meeting' => '1',
|
||||||
'is_pinned' => '1',
|
'is_pinned' => '1',
|
||||||
'is_important' => '1',
|
'is_highlighted' => '1',
|
||||||
'preview' => '1',
|
'preview' => '1',
|
||||||
]);
|
]);
|
||||||
$this->response->expects($this->once())
|
$this->response->expects($this->once())
|
||||||
|
@ -175,7 +175,7 @@ class NewsControllerTest extends ControllerTest
|
||||||
// Contains new text
|
// Contains new text
|
||||||
$this->assertTrue($news->is_meeting);
|
$this->assertTrue($news->is_meeting);
|
||||||
$this->assertTrue($news->is_pinned);
|
$this->assertTrue($news->is_pinned);
|
||||||
$this->assertTrue($news->is_important);
|
$this->assertTrue($news->is_highlighted);
|
||||||
$this->assertEquals('New title', $news->title);
|
$this->assertEquals('New title', $news->title);
|
||||||
$this->assertEquals('New text', $news->text);
|
$this->assertEquals('New text', $news->text);
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class NewsControllerTest extends ControllerTest
|
||||||
});
|
});
|
||||||
$this->auth->expects($this->atLeastOnce())
|
$this->auth->expects($this->atLeastOnce())
|
||||||
->method('can')
|
->method('can')
|
||||||
->with('news.important')
|
->with('news.highlight')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
/** @var NewsController $controller */
|
/** @var NewsController $controller */
|
||||||
|
@ -198,7 +198,7 @@ class NewsControllerTest extends ControllerTest
|
||||||
$this->assertEquals('**foo**', $news->text);
|
$this->assertEquals('**foo**', $news->text);
|
||||||
$this->assertFalse($news->is_meeting);
|
$this->assertFalse($news->is_meeting);
|
||||||
$this->assertFalse($news->is_pinned);
|
$this->assertFalse($news->is_pinned);
|
||||||
$this->assertFalse($news->is_important);
|
$this->assertFalse($news->is_highlighted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,7 @@ class NewsControllerTest extends ControllerTest
|
||||||
'text' => 'baz',
|
'text' => 'baz',
|
||||||
'is_meeting' => true,
|
'is_meeting' => true,
|
||||||
'is_pinned' => true,
|
'is_pinned' => true,
|
||||||
'is_important' => true,
|
'is_highlighted' => true,
|
||||||
'user_id' => 1,
|
'user_id' => 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue