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"}
14 <td colspan="2" class="crm-content-block">
17 {foreach from=$tagsetInfo.$tagsetType item=tagset}
18 {assign var="elemName" value=$tagset.tagsetElementName}
19 {if empty($tagsetElementName) or $tagsetElementName eq $elemName}
20 {assign var="parID" value=$tagset.parentID}
21 {assign var="skipEntityAction" value=$tagset.skipEntityAction}
25 {$form.$elemName.$parID.label}
27 <td class="{$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
28 {$form.$elemName.$parID.html}
32 <div class="crm-section tag-section {$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
33 <div class="crm-clearfix">
34 {$form.$elemName.$parID.label}
35 {$form.$elemName.$parID.html}
46 {if !$skipEntityAction and empty($form.frozen)}
47 <script type="text/javascript">
48 {* Add/remove entity tags via ajax api *}
51 var $el = $('.{/literal}{$tagsetType}-tagset{literal} input.crm-form-entityref');
52 // select2 provides "added" and "removed" properties in the event
53 $el.on('change', function(e) {
55 data = _.pick($(this).data(), 'entity_id', 'entity_table'),
58 tags = $.isArray(e.added) ? e.added : [e.added];
59 _.each(tags, function(tag) {
60 if (tag.id && tag.id != '0') {
61 apiCall.push(['entity_tag', 'create', $.extend({tag_id: tag.id}, data)]);
66 tags = $.isArray(e.removed) ? e.removed : [e.removed];
67 _.each(tags, function(tag) {
68 if (tag.id && tag.id != '0') {
69 apiCall.push(['entity_tag', 'delete', $.extend({tag_id: tag.id}, data)]);
74 CRM.api3(apiCall, true);