News: Preselect "Is Meeting" when adding from Meeting overview
This commit is contained in:
parent
21ee2bd0d7
commit
b814cf51e4
|
@ -41,7 +41,7 @@
|
|||
) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ f.checkbox('is_meeting', __('news.edit.is_meeting'), news ? news.is_meeting : false) }}
|
||||
{{ f.checkbox('is_meeting', __('news.edit.is_meeting'), is_meeting) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
{% extends 'layouts/app.twig' %}
|
||||
{% import 'macros/base.twig' as m %}
|
||||
|
||||
{% block title %}{{ not only_meetings|default(false) ? __('news.title') : __('news.title.meetings') }}{% endblock %}
|
||||
{% set only_meetings = only_meetings|default(false) %}
|
||||
{% block title %}{{ not only_meetings ? __('news.title') : __('news.title.meetings') }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>
|
||||
{{ block('title') }}
|
||||
{%- if has_permission_to('admin_news') and is_overview|default(false) -%}
|
||||
{{ m.button(__('news.add'), url('admin/news')) }}
|
||||
{{ m.button(__('news.add'), url('admin/news', only_meetings ? {'meeting': 1} : {})) }}
|
||||
{%- endif %}
|
||||
</h1>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ class NewsController extends BaseController
|
|||
{
|
||||
$id = $request->getAttribute('id');
|
||||
$news = $this->news->find($id);
|
||||
$isMeeting = $request->get('meeting', false);
|
||||
|
||||
if (
|
||||
$news
|
||||
|
@ -75,7 +76,7 @@ class NewsController extends BaseController
|
|||
|
||||
return $this->response->withView(
|
||||
'pages/news/edit.twig',
|
||||
['news' => $news] + $this->getNotifications()
|
||||
['news' => $news, 'is_meeting' => $news ? $news->is_meeting : $isMeeting] + $this->getNotifications(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,42 @@ class NewsControllerTest extends TestCase
|
|||
$controller->edit($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Engelsystem\Controllers\Admin\NewsController::edit
|
||||
*/
|
||||
public function testEditIsMeeting()
|
||||
{
|
||||
$isMeeting = false;
|
||||
$this->response->expects($this->exactly(3))
|
||||
->method('withView')
|
||||
->willReturnCallback(
|
||||
function ($view, $data) use (&$isMeeting) {
|
||||
$this->assertEquals($isMeeting, $data['is_meeting']);
|
||||
$isMeeting = !$isMeeting;
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
);
|
||||
$this->auth->expects($this->once())
|
||||
->method('can')
|
||||
->with('admin_news_html')
|
||||
->willReturn(true);
|
||||
|
||||
/** @var NewsController $controller */
|
||||
$controller = $this->app->make(NewsController::class);
|
||||
|
||||
// Is no meeting
|
||||
$controller->edit($this->request);
|
||||
|
||||
// Is meeting
|
||||
$this->request->query->set('meeting', 1);
|
||||
$controller->edit($this->request);
|
||||
|
||||
// Should stay no meeting
|
||||
$this->request->attributes->set('id', 1);
|
||||
$controller->edit($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Engelsystem\Controllers\Admin\NewsController::save
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue