Modify

Opened 12 years ago

Last modified 11 years ago

#10155 reopened enhancement

Autocomplete fields on the custom query page

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Component: AutocompleteUsersPlugin
Severity: normal Keywords:
Cc: falkb Trac Release: 0.11

Description

Autocomplete the cc, owner and reporter fields on the custom query page, as suggested by falkb.

Attachments (2)

autocomplete_query.js (1.5 KB) - added by Jun Omae 12 years ago.
autocomplete in query page on Trac 0.11-0.12
autocomplete_query-v2.js (1.5 KB) - added by Jun Omae 12 years ago.
autocomplete version 2 in query page on Trac 0.11-0.12

Download all attachments as: .zip

Change History (24)

comment:1 Changed 12 years ago by Ryan J Ollos

This is not quite working yet. I have the simple jQuery implemented that binds autocomplete to the text boxes, but I don't have the event handling setup so that the autocomplete is bound to fields that are added after the page is loaded. So if you navigate to /query?owner&cc&reporter, it will work fine, but it won't work yet if you navigate to query and then start adding filters that are dynamically added to the page client-side.

Any ideas on how to implement this?

comment:2 Changed 12 years ago by Ryan J Ollos

(In [11732]) Refs #10155: Partial support for autocompleting the reporter, owner and cc fields on the query page. The dynamic behavior has not yet been implemented, for binding autocomplete behavior to dynamically added filters.

comment:3 in reply to:  1 Changed 12 years ago by falkb

Replying to rjollos:

Any ideas on how to implement this?

Maybe run the plugin code on click events of the "add_filter_0" combobox.

You can find all the events you may use: here. The click event is described here. Just a guess - maybe something like this (?):

$("#add_filter_0").click(function() {
  addAutocompleteBehavior();
});

comment:4 in reply to:  1 ; Changed 12 years ago by Jun Omae

Replying to rjollos:

Any ideas on how to implement this?

For only Trac 0.12.x (jquery 1.4.x), I would suggest the following as autocomplete_query.js. However, For Trac 0.11.x (jquery 1.2.x), I have no idea.

$(document).ready(function() {
  function addAutocompleteBehavior() {
    $('#filters table').delegate('input:text', 'focus', function(event) {
      var input = $(this);
      if (/^[0-9]+_(?:owner|reporter|cc)$/.test(input.attr('name')) &&
          input.attr('autocomplete') !== 'off')
      {
        input.autocomplete('subjects', {formatItem: formatItem});
      }
    });
  }
  addAutocompleteBehavior();
});

Changed 12 years ago by Jun Omae

Attachment: autocomplete_query.js added

autocomplete in query page on Trac 0.11-0.12

comment:5 in reply to:  4 ; Changed 12 years ago by Jun Omae

I investigate again. attachment:autocomplete_query.js works fine for me on Trac 0.11 and 0.12. Confirmed with Firefox 14 and IE 8.

Could you please try it?

comment:6 in reply to:  5 Changed 12 years ago by falkb

Replying to jun66j5:

Could you please try it?

Works well with IE 9, Trac 0.12.2.

And for most cases with FF 14 Win32 :-) except the situation when I add a new condition by one of the two comboboxes. In this case after choosing e.g. CC the keyboard focus immediately jumps to the newly added edit field, and when I start to type the first letter it signals some action by displaying something like an hourglass, but nothing happens. When I click on another element and secondly set the keyboard focus back to that edit field, autocompletion suddenly works then.

comment:7 in reply to:  5 Changed 12 years ago by Ryan J Ollos

Status: newassigned

Replying to jun66j5:

Could you please try it?

Thank you! I'm in the process of testing ...

comment:8 Changed 12 years ago by Ryan J Ollos

I'm seeing the same behavior that falkb described in comment:6. This is on Debian 6 with Chrome 21.0.1180.41 beta, Trac 1.0dev-r11123.

comment:9 Changed 12 years ago by Ryan J Ollos

Here is a potential typo or syntax error: input.attr('autocomplete') !== 'off', but removing that line doesn't have any affect on the main issue we are dealing with here. I'm not sure what the intent is with checking the autocomplete attribute, but I won't worrry about that for the moment and continue to debug the primary issue here.

comment:10 in reply to:  9 ; Changed 12 years ago by Jun Omae

Thanks for the trying, falkb and rjollos!! I can reproduce the same issue in comment:6. It works well with Trac 0.12.3 (jquery 1.4.4). However, not with Trac 0.12.2 (jquery 1.4.2).

Replying to rjollos:

Here is a potential typo or syntax error: input.attr('autocomplete') !== 'off'

I think that it should do the check. $.autocomplete method set off to autocomplete attribute and it isn't assuming that the method is called multiple times for the same input.

I'll post the new version later.

Changed 12 years ago by Jun Omae

Attachment: autocomplete_query-v2.js added

autocomplete version 2 in query page on Trac 0.11-0.12

comment:11 Changed 12 years ago by Jun Omae

I just reworked. autocomplete_query-v2.js works well for me on Trac 0.12.2 and 0.12.3 with IE 8 and Firefox 14.

comment:12 in reply to:  10 ; Changed 12 years ago by Ryan J Ollos

Replying to jun66j5:

Replying to rjollos:

Here is a potential typo or syntax error: input.attr('autocomplete') !== 'off'

I think that it should do the check. $.autocomplete method set off to autocomplete attribute and it isn't assuming that the method is called multiple times for the same input.

I was actually just confused by the !== and === operators. Are those valid Javascript?

But also, thank you for the explanation about the $.autocomplete method setting the autocomplete attribute, because I had not understood how that works either.

Do you have commit access for the plugin? If not, I'd be happy to grant it to you if you'd like to co-maintain this with me.

comment:13 in reply to:  12 ; Changed 12 years ago by Jun Omae

Replying to rjollos:

I was actually just confused by the !== and === operators. Are those valid Javascript?

The operators are valid. See https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comparison_Operators.

Do you have commit access for the plugin? If not, I'd be happy to grant it to you if you'd like to co-maintain this with me.

I have no commit access. Ok. Could you please grant it?

comment:14 Changed 12 years ago by Ryan J Ollos

(In [11753]) Refs #10155: Added autocomplete of the reporter, owner and cc fields on the custom query page. Thanks to Jun Omae for the patch.

comment:15 Changed 12 years ago by Ryan J Ollos

While debugging an earlier version of the patch, I did some reading about the delegate and on methods, and would therefore propose the following addition:

  • trunk/autocompleteusers/htdocs/js/autocomplete_query.js

     
    2727        }
    2828      });
    2929    };
    30     if ($.fn.delegate) {
    31       // delegate method is available in jQuery 1.4+
     30    if ($.fn.on) {
     31      // on method is available in jQuery 1.7+
     32      filters.on('focusin', 'input:text', listener);
     33    }
     34    else if ($.fn.delegate) {
     35      // delegate method is available in jQuery 1.4.2+
    3236      filters.delegate('input:text', 'focus', listener);
    3337    }
    3438    else if (window.addEventListener) {

Thoughts?

Another follow-on task is to set the autocomplete multiple option to true when autocompleting the CC field.

comment:16 in reply to:  13 Changed 12 years ago by Ryan J Ollos

Replying to jun66j5:

Ok. Could you please grant it?

You have commit access now. Feel free to push changes!

comment:17 in reply to:  15 ; Changed 12 years ago by Jun Omae

Replying to rjollos:

While debugging an earlier version of the patch, I did some reading about the delegate and on methods, and would therefore propose the following addition: ... Thoughts?

Looks good! And works fine with Trac 1.0dev.

Another follow-on task is to set the autocomplete multiple option to true when autocompleting the CC field.

Of course! Additional patch for the task.

  • autocompleteusers/htdocs/js/autocomplete_query.js

     
    1818          var input = $(this).find('input:text').filter(function() {
    1919            return target === this;
    2020          });
     21          var name = input.attr('name');
    2122          if (input.attr('autocomplete') !== 'off' &&
    22               /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test(input.attr('name')))
     23              /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test(name))
    2324          {
    24             input.autocomplete('subjects', {formatItem: formatItem});
     25            input.autocomplete('subjects', {formatItem: formatItem,
     26                                            multiple: /cc$/.test(name)});
    2527            input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2
    2628          }
    2729        }

You have commit access now. Feel free to push changes!

Thanks, Ryan! I'll push the above patch later.

comment:18 Changed 12 years ago by Jun Omae

Resolution: fixed
Status: assignedclosed

(In [11757]) Uses jQuery.on method to call $.autocomplete if available and uses multiple option for the CC fields on the custom query

Closes #10155.

comment:19 Changed 12 years ago by falkb

yep, works well here, too. Thanks

comment:20 in reply to:  17 ; Changed 11 years ago by Genie

Resolution: fixed
Status: closedreopened

There are added fields for BatchModifyPlugin in Trac 1.0.

See t:#525 for more info.

This is patch for support Trac 1.0 and BatchModifyPlugin.

  • autocompleteusers/htdocs/js/autocomplete_query.js

     
    11$(document).ready(function ($) {
    22  function addAutocompleteBehavior() {
    3     var filters = $('#filters');
     3    var filters = $('#filters, #batchmod_fieldset');
    44    var contains = $.contains // jQuery 1.4+
    55      || function (container, contained) {
    66      while (contained !== null) {
     
    1919          });
    2020          var name = input.attr('name');
    2121          if (input.attr('autocomplete') !== 'off' &&
    22             /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test(name)) {
     22            /^(?:[0-9]+_|batchmod_value_)?(?:owner|reporter|cc)$/.test(name)) {
    2323            input.autocomplete('subjects', {formatItem: formatItem,
    2424              multiple: /cc$/.test(name)});
    2525            input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2

comment:21 Changed 11 years ago by Ryan J Ollos

Thank you for the patch. I will test and commit the changes.

comment:22 in reply to:  20 Changed 11 years ago by Genie

Add missing field for Trac 1.0+: #action_reassign_reassign_owner

  • autocompleteusers/htdocs/js/autocomplete_query.js

     
    11$(document).ready(function ($) {
    22  function addAutocompleteBehavior() {
    3     var filters = $('#filters');
     3    var filters = $('#filters, #batchmod_fieldset');
    44    var contains = $.contains // jQuery 1.4+
    55      || function (container, contained) {
    66      while (contained !== null) {
     
    1919          });
    2020          var name = input.attr('name');
    2121          if (input.attr('autocomplete') !== 'off' &&
    22             /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test(name)) {
     22            /^(?:[0-9]+_|batchmod_value_)?(?:owner|reporter|cc)$|reassign_owner$/.test(name)) {
    2323            input.autocomplete('subjects', {formatItem: formatItem,
    2424              multiple: /cc$/.test(name)});
    2525            input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The owner will remain Ryan J Ollos.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.