javascript and api to stop and display active records (#772)
This commit is contained in:
@@ -118,7 +118,13 @@ class ActivityController extends AbstractController
|
||||
{
|
||||
$stats = $this->getRepository()->getActivityStatistics($activity);
|
||||
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.activityUpdate kimai.activityDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
]
|
||||
])
|
||||
->add('activity', ActivityType::class, [
|
||||
'label' => 'label.activity',
|
||||
'query_builder' => function (ActivityRepository $repo) use ($activity) {
|
||||
|
||||
@@ -134,7 +134,13 @@ class CustomerController extends AbstractController
|
||||
{
|
||||
$stats = $this->getRepository()->getCustomerStatistics($customer);
|
||||
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.customerUpdate kimai.customerDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
]
|
||||
])
|
||||
->add('customer', CustomerType::class, [
|
||||
'label' => 'label.customer',
|
||||
'query_builder' => function (CustomerRepository $repo) use ($customer) {
|
||||
|
||||
@@ -119,7 +119,13 @@ class ProjectController extends AbstractController
|
||||
{
|
||||
$stats = $this->getRepository()->getProjectStatistics($project);
|
||||
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.projectUpdate kimai.projectDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
]
|
||||
])
|
||||
->add('project', ProjectType::class, [
|
||||
'label' => 'label.project',
|
||||
'query_builder' => function (ProjectRepository $repo) use ($project) {
|
||||
|
||||
@@ -14,6 +14,7 @@ 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\TimesheetModeType;
|
||||
use App\Repository\ConfigurationRepository;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
@@ -82,6 +83,16 @@ class SystemConfigurationController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/theme", name="system_configuration_theme", methods={"POST"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function theme(Request $request)
|
||||
{
|
||||
return $this->handleConfigUpdate($request, SystemConfigurationModel::SECTION_THEME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/timesheet", name="system_configuration_timesheet", methods={"POST"})
|
||||
*
|
||||
@@ -244,6 +255,15 @@ class SystemConfigurationController extends AbstractController
|
||||
->setLabel('currency')
|
||||
->setType(CurrencyType::class),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_THEME)
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('theme.select_type')
|
||||
->setLabel('theme.select_type')
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setType(EnhancedSelectboxType::class),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,20 +133,6 @@ class TimesheetController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The route to stop a running entry.
|
||||
*
|
||||
* @Route(path="/{id}/stop", name="timesheet_stop", methods={"GET"})
|
||||
* @Security("is_granted('stop', entry)")
|
||||
*
|
||||
* @param Timesheet $entry
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function stopAction(Timesheet $entry)
|
||||
{
|
||||
return $this->stop($entry, 'timesheet');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/start/{id}", name="timesheet_start", requirements={"id" = "\d+"}, methods={"GET", "POST"})
|
||||
* @Security("is_granted('start', timesheet)")
|
||||
@@ -233,10 +219,17 @@ class TimesheetController extends AbstractController
|
||||
* @param Timesheet $entry
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deleteAction(Timesheet $entry, Request $request)
|
||||
{
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.timesheetUpdate kimai.timesheetDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
],
|
||||
])
|
||||
->setAction($this->generateUrl('timesheet_delete', ['id' => $entry->getId()]))
|
||||
->setMethod('POST')
|
||||
->getForm();
|
||||
|
||||
@@ -69,23 +69,6 @@ trait TimesheetControllerTrait
|
||||
return $this->getDoctrine()->getRepository(Timesheet::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param string $route
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function stop(Timesheet $entry, $route)
|
||||
{
|
||||
try {
|
||||
$this->getRepository()->stopRecording($entry);
|
||||
$this->flashSuccess('timesheet.stop.success');
|
||||
} catch (\Exception $ex) {
|
||||
$this->flashError('timesheet.stop.error', ['%reason%' => $ex->getMessage()]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute($route);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Timesheet $entry
|
||||
* @param Request $request
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Form\DeleteType;
|
||||
use App\Form\TimesheetEditForm;
|
||||
use App\Form\Toolbar\TimesheetToolbarForm;
|
||||
use App\Repository\ActivityRepository;
|
||||
@@ -108,18 +109,6 @@ class TimesheetTeamController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{id}/stop", name="admin_timesheet_stop", methods={"GET"})
|
||||
* @Security("is_granted('stop', entry)")
|
||||
*
|
||||
* @param Timesheet $entry
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function stopAction(Timesheet $entry)
|
||||
{
|
||||
return $this->stop($entry, 'admin_timesheet');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{id}/edit", name="admin_timesheet_edit", methods={"GET", "POST"})
|
||||
* @Security("is_granted('edit', entry)")
|
||||
@@ -157,7 +146,13 @@ class TimesheetTeamController extends AbstractController
|
||||
*/
|
||||
public function deleteAction(Timesheet $entry, Request $request)
|
||||
{
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.timesheetUpdate kimai.timesheetDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
]
|
||||
])
|
||||
->setAction($this->generateUrl('admin_timesheet_delete', ['id' => $entry->getId()]))
|
||||
->setMethod('POST')
|
||||
->getForm();
|
||||
|
||||
@@ -140,7 +140,13 @@ class UserController extends AbstractController
|
||||
// $userToDelete MUST not be called $user, as $user is always the current user!
|
||||
$stats = $this->getDoctrine()->getRepository(Timesheet::class)->getUserStatistics($userToDelete);
|
||||
|
||||
$deleteForm = $this->createFormBuilder()
|
||||
$deleteForm = $this->createFormBuilder(null, [
|
||||
'attr' => [
|
||||
'data-form-event' => 'kimai.userUpdate kimai.userDelete',
|
||||
'data-msg-success' => 'action.delete.success',
|
||||
'data-msg-error' => 'action.delete.error',
|
||||
]
|
||||
])
|
||||
->setAction($this->generateUrl('admin_user_delete', ['id' => $userToDelete->getId()]))
|
||||
->setMethod('POST')
|
||||
->getForm();
|
||||
|
||||
Reference in New Issue
Block a user