fix weekly view day format (#2893)

* make duplicate project action available on details page
* move "weekly hours" form to main menu
* changed label of week chooser
* hide quick entries menu for punch mode users
This commit is contained in:
Kevin Papst
2021-11-01 20:23:17 +01:00
committed by GitHub
parent 1d32e4ecee
commit 36c08b0dea
14 changed files with 39 additions and 27 deletions

View File

@@ -25,7 +25,7 @@ use Symfony\Component\Routing\Annotation\Route;
* Controller used to enter times in weekly form.
*
* @Route(path="/quick_entry")
* @Security("is_granted('view_own_timesheet')")
* @Security("is_granted('edit_own_timesheet')")
*/
class QuickEntryController extends AbstractController
{
@@ -42,7 +42,6 @@ class QuickEntryController extends AbstractController
/**
* @Route(path="/{begin}", name="quick_entry", methods={"GET", "POST"})
* @Security("is_granted('edit_own_timesheet')")
*/
public function quickEntry(Request $request, ?string $begin = null)
{

View File

@@ -68,13 +68,13 @@ class ProjectSubscriber extends AbstractActionsSubscriber
'class' => 'modal-ajax-form'
]);
}
}
if ($this->isGranted('edit', $project)) {
$event->addAction(
'copy',
['url' => $this->path('admin_project_duplicate', ['id' => $project->getId()])]
);
}
if ($this->isGranted('edit', $project) && $this->isGranted('create_project')) {
$event->addAction(
'copy',
['url' => $this->path('admin_project_duplicate', ['id' => $project->getId()])]
);
}
if (($event->isIndexView() || $event->isView('customer_details')) && $this->isGranted('delete', $project)) {

View File

@@ -20,10 +20,6 @@ class QuickEntrySubscriber extends AbstractActionsSubscriber
public function onActions(PageActionsEvent $event): void
{
if ($this->isGranted('view_own_timesheet')) {
$event->addBack($this->path('timesheet'));
}
$event->addHelp($this->documentationLink('weekly-times.html'));
}
}

View File

@@ -35,7 +35,6 @@ class TimesheetsSubscriber extends AbstractActionsSubscriber
if ($this->isGranted('create_own_timesheet')) {
$event->addCreate($this->path('timesheet_create'));
$event->addAction('quick_entry', ['url' => $this->path('quick_entry'), 'class' => 'create-ts', 'icon' => 'weekly-times']);
}
$event->addHelp($this->documentationLink('timesheet.html'));

View File

@@ -10,6 +10,7 @@
namespace App\EventSubscriber;
use App\Event\ConfigureMainMenuEvent;
use App\Timesheet\TrackingModeService;
use App\Twig\IconExtension;
use App\Utils\MenuItemModel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -21,10 +22,12 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class MenuSubscriber implements EventSubscriberInterface
{
private $security;
private $trackingModeService;
public function __construct(AuthorizationCheckerInterface $security)
public function __construct(AuthorizationCheckerInterface $security, TrackingModeService $trackingModeService)
{
$this->security = $security;
$this->trackingModeService = $trackingModeService;
}
public static function getSubscribedEvents(): array
@@ -49,9 +52,18 @@ final class MenuSubscriber implements EventSubscriberInterface
if ($auth->isGranted('view_own_timesheet')) {
$timesheets = new MenuItemModel('timesheet', 'menu.timesheet', 'timesheet', [], $icons->icon('timesheet'));
$timesheets->setChildRoutes(['timesheet_export', 'timesheet_edit', 'timesheet_create', 'timesheet_multi_update', 'quick_entry']);
$timesheets->setChildRoutes(['timesheet_export', 'timesheet_edit', 'timesheet_create', 'timesheet_multi_update']);
$menu->addItem($timesheets);
if ($auth->isGranted('edit_own_timesheet')) {
$mode = $this->trackingModeService->getActiveMode();
if ($mode->canEditDuration() || $mode->canEditEnd()) {
$menu->addItem(
new MenuItemModel('quick_entry', 'quick_entry.title', 'quick_entry', [], $icons->icon('weekly-times'))
);
}
}
$menu->addItem(
new MenuItemModel('calendar', 'calendar.title', 'calendar', [], $icons->icon('calendar'))
);

View File

@@ -56,6 +56,7 @@ final class LocaleFormatExtensions extends AbstractExtension
new TwigFilter('date_time', [$this, 'dateTime']),
new TwigFilter('date_full', [$this, 'dateTimeFull']),
new TwigFilter('date_format', [$this, 'dateFormat']),
new TwigFilter('date_weekday', [$this, 'dateWeekday']),
new TwigFilter('time', [$this, 'time']),
new TwigFilter('hour24', [$this, 'hour24']),
new TwigFilter('duration', [$this, 'duration']),
@@ -188,6 +189,11 @@ final class LocaleFormatExtensions extends AbstractExtension
return $this->getFormatter()->dateFormat($date, $format);
}
public function dateWeekday(DateTime $date): string
{
return $this->dayName($date, true) . ', ' . $this->getFormatter()->dateFormat($date, 'd');
}
/**
* @param DateTime|string $date
* @return string

View File

@@ -156,7 +156,13 @@
<i class="{{ 'left'|icon }}"></i>
</a>
<a class="btn btn-default" href="#" onclick="return false;">
<span id="{{ form.vars.id }}_week_number">{{ 'stats.workingTimeWeek'|trans({'%week%': week|date_format('W')}) }}</span>
<span id="{{ form.vars.id }}_week_number" data-toggle="tooltip" data-placement="top" title="{{ 'stats.workingTimeWeek'|trans({'%week%': week|date_format('W')}) }}">
{{ week|month_name(true) }}
{% if week|date_format('m') != nextWeek|date_format('m') %}
&ndash;
{{ nextWeek|month_name(true) }}
{% endif %}
</span>
</a>
<a class="btn btn-default btn-right" href="#" onclick="jQuery('#{{ form.vars.id }}').val('{{ nextWeek|report_date }}').change()" data-toggle="tooltip" data-placement="top" title="{{ 'stats.workingTimeWeek'|trans({'%week%': nextWeek|date_format('W')}) }}">
<i class="{{ 'right'|icon }}"></i>

View File

@@ -29,8 +29,7 @@
<th>{{ 'label.activity'|trans }}</th>
{% for id, week in days %}
<th class="text-center{% if week.day is weekend %} weekend{% endif %}{% if week.day is today %} today{% endif %}">
{{ week.day|day_name(true) }}<br>
{{ week.day|format_date('short') }}
{{ week.day|date_weekday }}
</th>
{% endfor %}
<th class="summary">{{ 'label.duration'|trans }}</th>

View File

@@ -31,8 +31,7 @@
<th>&nbsp;</th>
{% for day in days.dateTimes %}
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
{{ day|day_name(true) }}<br>
{{ day|format_date('short') }}
{{ day|date_weekday }}
</th>
{% set columns = columns + 1 %}
{% set totals = totals|merge({(day|report_date): 0}) %}

View File

@@ -29,8 +29,7 @@
<th>&nbsp;</th>
{% for day in stats.0.getDateTimes() %}
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
{{ day|day_name(true) }}<br>
{{ day|format_date('short') }}
{{ day|date_weekday }}
</th>
{% set totals = totals|merge({(day|report_date): 0}) %}
{% endfor %}

View File

@@ -52,7 +52,6 @@ class QuickEntryControllerTest extends ControllerBaseTest
self::assertCount(10, $columns);
$this->assertPageActions($client, [
'back' => $this->createUrl('/timesheet/'),
'help' => 'https://www.kimai.org/documentation/weekly-times.html'
]);
}
@@ -95,7 +94,6 @@ class QuickEntryControllerTest extends ControllerBaseTest
self::assertCount(10, $columns);
$this->assertPageActions($client, [
'back' => $this->createUrl('/timesheet/'),
'help' => 'https://www.kimai.org/documentation/weekly-times.html'
]);
}

View File

@@ -44,7 +44,6 @@ class TimesheetControllerTest extends ControllerBaseTest
'visibility' => '#',
'download toolbar-action modal-ajax-form' => $this->createUrl('/timesheet/export/'),
'create modal-ajax-form' => $this->createUrl('/timesheet/create'),
'quick_entry create-ts' => $this->createUrl('/quick_entry'),
'help' => 'https://www.kimai.org/documentation/timesheet.html'
]);
}

View File

@@ -52,7 +52,7 @@ class LocaleFormatExtensionsTest extends TestCase
public function testGetFilters()
{
$filters = [
'month_name', 'day_name', 'date_short', 'date_time', 'date_full', 'date_format', 'time', 'hour24',
'month_name', 'day_name', 'date_short', 'date_time', 'date_full', 'date_format', 'date_weekday', 'time', 'hour24',
'duration', 'chart_duration', 'duration_decimal', 'money', 'currency', 'country', 'language', 'amount'
];
$i = 0;

View File

@@ -1265,7 +1265,7 @@
-->
<trans-unit id="quick_entry.title">
<source>quick_entry.title</source>
<target>Wöchentliche Arbeitsstunden</target>
<target>Wochen-Arbeitsstunden</target>
</trans-unit>
</body>
</file>