go back to calendar after editing and creation of time-records (#519)
This commit is contained in:
@@ -69,8 +69,8 @@ class TimesheetEntity
|
||||
|
||||
if (null === $entry->getEnd()) {
|
||||
// TODO move these colors to the controller
|
||||
$this->borderColor = '#f39c12';
|
||||
$this->backgroundColor = '#f39c12';
|
||||
$this->borderColor = '367fa9'; //'#f39c12';
|
||||
$this->backgroundColor = '#3c8dbc'; //'#f39c12';
|
||||
} else {
|
||||
$this->end = $entry->getEnd();
|
||||
}
|
||||
|
||||
@@ -164,9 +164,10 @@ class TimesheetController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
protected function getCreateForm(Timesheet $entry)
|
||||
protected function getCreateForm(Timesheet $entry, string $redirectRoute)
|
||||
{
|
||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||
'action' => $this->generateUrl('admin_timesheet_create'),
|
||||
@@ -178,14 +179,15 @@ class TimesheetController extends AbstractController
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param int $page
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
protected function getEditForm(Timesheet $entry, $page)
|
||||
protected function getEditForm(Timesheet $entry, $page, string $redirectRoute)
|
||||
{
|
||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||
'action' => $this->generateUrl('admin_timesheet_edit', [
|
||||
'id' => $entry->getId(),
|
||||
'page' => $page
|
||||
'page' => $page,
|
||||
]),
|
||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||
'include_user' => true,
|
||||
|
||||
@@ -79,14 +79,9 @@ class CalendarController extends AbstractController
|
||||
->setUser($this->getUser())
|
||||
->setState(TimesheetQuery::STATE_ALL)
|
||||
->setResultType(TimesheetQuery::RESULT_TYPE_QUERYBUILDER)
|
||||
->setEnd($end)
|
||||
;
|
||||
|
||||
// running entries should only occur for the current month, but they won't
|
||||
// be found if we add the end to the query
|
||||
if ((new \DateTime())->getTimestamp() > $end->getTimestamp()) {
|
||||
$query->setEnd($end);
|
||||
}
|
||||
|
||||
$repository = $this->getDoctrine()->getRepository(Timesheet::class);
|
||||
|
||||
/* @var $entries Timesheet[] */
|
||||
|
||||
@@ -190,11 +190,15 @@ class TimesheetController extends AbstractController
|
||||
*/
|
||||
public function editAction(Timesheet $entry, Request $request)
|
||||
{
|
||||
$route = 'timesheet';
|
||||
|
||||
if (null !== $request->get('page')) {
|
||||
return $this->edit($entry, $request, 'timesheet_paginated', 'timesheet/edit.html.twig');
|
||||
$route = 'timesheet_paginated';
|
||||
} elseif ('calendar' === $request->get('origin')) {
|
||||
$route = 'calendar';
|
||||
}
|
||||
|
||||
return $this->edit($entry, $request, 'timesheet', 'timesheet/edit.html.twig');
|
||||
return $this->edit($entry, $request, $route, 'timesheet/edit.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +210,12 @@ class TimesheetController extends AbstractController
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
{
|
||||
return $this->create($request, 'timesheet', 'timesheet/edit.html.twig');
|
||||
$route = 'timesheet';
|
||||
if ('calendar' === $request->get('origin')) {
|
||||
$route = 'calendar';
|
||||
}
|
||||
|
||||
return $this->create($request, $route, 'timesheet/edit.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,12 +243,13 @@ class TimesheetController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
protected function getCreateForm(Timesheet $entry)
|
||||
protected function getCreateForm(Timesheet $entry, string $redirectRoute)
|
||||
{
|
||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||
'action' => $this->generateUrl('timesheet_create'),
|
||||
'action' => $this->generateUrl('timesheet_create', ['origin' => $redirectRoute]),
|
||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||
]);
|
||||
}
|
||||
@@ -247,14 +257,16 @@ class TimesheetController extends AbstractController
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param int $page
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
protected function getEditForm(Timesheet $entry, $page)
|
||||
protected function getEditForm(Timesheet $entry, $page, string $redirectRoute)
|
||||
{
|
||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||
'action' => $this->generateUrl('timesheet_edit', [
|
||||
'id' => $entry->getId(),
|
||||
'page' => $page
|
||||
'page' => $page,
|
||||
'origin' => $redirectRoute,
|
||||
]),
|
||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||
]);
|
||||
|
||||
@@ -77,7 +77,7 @@ trait TimesheetControllerTrait
|
||||
*/
|
||||
protected function edit(Timesheet $entry, Request $request, $redirectRoute, $renderTemplate)
|
||||
{
|
||||
$editForm = $this->getEditForm($entry, $request->get('page'));
|
||||
$editForm = $this->getEditForm($entry, $request->get('page'), $request->get('origin', 'timesheet'));
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
@@ -154,7 +154,7 @@ trait TimesheetControllerTrait
|
||||
}
|
||||
}
|
||||
|
||||
$createForm = $this->getCreateForm($entry);
|
||||
$createForm = $this->getCreateForm($entry, $redirectRoute);
|
||||
$createForm->handleRequest($request);
|
||||
|
||||
if ($createForm->isSubmitted() && $createForm->isValid()) {
|
||||
@@ -203,16 +203,18 @@ trait TimesheetControllerTrait
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
abstract protected function getCreateForm(Timesheet $entry);
|
||||
abstract protected function getCreateForm(Timesheet $entry, string $redirectRoute);
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param int $page
|
||||
* @param string $redirectRoute
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
abstract protected function getEditForm(Timesheet $entry, $page);
|
||||
abstract protected function getEditForm(Timesheet $entry, $page, string $redirectRoute);
|
||||
|
||||
/**
|
||||
* Adds a "successful" flash message to the stack.
|
||||
|
||||
@@ -15,7 +15,6 @@ use App\Form\Type\ProjectType;
|
||||
use App\Form\Type\YesNoType;
|
||||
use App\Repository\CustomerRepository;
|
||||
use App\Repository\ProjectRepository;
|
||||
use App\Repository\Query\ProjectQuery;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
|
||||
@@ -39,6 +39,7 @@ class RateCalculator implements CalculatorInterface
|
||||
{
|
||||
if (null === $record->getEnd()) {
|
||||
$record->setRate(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,10 +91,10 @@
|
||||
});
|
||||
},
|
||||
eventClick: function(calEvent, jsEvent, view) {
|
||||
location.href = '{{ path('timesheet_edit', {id: '-XX-'}) }}'.replace('-XX-', calEvent.id);
|
||||
location.href = '{{ path('timesheet_edit', {id: '-XX-'}) }}?origin=calendar'.replace('-XX-', calEvent.id);
|
||||
},
|
||||
dayClick: function(date, jsEvent, view) {
|
||||
location.href = '{{ path('timesheet_create') }}' + '?begin=' + date.format();
|
||||
location.href = '{{ path('timesheet_create') }}' + '?origin=calendar&begin=' + date.format();
|
||||
},
|
||||
selectable: true,
|
||||
select: function( start, end, jsEvent, view) {
|
||||
|
||||
@@ -66,11 +66,11 @@ class TimesheetEntityTest extends TestCase
|
||||
$sut->setActivity('cccccccc');
|
||||
$this->assertEquals('cccccccc', $sut->getActivity());
|
||||
|
||||
$this->assertEquals('#f39c12', $sut->getBorderColor());
|
||||
$this->assertEquals('367fa9', $sut->getBorderColor());
|
||||
$sut->setBorderColor('#cccccc');
|
||||
$this->assertEquals('#cccccc', $sut->getBorderColor());
|
||||
|
||||
$this->assertEquals('#f39c12', $sut->getBackgroundColor());
|
||||
$this->assertEquals('#3c8dbc', $sut->getBackgroundColor());
|
||||
$sut->setBackgroundColor('#ffffff');
|
||||
$this->assertEquals('#ffffff', $sut->getBackgroundColor());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user