Modify

Opened 6 years ago

Closed 2 years ago

Last modified 9 days ago

#8477 closed enhancement (fixed)

Add support for custom fields

Reported by: sukender@… Owned by: rjollos
Priority: normal Component: AutocompleteUsersPlugin
Severity: normal Keywords:
Cc: ejucovy Trac Release: 0.11

Description

It could be nice to be able to have autocompletion on users' fields via trac.ini. Ex:

[AutocompleteUsers]
custom_fields = myField, anotherField

Attachments (3)

enable-autocomplete-dropdown-list-and-support-custom-fields.patch (13.5 KB) - added by t2y 3 years ago.
$ svn di > enable-autocomplete-dropdown-list-and-support-custom-fields.patch
enable-autocomplete-dropdown-list-and-support-custom-fields-for-review.patch (6.6 KB) - added by t2y 3 years ago.
$ svn di -x -w > enable-autocomplete-dropdown-list-and-support-custom-fields-for-review.patch
enable-autocomplete-dropdown-list-and-support-custom-fields-for-r13962.patch (13.7 KB) - added by t2y 2 years ago.
$ svn di > enable-autocomplete-dropdown-list-and-support-custom-fields.patch for r13962

Download all attachments as: .zip

Change History (25)

comment:1 Changed 4 years ago by ejucovy

  • Cc ejucovy added; anonymous removed

comment:2 Changed 3 years ago by t2y

I'll implement this.

comment:3 Changed 3 years ago by rjollos

Excellent. I will have some time this weekend to review your patch in #11415 as well.

Changed 3 years ago by t2y

$ svn di > enable-autocomplete-dropdown-list-and-support-custom-fields.patch

Changed 3 years ago by t2y

$ svn di -x -w > enable-autocomplete-dropdown-list-and-support-custom-fields-for-review.patch

comment:4 Changed 3 years ago by t2y

Note: attached patch includes the ticket:11415#comment:1 changes.

Patch summary:

This patch allow to enable auto complete function for custom fields. First of all, we need to set the custom field name into trac.ini. The configuration values are passed to javascript as a !global variable with add_script_data() function.

[autocomplete_users]
custom_fields = managers, reviewers

I confirmed that it works on trac-0.12.1 and trac-1.0.2dev.

comment:5 Changed 3 years ago by t2y

Could you review this?

comment:6 Changed 3 years ago by rjollos

It is in my Queue. It's a FIFO, so it will be a few more days before I can review.

The feature suggested in this ticket sounds fine to me, so I'm likely to commit the changes, even if they require some modification first. I'm less certain of ticket #11415. It would help move things along if you could provide a patch for just the features in this ticket. That should be fairly easy to do if you commit the patches into a DVCS such as Git.

Changed 2 years ago by t2y

$ svn di > enable-autocomplete-dropdown-list-and-support-custom-fields.patch for r13962

comment:8 Changed 2 years ago by t2y

We published the clone repository applying this patch. Try it!

https://github.com/arielnetworks/autocompleteusersplugin

comment:9 Changed 2 years ago by t2y

Originally, this fields list option of autocomplete section was added in r4407 (#3719) for drop down list. Now, I already supported to complement for drop down list in r14116 (#11415).

    selectfields = ListOption('autocomplete', 'fields', default='',              
        doc="select fields to transform to autocomplete text boxes")

Additionally, #3719 was closed with the unclear purpose. So, I think this fields option can be used to choose arbitrary fields without adding another settings: custome_fields. To specify fields to be complement is like this into trac.ini.

[autocomplete]
fields = custom_field1, custom_field2

comment:10 Changed 2 years ago by t2y

add_script_data() is not found in Trac 0.11.8dev.

http://trac-hacks.org/ticket/10240#comment:7

comment:11 Changed 2 years ago by t2y

I tried to replace add_script_data() with as below, but the data was not given to javascript.

req.chrome.setdefault('script_data', {}).update(data)

comment:12 Changed 2 years ago by t2y

hmm, to_json is still needed.

http://trac-hacks.org/ticket/10240#comment:9

comment:13 follow-up: Changed 2 years ago by jun66j5

I consider that we could pass values of fields option using add_script_data in post_process_request if available (Trac 0.12 and later). Otherwise, we could add script element with values of the option in filter_stream. In that case, we could use javascript_quote instead of to_json because the option is just a list of string.

See also post_process_request and filter_stream in tracdragdropplugin/0.11/tracdragdrop/web_ui.py.

comment:14 in reply to: ↑ 13 Changed 2 years ago by t2y

Replying to jun66j5:

See also post_process_request and filter_stream in tracdragdropplugin/0.11/tracdragdrop/web_ui.py.

I could implement to_json using what you referred, then I confirmed it works on Trac-0.11. Thank you for your advice!

comment:15 Changed 2 years ago by t2y

I committed to my repository for trunk-revision(r14198). I'm going to do testing whether this change works for all version (0.11.x, 0.12.x, 1.0.x). To specify custom fields, see comment:9.

https://github.com/arielnetworks/autocompleteusersplugin/commit/5134011df3eabce847c77015e147e13c106b2ba6

Last edited 2 years ago by t2y (previous) (diff)

comment:16 Changed 2 years ago by t2y

I tested on 0.11.x, 0.12.x and 1.0.2-beta and it seems good. :)

comment:17 Changed 2 years ago by t2y

In 14212:

Refs #8477: Add support for custom fields

comment:18 Changed 2 years ago by t2y

  • Resolution set to fixed
  • Status changed from new to closed
  • Trac Release changed from 0.12 to 0.11

comment:19 follow-up: Changed 11 days ago by massimo.b@…

Hast this change already been integrated into the official trunk branch? I see the change r14212 there. However custom_fields and restrict_owner are not documented. This does not work here with Trac 1.0.9:

[autocomplete_users]
custom_fields = testers

[ticket-custom]
testers = text
testers.label = Testers
testers.order = 20
testers.value =

While Cc works, the "Testers" field has no completion.

comment:20 in reply to: ↑ 19 Changed 10 days ago by jun66j5

Replying to massimo.b@…:

Hast this change already been integrated into the official trunk branch? I see the change r14212 there. However custom_fields and restrict_owner are not documented. This does not work here with Trac 1.0.9:

The option is documented in TracIni page of your Trac.

[autocomplete_users]
custom_fields = testers
...

While Cc works, the "Testers" field has no completion.

The section should be [autocomplete].

[autocomplete]
custom_fields = testers

comment:21 follow-up: Changed 10 days ago by massimo.b@…

Thanks, it works with

[autocomplete]
fields = testers

Although the behavior is different from the Cc which also adds a ", " after completion.

But this is not part of the core, it is still provided by this plugin? Didn't know that TracIni gets updated by plugins... However should be documented in the plugin wiki as well.

comment:22 in reply to: ↑ 21 Changed 10 days ago by jun66j5

Replying to massimo.b@…:

But this is not part of the core, it is still provided by this plugin?

That shouldn't be discussed in this ticket.

Didn't know that TracIni gets updated by plugins... However should be documented in the plugin wiki as well.

Anyone can modify the AutocompleteUsersPlugin page and could provide document in the plugin page at any time.

Last edited 9 days ago by rjollos (previous) (diff)

Add Comment

Modify Ticket

Action
as closed The owner will remain rjollos.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.