Modify

Opened 15 years ago

Closed 14 years ago

#6875 closed enhancement (fixed)

Allow batch keyword removal

Reported by: BradT Owned by: CuriousCurmudgeon
Priority: normal Component: BatchModifyPlugin
Severity: normal Keywords:
Cc: oliver@… Trac Release: 0.11

Description

We use keywords for some ad-hoc information and frequently need to remove one keyword and add another to a large number of tickets. The changes for ticket #2311 help with adding new keywords (which was pretty much unusable before), but it doesn't allow for batch removal of keywords. I looked through the tickets and didn't find anything about removing keywords.

This is my scenario

  1. Ticket A has keywords "foo bar baz" and is checked
  2. Ticket B has keywords "foo" and is checked
  3. I want to remove the keyword foo from the selected tickets. Once this is done, Ticket A should have keywords "bar baz" and ticket B should have an empty keywords field.

If keywords could be both added and removed simultaneously, that would be ideal.

I'm not sure what the best way to build this GUI would be, but it would be very useful for us to have the functionality

Attachments (1)

keywords.diff (2.9 KB) - added by oliver@… 15 years ago.
Patch to add keyword removal and modify the keyword modification behaviour to "make sense"

Download all attachments as: .zip

Change History (13)

comment:1 Changed 15 years ago by CuriousCurmudgeon

I agree that batch removal should be possible. When implementing #2311 I wasn't quite sure how to create the GUI for this as well. My only idea right now is that checking the Keywords checkbox would trigger an AJAX request to pull down all the keywords on the selected tickets. Then you would be able to choose the ones you want to remove. If the query already included keywords in the results the request is probably unnecessary.

comment:2 Changed 15 years ago by BradT

I the spirit of simplicity, what about simply having "keywords to add" and "keywords to remove"?

A friendlier version would be good, but just a separate field for removals would probably do the trick.

comment:3 Changed 15 years ago by oliver@…

Cc: oliver@… added; anonymous removed

I've created a patch that addresses this ticket in the simplest way I can think of. Basically, if you want to remove a keyword from a ticket, you stick a - (hyphen) in front of the keyword name.

This also addresses some shortcomings I've had with the keywords functionality. Maybe I'm misunderstanding the way it is supposed to work, but if I have the keyword field set to "foo" and I type "bar, baz", I would expect the keywords to be changed to "foo, bar, baz" — not "foo bar baz", as they seem to be.

Here's some example behaviour with the new format in this patch (in the format existing + input = output):

  1. foo + bar = foo, bar
  2. foo, bar + -foo = bar
  3. foo, bar, baz + foo, -bar, boo = foo, baz, boo

Hope this makes sense.

Changed 15 years ago by oliver@…

Attachment: keywords.diff added

Patch to add keyword removal and modify the keyword modification behaviour to "make sense"

comment:4 in reply to:  3 Changed 15 years ago by BradT

Replying to oliver@obeattie.com:

I've created a patch that addresses this ticket in the simplest way I can think of. Basically, if you want to remove a keyword from a ticket, you stick a - (hyphen) in front of the keyword name.

Thank you! I'm using a modified version of it now.

comment:5 Changed 15 years ago by CuriousCurmudgeon

(In [7967]) refs #6875

  • Applying patch from oliver.

comment:6 Changed 15 years ago by CuriousCurmudgeon

Status: newassigned

Patch applied. Thanks a lot. It's a very simple and clean way to solve the problem.

comment:7 Changed 15 years ago by CuriousCurmudgeon

Resolution: fixed
Status: assignedclosed

comment:8 Changed 15 years ago by BradT

Unfortunately this patch only allows comma separated keywords, so you might find some users don't like the change.

New:

regexp = re.compile(r'\,(\w+)?')

vs the original:

regexp = re.compile(r'\W+')

What I'm using:

regexp = re.compile(r'\s+')

comment:9 Changed 15 years ago by BradT

There was more in my comment, but it didn't take.

This is the regex I think we want, since it separates on anything but '-' or word characters.

 regexp = re.compile(r'[^-\w]+')
>>> regexp = re.compile(r'[^-\w]+')
>>> regexp.split("foo, -bar, baz gar")
['foo', '-bar', 'baz', 'gar']
>>> regexp.split("foo,-bar,baz gar")
['foo', '-bar', 'baz', 'gar']
>>> regexp.split("foo, -bar,baz gar")
['foo', '-bar', 'baz', 'gar']
>>> regexp.split("foo -bar baz gar")
['foo', '-bar', 'baz', 'gar']

comment:10 Changed 15 years ago by CuriousCurmudgeon

Resolution: fixed
Status: closedreopened

User expectations seem to vary quite a bit, but I lean towards using any whitespace character. I will use the above regex.

comment:11 Changed 15 years ago by CuriousCurmudgeon

(In [7983]) refs #6875

  • Changed regex back to allow different separators between keywords.

comment:12 Changed 14 years ago by CuriousCurmudgeon

Resolution: fixed
Status: reopenedclosed

The keyword separator confusion should be resolved by r8120 on #7181. You can now configure what you want the separators to be.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain CuriousCurmudgeon.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.