Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
# Changelog

 - FEATURE     #137   Added daterange to csv export overlay for sulu 1.5
 - BUGFIX      #135   Fixed missing translation and documentation
 - ENHANCEMENT #134   Added missing documentation
 - BUGFIX      #133   Fixed success email not sent to email in data json
 - BUGFIX      #132   Fixed missing uniqueness in form fields table
 - BUGFIX      #131   Fixed permission denied on fields action
 - FEATURE     #130   Added toggler to set email as replyTo
 - BUGFIX      #111   Fixed exception controller redirect
 - BUGFIX      #125   Fixed form select by using native select
 - FEATURE     #118   Added media collection strategy tree
 - FEATURE     #124   Added support to add dynamic list to article bundle
 - BUGFIX      #123   Fixed csv export for bool values
 - ENHANCEMENT #122   Fixed sort on dynamic list and removed search
 - FEATURE     #121   Added dynamic form list and export
 - BUGFIX      #120   Fixed permission problem on false locale
 - BUGFIX      #117   Fixed limitation of content type select
 - FEATURE     #115   Added options for attachment validation
 - BUGFIX      #114   Fixed multiple choices to text type columns
 - BUGFIX      #113   Fixed naming of mailchimp parameters
 - BUGFIX      #112   Fixed id of serialized dynamic array
 - BUGFIX      #106   Fixed datefield and add birthday option
 - ENHANCEMENT #105   Added new form layout
 - FEATURE     #102   Added recaptcha support with EWZRecaptchaBundle
 - ENHANCEMENT #101   Change mail settings options to toggler
 - FEATURE     #100   Added page based list output
 - BUGFIX      #99    Fixed csrf token esi for varnish
 - BUGFIX      #97    Fixed edit symbol on list
 - BUGFIX      #96    Fix inversedBy value at FormField#form property
 - FEATURE     #92    Clean up the backend view
 - FEATURE     #92    Added last flag for grid and update documentation
 - BUGFIX      #85    Fixed MailChimp-Key parameter in FormController
  • Loading branch information
alexander-schranz authored Feb 5, 2017
2 parents 0a404ec + ecf14aa commit ad43db8
Show file tree
Hide file tree
Showing 74 changed files with 3,653 additions and 1,097 deletions.
58 changes: 58 additions & 0 deletions Admin/DynamicListNavigationProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace L91\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@l91suluform');
$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;
}
}
65 changes: 51 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,60 @@
# Changelog

## 1.0.0

- FEATURE #137 Added daterange to csv export overlay for sulu 1.5
- BUGFIX #140 Fixed date type default value
- BUGFIX #139 Fixed form preview request analyzer
- BUGFIX #138 Fixed second date field type
- BUGFIX #135 Fixed missing translation and documentation
- ENHANCEMENT #134 Added missing documentation
- BUGFIX #133 Fixed success email not sent to email in data json
- BUGFIX #132 Fixed missing uniqueness in form fields table
- BUGFIX #131 Fixed permission denied on fields action
- FEATURE #130 Added toggler to set email as replyTo
- BUGFIX #111 Fixed exception controller redirect
- BUGFIX #125 Fixed form select by using native select
- FEATURE #118 Added media collection strategy tree
- FEATURE #124 Added support to add dynamic list to article bundle
- BUGFIX #123 Fixed csv export for bool values
- ENHANCEMENT #122 Fixed sort on dynamic list and removed search
- FEATURE #121 Added dynamic form list and export
- BUGFIX #120 Fixed permission problem on false locale
- BUGFIX #117 Fixed limitation of content type select
- FEATURE #115 Added options for attachment validation
- BUGFIX #114 Fixed multiple choices to text type columns
- BUGFIX #113 Fixed naming of mailchimp parameters
- BUGFIX #112 Fixed id of serialized dynamic array
- BUGFIX #106 Fixed datefield and add birthday option
- ENHANCEMENT #105 Added new form layout
- FEATURE #102 Added recaptcha support with EWZRecaptchaBundle
- ENHANCEMENT #101 Change mail settings options to toggler
- FEATURE #100 Added page based list output
- BUGFIX #99 Fixed csrf token esi for varnish
- BUGFIX #97 Fixed edit symbol on list
- BUGFIX #96 Fix inversedBy value at FormField#form property
- FEATURE #92 Clean up the backend view
- FEATURE #92 Added last flag for grid and update documentation
- BUGFIX #85 Fixed MailChimp-Key parameter in FormController

## 1.0.0-RC4

- BUGFIX #80 Fixed getCustomerDeactivateMails and getNotifyDeactivateMails Method
- BUGFIX #79 Fixed resolver of configureOptions in AbstractType
- BUGFIX #80 Fixed getCustomerDeactivateMails and getNotifyDeactivateMails Method
- BUGFIX #79 Fixed resolver of configureOptions in AbstractType

## 1.0.0-RC3

- FEATURE #74 Added mailchimp field type (requires https://github.com/drewm/mailchimp-api)
- BUGFIX #76 Fixed csrf token generation in esi
- BUGFIX #75 Fixed csrf token generation for dynamic form
- FEATURE #73 Added type sort after translation function
- FEATURE #74 Added mailchimp field type (requires https://github.com/drewm/mailchimp-api)
- BUGFIX #76 Fixed csrf token generation in esi
- BUGFIX #75 Fixed csrf token generation for dynamic form
- FEATURE #73 Added type sort after translation function

## 1.0.0-RC2
- BUGFIX #70 Fixed token esi response header
- BUGFIX #71 Fixed customer emails for dynamic forms
- FEATURE #68 Added checkboxes to deactivate notify and success emails
- FEATURE #67 Added sixths widths to fields
- BUGFIX #66 Fixed that dynamic is related to a form
- BUGFIX #65 Unlimited title column and changed string to text

- BUGFIX #70 Fixed token esi response header
- BUGFIX #71 Fixed customer emails for dynamic forms
- FEATURE #68 Added checkboxes to deactivate notify and success emails
- FEATURE #67 Added sixths widths to fields
- BUGFIX #66 Fixed that dynamic is related to a form
- BUGFIX #65 Unlimited title column and changed string to text

141 changes: 20 additions & 121 deletions Content/Types/FormSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

namespace L91\Sulu\Bundle\FormBundle\Content\Types;

use Doctrine\ORM\NoResultException;
use L91\Sulu\Bundle\FormBundle\Entity\Dynamic;
use L91\Sulu\Bundle\FormBundle\Event\DynFormSavedEvent;
use L91\Sulu\Bundle\FormBundle\Form\HandlerInterface;
use L91\Sulu\Bundle\FormBundle\Form\Type\DynamicFormType;
use L91\Sulu\Bundle\FormBundle\Form\BuilderInterface;
use L91\Sulu\Bundle\FormBundle\Repository\FormRepository;
use Sulu\Component\Content\Compat\PropertyInterface;
use Sulu\Component\Content\SimpleContentType;
use Sulu\Component\Media\SystemCollections\SystemCollectionManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Form\FormInterface;

/**
* ContentType for selecting a form.
Expand All @@ -32,58 +24,26 @@ class FormSelect extends SimpleContentType
private $formRepository;

/**
* @var RequestStack
* @var BuilderInterface
*/
private $requestStack;

/**
* @var FormFactoryInterface
*/
private $formFactory;

/**
* @var HandlerInterface
*/
private $formHandler;

/**
* @var SystemCollectionManagerInterface
*/
private $systemCollectionManager;

/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private $formBuilder;

/**
* FormSelect constructor.
*
* @param string $template
* @param FormRepository $formRepository
* @param RequestStack $requestStack
* @param FormFactoryInterface $formFactory
* @param HandlerInterface $formHandler
* @param SystemCollectionManagerInterface $systemCollectionManager
* @param EventDispatcherInterface $eventDispatcher
* @param BuilderInterface $formBuilder
*/
public function __construct(
$template,
FormRepository $formRepository,
RequestStack $requestStack,
FormFactoryInterface $formFactory,
HandlerInterface $formHandler,
SystemCollectionManagerInterface $systemCollectionManager,
EventDispatcherInterface $eventDispatcher
BuilderInterface $formBuilder
) {
parent::__construct('FormSelect', '');
$this->template = $template;
$this->formRepository = $formRepository;
$this->requestStack = $requestStack;
$this->formFactory = $formFactory;
$this->formHandler = $formHandler;
$this->systemCollectionManager = $systemCollectionManager;
$this->eventDispatcher = $eventDispatcher;
$this->formBuilder = $formBuilder;
}

/**
Expand All @@ -97,82 +57,21 @@ public function getContentData(PropertyInterface $property)
return;
}

$request = $this->requestStack->getCurrentRequest();

$form = null;

try {
// Create Dynamic Data
$uuid = $property->getStructure()->getUuid();
$webspaceKey = $property->getStructure()->getWebspaceKey();
$locale = $property->getStructure()->getLanguageCode();
$formEntity = $this->formRepository->findById($id, $locale);

// set Defaults
$defaults = [];
foreach ($formEntity->getFields() as $field) {
$translation = $field->getTranslation($locale);

if ($translation && $translation->getDefaultValue()) {
$value = $translation->getDefaultValue();

// handle special types
switch ($field->getType()) {
case Dynamic::TYPE_DATE:
$value = new \DateTime($value);
break;
case Dynamic::TYPE_DROPDOWN_MULTIPLE:
case Dynamic::TYPE_CHECKBOX_MULTIPLE:
$value = preg_split('/\r\n|\r|\n/', $value, -1, PREG_SPLIT_NO_EMPTY);
break;
}

$defaults[$field->getKey()] = $value;
}
}

// Create Form Type
$formType = new DynamicFormType(
$formEntity,
$locale,
$property->getName(),
$property->getStructure()->getView(),
$this->systemCollectionManager->getSystemCollection('l91_sulu_form.attachments')
);

$form = $this->formFactory->create(
$formType,
new Dynamic($uuid, $locale, $formEntity, $webspaceKey, $defaults)
);

// handle request
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$serializedObject = $formEntity->serializeForLocale($locale, $form->getData());

// save
$this->formHandler->handle(
$form,
[
'_form_type' => $formType,
'formEntity' => $serializedObject,
]
);

$event = new DynFormSavedEvent($serializedObject);
$this->eventDispatcher->dispatch(DynFormSavedEvent::NAME, $event);

// Do redirect after success
throw new HttpException(302, null, null, ['Location' => '?send=true']);
}

return $form->createView();
} catch (NoResultException $e) {
// do nothing
/** @var FormInterface $form */
list($formType, $form) = $this->formBuilder->build(
$id,
'page',
$property->getStructure()->getUuid(),
$property->getStructure()->getProperty('title')->getValue(),
$property->getStructure()->getLanguageCode(),
$property->getName()
);

if (!$form) {
return;
}

return;
return $form->createView();
}

/**
Expand Down
Loading

0 comments on commit ad43db8

Please sign in to comment.