diff --git a/app/bootstrap.php b/app/bootstrap.php index 39d8bed..9edadac 100755 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -8,7 +8,7 @@ $configurator = new Nette\Configurator; /* Setup to allow ladenka in production mode */ -//$configurator->setDebugMode(TRUE); // debug mode MUST NOT be enabled on production server +$configurator->setDebugMode(TRUE); // debug mode MUST NOT be enabled on production server $configurator->enableDebugger(__DIR__ . '/../log'); $configurator->setTempDirectory(__DIR__ . '/../temp'); diff --git a/app/components/form/FilterTask.php b/app/components/form/FilterTask.php new file mode 100644 index 0000000..ccf0c13 --- /dev/null +++ b/app/components/form/FilterTask.php @@ -0,0 +1,82 @@ +taskRepository = $taskRepository; + $this->taskGroupRepository = $taskGroupRepository; + } + + public function render() + { + $template = $this->template; + $template->setFile(__DIR__ . '/templates/FilterTask.latte'); + $template->render(); + } + + /** + * @param int $idTaskGroup + */ + public function setTaskGroupId($idTaskGroup) + { + $this->idTaskGroup = $idTaskGroup; + } + + /** + * @return Form + */ + protected function createComponentFilterTaskForm() + { + + $searchSession = $this->presenter->getSession('serach'); + $word = $searchSession->searchString; + + $form = new Form(); + $form->getElementPrototype()->class('newTaskForm ajax'); + $form->addText('search', 'Search') + ->setDefaultValue($word); + $form->addHidden('idTaskGroup', $this->idTaskGroup); + $form->addSubmit('submit', 'Filtruj'); + $form->onSuccess[] = array($this, 'filterTaskFromSuccess'); + return $form; + } + + /** + * @param Form $form + * @param $values + */ + public function filterTaskFromSuccess(Form $form, $values) + { + + $searchSession = $this->presenter->getSession('serach'); + $searchSession->searchString = $values->search; + + if ($this->presenter->isAjax()) { + $this->presenter->redrawControl('tasks'); + } else { + $this->redirect('this'); + } + + } +} diff --git a/app/components/form/InsertTask.php b/app/components/form/InsertTask.php index 9997c70..b9913bd 100644 --- a/app/components/form/InsertTask.php +++ b/app/components/form/InsertTask.php @@ -43,12 +43,26 @@ public function setTaskGroupId($idTaskGroup) $this->idTaskGroup = $idTaskGroup; } + /** + * @param int $id + */ + public function handleDeleteTaskGroup($id) + { + $this->taskGroupRepository->delete($id); + if ($this->isAjax()) { + $this->redrawControl('taskGroups'); + } else { + $this->redirect('this'); + } + } + /** * @return Form */ protected function createComponentInsertTaskForm() { $form = new Form(); + $form->getElementPrototype()->class('newTaskForm'); $form->addText('name', 'Name') ->setRequired('Please fill task name'); $form->addText('date', 'Date') @@ -73,6 +87,11 @@ public function insertTaskFromSuccess(Form $form, $values) $taskEntity->setTaskGroup($taskGroup); $this->taskRepository->insert($taskEntity); $this->presenter->flashMessage('Task was created', 'success'); - $this->redirect('this'); + if ($this->presenter->isAjax()) { + $this->presenter->redrawControl('tasks'); + } else { + $this->redirect('this'); + } + } } diff --git a/app/components/form/templates/FilterTask.latte b/app/components/form/templates/FilterTask.latte new file mode 100644 index 0000000..f92692f --- /dev/null +++ b/app/components/form/templates/FilterTask.latte @@ -0,0 +1,12 @@ +{form filterTaskForm} +