CRM-13966 - Remove another unused autocomplete
[civicrm-core.git] / templates / CRM / Admin / Page / Tag.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
232624b1 3 | CiviCRM version 4.4 |
6a488035
TO
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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/Admin/Form/Tag.tpl"}
31{else}
32<div class="crm-content-block">
33 <div id="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 {if !($action eq 1 and $action eq 2)}
39 <div class="crm-submit-buttons">
40 <div class="action-link">
41 <a href="{crmURL q="action=add&reset=1"}" id="newTag" class="button"><span><div class="icon add-icon"></div>{ts}Add Tag{/ts}</span></a>
42 {if $adminTagSet}
43 <a href="{crmURL q="action=add&reset=1&tagset=1"}" id="newTagSet" class="button"><span><div class="icon add-icon"></div>{ts}Add Tag Set{/ts}</span></a>
44 {/if}
45 </div>
46 </div>
47 {/if}
48
49 {include file="CRM/common/jsortable.tpl"}
50 <div id="merge_tag_status"></div>
51 <div id="cat">
52 {strip}
53 <table id="options" class="display">
54 <thead>
55 <tr>
56 <th>{ts}Tag{/ts}</th>
57 <th>{ts}ID{/ts}</th>
58 <th id="nosort">{ts}Description{/ts}</th>
59 <th>{ts}Parent (ID){/ts}</th>
60 <th>{ts}Used For{/ts}</th>
61 <th>{ts}Tag set?{/ts}</th>
62 <th>{ts}Reserved?{/ts}</th>
63 <th></th>
64 </tr>
65 </thead>
66 {foreach from=$rows item=row key=id }
67 <tr class="{cycle values="odd-row,even-row"} {$row.class} crm-tag crm-entity" id="tag-{$row.id}">
68 <td class="crm-tag-name crm-editable crmf-name">{$row.name}</td>
69 <td class="crm-tag-id">{$row.id}</td>
70 <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
71 <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
72 <td class="crm-tag-used_for">{$row.used_for}</td>
73 <td class="crm-tag-is_tagset">{if $row.is_tagset}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Tag Set{/ts}" />{/if}</td>
74 <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
75 <td>{$row.action|replace:'xx':$row.id}</td>
76 </tr>
77 {/foreach}
78 </table>
79 {/strip}
80 </div>
81 {if !($action eq 1 and $action eq 2)}
82 <div class="crm-submit-buttons">
83 <div class="action-link">
84 <a href="{crmURL q="action=add&reset=1"}" id="newTag" class="button"><span><div class="icon add-icon"></div>{ts}Add Tag{/ts}</span></a>
85 {if $adminTagSet}
86 <a href="{crmURL q="action=add&reset=1&tagset=1"}" id="newTagSet" class="button"><span><div class="icon add-icon"></div>{ts}Add Tag Set{/ts}</span></a>
87 {/if}
88 </div>
89 </div>
90 {/if}
91 {else}
92 <div class="messages status no-popup">
93 <div class="icon inform-icon"></div>&nbsp;
94 {capture assign=crmURL}{crmURL p='civicrm/admin/tag' q="action=add&reset=1"}{/capture}
95 {ts 1=$crmURL}There are no Tags present. You can <a href='%1'>add one</a>.{/ts}
96 </div>
97 {/if}
98
c109be6c 99<div id="mergeTagDialog" style="display:none;">
6a488035
TO
100 {ts}Begin typing name of tag to merge into.{/ts}<br/>
101 <input type="text" id="tag_name"/>
102 <input type="hidden" id="tag_name_id" value="">
103 <div id="used_for_warning" class="status message"></div>
104</div>
105
106</div>
107
108{literal}
109<script type="text/javascript">
110cj("#mergeTagDialog").hide( );
c109be6c
CW
111cj( function($) {
112 cj('.merge_tag').click(function(e){
113 var tagId = cj(this).closest('tr').attr('id').split('-');
d799c621 114 mergeTag(tagId[1]);
c109be6c 115 return false;
6a488035
TO
116 });
117});
118
119function mergeTag( fromId ) {
120 var fromTag = cj('#tag-' + fromId).children('td.crm-tag-name').text();
121 cj('#used_for_warning').html('');
122
6a488035
TO
123 cj("#mergeTagDialog").dialog({
124 title: "Merge tag '" + fromTag + "' into:",
125 modal: true,
126 bgiframe: true,
127 close: function(event, ui) { cj("#tag_name").unautocomplete( ); },
128 overlay: {
129 opacity: 0.5,
130 background: "black"
131 },
132
133 open:function() {
134 cj("#tag_name").val( "" );
135 cj("#tag_name_id").val( null );
136
137 var tagUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTagList' h=0 q='fromId='}"{literal} + fromId;
138
139 cj("#tag_name").autocomplete( tagUrl, {
140 width: 260,
141 selectFirst: false,
142 matchContains: true
143 });
144
145 cj("#tag_name").focus();
146 cj("#tag_name").result(function(event, data, formatted) {
147 cj("input[id=tag_name_id]").val(data[1]);
148 if ( data[2] == 1 ) {
149 cj('#used_for_warning').html("Warning: '" + fromTag + "' has different used-for options than the selected tag, which would be merged into the selected tag. Click Ok to proceed.");
150 } else {
151 cj('#used_for_warning').html('');
152 }
153 });
154 },
155
156 buttons: {
157 "Ok": function() {
158 if ( ! cj("#tag_name").val( ) ) {
159 alert('{/literal}{ts escape="js"}Select valid tag from the list{/ts}{literal}.');
160 return false;
161 }
162 var toId = cj("#tag_name_id").val( );
163 if ( ! toId ) {
164 alert('{/literal}{ts escape="js"}Select valid tag from the list{/ts}{literal}.');
165 return false;
166 }
167
168 /* send synchronous request so that disabling any actions for slow servers*/
169 var postUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTags' h=0 }"{literal};
d799c621 170 var data = {fromId: fromId, toId: toId, key:{/literal}"{crmKey name='civicrm/ajax/mergeTags'}"{literal}};
6a488035
TO
171 cj.ajax({ type : "POST",
172 url : postUrl,
173 data : data,
174 dataType : "json",
175 success : function( values ) {
176 if ( values.status == true ) {
177 cj('#tag-' + toId).children('td.crm-tag-used_for').text(values.tagB_used_for);
178 var msg = "'" + values.tagA + "' has been merged with '" + values.tagB + "'. All records previously tagged with '" + values.tagA + "' are now tagged with '" + values.tagB + "'.";
179 cj('#tag-' + fromId).html('<td colspan="8"><div class="status message"><div class="icon inform-icon"></div>' + msg + '</div></td>');
180 }
181 }
182 });
183
c109be6c 184 cj(this).dialog("close");
6a488035
TO
185 },
186
187 "Cancel": function() {
188 cj(this).dialog("close");
6a488035
TO
189 }
190 }
191 });
192}
193</script>
194{/literal}
195
196{/if}
197{include file="CRM/common/crmeditable.tpl"}