added more entity actions (#757)
This commit is contained in:
committed by
Kevin Papst
parent
b1855447b8
commit
e619b5fd31
@@ -10,6 +10,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Activity;
|
use App\Entity\Activity;
|
||||||
|
use App\Entity\Project;
|
||||||
use App\Form\ActivityEditForm;
|
use App\Form\ActivityEditForm;
|
||||||
use App\Form\Toolbar\ActivityToolbarForm;
|
use App\Form\Toolbar\ActivityToolbarForm;
|
||||||
use App\Form\Type\ActivityType;
|
use App\Form\Type\ActivityType;
|
||||||
@@ -75,14 +76,21 @@ class ActivityController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(path="/create", name="admin_activity_create", methods={"GET", "POST"})
|
* @Route(path="/create", name="admin_activity_create", methods={"GET", "POST"})
|
||||||
|
* @Route(path="/create/{project}", name="admin_activity_create_with_project", methods={"GET", "POST"})
|
||||||
* @Security("is_granted('create_activity')")
|
* @Security("is_granted('create_activity')")
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @param Project|null $project
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request, ?Project $project = null)
|
||||||
{
|
{
|
||||||
return $this->renderActivityForm(new Activity(), $request);
|
$activity = new Activity();
|
||||||
|
if (null !== $project) {
|
||||||
|
$activity->setProject($project);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderActivityForm($activity, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -76,14 +76,22 @@ class ProjectController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(path="/create", name="admin_project_create", methods={"GET", "POST"})
|
* @Route(path="/create", name="admin_project_create", methods={"GET", "POST"})
|
||||||
|
* @Route(path="/create/{customer}", name="admin_project_create_with_customer", methods={"GET", "POST"})
|
||||||
* @Security("is_granted('create_project')")
|
* @Security("is_granted('create_project')")
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @param Customer|null $customer
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request, ?Customer $customer = null)
|
||||||
{
|
{
|
||||||
return $this->renderProjectForm(new Project(), $request);
|
$project = new Project();
|
||||||
|
|
||||||
|
if (null !== $customer) {
|
||||||
|
$project->setCustomer($customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderProjectForm($project, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace App\Controller;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Form\TimesheetEditForm;
|
use App\Form\TimesheetEditForm;
|
||||||
use App\Form\Toolbar\TimesheetToolbarForm;
|
use App\Form\Toolbar\TimesheetToolbarForm;
|
||||||
|
use App\Repository\ActivityRepository;
|
||||||
|
use App\Repository\ProjectRepository;
|
||||||
use App\Repository\Query\TimesheetQuery;
|
use App\Repository\Query\TimesheetQuery;
|
||||||
use Doctrine\ORM\ORMException;
|
use Doctrine\ORM\ORMException;
|
||||||
use Pagerfanta\Pagerfanta;
|
use Pagerfanta\Pagerfanta;
|
||||||
@@ -210,16 +212,18 @@ class TimesheetController extends AbstractController
|
|||||||
* @Security("is_granted('create_own_timesheet')")
|
* @Security("is_granted('create_own_timesheet')")
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @param ProjectRepository $projectRepository
|
||||||
|
* @param ActivityRepository $activityRepository
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
{
|
{
|
||||||
$route = 'timesheet';
|
$route = 'timesheet';
|
||||||
if ('calendar' === $request->get('origin')) {
|
if ('calendar' === $request->get('origin')) {
|
||||||
$route = 'calendar';
|
$route = 'calendar';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->create($request, $route, 'timesheet/edit.html.twig');
|
return $this->create($request, $route, 'timesheet/edit.html.twig', $projectRepository, $activityRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace App\Controller;
|
|||||||
use App\Configuration\TimesheetConfiguration;
|
use App\Configuration\TimesheetConfiguration;
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Repository\ActivityRepository;
|
||||||
|
use App\Repository\ProjectRepository;
|
||||||
use App\Repository\TimesheetRepository;
|
use App\Repository\TimesheetRepository;
|
||||||
use App\Timesheet\UserDateTimeFactory;
|
use App\Timesheet\UserDateTimeFactory;
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
@@ -116,9 +118,11 @@ trait TimesheetControllerTrait
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $redirectRoute
|
* @param string $redirectRoute
|
||||||
* @param string $renderTemplate
|
* @param string $renderTemplate
|
||||||
|
* @param ProjectRepository $projectRepository
|
||||||
|
* @param ActivityRepository $activityRepository
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
protected function create(Request $request, $redirectRoute, $renderTemplate)
|
protected function create(Request $request, $redirectRoute, $renderTemplate, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
{
|
{
|
||||||
$entry = new Timesheet();
|
$entry = new Timesheet();
|
||||||
$entry->setUser($this->getUser());
|
$entry->setUser($this->getUser());
|
||||||
@@ -158,6 +162,16 @@ trait TimesheetControllerTrait
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->query->get('project')) {
|
||||||
|
$project = $projectRepository->find($request->query->get('project'));
|
||||||
|
$entry->setProject($project);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->query->get('activity')) {
|
||||||
|
$activity = $activityRepository->find($request->query->get('activity'));
|
||||||
|
$entry->setActivity($activity);
|
||||||
|
}
|
||||||
|
|
||||||
$createForm = $this->getCreateForm($entry, $redirectRoute);
|
$createForm = $this->getCreateForm($entry, $redirectRoute);
|
||||||
$createForm->handleRequest($request);
|
$createForm->handleRequest($request);
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace App\Controller;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Form\TimesheetEditForm;
|
use App\Form\TimesheetEditForm;
|
||||||
use App\Form\Toolbar\TimesheetToolbarForm;
|
use App\Form\Toolbar\TimesheetToolbarForm;
|
||||||
|
use App\Repository\ActivityRepository;
|
||||||
|
use App\Repository\ProjectRepository;
|
||||||
use App\Repository\Query\TimesheetQuery;
|
use App\Repository\Query\TimesheetQuery;
|
||||||
use Doctrine\ORM\ORMException;
|
use Doctrine\ORM\ORMException;
|
||||||
use Pagerfanta\Pagerfanta;
|
use Pagerfanta\Pagerfanta;
|
||||||
@@ -136,11 +138,13 @@ class TimesheetTeamController extends AbstractController
|
|||||||
* @Security("is_granted('create_other_timesheet')")
|
* @Security("is_granted('create_other_timesheet')")
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @param ProjectRepository $projectRepository
|
||||||
|
* @param ActivityRepository $activityRepository
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
{
|
{
|
||||||
return $this->create($request, 'admin_timesheet', 'timesheet-team/edit.html.twig');
|
return $this->create($request, 'admin_timesheet', 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% set actions = actions|merge({'edit': {'url': path('admin_activity_edit', {'id': activity.id}), 'class': class}}) %}
|
{% set actions = actions|merge({'edit': {'url': path('admin_activity_edit', {'id': activity.id}), 'class': class}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if is_granted('view_other_timesheet') %}
|
||||||
|
{% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': activity.project ? activity.project.customer.id : null, 'project': activity.project ? activity.project.id : null, 'activity': activity.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('create_other_timesheet') %}
|
||||||
|
{% set actions = actions|merge({'create-timesheet': path('admin_timesheet_create', {'project': activity.project ? activity.project.id : null, 'activity': activity.id})}) %}
|
||||||
|
{% endif %}
|
||||||
{% if view == 'index' and is_granted('delete', activity) %}
|
{% if view == 'index' and is_granted('delete', activity) %}
|
||||||
{% set actions = actions|merge({'trash': {'url': path('admin_activity_delete', {'id': activity.id}), 'class': 'modal-ajax-form'}}) %}
|
{% set actions = actions|merge({'trash': {'url': path('admin_activity_delete', {'id': activity.id}), 'class': 'modal-ajax-form'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -109,6 +115,12 @@
|
|||||||
{% if is_granted('view_activity') %}
|
{% if is_granted('view_activity') %}
|
||||||
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': project.customer.id, 'project': project.id})}) %}
|
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': project.customer.id, 'project': project.id})}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if is_granted('view_other_timesheet') %}
|
||||||
|
{% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': project.customer.id, 'project': project.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('create_activity') and project.visible and project.customer.visible %}
|
||||||
|
{% set actions = actions|merge({'create-activity': path('admin_activity_create_with_project', {'project': project.id})}) %}
|
||||||
|
{% endif %}
|
||||||
{% if view == 'index' and is_granted('delete', project) %}
|
{% if view == 'index' and is_granted('delete', project) %}
|
||||||
{% set actions = actions|merge({'trash': {'url': path('admin_project_delete', {'id': project.id}), 'class': 'modal-ajax-form'}}) %}
|
{% set actions = actions|merge({'trash': {'url': path('admin_project_delete', {'id': project.id}), 'class': 'modal-ajax-form'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -153,6 +165,15 @@
|
|||||||
{% if is_granted('view_project') %}
|
{% if is_granted('view_project') %}
|
||||||
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
|
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if is_granted('view_activity') %}
|
||||||
|
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': customer.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('view_other_timesheet') %}
|
||||||
|
{% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': customer.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('create_project') and customer.visible %}
|
||||||
|
{% set actions = actions|merge({'create-project': path('admin_project_create_with_customer', {'customer': customer.id})}) %}
|
||||||
|
{% endif %}
|
||||||
{% if view == 'index' and is_granted('delete', customer) %}
|
{% if view == 'index' and is_granted('delete', customer) %}
|
||||||
{% set actions = actions|merge({'trash': {'url': path('admin_customer_delete', {'id': customer.id}), 'class': 'modal-ajax-form'}}) %}
|
{% set actions = actions|merge({'trash': {'url': path('admin_customer_delete', {'id': customer.id}), 'class': 'modal-ajax-form'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -193,14 +214,12 @@
|
|||||||
{% set actions = {} %}
|
{% set actions = {} %}
|
||||||
|
|
||||||
{% if timesheet.id is not empty %}
|
{% if timesheet.id is not empty %}
|
||||||
{% if timesheet.end %}
|
{% if not timesheet.end and is_granted('stop', timesheet) %}
|
||||||
{% if is_granted('start', timesheet) %}
|
{% set actions = actions|merge({'stop': path('timesheet_stop', {'id' : timesheet.id})}) %}
|
||||||
{% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
{% if timesheet.end and is_granted('start', timesheet) %}
|
||||||
{% if is_granted('stop', timesheet) %}
|
{% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
|
||||||
{% set actions = actions|merge({'stop': path('timesheet_stop', {'id' : timesheet.id})}) %}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if is_granted('edit', timesheet) %}
|
{% if is_granted('edit', timesheet) %}
|
||||||
@@ -250,6 +269,14 @@
|
|||||||
{% set actions = {} %}
|
{% set actions = {} %}
|
||||||
|
|
||||||
{% if timesheet.id is not empty %}
|
{% if timesheet.id is not empty %}
|
||||||
|
{% if not timesheet.end and is_granted('stop', timesheet) %}
|
||||||
|
{% set actions = actions|merge({'stop': path('admin_timesheet_stop', {'id' : timesheet.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if timesheet.end and is_granted('start', timesheet) %}
|
||||||
|
{% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if is_granted('edit', timesheet) %}
|
{% if is_granted('edit', timesheet) %}
|
||||||
{% set class = '' %}
|
{% set class = '' %}
|
||||||
{% if view != 'edit' %}
|
{% if view != 'edit' %}
|
||||||
@@ -258,10 +285,6 @@
|
|||||||
{% set actions = actions|merge({'edit': {'url': path('admin_timesheet_edit', {'id': timesheet.id}), 'class': class}}) %}
|
{% set actions = actions|merge({'edit': {'url': path('admin_timesheet_edit', {'id': timesheet.id}), 'class': class}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not timesheet.end and is_granted('stop', timesheet) %}
|
|
||||||
{% set actions = actions|merge({'stop': path('admin_timesheet_stop', {'id' : timesheet.id})}) %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if view == 'index' and is_granted('delete', timesheet) %}
|
{% if view == 'index' and is_granted('delete', timesheet) %}
|
||||||
{% set actions = actions|merge({'trash': {'url': path('admin_timesheet_delete', {'id' : timesheet.id}), 'class': 'modal-ajax-form'}}) %}
|
{% set actions = actions|merge({'trash': {'url': path('admin_timesheet_delete', {'id' : timesheet.id}), 'class': 'modal-ajax-form'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -46,6 +46,18 @@
|
|||||||
<source>home</source>
|
<source>home</source>
|
||||||
<target>Homepage</target>
|
<target>Homepage</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="create-project">
|
||||||
|
<source>create-project</source>
|
||||||
|
<target>Projekt erstellen</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="create-activity">
|
||||||
|
<source>create-activity</source>
|
||||||
|
<target>Tätigkeit erstellen</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="create-timesheet">
|
||||||
|
<source>create-timesheet</source>
|
||||||
|
<target>Zeit erfassen</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|||||||
@@ -46,6 +46,18 @@
|
|||||||
<source>home</source>
|
<source>home</source>
|
||||||
<target>Homepage</target>
|
<target>Homepage</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="create-project">
|
||||||
|
<source>create-project</source>
|
||||||
|
<target>Create project</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="create-activity">
|
||||||
|
<source>create-activity</source>
|
||||||
|
<target>Create activity</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="create-timesheet">
|
||||||
|
<source>create-timesheet</source>
|
||||||
|
<target>Create timesheet</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|||||||
Reference in New Issue
Block a user