dd292d70b94bd6b980d5a9392d46c545f1c80a1b
[civicrm-core.git] / templates / CRM / Tag / Page / Tag.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2017 |
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
27 {capture assign=docLink}{docURL page="user/organising-your-data/groups-and-tags"}{/capture}
28
29 {if $action eq 1 or $action eq 2 or $action eq 8}
30 {include file="CRM/Tag/Form/Edit.tpl"}
31 {else}
32 <div class="crm-content-block">
33 <div class="help">
34 {ts 1=$docLink}Tags can be assigned to any contact record, and are a convenient way to find contacts. You can create as many tags as needed to organize and segment your records.{/ts} {$docLink}
35 </div>
36
37 {if $rows}
38 <div id="mainTabContainer">
39 <ul>
40 <li class="ui-corner-all crm-tab-button">
41 <a href="#tags">{ts}Tags{/ts}</a>
42 </li>
43 <li class="ui-corner-all crm-tab-button">
44 <a href="#tagsets">{ts}Tag Sets{/ts}</a>
45 </li>
46 </ul>
47 <div id="tags">
48 {if !($action eq 1 and $action eq 2)}
49 <div class="crm-submit-buttons">
50 <div class="action-link">
51 {crmButton q="action=add&reset=1" id="newTag" icon="plus-circle"}{ts}Add Tag{/ts}{/crmButton}
52 </div>
53 </div>
54 {/if}
55 {strip}
56 <table id="tags_table" class="display">
57 <thead>
58 <tr>
59 <th>{ts}Tag{/ts}</th>
60 <th>{ts}ID{/ts}</th>
61 <th id="nosort">{ts}Description{/ts}</th>
62 <th>{ts}Parent (ID){/ts}</th>
63 <th>{ts}Used For{/ts}</th>
64 <th>{ts}Reserved?{/ts}</th>
65 <th></th>
66 </tr>
67 </thead>
68 {foreach from=$rows item=row key=id }
69 {if !$row.is_tagset && !$row.is_tagset_child}
70 <tr class="{if $row.parent_id}child-row{/if} {if $row.grandparent_id}grandchild-row{/if} crm-tag crm-entity" id="tag-{$row.id}">
71 <td class="crm-tag-name crm-editable crmf-name" {if $row.color}style="background-color: {$row.color}; color: {$row.color|colorContrast};"{/if}>
72 {$row.name}
73 </td>
74 <td class="crm-tag-id">{$row.id}</td>
75 <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
76 <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
77 <td class="crm-tag-used_for">{$row.used_for}</td>
78 <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
79 <td>{$row.action|replace:'xx':$row.id}</td>
80 </tr>
81 {/if}
82 {/foreach}
83 </table>
84 {/strip}
85 </div>
86 <div id="tagsets">
87 {if !($action eq 1 and $action eq 2) && $adminTagSet}
88 <div class="crm-submit-buttons">
89 <div class="action-link">
90 {crmButton q="action=add&reset=1&tagset=1" id="newTagSet" icon="plus-circle"}{ts}Add Tag Set{/ts}{/crmButton}
91 </div>
92 </div>
93 {/if}
94 {strip}
95 <table id="tagsets_table" class="display">
96 <thead>
97 <tr>
98 <th>{ts}Tag{/ts}</th>
99 <th>{ts}ID{/ts}</th>
100 <th id="nosort">{ts}Description{/ts}</th>
101 <th>{ts}Parent (ID){/ts}</th>
102 <th>{ts}Used For{/ts}</th>
103 <th>{ts}Reserved?{/ts}</th>
104 <th></th>
105 </tr>
106 </thead>
107 {foreach from=$rows item=row key=id}
108 {if $row.is_tagset || $row.is_tagset_child}
109 <tr class="{if $row.parent_id}child-row{/if} crm-tag crm-entity" id="tag-{$row.id}">
110 <td class="crm-tag-name crm-editable crmf-name" {if $row.color}style="background-color: {$row.color}; color: {$row.color|colorContrast};"{/if}>
111 {$row.name}
112 </td>
113 <td class="crm-tag-id">{$row.id}</td>
114 <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
115 <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
116 <td class="crm-tag-used_for">{$row.used_for}</td>
117 <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
118 <td>{$row.action|replace:'xx':$row.id}</td>
119 </tr>
120 {/if}
121 {/foreach}
122 </table>
123 {/strip}
124 </div>
125 </div>
126 {if !($action eq 1 and $action eq 2)}
127 <div class="crm-submit-buttons">
128 <div class="action-link">
129 {crmButton q="action=add&reset=1" id="newTag" icon="plus-circle"}{ts}Add Tag{/ts}{/crmButton}
130 {if $adminTagSet}
131 {crmButton q="action=add&reset=1&tagset=1" id="newTagSet" icon="plus-circle"}{ts}Add Tag Set{/ts}{/crmButton}
132 {/if}
133 </div>
134 </div>
135 {/if}
136 <div id="merge_tag_status"></div>
137 {include file="CRM/common/jsortable.tpl"}
138 {else}
139 <div class="messages status no-popup">
140 <div class="icon inform-icon"></div>&nbsp;
141 {capture assign=crmURL}{crmURL p='civicrm/tag' q="action=add&reset=1"}{/capture}
142 {ts 1=$crmURL}There are no Tags present. You can <a href='%1'>add one</a>.{/ts}
143 </div>
144 {/if}
145
146 </div>
147
148 {literal}
149 <script type="text/javascript">
150 CRM.$(function($) {
151 var tag;
152 $('#mainTabContainer').tabs();
153 $('.merge_tag').click(function(e) {
154 tag = $(this).crmEditableEntity();
155 mergeTagDialog();
156 e.preventDefault();
157 });
158
159 function mergeTagDialog() {
160 var tagUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTagList' h=0}"{literal};
161 var title = {/literal}'{ts escape="js" 1="%1"}Merge tag %1 into:{/ts}'{literal};
162 CRM.confirm({
163 title: ts(title, {1: tag.name}),
164 message: '<input name="select_merge_tag" class="big" />',
165 open: function() {
166 var dialog = this;
167 $('input[name=select_merge_tag]', dialog)
168 .crmSelect2({
169 placeholder: {/literal}'{ts escape="js"}- select tag -{/ts}'{literal},
170 minimumInputLength: 1,
171 ajax: {
172 url: tagUrl,
173 data: function(term) {
174 return {term: term, fromId: tag.id};
175 },
176 results: function(response) {
177 return {results: response};
178 }
179 }
180 })
181 .change(function() {
182 $('.messages', dialog).remove();
183 if ($(this).val() && $(this).select2('data').warning) {
184 $(dialog).append('<div class="messages status">{/literal}{ts escape='js'}Note: the selected tag is used by additional entities.{/ts}{literal}</div>');
185 }
186 });
187 }
188 })
189 .on('dialogclose', function() {
190 $('input[name=select_merge_tag]', this).select2('destroy');
191 })
192 .on('crmConfirm:yes', function() {
193 var toId = $("input[name=select_merge_tag]", this).val();
194 if (!toId) {
195 $("input[name=select_merge_tag]", this).crmError('{/literal}{ts escape='js'}Select a tag{/ts}{literal}');
196 return false;
197 }
198 var postUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTags' h=0 }"{literal};
199 var data = {fromId: tag.id, toId: toId, key:{/literal}"{crmKey name='civicrm/ajax/mergeTags'}"{literal}};
200 $.ajax({
201 type: "POST",
202 url: postUrl,
203 data: data,
204 dataType: "json",
205 success: function(values) {
206 if ( values.status == true ) {
207 $('#tag-' + toId).children('td.crm-tag-used_for').text(values.tagB_used_for);
208 $('#tag-' + tag.id).html('<td colspan="8"><div class="status message"><div class="icon inform-icon"></div>' + values.message + '</div></td>');
209 }
210 }
211 });
212 });
213 }
214 });
215 </script>
216 <style type="text/css">
217 .crm-container tr.child-row td:first-child {
218 padding-left: 2em;
219 }
220 .crm-container tr.grandchild-row td:first-child {
221 padding-left: 3em;
222 }
223 </style>
224 {/literal}
225
226 {/if}