detail pages for customers and projects (#1371)

This commit is contained in:
Kevin Papst
2020-01-16 16:25:28 +01:00
committed by GitHub
parent 28c5357f11
commit 6a44dbfe83
131 changed files with 3055 additions and 1742 deletions

View File

@@ -11,17 +11,24 @@ namespace App\Controller;
use App\Configuration\FormConfiguration;
use App\Entity\Customer;
use App\Entity\CustomerComment;
use App\Entity\MetaTableTypeInterface;
use App\Entity\Team;
use App\Event\CustomerMetaDefinitionEvent;
use App\Event\CustomerMetaDisplayEvent;
use App\Form\CustomerCommentForm;
use App\Form\CustomerEditForm;
use App\Form\CustomerTeamPermissionForm;
use App\Form\Toolbar\CustomerToolbarForm;
use App\Form\Type\CustomerType;
use App\Repository\CustomerRepository;
use App\Repository\ProjectRepository;
use App\Repository\Query\CustomerFormTypeQuery;
use App\Repository\Query\CustomerQuery;
use App\Repository\Query\ProjectQuery;
use App\Repository\TeamRepository;
use Doctrine\ORM\ORMException;
use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormInterface;
@@ -34,42 +41,28 @@ use Symfony\Component\Routing\Annotation\Route;
* Controller used to manage customer in the admin part of the site.
*
* @Route(path="/admin/customer")
* @Security("is_granted('view_customer')")
* @Security("is_granted('view_customer') or is_granted('view_teamlead_customer') or is_granted('view_team_customer')")
*/
class CustomerController extends AbstractController
final class CustomerController extends AbstractController
{
/**
* @var CustomerRepository
*/
private $repository;
/**
* @var FormConfiguration
*/
private $configuration;
/**
* @var EventDispatcherInterface
*/
protected $dispatcher;
private $dispatcher;
public function __construct(CustomerRepository $repository, FormConfiguration $configuration, EventDispatcherInterface $dispatcher)
public function __construct(CustomerRepository $repository, EventDispatcherInterface $dispatcher)
{
$this->repository = $repository;
$this->configuration = $configuration;
$this->dispatcher = $dispatcher;
}
/**
* @return \App\Repository\CustomerRepository
*/
protected function getRepository()
{
return $this->repository;
}
/**
* @Route(path="/", defaults={"page": 1}, name="admin_customer", methods={"GET"})
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_customer_paginated", methods={"GET"})
* @Security("is_granted('view_customer')")
*/
public function indexAction($page, Request $request)
{
@@ -85,7 +78,7 @@ class CustomerController extends AbstractController
$query->resetByFormError($form->getErrors());
}
$entries = $this->getRepository()->getPagerfantaForQuery($query);
$entries = $this->repository->getPagerfantaForQuery($query);
return $this->render('customer/index.html.twig', [
'entries' => $entries,
@@ -99,7 +92,7 @@ class CustomerController extends AbstractController
* @param CustomerQuery $query
* @return MetaTableTypeInterface[]
*/
protected function findMetaColumns(CustomerQuery $query): array
private function findMetaColumns(CustomerQuery $query): array
{
$event = new CustomerMetaDisplayEvent($query, CustomerMetaDisplayEvent::CUSTOMER);
$this->dispatcher->dispatch($event);
@@ -111,16 +104,16 @@ class CustomerController extends AbstractController
* @Route(path="/create", name="admin_customer_create", methods={"GET", "POST"})
* @Security("is_granted('create_customer')")
*/
public function createAction(Request $request)
public function createAction(Request $request, FormConfiguration $configuration)
{
$timezone = date_default_timezone_get();
if (null !== $this->configuration->getCustomerDefaultTimezone()) {
$timezone = $this->configuration->getCustomerDefaultTimezone();
if (null !== $configuration->getCustomerDefaultTimezone()) {
$timezone = $configuration->getCustomerDefaultTimezone();
}
$customer = new Customer();
$customer->setCountry($this->configuration->getCustomerDefaultCountry());
$customer->setCurrency($this->configuration->getCustomerDefaultCurrency());
$customer->setCountry($configuration->getCustomerDefaultCountry());
$customer->setCurrency($configuration->getCustomerDefaultCurrency());
$customer->setTimezone($timezone);
return $this->renderCustomerForm($customer, $request);
@@ -130,7 +123,7 @@ class CustomerController extends AbstractController
* @Route(path="/{id}/permissions", name="admin_customer_permissions", methods={"GET", "POST"})
* @Security("is_granted('permissions', customer)")
*/
public function teamPermissions(Customer $customer, Request $request)
public function teamPermissionsAction(Customer $customer, Request $request)
{
$form = $this->createForm(CustomerTeamPermissionForm::class, $customer, [
'action' => $this->generateUrl('admin_customer_permissions', ['id' => $customer->getId()]),
@@ -141,11 +134,11 @@ class CustomerController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
try {
$this->getRepository()->saveCustomer($customer);
$this->repository->saveCustomer($customer);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_customer');
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
@@ -157,18 +150,160 @@ class CustomerController extends AbstractController
}
/**
* @Route(path="/{id}/budget", name="admin_customer_budget", methods={"GET"})
* @Security("is_granted('budget', customer)")
* @Route(path="/{id}/comment_delete", name="customer_comment_delete", methods={"GET"})
* @Security("is_granted('edit', comment.getCustomer()) and is_granted('comments', comment.getCustomer())")
*/
public function budgetAction(Customer $customer)
public function deleteCommentAction(CustomerComment $comment)
{
$stats = $this->getRepository()->getCustomerStatistics($customer);
$customerId = $comment->getCustomer()->getId();
// TODO sent event with stats
try {
$this->repository->deleteComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.delete.error', ['%reason%' => $ex->getMessage()]);
}
return $this->render('customer/budget.html.twig', [
return $this->redirectToRoute('customer_details', ['id' => $customerId]);
}
/**
* @Route(path="/{id}/comment_add", name="customer_comment_add", methods={"POST"})
* @Security("is_granted('edit', customer) and is_granted('comments', customer)")
*/
public function addCommentAction(Customer $customer, Request $request)
{
$comment = new CustomerComment();
$form = $this->getCommentForm($customer, $comment);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
return $this->redirectToRoute('customer_details', ['id' => $customer->getId()]);
}
/**
* @Route(path="/{id}/comment_pin", name="customer_comment_pin", methods={"GET"})
* @Security("is_granted('edit', comment.getCustomer()) and is_granted('comments', comment.getCustomer())")
*/
public function pinCommentAction(CustomerComment $comment)
{
$comment->setPinned(!$comment->isPinned());
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
return $this->redirectToRoute('customer_details', ['id' => $comment->getCustomer()->getId()]);
}
/**
* @Route(path="/{id}/create_team", name="customer_team_create", methods={"GET"})
* @Security("is_granted('create_team') and is_granted('permissions', customer)")
*/
public function createDefaultTeamAction(Customer $customer, TeamRepository $teamRepository)
{
$defaultTeam = $teamRepository->findOneBy(['name' => $customer->getName()]);
if (null !== $defaultTeam) {
$this->flashError('action.update.error', ['%reason%' => 'Team already existing']);
return $this->redirectToRoute('customer_details', ['id' => $customer->getId()]);
}
$defaultTeam = new Team();
$defaultTeam->setName($customer->getName());
$defaultTeam->setTeamLead($this->getUser());
$defaultTeam->addCustomer($customer);
try {
$teamRepository->saveTeam($defaultTeam);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
return $this->redirectToRoute('customer_details', ['id' => $customer->getId()]);
}
/**
* @Route(path="/{id}/projects/{page}", defaults={"page": 1}, name="customer_projects", methods={"GET", "POST"})
* @Security("is_granted('view', customer)")
*/
public function projectsAction(Customer $customer, int $page, ProjectRepository $projectRepository)
{
$query = new ProjectQuery();
$query->setCurrentUser($this->getUser());
$query->setPage($page);
$query->setPageSize(5);
$query->setCustomer($customer);
/* @var $entries Pagerfanta */
$entries = $projectRepository->getPagerfantaForQuery($query);
return $this->render('customer/embed_projects.html.twig', [
'customer' => $customer,
'projects' => $entries,
'page' => $page,
]);
}
/**
* @Route(path="/{id}/details", name="customer_details", methods={"GET", "POST"})
* @Security("is_granted('view', customer)")
*/
public function detailsAction(Customer $customer, TeamRepository $teamRepository)
{
$event = new CustomerMetaDefinitionEvent($customer);
$this->dispatcher->dispatch($event);
$stats = null;
$timezone = null;
$defaultTeam = null;
$commentForm = null;
$attachments = [];
$comments = null;
$teams = null;
$projects = null;
if ($this->isGranted('edit', $customer)) {
$commentForm = $this->getCommentForm($customer, new CustomerComment())->createView();
if ($this->isGranted('create_team')) {
$defaultTeam = $teamRepository->findOneBy(['name' => $customer->getName()]);
}
}
if (null !== $customer->getTimezone()) {
$timezone = new \DateTimeZone($customer->getTimezone());
}
if ($this->isGranted('budget', $customer)) {
$stats = $this->repository->getCustomerStatistics($customer);
}
if ($this->isGranted('comments', $customer)) {
$comments = $this->repository->getComments($customer);
}
if ($this->isGranted('permissions', $customer) || $this->isGranted('details', $customer) || $this->isGranted('view_team')) {
$teams = $customer->getTeams();
}
return $this->render('customer/details.html.twig', [
'customer' => $customer,
'comments' => $comments,
'commentForm' => $commentForm,
'attachments' => $attachments,
'stats' => $stats,
'team' => $defaultTeam,
'teams' => $teams,
'now' => new \DateTime('now', $timezone),
]);
}
@@ -187,7 +322,7 @@ class CustomerController extends AbstractController
*/
public function deleteAction(Customer $customer, Request $request)
{
$stats = $this->getRepository()->getCustomerStatistics($customer);
$stats = $this->repository->getCustomerStatistics($customer);
$deleteForm = $this->createFormBuilder(null, [
'attr' => [
@@ -215,7 +350,7 @@ class CustomerController extends AbstractController
if ($deleteForm->isSubmitted() && $deleteForm->isValid()) {
try {
$this->getRepository()->deleteCustomer($customer, $deleteForm->get('customer')->getData());
$this->repository->deleteCustomer($customer, $deleteForm->get('customer')->getData());
$this->flashSuccess('action.delete.success');
} catch (ORMException $ex) {
$this->flashError('action.delete.error', ['%reason%' => $ex->getMessage()]);
@@ -236,21 +371,18 @@ class CustomerController extends AbstractController
* @param Request $request
* @return RedirectResponse|Response
*/
protected function renderCustomerForm(Customer $customer, Request $request)
private function renderCustomerForm(Customer $customer, Request $request)
{
$event = new CustomerMetaDefinitionEvent($customer);
$this->dispatcher->dispatch($event);
$editForm = $this->createEditForm($customer);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
try {
$this->getRepository()->saveCustomer($customer);
$this->repository->saveCustomer($customer);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_customer');
return $this->redirectToRoute('customer_details', ['id' => $customer->getId()]);
} catch (ORMException $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
@@ -262,7 +394,7 @@ class CustomerController extends AbstractController
]);
}
protected function getToolbarForm(CustomerQuery $query): FormInterface
private function getToolbarForm(CustomerQuery $query): FormInterface
{
return $this->createForm(CustomerToolbarForm::class, $query, [
'action' => $this->generateUrl('admin_customer', [
@@ -272,8 +404,24 @@ class CustomerController extends AbstractController
]);
}
private function getCommentForm(Customer $customer, CustomerComment $comment): FormInterface
{
if (null === $comment->getId()) {
$comment->setCustomer($customer);
$comment->setCreatedBy($this->getUser());
}
return $this->createForm(CustomerCommentForm::class, $comment, [
'action' => $this->generateUrl('customer_comment_add', ['id' => $customer->getId()]),
'method' => 'POST',
]);
}
private function createEditForm(Customer $customer): FormInterface
{
$event = new CustomerMetaDefinitionEvent($customer);
$this->dispatcher->dispatch($event);
if ($customer->getId() === null) {
$url = $this->generateUrl('admin_customer_create');
} else {

View File

@@ -13,16 +13,21 @@ use App\Configuration\FormConfiguration;
use App\Entity\Customer;
use App\Entity\MetaTableTypeInterface;
use App\Entity\Project;
use App\Entity\ProjectComment;
use App\Entity\Team;
use App\Event\ProjectMetaDefinitionEvent;
use App\Event\ProjectMetaDisplayEvent;
use App\Form\ProjectCommentForm;
use App\Form\ProjectEditForm;
use App\Form\ProjectTeamPermissionForm;
use App\Form\Toolbar\ProjectToolbarForm;
use App\Form\Type\ProjectType;
use App\Repository\ActivityRepository;
use App\Repository\ProjectRepository;
use App\Repository\Query\ActivityQuery;
use App\Repository\Query\ProjectFormTypeQuery;
use App\Repository\Query\ProjectQuery;
use Doctrine\ORM\ORMException;
use App\Repository\TeamRepository;
use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -33,12 +38,12 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* Controller used to manage projects in the admin part of the site.
* Controller used to manage projects.
*
* @Route(path="/admin/project")
* @Security("is_granted('view_project')")
* @Security("is_granted('view_project') or is_granted('view_teamlead_project') or is_granted('view_team_project')")
*/
class ProjectController extends AbstractController
final class ProjectController extends AbstractController
{
/**
* @var ProjectRepository
@@ -51,7 +56,7 @@ class ProjectController extends AbstractController
/**
* @var EventDispatcherInterface
*/
protected $dispatcher;
private $dispatcher;
public function __construct(ProjectRepository $repository, FormConfiguration $configuration, EventDispatcherInterface $dispatcher)
{
@@ -60,15 +65,9 @@ class ProjectController extends AbstractController
$this->dispatcher = $dispatcher;
}
protected function getRepository(): ProjectRepository
{
return $this->repository;
}
/**
* @Route(path="/", defaults={"page": 1}, name="admin_project", methods={"GET"})
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_project_paginated", methods={"GET"})
* @Security("is_granted('view_project')")
*/
public function indexAction($page, Request $request)
{
@@ -85,7 +84,7 @@ class ProjectController extends AbstractController
}
/* @var $entries Pagerfanta */
$entries = $this->getRepository()->getPagerfantaForQuery($query);
$entries = $this->repository->getPagerfantaForQuery($query);
return $this->render('project/index.html.twig', [
'entries' => $entries,
@@ -122,11 +121,11 @@ class ProjectController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
try {
$this->getRepository()->saveProject($project);
$this->repository->saveProject($project);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_project');
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
@@ -154,18 +153,154 @@ class ProjectController extends AbstractController
}
/**
* @Route(path="/{id}/budget", name="admin_project_budget", methods={"GET"})
* @Security("is_granted('budget', project)")
* @Route(path="/{id}/comment_delete", name="project_comment_delete", methods={"GET"})
* @Security("is_granted('edit', comment.getProject()) and is_granted('comments', comment.getProject())")
*/
public function budgetAction(Project $project)
public function deleteCommentAction(ProjectComment $comment)
{
$stats = $this->getRepository()->getProjectStatistics($project);
$projectId = $comment->getProject()->getId();
// TODO sent event with stats
try {
$this->repository->deleteComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.delete.error', ['%reason%' => $ex->getMessage()]);
}
return $this->render('project/budget.html.twig', [
return $this->redirectToRoute('project_details', ['id' => $projectId]);
}
/**
* @Route(path="/{id}/comment_add", name="project_comment_add", methods={"POST"})
* @Security("is_granted('edit', project) and is_granted('comments', project)")
*/
public function addCommentAction(Project $project, Request $request)
{
$comment = new ProjectComment();
$form = $this->getCommentForm($project, $comment);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
return $this->redirectToRoute('project_details', ['id' => $project->getId()]);
}
/**
* @Route(path="/{id}/comment_pin", name="project_comment_pin", methods={"GET"})
* @Security("is_granted('edit', comment.getProject()) and is_granted('comments', comment.getProject())")
*/
public function pinCommentAction(ProjectComment $comment)
{
$comment->setPinned(!$comment->isPinned());
try {
$this->repository->saveComment($comment);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
return $this->redirectToRoute('project_details', ['id' => $comment->getProject()->getId()]);
}
/**
* @Route(path="/{id}/create_team", name="project_team_create", methods={"GET"})
* @Security("is_granted('create_team') and is_granted('edit', project)")
*/
public function createDefaultTeamAction(Project $project, TeamRepository $teamRepository)
{
$defaultTeam = $teamRepository->findOneBy(['name' => $project->getName()]);
if (null !== $defaultTeam) {
$this->flashError('action.update.error', ['%reason%' => 'Team already existing']);
return $this->redirectToRoute('project_details', ['id' => $project->getId()]);
}
$defaultTeam = new Team();
$defaultTeam->setName($project->getName());
$defaultTeam->setTeamLead($this->getUser());
$defaultTeam->addProject($project);
try {
$teamRepository->saveTeam($defaultTeam);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
return $this->redirectToRoute('project_details', ['id' => $project->getId()]);
}
/**
* @Route(path="/{id}/activities/{page}", defaults={"page": 1}, name="project_activities", methods={"GET", "POST"})
* @Security("is_granted('view', project)")
*/
public function activitiesAction(Project $project, int $page, ActivityRepository $activityRepository)
{
$query = new ActivityQuery();
$query->setCurrentUser($this->getUser());
$query->setPage($page);
$query->setPageSize(5);
$query->setProject($project);
$query->setExcludeGlobals(true);
/* @var $entries Pagerfanta */
$entries = $activityRepository->getPagerfantaForQuery($query);
return $this->render('project/embed_activities.html.twig', [
'project' => $project,
'stats' => $stats
'activities' => $entries,
'page' => $page,
]);
}
/**
* @Route(path="/{id}/details", name="project_details", methods={"GET", "POST"})
* @Security("is_granted('view', project)")
*/
public function detailsAction(Project $project, TeamRepository $teamRepository)
{
$event = new ProjectMetaDefinitionEvent($project);
$this->dispatcher->dispatch($event);
$stats = null;
$defaultTeam = null;
$commentForm = null;
$attachments = [];
$comments = null;
$teams = null;
if ($this->isGranted('edit', $project)) {
$commentForm = $this->getCommentForm($project, new ProjectComment())->createView();
if ($this->isGranted('create_team')) {
$defaultTeam = $teamRepository->findOneBy(['name' => $project->getName()]);
}
}
if ($this->isGranted('budget', $project)) {
$stats = $this->repository->getProjectStatistics($project);
}
if ($this->isGranted('comments', $project)) {
$comments = $this->repository->getComments($project);
}
if ($this->isGranted('permissions', $project) || $this->isGranted('details', $project) || $this->isGranted('view_team')) {
$teams = $project->getTeams();
}
return $this->render('project/details.html.twig', [
'project' => $project,
'comments' => $comments,
'commentForm' => $commentForm,
'attachments' => $attachments,
'stats' => $stats,
'team' => $defaultTeam,
'teams' => $teams,
]);
}
@@ -184,7 +319,7 @@ class ProjectController extends AbstractController
*/
public function deleteAction(Project $project, Request $request)
{
$stats = $this->getRepository()->getProjectStatistics($project);
$stats = $this->repository->getProjectStatistics($project);
$deleteForm = $this->createFormBuilder(null, [
'attr' => [
@@ -213,9 +348,9 @@ class ProjectController extends AbstractController
if ($deleteForm->isSubmitted() && $deleteForm->isValid()) {
try {
$this->getRepository()->deleteProject($project, $deleteForm->get('project')->getData());
$this->repository->deleteProject($project, $deleteForm->get('project')->getData());
$this->flashSuccess('action.delete.success');
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.delete.error', ['%reason%' => $ex->getMessage()]);
}
@@ -234,17 +369,14 @@ class ProjectController extends AbstractController
* @param Request $request
* @return RedirectResponse|Response
*/
protected function renderProjectForm(Project $project, Request $request)
private function renderProjectForm(Project $project, Request $request)
{
$event = new ProjectMetaDefinitionEvent($project);
$this->dispatcher->dispatch($event);
$editForm = $this->createEditForm($project);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
try {
$this->getRepository()->saveProject($project);
$this->repository->saveProject($project);
$this->flashSuccess('action.update.success');
if ($editForm->has('create_more') && $editForm->get('create_more')->getData() === true) {
@@ -254,9 +386,9 @@ class ProjectController extends AbstractController
$editForm->get('create_more')->setData(true);
$project = $newProject;
} else {
return $this->redirectToRoute('admin_project');
return $this->redirectToRoute('project_details', ['id' => $project->getId()]);
}
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
@@ -277,8 +409,24 @@ class ProjectController extends AbstractController
]);
}
private function getCommentForm(Project $project, ProjectComment $comment): FormInterface
{
if (null === $comment->getId()) {
$comment->setProject($project);
$comment->setCreatedBy($this->getUser());
}
return $this->createForm(ProjectCommentForm::class, $comment, [
'action' => $this->generateUrl('project_comment_add', ['id' => $project->getId()]),
'method' => 'POST',
]);
}
private function createEditForm(Project $project): FormInterface
{
$event = new ProjectMetaDefinitionEvent($project);
$this->dispatcher->dispatch($event);
$currency = $this->configuration->getCustomerDefaultCurrency();
$url = $this->generateUrl('admin_project_create');

View File

@@ -14,7 +14,6 @@ use App\Event\SystemConfigurationEvent;
use App\Form\Model\Configuration;
use App\Form\Model\SystemConfiguration as SystemConfigurationModel;
use App\Form\SystemConfigurationForm;
use App\Form\Type\EnhancedSelectboxType;
use App\Form\Type\LanguageType;
use App\Form\Type\RoundingModeType;
use App\Form\Type\SkinType;
@@ -293,25 +292,20 @@ class SystemConfigurationController extends AbstractController
->setSection(SystemConfigurationModel::SECTION_THEME)
->setConfiguration([
(new Configuration())
->setName('theme.select_type')
->setTranslationDomain('system-configuration')
->setType(EnhancedSelectboxType::class)
->setRequired(false),
->setName('theme.autocomplete_chars')
->setLabel('theme.autocomplete_chars')
->setType(IntegerType::class)
->setTranslationDomain('system-configuration'),
(new Configuration())
->setName('timesheet.markdown_content')
->setLabel('theme.markdown_content')
->setType(CheckboxType::class)
->setTranslationDomain('system-configuration'),
(new Configuration())
->setName('theme.autocomplete_chars')
->setLabel('theme.autocomplete_chars')
->setType(IntegerType::class)
->setTranslationDomain('system-configuration'),
// FIXME should that be configurable per user?
// TODO should that be configurable per user?
/*
(new Configuration())
->setName('theme.auto_reload_datatable')
->setLabel('theme.auto_reload_datatable') // FIXME translation
->setLabel('theme.auto_reload_datatable') // TODO translation
->setType(CheckboxType::class)
->setTranslationDomain('system-configuration'),
*/

View File

@@ -16,7 +16,6 @@ use App\Form\TeamProjectForm;
use App\Form\Toolbar\TeamToolbarForm;
use App\Repository\Query\TeamQuery;
use App\Repository\TeamRepository;
use Doctrine\ORM\ORMException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -28,7 +27,7 @@ use Symfony\Component\Routing\Annotation\Route;
* @Route(path="/admin/teams")
* @Security("is_granted('view_team')")
*/
class TeamController extends AbstractController
final class TeamController extends AbstractController
{
/**
* @var TeamRepository
@@ -93,6 +92,40 @@ class TeamController extends AbstractController
return $this->renderEditScreen($team, $request);
}
/**
* @Route(path="/{id}/edit_member", name="admin_team_member", methods={"GET", "POST"})
* @Security("is_granted('edit', team)")
*/
public function editMemberAction(Team $team, Request $request)
{
$editForm = $this->createForm(TeamEditForm::class, $team, [
'action' => $this->generateUrl('admin_team_member', ['id' => $team->getId()]),
'method' => 'POST',
]);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
try {
// make sure that the teamlead is always part of the team, otherwise permission checks
// and filtering might not work as expected!
$team->addUser($team->getTeamLead());
$this->repository->saveTeam($team);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]);
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
return $this->render('team/edit_member.html.twig', [
'team' => $team,
'form' => $editForm->createView(),
]);
}
private function renderEditScreen(Team $team, Request $request): Response
{
$customerForm = null;
@@ -122,7 +155,7 @@ class TeamController extends AbstractController
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]);
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
@@ -142,7 +175,7 @@ class TeamController extends AbstractController
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]);
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
@@ -161,7 +194,7 @@ class TeamController extends AbstractController
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_team_edit', ['id' => $team->getId()]);
} catch (ORMException $ex) {
} catch (\Exception $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}