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

Change Activity tag to use select2 #14247

Merged
merged 2 commits into from
Jun 5, 2019
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
29 changes: 18 additions & 11 deletions CRM/Activity/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,17 @@ public static function whereClauseSingle(&$values, &$query) {
}

case 'activity_tags':
$value = array_keys($value);
$activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]);

if (!is_array($value)) {
$value = explode(',', $value);
}

$names = [];
if (is_array($value)) {
foreach ($value as $k => $v) {
$names[] = $activityTags[$v];
}
foreach ($value as $k => $v) {
$names[] = $activityTags[$v];
}

$query->_where[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")";
$query->_qill[$grouping][] = ts('Activity Tag %1', [1 => $op]) . ' ' . implode(' ' . ts('OR') . ' ', $names);
$query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1;
Expand Down Expand Up @@ -525,13 +527,18 @@ public static function buildSearchForm(&$form) {
);

$form->addYesNo('activity_test', ts('Activity is a Test?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
$activity_tags = CRM_Core_BAO_Tag::getColorTags('civicrm_activity');

if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement = &$form->addElement('checkbox', "activity_tags[$tagID]",
NULL, $tagName
);
}
$form->add('select2', 'activity_tags', ts('Activity Tag(s)'),
$activity_tags, FALSE, [
'id' => 'activity_tags',
'multiple' =>
'multiple',
'class' => 'crm-select2',
'placeholder' => ts('- select -'),
]
);
}

$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
Expand Down
21 changes: 9 additions & 12 deletions templates/CRM/Activity/Form/Search/Common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,17 @@
</td></tr>
</table>
</td>
{if $form.activity_tags}
<td><label>{ts}Activity Tag(s){/ts}</label>
<div id="Tags" class="listing-box">
{foreach from=$form.activity_tags item="tag_val"}
<div class="{cycle values='odd-row,even-row'}">
{$tag_val.html}
</div>
{/foreach}
</td>
{else}
<td>&nbsp;</td>
{/if}
</tr>

{if $form.activity_tags}
<tr>
<td><label>{$form.activity_tags.label}</label>
<br/>
{$form.activity_tags.html}
</td>
</tr>
{/if}

<tr>
{include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="activity_date_time" colspan="2"}
<td>&nbsp;</td>
Expand Down