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