Skip to content

Commit

Permalink
QA fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Jun 17, 2017
1 parent a52a846 commit d8d2f9e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 74 deletions.
6 changes: 4 additions & 2 deletions CRM/Contact/Form/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,10 @@ public function postProcess() {

if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
//add contact to tags
$params['tag'] = array_flip(explode(',', $params['tag']));
CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
if (isset($params['tag']) && !empty($params['tag'])) {
$params['tag'] = array_flip(explode(',', $params['tag']));
CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
}

//save free tags
if (isset($params['contact_taglist']) && !empty($params['contact_taglist'])) {
Expand Down
11 changes: 5 additions & 6 deletions CRM/Contact/Form/Edit/TagsAndGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static function buildQuickForm(

if ($groupElementType == 'select' && !empty($groupsOptions)) {
$form->add('select', $fName, $groupName, $groupsOptions, FALSE,
array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 310px')
array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty')
);
$form->assign('groupCount', count($groupsOptions));
}
Expand All @@ -150,11 +150,11 @@ public static function buildQuickForm(
if (!empty($tags)) {
$form->add('select2', 'tag', ts('Tag(s)'), $tags, FALSE, array('class' => 'huge', 'placeholder' => ts('- select -'), 'multiple' => TRUE));
}
}

// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
}
$form->assign('tagGroup', $form->_tagGroup);
}

Expand Down Expand Up @@ -195,7 +195,6 @@ public static function setDefaults($id, &$defaults, $type = self::ALL, $fieldNam

if ($type & self::TAG) {
$defaults['tag'] = implode(',', CRM_Core_BAO_EntityTag::getTag($id, 'civicrm_contact'));
CRM_Core_Error::debug_var('tag', $defaults['tag']);
}
}

Expand Down
75 changes: 10 additions & 65 deletions templates/CRM/Contact/Form/Edit/TagsAndGroups.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,65 +23,6 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{literal}
<style>
#tagtree .highlighted > span {
background-color: #fefca6;
}
#tagtree .helpicon ins {
display: none;
}
#tagtree ins.jstree-icon {
cursor: pointer;
}
</style>
<script type="text/javascript">
(function($, _){{/literal}
var entityID='{$entityID}',
entityTable='{$entityTable}',
$form = $('form.{$form.formClass}');
{literal}

$(function() {
function highlightSelected() {
$("ul input:not(:checked)", '#tagtree').each(function () {
$(this).closest("li").removeClass('highlighted');
});
$("ul input:checked", '#tagtree').each(function () {
$(this).parents("li[id^=tag]").addClass('highlighted');
});
}
highlightSelected();

$("#tagtree input").change(function(){
highlightSelected();
});

var childTag = "{/literal}{$loadjsTree}{literal}";
if (childTag) {
//load js tree.
$("#tagtree").jstree({
plugins : ["themes", "html_data"],
themes: {
"theme": 'classic',
"dots": false,
"icons": false,
"url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
}
});
}
{/literal}
{if !empty($permission) && $permission neq 'edit'}
{literal}
$("#tagtree input").prop('disabled', true);
{/literal}
{/if}
{literal}
});
})(CRM.$, CRM._);
{/literal}
</script>

{if $title}
<div class="crm-accordion-wrapper crm-tagGroup-accordion collapsed">
<div class="crm-accordion-header">{$title}</div>
Expand All @@ -91,15 +32,22 @@
<tr>
{if !$type || $type eq 'tag'}
<td>
<span class="label">{if $title}{$form.tag.label}{/if}</span><br />
{$form.tag.html}
<div class="crm-section tag-section">
{if $title}{$form.tag.label}{/if}
{$form.tag.html}
</div>
{if $context NEQ 'profile'}
{include file="CRM/common/Tagset.tpl"}
{/if}
</td>
{/if}
{if !$type || $type eq 'group'}
<td>
{if $groupElementType eq 'select'}
<span class="label">{if $title}{$form.group.label}{/if}</span>
<div class="crm-section group-section">
{if $title}{$form.group.label}{/if}
{$form.group.html}
</div>
{else}
{foreach key=key item=item from=$tagGroup.group}
<div class="group-wrapper">
Expand All @@ -113,9 +61,6 @@
</td>
{/if}
</tr>
{if !$type || $type eq 'tag'}
<tr><td>{include file="CRM/common/Tagset.tpl"}</td></tr>
{/if}
</table>
{if $title}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Profile/Form/Dynamic.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
{if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
{include file="CRM/Profile/Form/GreetingType.tpl"}
{elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
{include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
{include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile" tableLayout=1}
{elseif ( $form.$n.name eq 'image_URL' )}
{$form.$n.html}
{if !empty($imageURL)}
Expand Down

0 comments on commit d8d2f9e

Please sign in to comment.