CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Any way to disable the AJAX for Tag Sets on Contact Screens?
Pages: [1]

Author Topic: Any way to disable the AJAX for Tag Sets on Contact Screens?  (Read 449 times)

DerekL

  • I post frequently
  • ***
  • Posts: 132
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Any way to disable the AJAX for Tag Sets on Contact Screens?
November 27, 2012, 12:05:40 pm
We've just grouped a set of tags under a tag set and our staff is now complaining about the fact that they now have to perform a search for a tag, instead of just selecting from a list.

I tried convincing them that "this is better", but I failed.

Is there any way to disable to ajax search on the tag fields specifically?


xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Any way to disable the AJAX for Tag Sets on Contact Screens?
November 28, 2012, 11:19:21 pm
You will have to code and alter the template to fetch the tags before and do a bit of smarty/jquery magic to replace the autocomplete with a select.

I did that on a .extra.tpl (with the tagset having an id 27 on activities edit). You won't be able to copy paste, but shouldn't be too complex to start with that and adjust.

Code: [Select]
{* replaces the facebook token by an autocomplete on activities *}
{literal}
<script>
cj(function($){
  var tag_id = [27];
  if ($('#token-input-activity_taglist_27').length ==0)
    return;
  if ($('#activity_taglist_'+tag_id[0]).length >0) {
    if ($('#activity_taglist_'+tag_id[0]).data('selectInitialized') == true) {
      $('#crmasmtemp.pre-init').remove();
      return;
    }
    $('#crmasmtemp').removeClass("pre-init");
    $('#activity_taglist_'+tag_id[0]).data('selectInitialized',true);
  } else
    return;
  $('.activity-tagset-27-section .token-input-list-facebook').hide().remove();
  $('.crm-activity-form-block-tag_set .token-input-list-facebook').hide().remove();
  $.each (tag_id, function (k,v) {
  $('#Activity').submit(function(){
    var t = [];
    $('#activity_taglist_'+v).val ('');
    $('#select_'+v+" option:selected").each (function () {
       t.push ($(this).val());
    });
    $('#activity_taglist_'+v).val (t.join(','));
    $(this).append('<input name="taglist[27]" value="'+t.join(',')+'" />');
  })
  $('#token-input-activity_taglist_'+v).remove();
  $('#select_'+v+':first').appendTo('.activity-tagset-'+v+'-section .content');//.attr('id','activity_taglist_'+v);
  $('#crmasmtemp #select_'+v).remove();
  t=$('#activity_taglist_'+v).val ().split(',');
  $('#select_'+v+' option').each (function() {
    if ( $.inArray ($(this).val(),t) >=0 ) {
      $(this).attr('selected','selected');   
    }
  });
  $('#select_'+v).crmasmSelect({
addItemTarget: 'bottom',
animate: false,
highlight: true,
sortable: true,
respectParents: true
});
  });
});
</script>
{/literal}
<div id="crmasmtemp" class="pre-init" style="display:none">
<select id="select_27" name="AAAactivity_taglist[27]"  multiple="multiple">
{crmAPI var="TagS" entity="Tag" action="get" parent_id="27"}
{foreach from=$TagS.values item=Tag}
<option value="{$Tag.id}">{$Tag.name}</option>
{/foreach}
</select>
</div>


Hope this helps.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Any way to disable the AJAX for Tag Sets on Contact Screens?

This forum was archived on 2017-11-26.