Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Jul 31, 2013
2 parents 0c2923d + 684f49e commit f8d31dc
Show file tree
Hide file tree
Showing 62 changed files with 1,548 additions and 447 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
CHANGELOG for 1.0.0-alpha4
===================
* 1.0.0-alpha4 (2013-07-31)
* Address Types Management. Added ability to set different type for addresses in Contact address book

CHANGELOG for 1.0.0-alpha3
===================

Expand Down
13 changes: 10 additions & 3 deletions src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,18 @@ public function updateAction(Account $entity = null)
return $this->get('oro_grid.renderer')->renderResultsJsonResponse($datagridView);
}

$backUrl = $this->generateUrl('orocrm_account_index');

if ($this->get('orocrm_account.form.handler.account')->process($entity)) {
$this->getFlashBag()->add('success', 'Account successfully saved');
return $this->redirect($backUrl);

return $this->get('oro_ui.router')->actionRedirect(
array(
'route' => 'orocrm_account_update',
'parameters' => array('id' => $entity->getId()),
),
array(
'route' => 'orocrm_account_index',
)
);
}

return array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

namespace OroCRM\Bundle\AccountBundle\Datagrid;

use Oro\Bundle\GridBundle\Datagrid\FlexibleDatagridManager;
use Oro\Bundle\GridBundle\Field\FieldDescriptionCollection;
use Oro\Bundle\GridBundle\Field\FieldDescription;
use Oro\Bundle\GridBundle\Field\FieldDescriptionInterface;
use Oro\Bundle\GridBundle\Filter\FilterInterface;
use Oro\Bundle\GridBundle\Sorter\SorterInterface;
use Oro\Bundle\GridBundle\Datagrid\ParametersInterface;
use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface;
use Oro\Bundle\GridBundle\Datagrid\ORM\QueryFactory\EntityQueryFactory;

class AccountContactUpdateDatagridManager extends AccountContactDatagridManager
{
/**
* @var string
*/
protected $hasAccountExpression;

/**
* {@inheritDoc}
*/
Expand All @@ -22,16 +27,17 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
$fieldHasAccount->setName('has_account');
$fieldHasAccount->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_BOOLEAN,
'label' => $this->translate('Assigned'),
'field_name' => 'hasCurrentAccount',
'expression' => 'hasCurrentAccount',
'nullable' => false,
'editable' => true,
'sortable' => true,
'filter_type' => FilterInterface::TYPE_BOOLEAN,
'filterable' => true,
'show_filter' => true,
'type' => FieldDescriptionInterface::TYPE_BOOLEAN,
'label' => $this->translate('Assigned'),
'field_name' => 'hasCurrentAccount',
'expression' => $this->getHasAccountExpression(),
'nullable' => false,
'editable' => true,
'sortable' => true,
'filter_type' => FilterInterface::TYPE_BOOLEAN,
'filterable' => true,
'show_filter' => true,
'filter_by_where' => true,
)
);
$fieldsCollection->add($fieldHasAccount);
Expand All @@ -46,24 +52,34 @@ protected function prepareQuery(ProxyQueryInterface $query)
{
$this->applyJoinWithAddressAndCountry($query);

$entityAlias = $query->getRootAlias();
$query->addSelect($this->getHasAccountExpression() . ' AS hasCurrentAccount', true);
}

if ($this->getAccount()->getId()) {
$query->addSelect(
"CASE WHEN " .
"(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " .
"$entityAlias.id NOT IN (:data_not_in) ".
"THEN 1 ELSE 0 END AS hasCurrentAccount",
true
);
} else {
$query->addSelect(
"CASE WHEN " .
"$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ".
"THEN 1 ELSE 0 END AS hasCurrentAccount",
true
);
/**
* @return string
*/
protected function getHasAccountExpression()
{
if (null === $this->hasAccountExpression) {
/** @var EntityQueryFactory $queryFactory */
$queryFactory = $this->queryFactory;
$entityAlias = $queryFactory->getAlias();

if ($this->getAccount()->getId()) {
$this->hasAccountExpression =
"CASE WHEN " .
"(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " .
"$entityAlias.id NOT IN (:data_not_in) ".
"THEN true ELSE false END";
} else {
$this->hasAccountExpression =
"CASE WHEN " .
"$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ".
"THEN true ELSE false END";
}
}

return $this->hasAccountExpression;
}

/**
Expand Down
39 changes: 37 additions & 2 deletions src/OroCRM/Bundle/AccountBundle/Entity/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible;
use OroCRM\Bundle\ContactBundle\Entity\Contact;

use Oro\Bundle\TagBundle\Entity\Taggable;
use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible;
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro;

/**
Expand All @@ -21,7 +23,7 @@
* @ORM\HasLifecycleCallbacks()
* @Oro\Loggable
*/
class Account extends AbstractEntityFlexible
class Account extends AbstractEntityFlexible implements Taggable
{
/**
* @ORM\Id
Expand Down Expand Up @@ -62,6 +64,11 @@ class Account extends AbstractEntityFlexible
*/
protected $values;

/**
* @var ArrayCollection $tags
*/
protected $tags;

public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -185,4 +192,32 @@ public function doPreUpdate()
{
$this->updated = new \DateTime('now', new \DateTimeZone('UTC'));
}

/**
* {@inheritdoc}
*/
public function getTaggableId()
{
return $this->getId();
}

/**
* {@inheritdoc}
*/
public function getTags()
{
$this->tags = $this->tags ?: new ArrayCollection();

return $this->tags;
}

/**
* {@inheritdoc}
*/
public function setTags($tags)
{
$this->tags = $tags;

return $this;
}
}
23 changes: 20 additions & 3 deletions src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;

use Doctrine\Common\Persistence\ObjectManager;

use Oro\Bundle\TagBundle\Entity\TagManager;
use OroCRM\Bundle\AccountBundle\Entity\Account;
use OroCRM\Bundle\ContactBundle\Entity\Contact;
use Oro\Bundle\TagBundle\Form\Handler\TagHandlerInterface;

class AccountHandler
class AccountHandler implements TagHandlerInterface
{
/**
* @var FormInterface
Expand All @@ -26,6 +28,11 @@ class AccountHandler
*/
protected $manager;

/**
* @var TagManager
*/
protected $tagManager;

/**
*
* @param FormInterface $form
Expand All @@ -50,7 +57,7 @@ public function process(Account $entity)
$this->form->setData($entity);

if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
$this->form->bind($this->request);
$this->form->submit($this->request);

if ($this->form->isValid()) {
$appendContacts = $this->form->get('appendContacts')->getData();
Expand All @@ -75,8 +82,10 @@ protected function onSuccess(Account $entity, array $appendContacts, array $remo
{
$this->appendContacts($entity, $appendContacts);
$this->removeContacts($entity, $removeContacts);

$this->manager->persist($entity);
$this->manager->flush();
$this->tagManager->saveTagging($entity);
}

/**
Expand Down Expand Up @@ -104,4 +113,12 @@ protected function removeContacts(Account $account, array $contacts)
$account->removeContact($contact);
}
}

/**
* {@inheritdoc}
*/
public function setTagManager(TagManager $tagManager)
{
$this->tagManager = $tagManager;
}
}
6 changes: 6 additions & 0 deletions src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function addEntityFields(FormBuilderInterface $builder)
)
);

// tags
$builder->add(
'tags',
'oro_tag_select'
);

// contacts
$builder->add(
'appendContacts',
Expand Down
4 changes: 0 additions & 4 deletions src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ oro_menu_config:
route: 'orocrm_account_index'
extras:
routes: ['orocrm_account_*']
description: List of accounts

shortcut_new_account:
label: Create new account
Expand All @@ -36,7 +37,7 @@ oro_menu_config:
shortcut_list_accounts: ~

oro_titles:
orocrm_account_index: Accounts
orocrm_account_view: %%account.name%% - Accounts
orocrm_account_index: ~
orocrm_account_view: %%account.name%%
orocrm_account_create: Create Account
orocrm_account_update: %%account.name%% - Accounts
orocrm_account_update: %%account.name%%
4 changes: 4 additions & 0 deletions src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ services:
- @orocrm_account.form.account
- @request
- @doctrine.orm.entity_manager
tags:
- { name: oro_tag.tag_manager }

# Form type
orocrm_account.form.type.account_select:
Expand Down Expand Up @@ -124,6 +126,8 @@ services:
- @orocrm_account.form.account.api
- @request
- @doctrine.orm.entity_manager
tags:
- { name: oro_tag.tag_manager }

orocrm_account.form.autocomplete.account.search_handler:
parent: oro_form.autocomplete.search_handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
Available variables:
* entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account
* entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account or null
* indexer_item - indexer item Oro\Bundle\SearchBundle\Query\Result\Item
#}
{% extends 'OroSearchBundle:Search:searchResultItem.html.twig' %}
Expand All @@ -9,11 +9,9 @@
{% set format = oro_config_value('oro_user.name_format') %}
{% set showImage = false %}

{% if entity %}
{% set recordUrl = indexer_item.recordUrl %}
{% endif %}

{% set recordUrl = indexer_item.recordUrl %}
{% set title = indexer_item.recordTitle %}

{% set entityType = 'Account'|trans %}

{% set entityInfo = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'OroUIBundle:actions:update.html.twig' %}
{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig'] %}
{% import 'OroTagBundle::macros.html.twig' as _tag %}
{% form_theme form with ['OroAddressBundle:Include:fields.html.twig', 'OroFormBundle:Form:fields.html.twig', 'OroTagBundle:Form:fields.html.twig'] %}
{% set format = oro_config_value('oro_user.name_format') %}
{% set title = form.vars.value.id ? form.vars.value.fullname(format)|default('N/A') ~ ' - ' ~ 'Update Account'|trans : 'New Account'|trans %}
{% oro_title_set({params : {"%account.name%": form.vars.value.name|default('N/A')} }) %}
Expand Down Expand Up @@ -38,7 +39,8 @@
{{ UI.buttonSeparator() }}
{% endif %}
{{ UI.button({'path' : path('orocrm_account_index'), 'title' : 'Cancel', 'label' : 'Cancel'}) }}
{{ UI.buttonType({'type': 'submit', 'class': 'btn-success', 'label': 'Save'}) }}
{{ UI.saveAndStayButton() }}
{{ UI.saveAndCloseButton() }}
{% endblock %}

{% block pageHeader %}
Expand Down Expand Up @@ -66,7 +68,8 @@
{
'title': 'Basic Information',
'data': [
form_row(form.name)
form_row(form.name),
_tag.tagInputField('Tags', form)
]
}
]
Expand Down

0 comments on commit f8d31dc

Please sign in to comment.