2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2017 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
26 {if empty($tagsetType)}
27 {assign var="tagsetType" value="contact"}
29 {foreach from=$tagsetInfo.$tagsetType item=tagset}
30 {assign var="elemName" value=$tagset.tagsetElementName}
31 {if empty($tagsetElementName) or $tagsetElementName eq $elemName}
32 {assign var="parID" value=$tagset.parentID}
33 {assign var="skipEntityAction" value=$tagset.skipEntityAction}
36 {$form.$elemName.$parID.label}
38 <td class="{$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
39 {$form.$elemName.$parID.html}
42 <div class="crm-section tag-section {$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
43 <div class="crm-clearfix">
44 {$form.$elemName.$parID.label}
45 {$form.$elemName.$parID.html}
52 {if !$skipEntityAction and empty($form.frozen)}
53 <script type="text/javascript">
54 {* Add/remove entity tags via ajax api *}
57 var $el = $('.{/literal}{$tagsetType}-tagset{literal} input.crm-form-entityref');
58 // select2 provides "added" and "removed" properties in the event
59 $el.on('change', function(e) {
61 data = _.pick($(this).data(), 'entity_id', 'entity_table'),
64 tags = $.isArray(e.added) ? e.added : [e.added];
65 _.each(tags, function(tag) {
66 if (tag.id && tag.id != '0') {
67 apiCall.push(['entity_tag', 'create', $.extend({tag_id: tag.id}, data)]);
72 tags = $.isArray(e.removed) ? e.removed : [e.removed];
73 _.each(tags, function(tag) {
74 if (tag.id && tag.id != '0') {
75 apiCall.push(['entity_tag', 'delete', $.extend({tag_id: tag.id}, data)]);
80 CRM.api3(apiCall, true);