2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
10 {if empty($tagsetType)}
11 {assign var="tagsetType" value="contact"}
13 {if !empty($tableLayout)}
14 <td colspan="2" class="crm-content-block">
17 {if !empty($tagsetInfo)}
18 {foreach from=$tagsetInfo.$tagsetType item=tagset}
19 {assign var="elemName" value=$tagset.tagsetElementName}
20 {if empty($tagsetElementName) or $tagsetElementName eq $elemName}
21 {assign var="parID" value=$tagset.parentID}
22 {assign var="skipEntityAction" value=$tagset.skipEntityAction}
23 {if !empty($tableLayout)}
26 {$form.$elemName.$parID.label}
28 <td class="{$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
29 {$form.$elemName.$parID.html}
33 <div class="crm-section tag-section {$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
34 <div class="crm-clearfix">
35 {$form.$elemName.$parID.label}
36 {$form.$elemName.$parID.html}
43 {if !empty($tableLayout)}
48 {if empty($skipEntityAction) and empty($form.frozen)}
49 <script type="text/javascript">
50 {* Add/remove entity tags via ajax api *}
53 var $el = $('.{/literal}{$tagsetType}-tagset{literal} input.crm-form-entityref');
54 // select2 provides "added" and "removed" properties in the event
55 $el.on('change', function(e) {
57 data = _.pick($(this).data(), 'entity_id', 'entity_table'),
60 tags = $.isArray(e.added) ? e.added : [e.added];
61 _.each(tags, function(tag) {
62 if (tag.id && tag.id != '0') {
63 apiCall.push(['entity_tag', 'create', $.extend({tag_id: tag.id}, data)]);
68 tags = $.isArray(e.removed) ? e.removed : [e.removed];
69 _.each(tags, function(tag) {
70 if (tag.id && tag.id != '0') {
71 apiCall.push(['entity_tag', 'delete', $.extend({tag_id: tag.id}, data)]);
76 CRM.api3(apiCall, true);