diff --git a/CHANGELOG.md b/CHANGELOG.md
index c717fb1c23d..be46d6b80e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
===================
diff --git a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php
index 83ed41fc2bf..431afb854b2 100644
--- a/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php
+++ b/src/OroCRM/Bundle/AccountBundle/Controller/AccountController.php
@@ -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(
diff --git a/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php b/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php
index 62ba165bdb0..6312fc7df0a 100644
--- a/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php
+++ b/src/OroCRM/Bundle/AccountBundle/Datagrid/AccountContactUpdateDatagridManager.php
@@ -2,7 +2,6 @@
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;
@@ -10,9 +9,15 @@
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}
*/
@@ -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);
@@ -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;
}
/**
diff --git a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php
index 27c0271f6bf..905244bd262 100644
--- a/src/OroCRM/Bundle/AccountBundle/Entity/Account.php
+++ b/src/OroCRM/Bundle/AccountBundle/Entity/Account.php
@@ -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;
/**
@@ -21,7 +23,7 @@
* @ORM\HasLifecycleCallbacks()
* @Oro\Loggable
*/
-class Account extends AbstractEntityFlexible
+class Account extends AbstractEntityFlexible implements Taggable
{
/**
* @ORM\Id
@@ -62,6 +64,11 @@ class Account extends AbstractEntityFlexible
*/
protected $values;
+ /**
+ * @var ArrayCollection $tags
+ */
+ protected $tags;
+
public function __construct()
{
parent::__construct();
@@ -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;
+ }
}
diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php
index 1b58dd34f70..9a13c39ae02 100644
--- a/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php
+++ b/src/OroCRM/Bundle/AccountBundle/Form/Handler/AccountHandler.php
@@ -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
@@ -26,6 +28,11 @@ class AccountHandler
*/
protected $manager;
+ /**
+ * @var TagManager
+ */
+ protected $tagManager;
+
/**
*
* @param FormInterface $form
@@ -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();
@@ -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);
}
/**
@@ -104,4 +113,12 @@ protected function removeContacts(Account $account, array $contacts)
$account->removeContact($contact);
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setTagManager(TagManager $tagManager)
+ {
+ $this->tagManager = $tagManager;
+ }
}
diff --git a/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php b/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php
index 23e8dc33b02..023a150b7f4 100644
--- a/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php
+++ b/src/OroCRM/Bundle/AccountBundle/Form/Type/AccountType.php
@@ -27,6 +27,12 @@ public function addEntityFields(FormBuilderInterface $builder)
)
);
+ // tags
+ $builder->add(
+ 'tags',
+ 'oro_tag_select'
+ );
+
// contacts
$builder->add(
'appendContacts',
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml
deleted file mode 100644
index 6000d9cb935..00000000000
--- a/src/OroCRM/Bundle/AccountBundle/Resources/config/assets.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-js:
- - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js'
- - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js'
- - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js'
\ No newline at end of file
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml
index 138af99dbbf..65b03524259 100644
--- a/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml
+++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/navigation.yml
@@ -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
@@ -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%%
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml
index 9febce0e18c..c6a8ec88313 100644
--- a/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml
+++ b/src/OroCRM/Bundle/AccountBundle/Resources/config/services.yml
@@ -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:
@@ -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
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig
index d26d8b2de1b..9f410ff7922 100644
--- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig
+++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/searchResult.html.twig
@@ -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' %}
@@ -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 = [
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig
index 70c3f3fcf85..06a0beef009 100644
--- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig
+++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/update.html.twig
@@ -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')} }) %}
@@ -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 %}
@@ -66,7 +68,8 @@
{
'title': 'Basic Information',
'data': [
- form_row(form.name)
+ form_row(form.name),
+ _tag.tagInputField('Tags', form)
]
}
]
diff --git a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig
index 135cfa0570a..2ef47730247 100644
--- a/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig
+++ b/src/OroCRM/Bundle/AccountBundle/Resources/views/Account/view.html.twig
@@ -1,5 +1,6 @@
{% extends 'OroUIBundle:actions:view.html.twig' %}
{% import 'OroUIBundle::macros.html.twig' as macros %}
+{% import 'OroTagBundle::macros.html.twig' as _tag %}
{% import 'OroAddressBundle:Include:viewMacro.html.twig' as addressView %}
{% set format = oro_config_value('oro_user.name_format') %}
{% oro_title_set({params : {"%account.name%": entity.name|default('N/A')} }) %}
@@ -9,7 +10,6 @@
{% endblock %}
{% block navButtons %}
- {{ UI.button({'path': path('orocrm_account_index'), 'iClass': 'icon-chevron-left ', 'title': 'Back', 'label': 'Back'}) }}
{% if resource_granted('orocrm_account_update') %}
{{ UI.button({'path': path('orocrm_account_update', {'id': entity.id}), 'iClass': 'icon-edit', 'title': 'Edit account', 'label': 'Edit'}) }}
{% endif %}
@@ -71,6 +71,11 @@
{% set additional = additional|merge([{'title' : null, 'data' : attributes}]) %}
{% endif %}
+ {% set dataSubBlocks = [UI.attibuteRow('Account Name', entity.name)] %}
+ {% if resource_granted('oro_tag_view_tag_cloud') %}
+ {% set dataSubBlocks = dataSubBlocks|merge([UI.renderAttribute('Tags', _tag.renderView(entity))]) %}
+ {% endif %}
+
{% set dataBlocks =
[
{
@@ -79,15 +84,15 @@
'subblocks': [
{
'title': 'Basic Information',
- 'data': [
- UI.attibuteRow('Account Name', entity.name),
- ]
+ 'data' : dataSubBlocks
}
]
}
]
%}
+
+
{% if (accountAddresses|length) %}
{% set dataBlocks = dataBlocks|merge([{'title' : 'Addresses', 'subblocks': accountAddresses}])%}
{% endif %}
diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php
index f79b6c074e3..e3068cdde29 100644
--- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php
+++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/RestAccountApiTest.php
@@ -12,11 +12,16 @@
*/
class RestAccountApiTest extends WebTestCase
{
- public $client = null;
+ /** @var Client */
+ protected $client;
public function setUp()
{
- $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
+ if (!isset($this->client)) {
+ $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
+ } else {
+ $this->client->restart();
+ }
}
public function testCreateAccount()
@@ -32,7 +37,7 @@ public function testCreateAccount()
)
)
);
- $this->client->request('POST', 'http://localhost/api/rest/latest/account', $request);
+ $this->client->request('POST', $this->client->generate('oro_api_post_account'), $request);
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 201);
@@ -44,9 +49,9 @@ public function testCreateAccount()
* @depends testCreateAccount
* @return array
*/
- public function testGetContact($request)
+ public function testGetAccount($request)
{
- $this->client->request('GET', 'http://localhost/api/rest/latest/accounts');
+ $this->client->request('GET', $this->client->generate('oro_api_get_accounts'));
$result = $this->client->getResponse();
$result = json_decode($result->getContent(), true);
$flag = 1;
@@ -58,7 +63,7 @@ public function testGetContact($request)
}
$this->assertEquals(0, $flag);
- $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id']);
+ $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $account['id'])));
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 200);
@@ -68,16 +73,16 @@ public function testGetContact($request)
/**
* @param $account
* @param $request
- * @depends testGetContact
+ * @depends testGetAccount
* @depends testCreateAccount
*/
- public function testUpdateContact($account, $request)
+ public function testUpdateAccount($account, $request)
{
$request['account']['attributes']['description'] .= "_Updated";
- $this->client->request('PUT', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id'], $request);
+ $this->client->request('PUT', $this->client->generate('oro_api_put_account', array('id' => $account['id'])), $request);
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 204);
- $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $account['id']);
+ $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $account['id'])));
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 200);
$result = json_decode($result->getContent(), true);
@@ -86,14 +91,14 @@ public function testUpdateContact($account, $request)
/**
* @param $contact
- * @depends testGetContact
+ * @depends testGetAccount
*/
- public function testDeleteContact($contact)
+ public function testDeleteAccount($contact)
{
- $this->client->request('DELETE', 'http://localhost/api/rest/latest/accounts' . '/' . $contact['id']);
+ $this->client->request('DELETE', $this->client->generate('oro_api_delete_account', array('id' => $contact['id'])));
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 204);
- $this->client->request('GET', 'http://localhost/api/rest/latest/accounts' . '/' . $contact['id']);
+ $this->client->request('GET', $this->client->generate('oro_api_get_account', array('id' => $contact['id'])));
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 404);
}
diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php
index 7350f8e2415..5509c9e9524 100644
--- a/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php
+++ b/src/OroCRM/Bundle/AccountBundle/Tests/Functional/API/SoapAccountApiTest.php
@@ -12,21 +12,26 @@
*/
class SoapAccountApiTest extends WebTestCase
{
- /** @var \SoapClient */
- protected $clientSoap = null;
+ /** @var Client */
+ protected $client;
public function setUp()
{
$this->markTestSkipped('BAP-717');
- $this->clientSoap = static::createClient(array(), ToolsAPI::generateWsseHeader());
+ if (!isset($this->client)) {
+ $this->client = static::createClient(array(), ToolsAPI::generateWsseHeader());
- $this->clientSoap->soap(
- "http://localhost/api/soap",
- array(
- 'location' => 'http://localhost/api/soap',
- 'soap_version' => SOAP_1_2
- )
- );
+ $this->client->soap(
+ "http://localhost/api/soap",
+ array(
+ 'location' => 'http://localhost/api/soap',
+ 'soap_version' => SOAP_1_2
+ )
+ );
+
+ } else {
+ $this->client->restart();
+ }
}
/**
@@ -37,8 +42,8 @@ public function setUp()
*/
public function testCreateAccount($request, $response)
{
- $result = $this->clientSoap->soapClient->createAccount($request);
- ToolsAPI::assertEqualsResponse($response, $result, $this->clientSoap->soapClient->__getLastResponse());
+ $result = $this->client->soapClient->createAccount($request);
+ ToolsAPI::assertEqualsResponse($response, $result, $this->client->soapClient->__getLastResponse());
return $request;
}
@@ -51,7 +56,7 @@ public function testCreateAccount($request, $response)
*/
public function testGetAccounts($request)
{
- $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000);
+ $accounts = $this->client->soapClient->getAccounts(1, 1000);
$accounts = ToolsAPI::classToArray($accounts);
$result = false;
foreach ($accounts as $account) {
@@ -72,7 +77,7 @@ public function testGetAccounts($request)
*/
public function testUpdateAccount($request, $response)
{
- $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000);
+ $accounts = $this->client->soapClient->getAccounts(1, 1000);
$accounts = ToolsAPI::classToArray($accounts);
$result = false;
foreach ($accounts as $account) {
@@ -83,9 +88,9 @@ public function testUpdateAccount($request, $response)
}
}
$request['attributes']['description'] .= '_Updated';
- $result = $this->clientSoap->soapClient->updateAccount($accountId, $request);
+ $result = $this->client->soapClient->updateAccount($accountId, $request);
$this->assertTrue($result);
- $account = $this->clientSoap->soapClient->getAccount($accountId);
+ $account = $this->client->soapClient->getAccount($accountId);
$account = ToolsAPI::classToArray($account);
$result = false;
if ($account['attributes']['description'] == $request['attributes']['description']) {
@@ -103,9 +108,9 @@ public function testUpdateAccount($request, $response)
* @depends testUpdateAccount
* @throws \Exception|\SoapFault
*/
- public function testDeleteContactGroup($request, $response)
+ public function testDeleteAccount($request, $response)
{
- $accounts = $this->clientSoap->soapClient->getAccounts(1, 1000);
+ $accounts = $this->client->soapClient->getAccounts(1, 1000);
$accounts = ToolsAPI::classToArray($accounts);
$result = false;
foreach ($accounts as $account) {
@@ -115,10 +120,10 @@ public function testDeleteContactGroup($request, $response)
break;
}
}
- $result = $this->clientSoap->soapClient->deleteAccount($accountId);
+ $result = $this->client->soapClient->deleteAccount($accountId);
$this->assertTrue($result);
try {
- $this->clientSoap->soapClient->getAccount($accountId);
+ $this->client->soapClient->getAccount($accountId);
} catch (\SoapFault $e) {
if ($e->faultcode != 'NOT_FOUND') {
throw $e;
diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php
index 653058b8a62..8bc91ceae3d 100644
--- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php
+++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Handler/AccountHandlerTest.php
@@ -51,6 +51,11 @@ protected function setUp()
$this->entity = new Account();
$this->handler = new AccountHandler($this->form, $this->request, $this->manager);
+ $this->handler->setTagManager(
+ $this->getMockBuilder('Oro\Bundle\TagBundle\Entity\TagManager')
+ ->disableOriginalConstructor()
+ ->getMock()
+ );
}
@@ -61,7 +66,7 @@ public function testProcessUnsupportedRequest()
->with($this->entity);
$this->form->expects($this->never())
- ->method('bind');
+ ->method('submit');
$this->assertFalse($this->handler->process($this->entity));
}
@@ -79,7 +84,7 @@ public function testProcessSupportedRequest($method)
->with($this->entity);
$this->form->expects($this->once())
- ->method('bind')
+ ->method('submit')
->with($this->request);
$this->assertFalse($this->handler->process($this->entity));
@@ -110,7 +115,7 @@ public function testProcessValidData()
->with($this->entity);
$this->form->expects($this->once())
- ->method('bind')
+ ->method('submit')
->with($this->request);
$this->form->expects($this->once())
diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php
index c32fcfac6c9..115a7585f39 100644
--- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php
+++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountApiTypeTest.php
@@ -55,9 +55,13 @@ public function testAddEntityFields()
->will($this->returnSelf());
$builder->expects($this->at(2))
->method('add')
- ->with('appendContacts', 'oro_entity_identifier')
+ ->with('tags', 'oro_tag_select')
->will($this->returnSelf());
$builder->expects($this->at(3))
+ ->method('add')
+ ->with('appendContacts', 'oro_entity_identifier')
+ ->will($this->returnSelf());
+ $builder->expects($this->at(4))
->method('add')
->with('removeContacts', 'oro_entity_identifier')
->will($this->returnSelf());
diff --git a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php
index 181057cf44b..68e263673ed 100644
--- a/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php
+++ b/src/OroCRM/Bundle/AccountBundle/Tests/Unit/Form/Type/AccountTypeTest.php
@@ -35,9 +35,13 @@ public function testAddEntityFields()
->will($this->returnSelf());
$builder->expects($this->at(2))
->method('add')
- ->with('appendContacts', 'oro_entity_identifier')
+ ->with('tags', 'oro_tag_select')
->will($this->returnSelf());
$builder->expects($this->at(3))
+ ->method('add')
+ ->with('appendContacts', 'oro_entity_identifier')
+ ->will($this->returnSelf());
+ $builder->expects($this->at(4))
->method('add')
->with('removeContacts', 'oro_entity_identifier')
->will($this->returnSelf());
diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php
new file mode 100644
index 00000000000..6e03222b1ca
--- /dev/null
+++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php
@@ -0,0 +1,126 @@
+getManager()->find($id);
+
+ if ($contact) {
+ $address = $contact->getAddressByTypeName($typeName);
+ } else {
+ $address = null;
+ }
+
+ $responseData = $address ? json_encode($this->getPreparedItem($address)) : '';
+
+ return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND);
+ }
+
+ /**
+ * REST GET primary address
+ *
+ * @param string $id
+ *
+ * @ApiDoc(
+ * description="Get contact primary address",
+ * resource=true
+ * )
+ * @AclAncestor("orocrm_contact_view")
+ * @return Response
+ */
+ public function getPrimaryAction($id)
+ {
+ /** @var Contact $contact */
+ $contact = $this->getManager()->find($id);
+
+ if ($contact) {
+ $address = $contact->getPrimaryAddress();
+ } else {
+ $address = null;
+ }
+
+ $responseData = $address ? json_encode($this->getPreparedItem($address)) : '';
+
+ return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getManager()
+ {
+ return $this->get('orocrm_contact.contact.manager.api');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getForm()
+ {
+ throw new \BadMethodCallException('Form is not available.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormHandler()
+ {
+ throw new \BadMethodCallException('FormHandler is not available.');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getPreparedItem($entity)
+ {
+ // convert addresses to plain array
+ $addressTypesData = array();
+
+ /** @var $entity ContactAddress */
+ foreach ($entity->getTypes() as $addressType) {
+ $addressTypesData[] = parent::getPreparedItem($addressType);
+ }
+
+ $result = parent::getPreparedItem($entity);
+ $result['types'] = $addressTypesData;
+
+ unset($result['owner']);
+
+ return $result;
+ }
+}
diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php
index e8fe6614824..66703317df2 100644
--- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php
+++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactController.php
@@ -2,23 +2,27 @@
namespace OroCRM\Bundle\ContactBundle\Controller\Api\Rest;
+use Symfony\Component\Form\FormInterface;
+use Symfony\Component\HttpFoundation\Response;
+
use FOS\RestBundle\Controller\Annotations\NamePrefix;
use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\QueryParam;
+use FOS\RestBundle\Routing\ClassResourceInterface;
+
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
+
use Oro\Bundle\AddressBundle\Entity\AddressType;
-use Oro\Bundle\AddressBundle\Form\DataTransformer\AddressTypeToTypeTransformer;
+
use Oro\Bundle\UserBundle\Annotation\Acl;
use Oro\Bundle\UserBundle\Annotation\AclAncestor;
-use Symfony\Component\Form\FormInterface;
-use Symfony\Component\HttpFoundation\Response;
-use FOS\RestBundle\Routing\ClassResourceInterface;
use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler;
use Oro\Bundle\SoapBundle\Controller\Api\Rest\FlexibleRestController;
use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager;
+
use OroCRM\Bundle\ContactBundle\Entity\Contact;
-use Oro\Bundle\AddressBundle\Entity\TypedAddress;
+use OroCRM\Bundle\ContactBundle\Entity\ContactAddress;
/**
* @RouteResource("contact")
@@ -142,14 +146,6 @@ public function getFormHandler()
return $this->get('orocrm_contact.form.handler.contact.api');
}
- /**
- * @return AddressTypeToTypeTransformer
- */
- protected function getAddressTypeTransformer()
- {
- return $this->get('oro_address.typed.transformer');
- }
-
/**
* {@inheritDoc}
*/
@@ -158,16 +154,18 @@ protected function getPreparedItem($entity)
// convert addresses to plain array
$addressData = array();
/** @var $entity Contact */
- /** @var $address TypedAddress */
- foreach ($entity->getMultiAddress() as $address) {
+ /** @var ContactAddress $address */
+ foreach ($entity->getAddresses() as $address) {
$addressArray = parent::getPreparedItem($address);
- $addressArray['type'] = $this->getAddressTypeTransformer()->transform($address->getType());
+ $addressArray['types'] = $address->getTypeNames();
+
+ unset($addressArray['owner']);
+
$addressData[] = $addressArray;
}
$result = parent::getPreparedItem($entity);
$result['addresses'] = $addressData;
- unset($result['multiAddress']);
return $result;
}
@@ -183,18 +181,6 @@ protected function fixRequestAttributes($entity)
$request = $this->getRequest()->request;
$data = $request->get($requestVariable, array());
- $data['multiAddress'] = !empty($data['addresses']) ? $data['addresses'] : array();
- foreach ($data['multiAddress'] as &$address) {
- /** @var bool|AddressType $addressType */
- $addressType = isset($address['type'])
- ? $this->getAddressTypeTransformer()->reverseTransform($address['type'])
- : null;
- if ($addressType) {
- $address['type'] = $addressType->getId();
- }
- }
- unset($data['addresses']);
-
$request->set($requestVariable, $data);
}
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php
index 4c1c0570811..51ea92fcbc1 100644
--- a/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php
+++ b/src/OroCRM/Bundle/ContactBundle/Controller/Api/Soap/ContactController.php
@@ -5,10 +5,14 @@
use Symfony\Component\Form\FormInterface;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
+use Oro\Bundle\UserBundle\Annotation\AclAncestor;
+
use Oro\Bundle\SoapBundle\Controller\Api\Soap\FlexibleSoapController;
use Oro\Bundle\SoapBundle\Entity\Manager\ApiFlexibleEntityManager;
use Oro\Bundle\SoapBundle\Form\Handler\ApiFormHandler;
+use OroCRM\Bundle\ContactBundle\Entity\Contact;
+
class ContactController extends FlexibleSoapController
{
/**
@@ -16,6 +20,7 @@ class ContactController extends FlexibleSoapController
* @Soap\Param("page", phpType="int")
* @Soap\Param("limit", phpType="int")
* @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\Contact[]")
+ * @AclAncestor("orocrm_contact_list")
*/
public function cgetAction($page = 1, $limit = 10)
{
@@ -26,12 +31,52 @@ public function cgetAction($page = 1, $limit = 10)
* @Soap\Method("getContact")
* @Soap\Param("id", phpType = "int")
* @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\Contact")
+ * @AclAncestor("orocrm_contact_view")
*/
public function getAction($id)
{
return $this->handleGetRequest($id);
}
+ /**
+ * @Soap\Method("getContactAddressByTypeName")
+ * @Soap\Param("id", phpType = "int")
+ * @Soap\Param("typeName", phpType = "string")
+ * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactAddress")
+ * @AclAncestor("orocrm_contact_view")
+ */
+ public function getAddressByTypeNameAction($id, $typeName)
+ {
+ /** @var Contact $contact */
+ $contact = $this->getEntity($id);
+ $address = $contact->getAddressByTypeName($typeName);
+
+ if (!$address) {
+ throw new \SoapFault('NOT_FOUND', sprintf('Contact address with type "%s" can\'t be found', $typeName));
+ }
+
+ return $address;
+ }
+
+ /**
+ * @Soap\Method("getContactPrimaryAddress")
+ * @Soap\Param("id", phpType = "int")
+ * @Soap\Result(phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactAddress")
+ * @AclAncestor("orocrm_contact_view")
+ */
+ public function getPrimaryAddressAction($id)
+ {
+ /** @var Contact $contact */
+ $contact = $this->getEntity($id);
+ $address = $contact->getPrimaryAddress();
+
+ if (!$address) {
+ throw new \SoapFault('NOT_FOUND', sprintf('Contact has no primary address', $address));
+ }
+
+ return $address;
+ }
+
/**
* @Soap\Method("createContact")
* @Soap\Param("contact", phpType = "OroCRM\Bundle\ContactBundle\Entity\ContactSoap")
diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php
index 4587bd2bf7b..a1b6d8c1104 100644
--- a/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php
+++ b/src/OroCRM/Bundle/ContactBundle/Controller/ContactController.php
@@ -99,11 +99,18 @@ public function updateAction(Contact $entity = null)
return $this->get('oro_grid.renderer')->renderResultsJsonResponse($datagridView);
}
- $backUrl = $this->generateUrl('orocrm_contact_index');
-
if ($this->get('orocrm_contact.form.handler.contact')->process($entity)) {
$this->getFlashBag()->add('success', 'Contact successfully saved');
- return $this->redirect($backUrl);
+
+ return $this->get('oro_ui.router')->actionRedirect(
+ array(
+ 'route' => 'orocrm_contact_update',
+ 'parameters' => array('id' => $entity->getId()),
+ ),
+ array(
+ 'route' => 'orocrm_contact_index',
+ )
+ );
}
return array(
diff --git a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php
index 300cdd960ef..bf422901359 100644
--- a/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php
+++ b/src/OroCRM/Bundle/ContactBundle/Controller/GroupController.php
@@ -61,7 +61,16 @@ public function updateAction(Group $entity)
$this->get('session')->getFlashBag()->add('success', 'Group successfully saved');
if (!$this->getRequest()->get('_widgetContainer')) {
- return $this->redirect($this->generateUrl('orocrm_contact_group_index'));
+
+ return $this->get('oro_ui.router')->actionRedirect(
+ array(
+ 'route' => 'orocrm_contact_group_update',
+ 'parameters' => array('id' => $entity->getId()),
+ ),
+ array(
+ 'route' => 'orocrm_contact_group_index',
+ )
+ );
}
}
diff --git a/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php b/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php
index 341afe52aa5..1dc0923e695 100644
--- a/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php
+++ b/src/OroCRM/Bundle/ContactBundle/DataFixtures/ORM/LoadContactAttrData.php
@@ -82,9 +82,9 @@ public function load(ObjectManager $manager)
'searchable' => true
),
array(
- 'code' => 'lead_source',
+ 'code' => 'source',
'type' => 'oro_flexibleentity_simpleselect',
- 'label' => 'Lead Source',
+ 'label' => 'Source',
'options' => array(
'other', 'call', 'TV', 'website'
),
diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php
index eb741836306..7998060bd90 100644
--- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php
+++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactAccountUpdateDatagridManager.php
@@ -4,7 +4,6 @@
use Doctrine\ORM\QueryBuilder;
-use Oro\Bundle\GridBundle\Datagrid\FlexibleDatagridManager;
use Oro\Bundle\GridBundle\Field\FieldDescriptionCollection;
use Oro\Bundle\GridBundle\Field\FieldDescription;
use Oro\Bundle\GridBundle\Field\FieldDescriptionInterface;
@@ -12,9 +11,15 @@
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 ContactAccountUpdateDatagridManager extends ContactAccountDatagridManager
{
+ /**
+ * @var string
+ */
+ protected $hasContactExpression;
+
/**
* {@inheritDoc}
*/
@@ -24,16 +29,17 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
$fieldHasContact->setName('has_contact');
$fieldHasContact->setOptions(
array(
- 'type' => FieldDescriptionInterface::TYPE_BOOLEAN,
- 'label' => $this->translate('Assigned'),
- 'field_name' => 'hasCurrentContact',
- 'expression' => 'hasCurrentContact',
- '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' => 'hasCurrentContact',
+ 'expression' => $this->getHasContactExpression(),
+ 'nullable' => false,
+ 'editable' => true,
+ 'sortable' => true,
+ 'filter_type' => FilterInterface::TYPE_BOOLEAN,
+ 'filterable' => true,
+ 'show_filter' => true,
+ 'filter_by_where' => true,
)
);
$fieldsCollection->add($fieldHasContact);
@@ -46,24 +52,34 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
*/
protected function prepareQuery(ProxyQueryInterface $query)
{
- $entityAlias = $query->getRootAlias();
+ $query->addSelect($this->getHasContactExpression() . ' AS hasCurrentContact', true);
+ }
- if ($this->getContact()->getId()) {
- $query->addSelect(
- "CASE WHEN " .
- "(:contact MEMBER OF $entityAlias.contacts OR $entityAlias.id IN (:data_in)) AND " .
- "$entityAlias.id NOT IN (:data_not_in) ".
- 'THEN 1 ELSE 0 END AS hasCurrentContact',
- 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 hasCurrentContact",
- true
- );
+ /**
+ * @return string
+ */
+ protected function getHasContactExpression()
+ {
+ if (null === $this->hasContactExpression) {
+ /** @var EntityQueryFactory $queryFactory */
+ $queryFactory = $this->queryFactory;
+ $entityAlias = $queryFactory->getAlias();
+
+ if ($this->getContact()->getId()) {
+ $this->hasContactExpression =
+ "CASE WHEN " .
+ "(:contact MEMBER OF $entityAlias.contacts OR $entityAlias.id IN (:data_in)) AND " .
+ "$entityAlias.id NOT IN (:data_not_in) ".
+ "THEN true ELSE false END";
+ } else {
+ $this->hasContactExpression =
+ "CASE WHEN " .
+ "$entityAlias.id IN (:data_in) AND $entityAlias.id NOT IN (:data_not_in) ".
+ "THEN true ELSE false END";
+ }
}
+
+ return $this->hasContactExpression;
}
/**
diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php
index c38449bd222..ced85024d67 100644
--- a/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php
+++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/ContactDatagridManager.php
@@ -13,10 +13,20 @@
use Oro\Bundle\GridBundle\Filter\FilterInterface;
use Oro\Bundle\GridBundle\Action\ActionInterface;
use Oro\Bundle\GridBundle\Property\UrlProperty;
+use Oro\Bundle\GridBundle\Property\FixedProperty;
use Oro\Bundle\GridBundle\Datagrid\ProxyQueryInterface;
+use Oro\Bundle\GridBundle\Sorter\SorterInterface;
class ContactDatagridManager extends FlexibleDatagridManager
{
+ /**
+ * Expression to get region text or label, CONCAT is used as type cast function
+ *
+ * @var string
+ */
+ protected $regionExpression
+ = "CONCAT(CASE WHEN address.stateText IS NOT NULL THEN address.stateText ELSE region.name END, '')";
+
/**
* {@inheritDoc}
*/
@@ -40,7 +50,7 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
$fieldId->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_INTEGER,
- 'label' => $this->translate('ID'),
+ 'label' => $this->translate('orocrm.contact.datagrid.contact_id'),
'field_name' => 'id',
'filter_type' => FilterInterface::TYPE_NUMBER,
'show_column' => false
@@ -48,23 +58,48 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
);
$fieldsCollection->add($fieldId);
- $this->configureFlexibleField($fieldsCollection, 'first_name');
- $this->configureFlexibleField($fieldsCollection, 'last_name');
- $this->configureFlexibleField($fieldsCollection, 'phone');
+ $this->configureFlexibleField($fieldsCollection, 'first_name', array('show_filter' => true));
+ $this->configureFlexibleField($fieldsCollection, 'last_name', array('show_filter' => true));
$this->configureFlexibleField($fieldsCollection, 'email', array('show_filter' => true));
+ $this->configureFlexibleField($fieldsCollection, 'phone', array('show_filter' => true));
+
+ $rolesLabel = new FieldDescription();
+ $rolesLabel->setName('groups');
+ $rolesLabel->setProperty(new FixedProperty('groups', 'groupLabelsAsString'));
+ $rolesLabel->setOptions(
+ array(
+ 'type' => FieldDescriptionInterface::TYPE_TEXT,
+ 'label' => $this->translate('orocrm.contact.datagrid.groups'),
+ 'field_name' => 'groups',
+ 'expression' => 'contactGroup',
+ 'filter_type' => FilterInterface::TYPE_ENTITY,
+ 'sort_field_mapping' => array(
+ 'entityAlias' => 'contactGroup',
+ 'fieldName' => 'label',
+ ),
+ 'sortable' => true,
+ 'filterable' => true,
+ // entity filter options
+ 'class' => 'OroCRMContactBundle:Group',
+ 'property' => 'label',
+ 'filter_by_where' => true
+ )
+ );
+ $fieldsCollection->add($rolesLabel);
+
+ $this->configureFlexibleField($fieldsCollection, 'source');
$fieldCountry = new FieldDescription();
$fieldCountry->setName('country');
$fieldCountry->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_TEXT,
- 'label' => $this->translate('Country'),
+ 'label' => $this->translate('orocrm.contact.datagrid.country'),
'field_name' => 'countryName',
'expression' => 'address.country',
'filter_type' => FilterInterface::TYPE_ENTITY,
'sortable' => true,
'filterable' => true,
- 'show_filter' => true,
// entity filter options
'multiple' => true,
'class' => 'OroAddressBundle:Country',
@@ -79,12 +114,44 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
);
$fieldsCollection->add($fieldCountry);
+ $fieldRegion = new FieldDescription();
+ $fieldRegion->setName('region');
+ $fieldRegion->setOptions(
+ array(
+ 'type' => FieldDescriptionInterface::TYPE_TEXT,
+ 'label' => $this->translate('orocrm.contact.datagrid.region'),
+ 'field_name' => 'regionLabel',
+ 'expression' => $this->regionExpression,
+ 'filter_type' => FilterInterface::TYPE_STRING,
+ 'sortable' => true,
+ 'filterable' => true,
+ 'filter_by_where' => true,
+ )
+ );
+ $fieldsCollection->add($fieldRegion);
+
+ $fieldPostalCode = new FieldDescription();
+ $fieldPostalCode->setName('postal_code');
+ $fieldPostalCode->setOptions(
+ array(
+ 'type' => FieldDescriptionInterface::TYPE_TEXT,
+ 'label' => $this->translate('orocrm.contact.datagrid.postal_code'),
+ 'field_name' => 'addressPostalCode',
+ 'expression' => 'address.postalCode',
+ 'filter_type' => FilterInterface::TYPE_STRING,
+ 'sortable' => true,
+ 'filterable' => true,
+ 'filter_by_where' => true,
+ )
+ );
+ $fieldsCollection->add($fieldPostalCode);
+
$fieldCreated = new FieldDescription();
$fieldCreated->setName('created');
$fieldCreated->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_DATETIME,
- 'label' => $this->translate('Created At'),
+ 'label' => $this->translate('orocrm.contact.datagrid.created_at'),
'field_name' => 'created',
'filter_type' => FilterInterface::TYPE_DATETIME,
'sortable' => true,
@@ -99,12 +166,11 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
$fieldUpdated->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_DATETIME,
- 'label' => $this->translate('Updated At'),
+ 'label' => $this->translate('orocrm.contact.datagrid.updated_at'),
'field_name' => 'updated',
'filter_type' => FilterInterface::TYPE_DATETIME,
'sortable' => true,
'filterable' => true,
- 'show_filter' => true,
)
);
$fieldsCollection->add($fieldUpdated);
@@ -120,7 +186,7 @@ protected function getRowActions()
'type' => ActionInterface::TYPE_REDIRECT,
'acl_resource' => 'orocrm_contact_view',
'options' => array(
- 'label' => $this->translate('View'),
+ 'label' => $this->translate('orocrm.contact.datagrid.view'),
'link' => 'view_link',
'runOnRowClick' => true,
)
@@ -131,7 +197,7 @@ protected function getRowActions()
'type' => ActionInterface::TYPE_REDIRECT,
'acl_resource' => 'orocrm_contact_view',
'options' => array(
- 'label' => $this->translate('View'),
+ 'label' => $this->translate('orocrm.contact.datagrid.view'),
'icon' => 'user',
'link' => 'view_link',
)
@@ -142,7 +208,7 @@ protected function getRowActions()
'type' => ActionInterface::TYPE_REDIRECT,
'acl_resource' => 'orocrm_contact_update',
'options' => array(
- 'label' => $this->translate('Update'),
+ 'label' => $this->translate('orocrm.contact.datagrid.update'),
'icon' => 'edit',
'link' => 'update_link',
)
@@ -153,7 +219,7 @@ protected function getRowActions()
'type' => ActionInterface::TYPE_DELETE,
'acl_resource' => 'orocrm_contact_delete',
'options' => array(
- 'label' => $this->translate('Delete'),
+ 'label' => $this->translate('orocrm.contact.datagrid.delete'),
'icon' => 'trash',
'link' => 'delete_link',
)
@@ -178,15 +244,31 @@ protected function applyJoinWithAddressAndCountry(ProxyQueryInterface $query)
// need to translate countries
$query->setQueryHint(
Query::HINT_CUSTOM_OUTPUT_WALKER,
- 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
+ 'Gedmo\Translatable\Query\TreeWalker\TranslationWalker'
);
$entityAlias = $query->getRootAlias();
/** @var $query QueryBuilder */
- $query->leftJoin("$entityAlias.multiAddress", 'address', 'WITH', 'address.primary = 1')
- ->leftJoin('address.country', 'country');
+ $query
+ ->leftJoin("$entityAlias.addresses", 'address', 'WITH', 'address.primary = true')
+ ->leftJoin("$entityAlias.groups", 'contactGroup')
+ ->leftJoin('address.country', 'country')
+ ->leftJoin('address.state', 'region');
$query->addSelect('country.name as countryName', true);
+ $query->addSelect('address.postalCode as addressPostalCode', true);
+ $query->addSelect($this->regionExpression . ' AS regionLabel', true);
+ }
+
+ /**
+ * @return array
+ */
+ protected function getDefaultSorters()
+ {
+ return array(
+ 'first_name' => SorterInterface::DIRECTION_ASC,
+ 'last_name' => SorterInterface::DIRECTION_ASC,
+ );
}
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php b/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php
index a3971dfd731..55eff2c74d6 100644
--- a/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php
+++ b/src/OroCRM/Bundle/ContactBundle/Datagrid/GroupDatagridManager.php
@@ -42,12 +42,12 @@ protected function configureFields(FieldDescriptionCollection $fieldsCollection)
$fieldsCollection->add($fieldId);
$fieldName = new FieldDescription();
- $fieldName->setName('name');
+ $fieldName->setName('label');
$fieldName->setOptions(
array(
'type' => FieldDescriptionInterface::TYPE_TEXT,
- 'label' => $this->translate('Name'),
- 'field_name' => 'name',
+ 'label' => $this->translate('Label'),
+ 'field_name' => 'label',
'filter_type' => FilterInterface::TYPE_STRING,
'sortable' => true,
'filterable' => true,
diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php
index 8bb6933c927..79c8e358087 100644
--- a/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php
+++ b/src/OroCRM/Bundle/ContactBundle/Entity/Contact.php
@@ -5,22 +5,24 @@
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
-use OroCRM\Bundle\AccountBundle\Entity\Account;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\Exclude;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
+use OroCRM\Bundle\AccountBundle\Entity\Account;
+
+use Oro\Bundle\TagBundle\Entity\Taggable;
+use Oro\Bundle\AddressBundle\Entity\AddressType;
use Oro\Bundle\FlexibleEntityBundle\Entity\Mapping\AbstractEntityFlexible;
-use Oro\Bundle\AddressBundle\Entity\TypedAddress;
/**
* @ORM\Entity(repositoryClass="Oro\Bundle\FlexibleEntityBundle\Entity\Repository\FlexibleEntityRepository")
* @ORM\Table(name="orocrm_contact")
* @ORM\HasLifecycleCallbacks()
*/
-class Contact extends AbstractEntityFlexible
+class Contact extends AbstractEntityFlexible implements Taggable
{
/**
* @ORM\Id
@@ -32,7 +34,7 @@ class Contact extends AbstractEntityFlexible
protected $id;
/**
- * @var Group[]
+ * @var Collection
*
* @ORM\ManyToMany(targetEntity="Group")
* @ORM\JoinTable(name="orocrm_contact_to_contact_group",
@@ -47,7 +49,7 @@ class Contact extends AbstractEntityFlexible
/**
* Accounts storage
*
- * @var ArrayCollection $accounts
+ * @var Collection
*
* @ORM\ManyToMany(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account", mappedBy="contacts")
* @ORM\JoinTable(name="orocrm_contact_to_account")
@@ -56,13 +58,13 @@ class Contact extends AbstractEntityFlexible
protected $accounts;
/**
- * @var ArrayCollection $multiAddress
- * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"})
+ * @var Collection
+ * @ORM\OneToMany(targetEntity="ContactAddress", mappedBy="owner", cascade={"all"}, orphanRemoval=true)
* @ORM\OrderBy({"primary" = "DESC"})
- *
+ * @Soap\ComplexType("OroCRM\Bundle\ContactBundle\Entity\ContactAddress[]", nillable=true)
* @Exclude
*/
- protected $multiAddress;
+ protected $addresses;
/**
* @var \Oro\Bundle\FlexibleEntityBundle\Model\AbstractFlexibleValue[]
@@ -80,12 +82,17 @@ class Contact extends AbstractEntityFlexible
*/
protected $nameFormat;
+ /**
+ * @var ArrayCollection
+ */
+ private $tags;
+
public function __construct()
{
parent::__construct();
$this->groups = new ArrayCollection();
$this->accounts = new ArrayCollection();
- $this->multiAddress = new ArrayCollection();
+ $this->addresses = new ArrayCollection();
}
/**
@@ -138,6 +145,33 @@ public function doPreUpdate()
$this->updated = new \DateTime('now', new \DateTimeZone('UTC'));
}
+ /**
+ * Get group labels separated with comma.
+ *
+ * @return string
+ */
+ public function getGroupLabelsAsString()
+ {
+ return implode(', ', $this->getGroupLabels());
+ }
+
+ /**
+ * Get list of group labels
+ *
+ * @return array
+ */
+ public function getGroupLabels()
+ {
+ $result = array();
+
+ /** @var Group $group */
+ foreach ($this->getGroups() as $group) {
+ $result[] = $group->getLabel();
+ }
+
+ return $result;
+ }
+
/**
* Gets the groups related to contact
*
@@ -221,17 +255,19 @@ public function removeAccount(Account $account)
}
/**
- * Set addresses
+ * Set addresses.
*
- * @param ContactAddress[] $addresses
+ * This method could not be named setAddresses because of bug CRM-253.
+ *
+ * @param Collection|ContactAddress[] $addresses
* @return Contact
*/
- public function setMultiAddress($addresses)
+ public function resetAddresses($addresses)
{
- $this->multiAddress->clear();
+ $this->addresses->clear();
foreach ($addresses as $address) {
- $this->addMultiAddress($address);
+ $this->addAddress($address);
}
return $this;
@@ -243,10 +279,10 @@ public function setMultiAddress($addresses)
* @param ContactAddress $address
* @return Contact
*/
- public function addMultiAddress(ContactAddress $address)
+ public function addAddress(ContactAddress $address)
{
- if (!$this->multiAddress->contains($address)) {
- $this->multiAddress->add($address);
+ if (!$this->addresses->contains($address)) {
+ $this->addresses->add($address);
$address->setOwner($this);
}
@@ -256,13 +292,13 @@ public function addMultiAddress(ContactAddress $address)
/**
* Remove address
*
- * @param mixed $address
+ * @param ContactAddress $address
* @return Contact
*/
- public function removeMultiAddress($address)
+ public function removeAddress(ContactAddress $address)
{
- if ($this->multiAddress->contains($address)) {
- $this->multiAddress->removeElement($address);
+ if ($this->addresses->contains($address)) {
+ $this->addresses->removeElement($address);
}
return $this;
@@ -271,11 +307,61 @@ public function removeMultiAddress($address)
/**
* Get addresses
*
- * @return ContactAddress[]
+ * @return Collection|ContactAddress[]
*/
- public function getMultiAddress()
+ public function getAddresses()
{
- return $this->multiAddress;
+ return $this->addresses;
+ }
+
+ /**
+ * Gets primary address if it's available.
+ *
+ * @return ContactAddress|null
+ */
+ public function getPrimaryAddress()
+ {
+ $result = null;
+
+ foreach ($this->getAddresses() as $address) {
+ if ($address->isPrimary()) {
+ $result = $address;
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets one address that has specified type.
+ *
+ * @param AddressType $type
+ * @return ContactAddress|null
+ */
+ public function getAddressByType(AddressType $type)
+ {
+ return $this->getAddressByTypeName($type->getName());
+ }
+
+ /**
+ * Gets one address that has specified type name.
+ *
+ * @param string $typeName
+ * @return ContactAddress|null
+ */
+ public function getAddressByTypeName($typeName)
+ {
+ $result = null;
+
+ foreach ($this->getAddresses() as $address) {
+ if ($address->hasTypeWithName($typeName)) {
+ $result = $address;
+ break;
+ }
+ }
+
+ return $result;
}
/**
@@ -341,4 +427,32 @@ public function getAttributeData($attributeCode)
return $value;
}
+
+ /**
+ * {@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;
+ }
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php
index 9f2cc10bc0e..cadd9941aaa 100644
--- a/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php
+++ b/src/OroCRM/Bundle/ContactBundle/Entity/ContactAddress.php
@@ -3,26 +3,48 @@
namespace OroCRM\Bundle\ContactBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use Oro\Bundle\AddressBundle\Entity\TypedAddress;
+use Doctrine\Common\Collections\Collection;
use JMS\Serializer\Annotation\Exclude;
+use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
+
+use Oro\Bundle\AddressBundle\Entity\AbstractTypedAddress;
/**
* @ORM\Table("orocrm_contact_address")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Oro\Bundle\AddressBundle\Entity\Repository\AddressRepository")
*/
-class ContactAddress extends TypedAddress
+class ContactAddress extends AbstractTypedAddress
{
/**
- * @ORM\ManyToOne(targetEntity="Contact", inversedBy="multiAddress")
+ * @ORM\ManyToOne(targetEntity="Contact", inversedBy="addresses")
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
*/
protected $owner;
+ /**
+ * @var Collection
+ *
+ * @ORM\ManyToMany(targetEntity="Oro\Bundle\AddressBundle\Entity\AddressType")
+ * @ORM\JoinTable(
+ * name="orocrm_contact_address_to_address_type",
+ * joinColumns={@ORM\JoinColumn(name="contact_address_id", referencedColumnName="id")},
+ * inverseJoinColumns={@ORM\JoinColumn(name="type_name", referencedColumnName="name")}
+ * )
+ * @Soap\ComplexType("string[]", nillable=true)
+ * @Exclude
+ **/
+ protected $types;
+
/**
* @var \Oro\Bundle\FlexibleEntityBundle\Model\AbstractFlexibleValue[]
*
- * @ORM\OneToMany(targetEntity="Oro\Bundle\AddressBundle\Entity\Value\AddressValue", mappedBy="entity", cascade={"persist", "remove"}, orphanRemoval=true)
+ * @ORM\OneToMany(
+ * targetEntity="Oro\Bundle\AddressBundle\Entity\Value\AddressValue",
+ * mappedBy="entity",
+ * cascade={"persist", "remove"},
+ * orphanRemoval=true
+ * )
* @Exclude
*/
protected $values;
@@ -32,7 +54,7 @@ class ContactAddress extends TypedAddress
*
* @param Contact $owner
*/
- public function setOwner($owner)
+ public function setOwner(Contact $owner = null)
{
$this->owner = $owner;
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Entity/Group.php b/src/OroCRM/Bundle/ContactBundle/Entity/Group.php
index 940692cbdbc..4b30a60f26a 100644
--- a/src/OroCRM/Bundle/ContactBundle/Entity/Group.php
+++ b/src/OroCRM/Bundle/ContactBundle/Entity/Group.php
@@ -33,14 +33,14 @@ class Group
* @Type("string")
* @Oro\Versioned
*/
- protected $name;
+ protected $label;
/**
- * @param string $name [optional] Group name
+ * @param string|null $label [optional] Group name
*/
- public function __construct($name = '')
+ public function __construct($label = null)
{
- $this->name = $name;
+ $this->label = $label;
}
/**
@@ -54,24 +54,24 @@ public function getId()
/**
* @return string
*/
- public function getName()
+ public function getLabel()
{
- return $this->name;
+ return $this->label;
}
/**
* @param string $name
* @return Group
*/
- public function setName($name)
+ public function setLabel($name)
{
- $this->name = $name;
+ $this->label = $name;
return $this;
}
public function __toString()
{
- return (string)$this->getName();
+ return (string)$this->getLabel();
}
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php
index 4c31e3dbc1a..89496d21580 100644
--- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php
+++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/ContactHandler.php
@@ -4,12 +4,14 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
-
use Doctrine\Common\Persistence\ObjectManager;
-use OroCRM\Bundle\ContactBundle\Entity\Contact;
+
+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 ContactHandler
+class ContactHandler implements TagHandlerInterface
{
/**
* @var FormInterface
@@ -26,6 +28,11 @@ class ContactHandler
*/
protected $manager;
+ /**
+ * @var TagManager
+ */
+ protected $tagManager;
+
/**
*
* @param FormInterface $form
@@ -50,7 +57,7 @@ public function process(Contact $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()) {
$appendAccounts = $this->form->get('appendAccounts')->getData();
@@ -75,8 +82,10 @@ protected function onSuccess(Contact $entity, array $appendAccounts, array $remo
{
$this->appendAccounts($entity, $appendAccounts);
$this->removeAccounts($entity, $removeAccounts);
+
$this->manager->persist($entity);
$this->manager->flush();
+ $this->tagManager->saveTagging($entity);
}
/**
@@ -104,4 +113,12 @@ protected function removeAccounts(Contact $contact, array $accounts)
$contact->removeAccount($account);
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setTagManager(TagManager $tagManager)
+ {
+ $this->tagManager = $tagManager;
+ }
}
diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php b/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php
index 90102f6ebfa..c312c97cbb7 100644
--- a/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php
+++ b/src/OroCRM/Bundle/ContactBundle/Form/Handler/GroupHandler.php
@@ -50,7 +50,7 @@ public function process(Group $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();
diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php
index b010cad59a2..267871336ec 100644
--- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php
+++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactAddressType.php
@@ -2,9 +2,9 @@
namespace OroCRM\Bundle\ContactBundle\Form\Type;
-use Oro\Bundle\AddressBundle\Form\Type\AddressTypedType;
+use Oro\Bundle\AddressBundle\Form\Type\AbstractTypedAddressType;
-class ContactAddressType extends AddressTypedType
+class ContactAddressType extends AbstractTypedAddressType
{
/**
* {@inheritdoc}
diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php
index 3ea65d2502c..be95ebb6f28 100644
--- a/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php
+++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/ContactType.php
@@ -38,7 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->addEventSubscriber(
- new AddressCollectionTypeSubscriber('multiAddress', $this->addressClass)
+ new AddressCollectionTypeSubscriber('addresses', $this->addressClass)
);
}
@@ -50,9 +50,15 @@ public function addEntityFields(FormBuilderInterface $builder)
// add default flexible fields
parent::addEntityFields($builder);
+ // tags
+ $builder->add(
+ 'tags',
+ 'oro_tag_select'
+ );
+
// Addresses
$builder->add(
- 'multiAddress',
+ 'addresses',
'oro_address_collection',
array(
'required' => true,
@@ -66,7 +72,7 @@ public function addEntityFields(FormBuilderInterface $builder)
'entity',
array(
'class' => 'OroCRMContactBundle:Group',
- 'property' => 'name',
+ 'property' => 'label',
'multiple' => true,
'expanded' => true,
'required' => false,
diff --git a/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php b/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php
index 67391f0a8c7..a2a99be4779 100644
--- a/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php
+++ b/src/OroCRM/Bundle/ContactBundle/Form/Type/GroupType.php
@@ -15,7 +15,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(
- 'name',
+ 'label',
'text',
array(
'required' => true,
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml
deleted file mode 100644
index 6000d9cb935..00000000000
--- a/src/OroCRM/Bundle/ContactBundle/Resources/config/assets.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-js:
- - '@OroUIBundle/Resources/public/lib/bootstrap/js/bootstrap-scrollspy.js'
- - '@OroUIBundle/Resources/public/lib/backbone.bootstrap-modal.js'
- - '@OroUIBundle/Resources/public/lib/jquery/select2.min.js'
\ No newline at end of file
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml
index 9d48e1a9398..120b80bfab3 100644
--- a/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml
+++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/navigation.yml
@@ -10,11 +10,13 @@ oro_menu_config:
route: 'orocrm_contact_index'
extras:
routes: ['/^orocrm_contact_(?!group\w+|group\w+)\w+$/']
+ description: List of contacts
contact_group_list:
label: 'Contact Groups'
route: 'orocrm_contact_group_index'
extras:
routes: ['orocrm_contact_group_*']
+ description: List of contact groups
shortcut_new_contact:
label: Create new contact
route: orocrm_contact_create
@@ -26,6 +28,11 @@ oro_menu_config:
route: orocrm_contact_index
extras:
description: List of contacts
+ shortcut_new_contact_group:
+ label: Create new contact group
+ route: orocrm_contact_group_create
+ extras:
+ description: Create new contact group instance
tree:
application_menu:
@@ -39,13 +46,14 @@ oro_menu_config:
children:
shortcut_new_contact: ~
shortcut_list_contacts: ~
+ shortcut_new_contact_group: ~
oro_titles:
- orocrm_contact_index: Contacts
- orocrm_contact_view: %%contact.name%% - Contacts
+ orocrm_contact_index: ~
+ orocrm_contact_view: %%contact.name%%
orocrm_contact_create: Create Contact
- orocrm_contact_update: %%contact.name%% - Contacts
+ orocrm_contact_update: %%contact.name%%
- orocrm_contact_group_index: Contact Groups
+ orocrm_contact_group_index: ~
orocrm_contact_group_create: Create Contact Group
- orocrm_contact_group_update: %%group.name%% - Contact Group
+ orocrm_contact_group_update: %%group.label%%
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml
index 49c9ba659f1..3429b3d8fed 100644
--- a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml
+++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing.yml
@@ -3,16 +3,9 @@ orocrm_contact_bundle:
type: annotation
prefix: /contact
-orocrm_contact_api:
- resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactController.php"
- type: rest
- prefix: api/rest/{version}/
- defaults:
- version: latest
-
-orocrm_contact_group_api:
- resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactGroupController.php"
- type: rest
- prefix: api/rest/{version}/
+orocrm_contact_bundle_api:
+ resource: "@OroCRMContactBundle/Resources/config/routing_api.yml"
+ type: rest
+ prefix: api/rest/{version}
defaults:
version: latest
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml
new file mode 100644
index 00000000000..47ac49de585
--- /dev/null
+++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/routing_api.yml
@@ -0,0 +1,12 @@
+orocrm_contact_api:
+ resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactController.php"
+ type: rest
+
+orocrm_contact_group_api:
+ resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactGroupController.php"
+ type: rest
+
+orocrm_contact_address_api:
+ resource: "@OroCRMContactBundle/Controller/Api/Rest/ContactAddressController.php"
+ type: rest
+ parent: orocrm_contact_api
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml
index 4a5f8706d92..da8bbd10a05 100644
--- a/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml
+++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/services.yml
@@ -78,6 +78,8 @@ services:
- @orocrm_contact.form.contact
- @request
- @doctrine.orm.entity_manager
+ tags:
+ - { name: oro_tag.tag_manager }
orocrm_contact.contact.manager:
class: %orocrm_contact.contact.manager.api.class%
@@ -144,6 +146,8 @@ services:
- @orocrm_contact.form.contact.api
- @request
- @doctrine.orm.entity_manager
+ tags:
+ - { name: oro_tag.tag_manager }
# Group API
orocrm_contact.group.manager.api:
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml
index 254b47caaea..9150c6eb1f5 100644
--- a/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml
+++ b/src/OroCRM/Bundle/ContactBundle/Resources/config/validation.yml
@@ -1,8 +1,8 @@
OroCRM\Bundle\ContactBundle\Entity\Group:
constraints:
- - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: name
+ - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: label
properties:
- name:
+ label:
- NotBlank: ~
- Length:
min: 3
@@ -10,5 +10,6 @@ OroCRM\Bundle\ContactBundle\Entity\Group:
OroCRM\Bundle\ContactBundle\Entity\Contact:
properties:
- multiAddress:
- - Oro\Bundle\AddressBundle\Validator\Constraints\ContainsPrimary: ~
\ No newline at end of file
+ addresses:
+ - Oro\Bundle\AddressBundle\Validator\Constraints\ContainsPrimary: ~
+ - Oro\Bundle\AddressBundle\Validator\Constraints\UniqueAddressTypes: ~
diff --git a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff b/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff
deleted file mode 100644
index 91049a64843..00000000000
--- a/src/OroCRM/Bundle/ContactBundle/Resources/translations/datagrid.en.xliff
+++ /dev/null
@@ -1,62 +0,0 @@
-
-