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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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'))
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user