Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21634 Standardise search fields as they relate to contacts #11492

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions CRM/Contribute/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,7 @@ public function setDefaultValues() {
*/
public function buildQuickForm() {
parent::buildQuickForm();
$this->addSortNameField();

$this->_group = CRM_Core_PseudoConstant::nestedGroup();

// multiselect for groups
if ($this->_group) {
$this->add('select', 'group', ts('Groups'), $this->_group, FALSE,
array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')
);
}

// multiselect for tags
$contactTags = CRM_Core_BAO_Tag::getTags();

if ($contactTags) {
$this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE,
array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2')
);
}
$this->addContactSearchFields();

CRM_Contribute_BAO_Query::buildSearchForm($this);

Expand Down Expand Up @@ -229,6 +211,36 @@ protected function getSortNameLabelWithOutEmail() {
return ts('Contributor Name');
}

/**
* Get the label for the tag field.
*
* We do this in a function so the 'ts' wraps the whole string to allow
* better translation.
*
* @return string
*/
protected function getTagLabel() {
return ts('Contributor Tag(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getGroupLabel() {
return ts('Contributor Group(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getContactTypeLabel() {
return ts('Contributor Contact Type');
}

/**
* The post processing of the form gets done here.
*
Expand Down
35 changes: 35 additions & 0 deletions CRM/Core/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,39 @@ public function getDefaultContext() {
return 'search';
}

/**
* Add generic fields that specify the contact.
*/
protected function addContactSearchFields() {
$this->addSortNameField();

$this->_group = CRM_Core_PseudoConstant::nestedGroup();
if ($this->_group) {
$this->add('select', 'group', $this->getGroupLabel(), $this->_group, FALSE,
array(
'id' => 'group',
'multiple' => 'multiple',
'class' => 'crm-select2',
)
);
}

$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$this->add('select', 'contact_tags', $this->getTagLabel(), $contactTags, FALSE,
array(
'id' => 'contact_tags',
'multiple' => 'multiple',
'class' => 'crm-select2',
)
);
}
$this->addField('contact_type', array('entity' => 'Contact'));

if (CRM_Core_Permission::check('access deleted contacts') && Civi::settings()->get('contact_undelete')) {
$this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
}

}

}
38 changes: 31 additions & 7 deletions CRM/Event/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/

/**
Expand Down Expand Up @@ -168,11 +166,7 @@ public function preProcess() {
*/
public function buildQuickForm() {
parent::buildQuickForm();
$this->addSortNameField();

if (CRM_Core_Permission::check('access deleted contacts') and Civi::settings()->get('contact_undelete')) {
$this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
}
$this->addContactSearchFields();

CRM_Event_BAO_Query::buildSearchForm($this);

Expand Down Expand Up @@ -272,6 +266,36 @@ protected function getSortNameLabelWithOutEmail() {
return ts('Participant Name');
}

/**
* Get the label for the tag field.
*
* We do this in a function so the 'ts' wraps the whole string to allow
* better translation.
*
* @return string
*/
protected function getTagLabel() {
return ts('Participant Tag(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getGroupLabel() {
return ts('Participant Group(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getContactTypeLabel() {
return ts('Participant Contact Type');
}

/**
* The post processing of the form gets done here.
*
Expand Down
32 changes: 31 additions & 1 deletion CRM/Member/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function preProcess() {
*/
public function buildQuickForm() {
parent::buildQuickForm();
$this->addSortNameField();
$this->addContactSearchFields();

CRM_Member_BAO_Query::buildSearchForm($this);

Expand Down Expand Up @@ -192,6 +192,36 @@ protected function getSortNameLabelWithOutEmail() {
return ts('Member Name');
}

/**
* Get the label for the tag field.
*
* We do this in a function so the 'ts' wraps the whole string to allow
* better translation.
*
* @return string
*/
protected function getTagLabel() {
return ts('Member Tag(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getGroupLabel() {
return ts('Member Group(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getContactTypeLabel() {
return ts('Member Contact Type');
}

/**
* The post processing of the form gets done here.
*
Expand Down
32 changes: 31 additions & 1 deletion CRM/Pledge/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function preProcess() {
*/
public function buildQuickForm() {
parent::buildQuickForm();
$this->addSortNameField();
$this->addContactSearchFields();

CRM_Pledge_BAO_Query::buildSearchForm($this);

Expand Down Expand Up @@ -184,6 +184,36 @@ protected function getSortNameLabelWithOutEmail() {
return ts('Pledger Name');
}

/**
* Get the label for the tag field.
*
* We do this in a function so the 'ts' wraps the whole string to allow
* better translation.
*
* @return string
*/
protected function getTagLabel() {
return ts('Pledger Tag(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getGroupLabel() {
return ts('Pledger Group(s)');
}

/**
* Get the label for the group field.
*
* @return string
*/
protected function getContactTypeLabel() {
return ts('Pledger Contact Type');
}

/**
* The post processing of the form gets done here.
*
Expand Down
31 changes: 31 additions & 0 deletions templates/CRM/Contact/Form/Search/ContactSearchFields.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<tr>
<td class="font-size12pt">
{$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}
</td>
<td>{$form.buttons.html}</td>
</tr>
<tr>
{if $form.contact_tags}
<td><label>{$form.contact_tags.label}</label>
{$form.contact_tags.html}
</td>
{else}
<td>&nbsp;</td>
{/if}

{if $form.group}
<td><label>{$form.group.label}</label>
{$form.group.html}
</td>
{else}
<td>&nbsp;</td>
{/if}
</tr>
<tr class="crm-event-search-form-block-deleted_contacts">
<td>{$form.contact_type.label}&nbsp;&nbsp;{$form.contact_type.html}<br></td>
<td>
{if $form.deleted_contacts}
{$form.deleted_contacts.html}&nbsp;&nbsp;{$form.deleted_contacts.label}
{/if}
</td>
</tr>
24 changes: 2 additions & 22 deletions templates/CRM/Contribute/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,8 @@
<div class="crm-accordion-body">
{strip}
<table class="form-layout">
<tr>
<td class="font-size12pt" colspan="2"> {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
</td>
</tr>
<tr>
{if $form.contact_tags}
<td><label>{ts}Contributor Tag(s){/ts}</label>
{$form.contact_tags.html}
</td>
{else}
<td>&nbsp;</td>
{/if}

{if $form.group}
<td><label>{ts}Contributor Group(s){/ts}</label>
{$form.group.html}
</td>
{else}
<td>&nbsp;</td>
{/if}
</tr>
{include file="CRM/Contribute/Form/Search/Common.tpl"}
{include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
{include file="CRM/Contribute/Form/Search/Common.tpl"}
<tr>
<td colspan="2">{$form.buttons.html}</td>
</tr>
Expand Down
13 changes: 1 addition & 12 deletions templates/CRM/Event/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,7 @@
<div id="searchForm">
{strip}
<table class="form-layout">
<tr class="crm-event-search-form-block-sort_name">
<td class="font-size12pt" colspan="2">
{$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
</td>
</tr>
{if $form.deleted_contacts}
<tr class="crm-event-search-form-block-deleted_contacts">
<td colspan="2">
{$form.deleted_contacts.html}&nbsp;&nbsp;{$form.deleted_contacts.label}
</td>
</tr>
{/if}
{include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}

{include file="CRM/Event/Form/Search/Common.tpl"}

Expand Down
7 changes: 1 addition & 6 deletions templates/CRM/Member/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@
<div class="crm-accordion-body">
{strip}
<table class="form-layout">
<tr>
<td class="font-size12pt" colspan="2">
{$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
</td>
</tr>

{include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
{include file="CRM/Member/Form/Search/Common.tpl"}

<tr>
Expand Down
6 changes: 1 addition & 5 deletions templates/CRM/Pledge/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
<div id="searchForm">
{strip}
<table class="form-layout">
<tr>
<td class="font-size12pt" colspan="2">
{$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
</td>
</tr>
{include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
{include file="CRM/Pledge/Form/Search/Common.tpl"}

<tr>
Expand Down