Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {if !$tagsetType or $tagsetType eq 'contact'} |
2 | {foreach from=$tagsetInfo_contact item=tagset} | |
3 | <div class="crm-section tag-section contact-tagset-{$tagset.parentID}-section"> | |
4 | <label>{$tagset.parentName}</label> | |
5 | <div{if $context EQ "contactTab"} style="margin-top:-15px;"{/if}> | |
6 | {assign var=elemName value = $tagset.tagsetElementName} | |
7 | {assign var=parID value = $tagset.parentID} | |
8 | {assign var=editTagSet value=false} | |
9 | {$form.$elemName.$parID.html} | |
10 | {if $action ne 4 } | |
11 | {assign var=editTagSet value=true} | |
12 | {if $action eq 16 and !($permission eq 'edit') } | |
13 | {assign var=editTagSet value=false} | |
14 | {/if} | |
15 | {/if} | |
16 | {if $editTagSet} | |
17 | <script type="text/javascript"> | |
18 | {literal} | |
19 | var tagUrl = {/literal}"{$tagset.tagUrl}&key={crmKey name='civicrm/ajax/taglist'}"{literal}; | |
20 | var contactEntityTags = ''; | |
21 | {/literal}{if $tagset.entityTags}{literal} | |
22 | eval( 'contactEntityTags = ' + {/literal}'{$tagset.entityTags}'{literal} ); | |
23 | {/literal}{/if}{literal} | |
24 | var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing tag.{/ts}{literal}"; | |
25 | ||
26 | cj( ".contact-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) input") | |
27 | .addClass("contact-taglist_{/literal}{$tagset.parentID}{literal}"); | |
28 | cj( ".contact-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) .contact-taglist_{/literal}{$tagset.parentID}{literal}" ) | |
29 | .tokenInput( tagUrl, { | |
30 | prePopulate: contactEntityTags, | |
31 | theme: 'facebook', | |
32 | hintText: hintText, | |
33 | onAdd: function ( item ) { | |
34 | processContactTags_{/literal}{$tagset.parentID}{literal}( 'select', item.id ); | |
35 | ||
36 | //update count of tags in summary tab | |
37 | if ( cj( '.ui-tabs-nav #tab_tag a' ).length ) { | |
38 | var existingTagsInTagset = cj('.token-input-delete-token-facebook').length; | |
39 | var tagCount = cj("#tagtree input:checkbox:checked").length + existingTagsInTagset; | |
40 | cj( '.ui-tabs-nav #tab_tag a' ).html( 'Tags <em>' + tagCount + '</em>'); | |
41 | } | |
42 | }, | |
43 | onDelete: function ( item ) { | |
44 | processContactTags_{/literal}{$tagset.parentID}{literal}( 'delete', item.id ); | |
45 | ||
46 | //update count of tags in summary tab | |
47 | if ( cj( '.ui-tabs-nav #tab_tag a' ).length ) { | |
48 | var existingTagsInTagset = cj('.token-input-delete-token-facebook').length; | |
49 | var tagCount = cj("#tagtree input:checkbox:checked").length + existingTagsInTagset; | |
50 | cj( '.ui-tabs-nav #tab_tag a' ).html( 'Tags <em>' + tagCount + '</em>'); | |
51 | } | |
52 | } | |
53 | } | |
54 | ); | |
55 | ||
56 | cj( ".contact-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input)").addClass("crm-processed-input"); | |
57 | ||
58 | function processContactTags_{/literal}{$tagset.parentID}{literal}( action, id ) { | |
59 | var postUrl = "{/literal}{crmURL p='civicrm/ajax/processTags' h=0}{literal}"; | |
60 | var parentId = "{/literal}{$tagset.parentID}{literal}"; | |
61 | var entityId = "{/literal}{$tagset.entityId}{literal}"; | |
62 | var entityTable = "{/literal}{$tagset.entityTable}{literal}"; | |
63 | var skipTagCreate = "{/literal}{$tagset.skipTagCreate}{literal}"; | |
64 | var skipEntityAction = "{/literal}{$tagset.skipEntityAction}{literal}"; | |
65 | ||
66 | cj.post( postUrl, { action: action, tagID: id, parentId: parentId, entityId: entityId, entityTable: entityTable, | |
67 | skipTagCreate: skipTagCreate, skipEntityAction: skipEntityAction, key: {/literal}"{crmKey name='civicrm/ajax/processTags'}"{literal} }, | |
68 | function ( response ) { | |
69 | // update hidden element | |
70 | if ( response.id ) { | |
71 | var curVal = cj( ".contact-taglist_{/literal}{$tagset.parentID}{literal}" ).val( ); | |
72 | var valArray = curVal.split(','); | |
73 | var setVal = Array( ); | |
74 | if ( response.action == 'delete' ) { | |
75 | for ( x in valArray ) { | |
76 | if ( valArray[x] != response.id ) { | |
77 | setVal[x] = valArray[x]; | |
78 | } | |
79 | } | |
80 | } | |
81 | else if ( response.action == 'select' ) { | |
82 | setVal = valArray; | |
83 | setVal[ setVal.length ] = response.id; | |
84 | } | |
85 | ||
86 | var actualValue = setVal.join( ',' ); | |
87 | cj( ".contact-taglist_{/literal}{$tagset.parentID}{literal}" ).val( actualValue ); | |
88 | } | |
89 | }, | |
90 | "json" ); | |
91 | } | |
92 | {/literal} | |
93 | </script> | |
94 | {else} | |
95 | {if $tagset.entityTagsArray} | |
96 | {foreach from=$tagset.entityTagsArray item=val name="tagsetList"} | |
97 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
98 | {/foreach} | |
99 | {/if} | |
100 | {/if} | |
101 | </div> | |
102 | <div class="clear"></div> | |
103 | </div> | |
104 | {/foreach} | |
105 | ||
106 | {elseif $tagsetType eq 'activity'} | |
107 | {foreach from=$tagsetInfo_activity item=tagset} | |
108 | <div class="crm-section tag-section activity-tagset-{$tagset.parentID}-section"> | |
109 | <div class="label"> | |
110 | <label>{$tagset.parentName}</label> | |
111 | </div> | |
112 | <div class="content"> | |
113 | {assign var=elemName value = $tagset.tagsetElementName} | |
114 | {assign var=parID value = $tagset.parentID} | |
115 | {assign var=editTagSet value=false} | |
116 | {$form.$elemName.$parID.html} | |
117 | {if $action ne 4 } | |
118 | {assign var=editTagSet value=true} | |
119 | {if $action eq 16 and !($permission eq 'edit') } | |
120 | {assign var=editTagSet value=false} | |
121 | {/if} | |
122 | {/if} | |
123 | {if $editTagSet} | |
124 | <script type="text/javascript"> | |
125 | {literal} | |
126 | var tagUrl = {/literal}"{$tagset.tagUrl}&key={crmKey name='civicrm/ajax/taglist'}"{literal}; | |
127 | var activityEntityTags = ''; | |
128 | {/literal}{if $tagset.entityTags}{literal} | |
129 | eval( 'activityEntityTags = ' + {/literal}'{$tagset.entityTags}'{literal} ); | |
130 | {/literal}{/if}{literal} | |
131 | var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing tag.{/ts}{literal}"; | |
132 | ||
133 | cj( ".activity-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) input") | |
134 | .addClass("activity-taglist_{/literal}{$tagset.parentID}{literal}"); | |
135 | ||
136 | cj( ".activity-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) .activity-taglist_{/literal}{$tagset.parentID}{literal}" ) | |
137 | .tokenInput( tagUrl, { | |
138 | prePopulate: activityEntityTags, | |
139 | theme: 'facebook', | |
140 | hintText: hintText, | |
141 | onAdd: function ( item ) { | |
142 | processActivityTags_{/literal}{$tagset.parentID}{literal}( 'select', item.id ); | |
143 | }, | |
144 | onDelete: function ( item ) { | |
145 | processActivityTags_{/literal}{$tagset.parentID}{literal}( 'delete', item.id ); | |
146 | } | |
147 | } | |
148 | ); | |
149 | ||
150 | cj( ".activity-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input)").addClass("crm-processed-input"); | |
151 | function processActivityTags_{/literal}{$tagset.parentID}{literal}( action, id ) { | |
152 | var postUrl = "{/literal}{crmURL p='civicrm/ajax/processTags' h=0}{literal}"; | |
153 | var parentId = "{/literal}{$tagset.parentID}{literal}"; | |
154 | var entityId = "{/literal}{$tagset.entityId}{literal}"; | |
155 | var entityTable = "{/literal}{$tagset.entityTable}{literal}"; | |
156 | var skipTagCreate = "{/literal}{$tagset.skipTagCreate}{literal}"; | |
157 | var skipEntityAction = "{/literal}{$tagset.skipEntityAction}{literal}"; | |
158 | ||
159 | cj.post( postUrl, { action: action, tagID: id, parentId: parentId, entityId: entityId, entityTable: entityTable, | |
160 | skipTagCreate: skipTagCreate, skipEntityAction: skipEntityAction, key: {/literal}"{crmKey name='civicrm/ajax/processTags'}"{literal} }, | |
161 | function ( response ) { | |
162 | // update hidden element | |
163 | if ( response.id ) { | |
164 | var curVal = cj( ".activity-taglist_{/literal}{$tagset.parentID}{literal}" ).val( ); | |
165 | var valArray = curVal.split(','); | |
166 | var setVal = Array( ); | |
167 | if ( response.action == 'delete' ) { | |
168 | for ( x in valArray ) { | |
169 | if ( valArray[x] != response.id ) { | |
170 | setVal[x] = valArray[x]; | |
171 | } | |
172 | } | |
173 | } | |
174 | else if ( response.action == 'select' ) { | |
175 | setVal = valArray; | |
176 | setVal[ setVal.length ] = response.id; | |
177 | } | |
178 | ||
179 | var actualValue = setVal.join( ',' ); | |
180 | cj( ".activity-taglist_{/literal}{$tagset.parentID}{literal}" ).val( actualValue ); | |
181 | } | |
182 | }, | |
183 | "json" ); | |
184 | } | |
185 | {/literal} | |
186 | </script> | |
187 | {else} | |
188 | {if $tagset.entityTagsArray} | |
189 | {foreach from=$tagset.entityTagsArray item=val name="tagsetList"} | |
190 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
191 | {/foreach} | |
192 | {/if} | |
193 | {/if} | |
194 | </div> | |
195 | <div class="clear"></div> | |
196 | </div> | |
197 | {/foreach} | |
198 | ||
199 | {elseif $tagsetType eq 'case'} | |
200 | {foreach from=$tagsetInfo_case item=tagset} | |
201 | <div class="crm-section tag-section case-tagset-{$tagset.parentID}-section"> | |
202 | <div class="label"> | |
203 | <label>{$tagset.parentName}</label> | |
204 | </div> | |
205 | <div class="content"> | |
206 | {assign var=elemName value = $tagset.tagsetElementName} | |
207 | {assign var=parID value = $tagset.parentID} | |
208 | {assign var=editTagSet value=false} | |
209 | {$form.$elemName.$parID.html} | |
210 | {if $action ne 4 or $form.formName eq 'CaseView' } | |
211 | {assign var=editTagSet value=true} | |
212 | {if $action eq 16 and !($permission eq 'edit') } | |
213 | {assign var=editTagSet value=false} | |
214 | {/if} | |
215 | {/if} | |
216 | {if $editTagSet} | |
217 | <script type="text/javascript"> | |
218 | {literal} | |
219 | var tagUrl = {/literal}"{$tagset.tagUrl}&key={crmKey name='civicrm/ajax/taglist'}"{literal}; | |
220 | var caseEntityTags = ''; | |
221 | {/literal}{if $tagset.entityTags}{literal} | |
222 | eval( 'caseEntityTags = ' + {/literal}'{$tagset.entityTags}'{literal} ); | |
223 | {/literal}{/if}{literal} | |
224 | var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing tag.{/ts}{literal}"; | |
225 | ||
226 | cj( ".case-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) input") | |
227 | .addClass("case-taglist_{/literal}{$tagset.parentID}{literal}"); | |
228 | ||
229 | cj( ".case-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) .case-taglist_{/literal}{$tagset.parentID}{literal}") | |
230 | .tokenInput( tagUrl, { | |
231 | prePopulate: caseEntityTags, | |
232 | theme: 'facebook', | |
233 | hintText: hintText, | |
234 | onAdd: function ( item ) { | |
235 | processCaseTags_{/literal}{$tagset.parentID}{literal}( 'select', item.id ); | |
236 | }, | |
237 | onDelete: function ( item ) { | |
238 | processCaseTags_{/literal}{$tagset.parentID}{literal}( 'delete', item.id ); | |
239 | } | |
240 | } | |
241 | ); | |
242 | ||
243 | cj( ".case-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input)").addClass("crm-processed-input"); | |
244 | ||
245 | function processCaseTags_{/literal}{$tagset.parentID}{literal}( action, id ) { | |
246 | var postUrl = "{/literal}{crmURL p='civicrm/ajax/processTags' h=0}{literal}"; | |
247 | var parentId = "{/literal}{$tagset.parentID}{literal}"; | |
248 | var entityId = "{/literal}{$tagset.entityId}{literal}"; | |
249 | var entityTable = "{/literal}{$tagset.entityTable}{literal}"; | |
250 | var skipTagCreate = "{/literal}{$tagset.skipTagCreate}{literal}"; | |
251 | var skipEntityAction = "{/literal}{$tagset.skipEntityAction}{literal}"; | |
252 | ||
253 | cj.post( postUrl, { action: action, tagID: id, parentId: parentId, entityId: entityId, entityTable: entityTable, | |
254 | skipTagCreate: skipTagCreate, skipEntityAction: skipEntityAction, key: {/literal}"{crmKey name='civicrm/ajax/processTags'}"{literal} }, | |
255 | function ( response ) { | |
256 | // update hidden element | |
257 | if ( response.id ) { | |
258 | var curVal = cj( ".case-taglist_{/literal}{$tagset.parentID}{literal}" ).val( ); | |
259 | var valArray = curVal.split(','); | |
260 | var setVal = Array( ); | |
261 | if ( response.action == 'delete' ) { | |
262 | for ( x in valArray ) { | |
263 | if ( valArray[x] != response.id ) { | |
264 | setVal[x] = valArray[x]; | |
265 | } | |
266 | } | |
267 | } | |
268 | else if ( response.action == 'select' ) { | |
269 | setVal = valArray; | |
270 | setVal[ setVal.length ] = response.id; | |
271 | } | |
272 | ||
273 | var actualValue = setVal.join( ',' ); | |
274 | cj( ".case-taglist_{/literal}{$tagset.parentID}{literal}" ).val( actualValue ); | |
275 | } | |
276 | }, | |
277 | "json" ); | |
278 | } | |
279 | {/literal} | |
280 | </script> | |
281 | {else} | |
282 | {if $tagset.entityTagsArray} | |
283 | {foreach from=$tagset.entityTagsArray item=val name="tagsetList"} | |
284 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
285 | {/foreach} | |
286 | {/if} | |
287 | {/if} | |
288 | </div> | |
289 | <div class="clear"></div> | |
290 | </div> | |
291 | {/foreach} | |
292 | {elseif $tagsetType eq 'attachment'} | |
293 | {assign var=tagset value = $tagsetInfo_attachment.$tagsetNumber} | |
294 | <div class="crm-section tag-section attachment-tagset-{$tagset.parentID}-section"> | |
295 | <div class="crm-attachment-tagset-label"> | |
296 | <label>{$tagset.parentName}</label> | |
297 | </div> | |
298 | <div class="crm-attachment-tagset"> | |
299 | {assign var=elemName value = $tagset.tagsetElementName} | |
300 | {assign var=parID value = $tagset.parentID} | |
301 | {assign var=editTagSet value=false} | |
302 | {$form.$elemName.$parID.html} | |
303 | {if $action ne 4 or $form.formName eq 'CaseView' } | |
304 | {assign var=editTagSet value=true} | |
305 | {if $action eq 16 and !($permission eq 'edit') } | |
306 | {assign var=editTagSet value=false} | |
307 | {/if} | |
308 | {/if} | |
309 | {if $editTagSet} | |
310 | <script type="text/javascript"> | |
311 | {literal} | |
312 | var tagUrl = {/literal}"{$tagset.tagUrl}&key={crmKey name='civicrm/ajax/taglist'}"{literal}; | |
313 | var attachmentEntityTags = ''; | |
314 | {/literal}{if $tagset.entityTags}{literal} | |
315 | eval( 'attachmentEntityTags = ' + {/literal}'{$tagset.entityTags}'{literal} ); | |
316 | {/literal}{/if}{literal} | |
317 | var hintText = "{/literal}{ts escape='js'}Type in a partial or complete name of an existing tag.{/ts}{literal}"; | |
318 | ||
319 | cj( ".attachment-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) input") | |
320 | .addClass("attachment-taglist_{/literal}{$tagset.parentID}{literal}"); | |
321 | ||
322 | cj( ".attachment-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input) .attachment-taglist_{/literal}{$tagset.parentID}{literal}") | |
323 | .tokenInput( tagUrl, { | |
324 | prePopulate: attachmentEntityTags, | |
325 | theme: 'facebook', | |
326 | hintText: hintText, | |
327 | onAdd: function ( item ) { | |
328 | processAttachmentTags_{/literal}{$tagset.parentID}{literal}( 'select', item.id ); | |
329 | }, | |
330 | onDelete: function ( item ) { | |
331 | processAttachmentTags_{/literal}{$tagset.parentID}{literal}( 'delete', item.id ); | |
332 | } | |
333 | } | |
334 | ); | |
335 | ||
336 | cj( ".attachment-tagset-{/literal}{$tagset.parentID}{literal}-section:not(.crm-processed-input)").addClass("crm-processed-input"); | |
337 | ||
338 | function processAttachmentTags_{/literal}{$tagset.parentID}{literal}( action, id ) { | |
339 | var postUrl = "{/literal}{crmURL p='civicrm/ajax/processTags' h=0}{literal}"; | |
340 | var parentId = "{/literal}{$tagset.parentID}{literal}"; | |
341 | var entityId = "{/literal}{$tagset.entityId}{literal}"; | |
342 | var entityTable = "{/literal}{$tagset.entityTable}{literal}"; | |
343 | var skipTagCreate = "{/literal}{$tagset.skipTagCreate}{literal}"; | |
344 | var skipEntityAction = "{/literal}{$tagset.skipEntityAction}{literal}"; | |
345 | ||
346 | cj.post( postUrl, { action: action, tagID: id, parentId: parentId, entityId: entityId, entityTable: entityTable, | |
347 | skipTagCreate: skipTagCreate, skipEntityAction: skipEntityAction, key: {/literal}"{crmKey name='civicrm/ajax/processTags'}"{literal} }, | |
348 | function ( response ) { | |
349 | // update hidden element | |
350 | if ( response.id ) { | |
351 | var curVal = cj( ".attachment-taglist_{/literal}{$tagset.parentID}{literal}" ).val( ); | |
352 | var valArray = curVal.split(','); | |
353 | var setVal = Array( ); | |
354 | if ( response.action == 'delete' ) { | |
355 | for ( x in valArray ) { | |
356 | if ( valArray[x] != response.id ) { | |
357 | setVal[x] = valArray[x]; | |
358 | } | |
359 | } | |
360 | } | |
361 | else if ( response.action == 'select' ) { | |
362 | setVal = valArray; | |
363 | setVal[ setVal.length ] = response.id; | |
364 | } | |
365 | ||
366 | var actualValue = setVal.join( ',' ); | |
367 | cj( ".attachment-taglist_{/literal}{$tagset.parentID}{literal}" ).val( actualValue ); | |
368 | } | |
369 | }, | |
370 | "json"); | |
371 | } | |
372 | {/literal} | |
373 | </script> | |
374 | {else} | |
375 | {if $tagset.entityTagsArray} | |
376 | {foreach from=$tagset.entityTagsArray item=val name="tagsetList"} | |
377 | {$val.name}{if !$smarty.foreach.tagsetList.last},{/if} | |
378 | {/foreach} | |
379 | {/if} | |
380 | {/if} | |
381 | </div> | |
382 | <div class="clear"></div> | |
383 | </div> | |
384 | {/if} | |
385 |