Modify

Opened 8 years ago

Closed 7 years ago

#13171 closed defect (worksforme)

Unclear how to use invalid_when validation rule

Reported by: chuchurocket27 Owned by: Ryan J Ollos
Priority: normal Component: DynamicFieldsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

I have the following snippet in my trac.ini:

trunk_link.invalid_if = ^((?!trunk).)*$
trunk_link.invalid_when = .status .in\s+work (msg:Link to Working Copy must point to an SVN trunk URL)

This validation rule is to make sure the field has the word "trunk" in it before the user can change the status of the ticket. It works fine when the invalid_when line is commented out (i.e., enforced always) but I want to only enforce this rule when my ticket is set to "in work" (i.e., cannot be routed out of "in work" until that field is valid").

Adding the invalid_when does not work. I don't think I'm setting this rule correctly - is the preceding . specific to the CodeReviewPlugin?

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by Ryan J Ollos

Resolution: worksforme
Status: newclosed

invalid_when should be a jQuery selector. The following selector worked for me when the ticket has status accepted:

trunk_link.invalid_when = .trac-status a:contains(accepted) (msg:Link to Working Copy must point to an SVN trunk URL)

So presumably you could use:

trunk_link.invalid_when = .trac-status a:contains(in work) (msg:Link to Working Copy must point to an SVN trunk URL)

However that will prevent *any* ticket changes when the status is in work.

It sounds like you want to prevent only ticket state changes when the status is in work and the trunk_link field does not contain trunk. That's pretty complex for DynamicFieldsPlugin to handle, but you could implement an ITicketManipulator or write a few lines of custom JavaScript (see TracInterfaceCustomization#SiteAppearance).

I think it would be very simple to implement in an ITicketManipulator and couldn't be circumvented by disabling JavaScript, as DynamicFieldsPlugin can. If you are interested in pursuing it, please ask on the MailingList and we can talk through how it can be done.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
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.