CRM-13966 - Remove unneeded tpl variable
[civicrm-core.git] / templates / CRM / common / Tagset.tpl
CommitLineData
6d538af3
CW
1{*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
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. |
12 | |
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. |
17 | |
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 +--------------------------------------------------------------------+
25*}
26{if empty($tagsetType)}
e4f4dc22 27 {assign var="tagsetType" value="contact"}contact{/capture}
6d538af3
CW
28{/if}
29{foreach from=$tagsetInfo.$tagsetType item=tagset}
30 <div class="crm-section tag-section {$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
191279e0 31 <div class="crm-clearfix">
e4f4dc22
CW
32 {assign var="elemName" value=$tagset.tagsetElementName}
33 {assign var="parID" value=$tagset.parentID}
34 {$form.$elemName.$parID.label}
6d538af3 35 {$form.$elemName.$parID.html}
6d538af3 36 </div>
e4f4dc22
CW
37 {if !$tagset.skipEntityAction}
38 <script type="text/javascript">
39 {* Add/remove entity tags via ajax api *}
40 {literal}
41 (function($, _) {
42 var $el = $('.{/literal}{$tagsetType}-tagset-{$tagset.parentID}-section{literal} input.crm-form-entityref');
43 // select2 provides "added" and "removed" properties in the event
44 $el.on('change', function(e) {
45 var tags,
46 data = _.pick($(this).data(), 'entity_id', 'entity_table'),
47 apiCall = [];
48 if (e.added) {
49 tags = $.isArray(e.added) ? e.added : [e.added];
50 _.each(tags, function(tag) {
51 if (tag.id && tag.id != '0') {
52 apiCall.push(['entity_tag', 'create', $.extend({tag_id: tag.id}, data)]);
53 }
54 });
55 }
56 if (e.removed) {
57 tags = $.isArray(e.removed) ? e.removed : [e.removed];
58 _.each(tags, function(tag) {
59 if (tag.id && tag.id != '0') {
60 apiCall.push(['entity_tag', 'delete', $.extend({tag_id: tag.id}, data)]);
61 }
62 });
63 }
64 if (apiCall.length) {
65 CRM.api3(apiCall, true);
66 }
67 });
68 }(CRM.$, CRM._));
69 {/literal}
70 </script>
71 {/if}
6d538af3
CW
72 </div>
73{/foreach}