Opened 18 years ago
Closed 18 years ago
#3771 closed defect (fixed)
Custom query - radio button shows wrong selection even though results are correct
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | low | Milestone: | 0.11 |
Component: | report system | Version: | 0.9.6 |
Severity: | minor | Keywords: | query patch |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I have a custom ticket field called "crb_approved", and I created this custom query with a link from another page:
[query:status=closed&crb_approved=0&order=id Unapproved closed tickets]
When I view the report, the results are correct, but the crb_approved radio button displayed on the Custom Query page shows up with "True" (should be "False") for the crb_approved field based on the query.
Attachments (0)
Change History (6)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Keywords: | query added |
---|---|
Severity: | trivial → minor |
The workaround is to use this query instead:
[query:status=closed&crb_approved=!1&order=id Unapproved closed tickets]
It chooses the correct radio button, and pressing Update on the query afterwards displays the correct results.
comment:3 by , 18 years ago
I can duplicate this easily on 0.11.
- Add a
checkbox
custom field totrac.ini
.approved = checkbox approved.label = Approved by me approved.value = 0
- Create a few sample tickets, checking the checkbox in some, and not in others
- Run a custom query using that custom field as a filter
- Try to choose "No" for that custom field, then press "Update".
The "Yes" radio button will show every time. The results are correct though, but if you hit update again without paying attention, the results are dramatically different.
comment:4 by , 18 years ago
Keywords: | patch added |
---|---|
Milestone: | 0.10.4 → 0.11 |
Turns out to be a pretty easy fix:
-
templates/query.html
85 85 86 86 <py:when test="'checkbox'"> 87 87 <input type="radio" id="${field_name}_on" name="$field_name" value="1" 88 checked="${constraint.mode != '!' or None}" />88 checked="${constraint.mode != '!' or constraint_value == '1' or None}" /> 89 89 <label for="${field_name}_on">yes</label> 90 90 <input type="radio" id="${field_name}_off" name="$field_name" value="0" 91 checked="${constraint.mode == '!' or None}" />91 checked="${constraint.mode == '!' or constraint_value == '0' or None}" /> 92 92 <label for="${field_name}_off">no</label> 93 93 </py:when>
I tested this and it fixes the example in comment:3, and also my originally reported issue as well.
comment:5 by , 18 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
OK, I'll try to commit that this evening.
comment:6 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Applied in r4462. Also fixed the initial value for the _off
radio button when added by Javascript by using "0" instead of "!1". Besides being clearer, this is also not the same: "!1" also matched the tickets for which the field was unset.
There's still a very minor issue when the field is not added by Javascript. As this is very minor and will probably be fixed when the fields are reworked (WorkFlow branch), I'm closing this as fixed.
Thanks for the patch, sid!
The reason I noticed this is when I close some of those tickets in the custom query, then hit update, the incorrect value for the checkbox is used, and the wrong results come back. Quite confusing.