-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update sulu from
alexander-schranz/sulu-form-bundle
from commit `c1…
…10e72e44a58a0f53428c153e405124695506f6` - BUGFIX #24 Fixed form preview request analyzer - BUGFIX #24 Fixed second date field type - BUGFIX #24 Fixed missing translation and documentation - ENHANCEMENT #24 Added missing documentation - BUGFIX #24 Fixed success email not sent to email in data json - BUGFIX #24 Fixed missing uniqueness in form fields table - BUGFIX #24 Fixed permission denied on fields action - FEATURE #24 Added toggler to set email as replyTo - BUGFIX #24 Fixed exception controller redirect - BUGFIX #24 Fixed form select by using native select - FEATURE #24 Added media collection strategy tree - FEATURE #24 Added support to add dynamic list to article bundle - BUGFIX #24 Fixed csv export for bool values - ENHANCEMENT #24 Fixed sort on dynamic list and removed search - FEATURE #24 Added dynamic form list and export
- Loading branch information
Showing
47 changed files
with
2,160 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Sulu\Bundle\FormBundle\Admin; | ||
|
||
use Sulu\Bundle\AdminBundle\Navigation\ContentNavigationItem; | ||
use Sulu\Bundle\AdminBundle\Navigation\ContentNavigationProviderInterface; | ||
use Sulu\Bundle\AdminBundle\Navigation\DisplayCondition; | ||
|
||
/** | ||
* Register new tab for dynamic list to specific template. | ||
*/ | ||
class DynamicListNavigationProvider implements ContentNavigationProviderInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* DynamicListNavigationProvider constructor. | ||
* | ||
* @param array $config | ||
*/ | ||
public function __construct(array $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getNavigationItems(array $options = []) | ||
{ | ||
$items = []; | ||
|
||
foreach ($this->config as $templateKey => $config) { | ||
$item = new ContentNavigationItem('Formular'); | ||
$item->setAction('form-list'); | ||
$item->setDisplay(['edit']); | ||
$item->setComponent('dynamics/list@suluform'); | ||
$item->setComponentOptions([ | ||
'template' => $templateKey, | ||
'property' => $config['property'], | ||
'view' => isset($config['view']) ? $config['view'] : 'default', | ||
]); | ||
|
||
$item->setDisplayConditions( | ||
[ | ||
new DisplayCondition('template', DisplayCondition::OPERATOR_EQUAL, $templateKey), | ||
] | ||
); | ||
|
||
$items[] = $item; | ||
} | ||
|
||
return $items; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
namespace Sulu\Bundle\FormBundle\Controller; | ||
|
||
use FOS\RestBundle\Routing\ClassResourceInterface; | ||
use Sulu\Bundle\FormBundle\Entity\Form; | ||
use Sulu\Component\Rest\ListBuilder\ListRepresentation; | ||
use Sulu\Component\Rest\RestController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
|
||
/** | ||
* Controller to create dynamic form entries list. | ||
*/ | ||
class DynamicController extends RestController implements ClassResourceInterface | ||
{ | ||
/** | ||
* Return dynamic form entries. | ||
* | ||
* @param Request $request | ||
* | ||
* @return Response | ||
*/ | ||
public function cgetAction(Request $request) | ||
{ | ||
$repository = $this->get('sulu_form.repository.dynamic'); | ||
|
||
$filters = $this->getFilters($request); | ||
$page = $request->get('page', 1); | ||
$limit = $request->get('limit'); | ||
$offset = (($page - 1) * $limit); | ||
$view = $request->get('view', 'default'); | ||
$sortOrder = $request->get('sortOrder', 'asc'); | ||
$sortBy = $request->get('sortBy', 'created'); | ||
|
||
$entries = $repository->findBy( | ||
$filters, | ||
[$sortBy => $sortOrder], | ||
$limit, | ||
$offset | ||
); | ||
|
||
$entries = $this->get('sulu_form.list_builder.dynamic_list_factory')->build($entries, $view); | ||
|
||
// avoid total request when entries < limit | ||
if (count($entries) == $limit) { | ||
$total = count($repository->findBy($filters)); | ||
} else { | ||
// calculate total | ||
$total = count($entries) + $offset; | ||
} | ||
|
||
// create list representation | ||
$representation = new ListRepresentation( | ||
$entries, | ||
'dynamics', | ||
$request->get('_route'), | ||
$request->query->all(), | ||
$page, | ||
$limit, | ||
$total | ||
); | ||
|
||
return $this->handleView($this->view($representation)); | ||
} | ||
|
||
/** | ||
* Returns the fields for a dynamic form. | ||
* | ||
* @param Request $request | ||
* | ||
* @return Response | ||
*/ | ||
public function cgetFieldsAction(Request $request) | ||
{ | ||
$form = $this->loadForm($request); | ||
$locale = $request->getLocale(); | ||
|
||
$fieldDescriptors = $this->get('sulu_form.list_builder.dynamic_list_factory') | ||
->getFieldDescriptors($form, $locale); | ||
|
||
return $this->handleView($this->view(array_values($fieldDescriptors))); | ||
} | ||
|
||
/** | ||
* Get filters. | ||
* | ||
* @param Request $request | ||
* | ||
* @return array | ||
*/ | ||
protected function getFilters(Request $request) | ||
{ | ||
$filters = [ | ||
'uuid' => $request->get('uuid'), | ||
'webspaceKey' => $request->get('webspaceKey'), | ||
'form' => $request->get('form'), | ||
]; | ||
|
||
return array_filter($filters); | ||
} | ||
|
||
/** | ||
* Get form. | ||
* | ||
* @param Request $request | ||
* | ||
* @return Form | ||
*/ | ||
protected function loadForm(Request $request) | ||
{ | ||
$formId = (int) $request->get('form'); | ||
|
||
if (!$formId) { | ||
throw new BadRequestHttpException('"form" is required parameter'); | ||
} | ||
|
||
return $this->get('sulu_form.repository.form')->findById($formId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.