Opened 12 years ago
Last modified 12 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)
Change History (24)
comment:1 follow-ups: 3 4 Changed 12 years ago by
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
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 follow-up: 5 Changed 12 years ago by
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
Attachment: | autocomplete_query.js added |
---|
autocomplete in query page on Trac 0.11-0.12
comment:5 follow-ups: 6 7 Changed 12 years ago by
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 Changed 12 years ago by
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 Changed 12 years ago by
Status: | new → assigned |
---|
comment:8 Changed 12 years ago by
comment:9 follow-up: 10 Changed 12 years ago by
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 follow-up: 12 Changed 12 years ago by
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
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
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 follow-up: 13 Changed 12 years ago by
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 setoff
toautocomplete
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 follow-up: 16 Changed 12 years ago by
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
comment:15 follow-up: 17 Changed 12 years ago by
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
27 27 } 28 28 }); 29 29 }; 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+ 32 36 filters.delegate('input:text', 'focus', listener); 33 37 } 34 38 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 Changed 12 years ago by
Replying to jun66j5:
Ok. Could you please grant it?
You have commit access now. Feel free to push changes!
comment:17 follow-up: 20 Changed 12 years ago by
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 totrue
when autocompleting the CC field.
Of course! Additional patch for the task.
-
autocompleteusers/htdocs/js/autocomplete_query.js
18 18 var input = $(this).find('input:text').filter(function() { 19 19 return target === this; 20 20 }); 21 var name = input.attr('name'); 21 22 if (input.attr('autocomplete') !== 'off' && 22 /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test( input.attr('name')))23 /^(?:[0-9]+_)?(?:owner|reporter|cc)$/.test(name)) 23 24 { 24 input.autocomplete('subjects', {formatItem: formatItem}); 25 input.autocomplete('subjects', {formatItem: formatItem, 26 multiple: /cc$/.test(name)}); 25 27 input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2 26 28 } 27 29 }
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
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:20 follow-up: 22 Changed 12 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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
1 1 $(document).ready(function ($) { 2 2 function addAutocompleteBehavior() { 3 var filters = $('#filters ');3 var filters = $('#filters, #batchmod_fieldset'); 4 4 var contains = $.contains // jQuery 1.4+ 5 5 || function (container, contained) { 6 6 while (contained !== null) { … … 19 19 }); 20 20 var name = input.attr('name'); 21 21 if (input.attr('autocomplete') !== 'off' && 22 /^(?:[0-9]+_ )?(?:owner|reporter|cc)$/.test(name)) {22 /^(?:[0-9]+_|batchmod_value_)?(?:owner|reporter|cc)$/.test(name)) { 23 23 input.autocomplete('subjects', {formatItem: formatItem, 24 24 multiple: /cc$/.test(name)}); 25 25 input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2
comment:22 Changed 12 years ago by
Add missing field for Trac 1.0+: #action_reassign_reassign_owner
-
autocompleteusers/htdocs/js/autocomplete_query.js
1 1 $(document).ready(function ($) { 2 2 function addAutocompleteBehavior() { 3 var filters = $('#filters ');3 var filters = $('#filters, #batchmod_fieldset'); 4 4 var contains = $.contains // jQuery 1.4+ 5 5 || function (container, contained) { 6 6 while (contained !== null) { … … 19 19 }); 20 20 var name = input.attr('name'); 21 21 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)) { 23 23 input.autocomplete('subjects', {formatItem: formatItem, 24 24 multiple: /cc$/.test(name)}); 25 25 input.focus(); // XXX Workaround for Trac 0.12.2 and jQuery 1.4.2
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 theautocomplete
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 toquery
and then start adding filters that are dynamically added to the page client-side.Any ideas on how to implement this?