Skip to content

Commit f8d31dc

Browse files
committed
Merge branch 'release'
2 parents 0c2923d + 684f49e commit f8d31dc

File tree

62 files changed

+1548
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1548
-447
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
CHANGELOG for 1.0.0-alpha4
2+
===================
3+
* 1.0.0-alpha4 (2013-07-31)
4+
* Address Types Management. Added ability to set different type for addresses in Contact address book
5+
16
CHANGELOG for 1.0.0-alpha3
27
===================
38

src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ public function updateAction(Account $entity = null)
117117
return $this->get('oro_grid.renderer')->renderResultsJsonResponse($datagridView);
118118
}
119119

120-
$backUrl = $this->generateUrl('orocrm_account_index');
121-
122120
if ($this->get('orocrm_account.form.handler.account')->process($entity)) {
123121
$this->getFlashBag()->add('success', 'Account successfully saved');
124-
return $this->redirect($backUrl);
122+
123+
return $this->get('oro_ui.router')->actionRedirect(
124+
array(
125+
'route' => 'orocrm_account_update',
126+
'parameters' => array('id' => $entity->getId()),
127+
),
128+
array(
129+
'route' => 'orocrm_account_index',
130+
)
131+
);
125132
}
126133

127134
return array(

src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php

+43-27
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
namespace OroCRM\Bundle\AccountBundle\Datagrid;
44

5-
use Oro\Bundle\GridBundle\Datagrid\FlexibleDatagridManager;
65
use Oro\Bundle\GridBundle\Field\FieldDescriptionCollection;
76
use Oro\Bundle\GridBundle\Field\FieldDescription;
87
use Oro\Bundle\GridBundle\Field\FieldDescriptionInterface;
98
use Oro\Bundle\GridBundle\Filter\FilterInterface;
109
use Oro\Bundle\GridBundle\Sorter\SorterInterface;
1110
use Oro\Bundle\GridBundle\Datagrid\ParametersInterface;
1211
use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface;
12+
use Oro\Bundle\GridBundle\Datagrid\ORM\QueryFactory\EntityQueryFactory;
1313

1414
class AccountContactUpdateDatagridManager extends AccountContactDatagridManager
1515
{
16+
/**
17+
* @var string
18+
*/
19+
protected $hasAccountExpression;
20+
1621
/**
1722
* {@inheritDoc}
1823
*/
@@ -22,16 +27,17 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
2227
$fieldHasAccount->setName('has_account');
2328
$fieldHasAccount->setOptions(
2429
array(
25-
'type' => FieldDescriptionInterface::TYPE_BOOLEAN,
26-
'label' => $this->translate('Assigned'),
27-
'field_name' => 'hasCurrentAccount',
28-
'expression' => 'hasCurrentAccount',
29-
'nullable' => false,
30-
'editable' => true,
31-
'sortable' => true,
32-
'filter_type' => FilterInterface::TYPE_BOOLEAN,
33-
'filterable' => true,
34-
'show_filter' => true,
30+
'type' => FieldDescriptionInterface::TYPE_BOOLEAN,
31+
'label' => $this->translate('Assigned'),
32+
'field_name' => 'hasCurrentAccount',
33+
'expression' => $this->getHasAccountExpression(),
34+
'nullable' => false,
35+
'editable' => true,
36+
'sortable' => true,
37+
'filter_type' => FilterInterface::TYPE_BOOLEAN,
38+
'filterable' => true,
39+
'show_filter' => true,
40+
'filter_by_where' => true,
3541
)
3642
);
3743
$fieldsCollection->add($fieldHasAccount);
@@ -46,24 +52,34 @@ protected function prepareQuery(ProxyQueryInterface $query)
4652
{
4753
$this->applyJoinWithAddressAndCountry($query);
4854

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

51-
if ($this->getAccount()->getId()) {
52-
$query->addSelect(
53-
"CASE WHEN " .
54-
"(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " .
55-
"$entityAlias.id NOT IN (:data_not_in) ".
56-
"THEN 1 ELSE 0 END AS hasCurrentAccount",
57-
true
58-
);
59-
} else {
60-
$query->addSelect(
61-
"CASE WHEN " .
62-
"$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ".
63-
"THEN 1 ELSE 0 END AS hasCurrentAccount",
64-
true
65-
);
58+
/**
59+
* @return string
60+
*/
61+
protected function getHasAccountExpression()
62+
{
63+
if (null === $this->hasAccountExpression) {
64+
/** @var EntityQueryFactory $queryFactory */
65+
$queryFactory = $this->queryFactory;
66+
$entityAlias = $queryFactory->getAlias();
67+
68+
if ($this->getAccount()->getId()) {
69+
$this->hasAccountExpression =
70+
"CASE WHEN " .
71+
"(:account MEMBER OF $entityAlias.accounts OR $entityAlias.id IN (:data_in)) AND " .
72+
"$entityAlias.id NOT IN (:data_not_in) ".
73+
"THEN true ELSE false END";
74+
} else {
75+
$this->hasAccountExpression =
76+
"CASE WHEN " .
77+
"$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ".
78+
"THEN true ELSE false END";
79+
}
6680
}
81+
82+
return $this->hasAccountExpression;
6783
}
6884

6985
/**

src/OroCRM/Bundle/AccountBundle/Entity/Account.php

+37-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
1313

14-
use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible;
1514
use OroCRM\Bundle\ContactBundle\Entity\Contact;
15+
16+
use Oro\Bundle\TagBundle\Entity\Taggable;
17+
use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible;
1618
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro;
1719

1820
/**
@@ -21,7 +23,7 @@
2123
* @ORM\HasLifecycleCallbacks()
2224
* @Oro\Loggable
2325
*/
24-
class Account extends AbstractEntityFlexible
26+
class Account extends AbstractEntityFlexible implements Taggable
2527
{
2628
/**
2729
* @ORM\Id
@@ -62,6 +64,11 @@ class Account extends AbstractEntityFlexible
6264
*/
6365
protected $values;
6466

67+
/**
68+
* @var ArrayCollection $tags
69+
*/
70+
protected $tags;
71+
6572
public function __construct()
6673
{
6774
parent::__construct();
@@ -185,4 +192,32 @@ public function doPreUpdate()
185192
{
186193
$this->updated = new \DateTime('now', new \DateTimeZone('UTC'));
187194
}
195+
196+
/**
197+
* {@inheritdoc}
198+
*/
199+
public function getTaggableId()
200+
{
201+
return $this->getId();
202+
}
203+
204+
/**
205+
* {@inheritdoc}
206+
*/
207+
public function getTags()
208+
{
209+
$this->tags = $this->tags ?: new ArrayCollection();
210+
211+
return $this->tags;
212+
}
213+
214+
/**
215+
* {@inheritdoc}
216+
*/
217+
public function setTags($tags)
218+
{
219+
$this->tags = $tags;
220+
221+
return $this;
222+
}
188223
}

src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use Symfony\Component\Form\FormInterface;
66
use Symfony\Component\HttpFoundation\Request;
7-
87
use Doctrine\Common\Persistence\ObjectManager;
8+
9+
use Oro\Bundle\TagBundle\Entity\TagManager;
910
use OroCRM\Bundle\AccountBundle\Entity\Account;
1011
use OroCRM\Bundle\ContactBundle\Entity\Contact;
12+
use Oro\Bundle\TagBundle\Form\Handler\TagHandlerInterface;
1113

12-
class AccountHandler
14+
class AccountHandler implements TagHandlerInterface
1315
{
1416
/**
1517
* @var FormInterface
@@ -26,6 +28,11 @@ class AccountHandler
2628
*/
2729
protected $manager;
2830

31+
/**
32+
* @var TagManager
33+
*/
34+
protected $tagManager;
35+
2936
/**
3037
*
3138
* @param FormInterface $form
@@ -50,7 +57,7 @@ public function process(Account $entity)
5057
$this->form->setData($entity);
5158

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

5562
if ($this->form->isValid()) {
5663
$appendContacts = $this->form->get('appendContacts')->getData();
@@ -75,8 +82,10 @@ protected function onSuccess(Account $entity, array $appendContacts, array $remo
7582
{
7683
$this->appendContacts($entity, $appendContacts);
7784
$this->removeContacts($entity, $removeContacts);
85+
7886
$this->manager->persist($entity);
7987
$this->manager->flush();
88+
$this->tagManager->saveTagging($entity);
8089
}
8190

8291
/**
@@ -104,4 +113,12 @@ protected function removeContacts(Account $account, array $contacts)
104113
$account->removeContact($contact);
105114
}
106115
}
116+
117+
/**
118+
* {@inheritdoc}
119+
*/
120+
public function setTagManager(TagManager $tagManager)
121+
{
122+
$this->tagManager = $tagManager;
123+
}
107124
}

src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public function addEntityFields(FormBuilderInterface $builder)
2727
)
2828
);
2929

30+
// tags
31+
$builder->add(
32+
'tags',
33+
'oro_tag_select'
34+
);
35+
3036
// contacts
3137
$builder->add(
3238
'appendContacts',

src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml

-4
This file was deleted.

src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ oro_menu_config:
1010
route: 'orocrm_account_index'
1111
extras:
1212
routes: ['orocrm_account_*']
13+
description: List of accounts
1314

1415
shortcut_new_account:
1516
label: Create new account
@@ -36,7 +37,7 @@ oro_menu_config:
3637
shortcut_list_accounts: ~
3738

3839
oro_titles:
39-
orocrm_account_index: Accounts
40-
orocrm_account_view: %%account.name%% - Accounts
40+
orocrm_account_index: ~
41+
orocrm_account_view: %%account.name%%
4142
orocrm_account_create: Create Account
42-
orocrm_account_update: %%account.name%% - Accounts
43+
orocrm_account_update: %%account.name%%

src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ services:
6262
- @orocrm_account.form.account
6363
- @request
6464
- @doctrine.orm.entity_manager
65+
tags:
66+
- { name: oro_tag.tag_manager }
6567

6668
# Form type
6769
orocrm_account.form.type.account_select:
@@ -124,6 +126,8 @@ services:
124126
- @orocrm_account.form.account.api
125127
- @request
126128
- @doctrine.orm.entity_manager
129+
tags:
130+
- { name: oro_tag.tag_manager }
127131

128132
orocrm_account.form.autocomplete.account.search_handler:
129133
parent: oro_form.autocomplete.search_handler

src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{#
22
Available variables:
3-
* entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account
3+
* entity - user entity OroCRM\Bundle\AccountBundle\Entity\Account or null
44
* indexer_item - indexer item Oro\Bundle\SearchBundle\Query\Result\Item
55
#}
66
{% extends 'OroSearchBundle:Search:searchResultItem.html.twig' %}
@@ -9,11 +9,9 @@
99
{% set format = oro_config_value('oro_user.name_format') %}
1010
{% set showImage = false %}
1111

12-
{% if entity %}
13-
{% set recordUrl = indexer_item.recordUrl %}
14-
{% endif %}
15-
12+
{% set recordUrl = indexer_item.recordUrl %}
1613
{% set title = indexer_item.recordTitle %}
14+
1715
{% set entityType = 'Account'|trans %}
1816

1917
{% set entityInfo = [

src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig

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

4446
{% block pageHeader %}
@@ -66,7 +68,8 @@
6668
{
6769
'title': 'Basic Information',
6870
'data': [
69-
form_row(form.name)
71+
form_row(form.name),
72+
_tag.tagInputField('Tags', form)
7073
]
7174
}
7275
]

0 commit comments

Comments
 (0)