#11269 closed enhancement (fixed)
Ticket validation warnings are difficult to notice
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | 1.4 |
Component: | ticket system | Version: | 1.0-stable |
Severity: | normal | Keywords: | |
Cc: | martin@… | Branch: | |
Release Notes: |
Improved placement of ticket validation warnings on ticket page. |
||
API Changes: | |||
Internal Changes: |
Description
When a ticket validation fails, e.g. due to ITicketManipulator.validate_ticket(..), a warning message is displayed at the top of the page (just below nav). However, the page is scrolled to #trac-add-comment
, which means the warning is most likely not in view. Inexperienced users might not notice that the change/comment was not saved.
When the validation fails due to a concurrent change, there are 2 informations displayed:
- The warning at the top of the page
- The explanation near the comment field
This makes it much easier to notice the issue. It would make sense to display other validation warnings also near the comment field.
Is there support for providing both a warning and an explanation message from ITicketManipulator.validate_ticket(..) or is there some other mechanism used when a concurrent change is detected?
I can probably produce a patch with some guidance.
Attachments (2)
Change History (24)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Cc: | added |
---|
I'm not sure if this will make it into 1.0.2, but I plan to do something about it.
follow-up: 4 comment:3 by , 11 years ago
I did some investigation on how the warnings are produced.
- The ticket validation warnings are produced using
add_warning
on the req. Displayed by theme.html. - The concurrent change warning seems to have special support in the ticket template.
Some ideas on different approaches:
- Duplicate the warning block in theme.html to make the warnings appear twice: current location (top) and just above the footer.
- Introduce display of warnings in ticket.html, e.g. just above the concurrent edit warning ("trac-edit-warning").
- Is there some way of avoiding the scrolling to force the window position to stay at the top when there is a warning? Anything useful in #11084 ?
by , 11 years ago
Attachment: | WarningAboveCommentBox.png added |
---|
follow-ups: 18 21 comment:4 by , 11 years ago
Replying to thomas.akesson@…:
- Introduce display of warnings in ticket.html, e.g. just above the concurrent edit warning ("trac-edit-warning").
- Is there some way of avoiding the scrolling to force the window position to stay at the top when there is a warning? Anything useful in #11084 ?
Your analysis looks good. I think either of these two options would work well, however there are complications that I'll mention in a moment.
I tried the following based on your suggestion,
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht index 6a39059..91b7a96 100644
a b 182 182 <div py:if="ticket.exists and can_append" id="trac-add-comment" class=" 183 183 <h3 class="foldable" id="edit">Add Comment</h3> 184 184 <div> 185 <div id="warning" py:if="chrome.warnings" class="system-message"> 186 <py:choose test="len(chrome.warnings)"> 187 <strong>Warning:</strong> 188 <py:when test="1">${chrome.warnings[0]}</py:when> 189 <py:otherwise><ul><li py:for="warning in chrome.warnings">$warn 190 </py:choose> 191 </div> 185 192 <div id="trac-edit-warning" class="warning system-message" 186 193 style="${'display: none' if start_time == ticket['changetime'] 187 194 i18n:msg="">
One easy way to produce a warning is to remove the Summary from a ticket. Here is the case of a ticket change in which the summary was removed, and there is also a concurrent edit collision:
We are displaying warnings in the ticket warning box that have nothing to do with the ticket. Maybe if add_warning
had a realm parameter, we could filter the warnings to just the ticket realm. Alternatively, we could wrap the add_warning
calls in tags/trac-1.0.1/trac/ticket/web_ui.py with a function that also passes the text to the template to be displayed in our warning box above the ticket comment box. I tend to think the latter could work okay. In that case, we could also not show the Sorry you cannot save your changes… here, and just show the This ticket has been modified … in the Warning: box.
Since you mentioned #11084, I started looking at the scrollToTop function. However, from what I see this code can be removed since it only appears when the user presses Preview, and when a preview is requested the scroll is handled by POSTing to the href
#trac-add-comment
: tags/trac-1.0.1/trac/ticket/templates/ticket.html@:182#L180. The scrollToTop
was added in [8753#file8]. It may have been intended to work in auto-preview mode, but if that is the case we'll have to add logic in the JavaScript code rather than the template code.
For the case of the New Ticket page, a similar thing happens when you try to create a ticket without a Summary. The warning can't be seen on the page because the #ticket
fragment in the URL causes a scroll as well: tags/trac-1.0.1/trac/ticket/templates/ticket.html@:183#L180.
In order to prevent the scrolling, it appears we'd need to somehow remove or not add the fragment when warnings are present.
comment:5 by , 11 years ago
Milestone: | → next-stable-1.0.x |
---|
follow-up: 7 comment:6 by , 11 years ago
Hello, I solved this specifically with a solution in the net about javascript scrollable panes and applied it to the ticket warning box, here are the steps to change in theme.html:
- Create a father div for the warning box div and give it the style 1margin-top:10px; width: 100%; z-index: 9991
- Create a div before the one in 1) that will serve as an anchor
- Some javascript text before all of these div's and some javascript after
There is a small flicker problem but its acceptable (I think). Here is the full code:
<script type='text/javascript'>//<![CDATA[ function moveScroller() { var move = function() { var st = $(window).scrollTop(); var ot = $("#scroller-anchor").offset().top; var s = $("#scroller"); if(st > ot) { s.css({ position: "fixed", top: "0px" }); } else { if(st <= ot) { s.css({ position: "relative", top: "" }); } } }; $(window).scroll(move); move(); }//]]> </script> <div id="scroller-anchor"></div> <div id="scroller" style="margin-top:10px;width: 100%;z-index: 999"> <div id="warning" py:if="chrome.warnings" class="system-message"> <a class="trac-close-msg" href="#" title="Hide this warning"><span>close</span></a> <py:choose test="len(chrome.warnings)"> <strong>Atenção:</strong> <py:when test="1">${chrome.warnings[0]}</py:when> <py:otherwise><ul><li py:for="warning in chrome.warnings">$warning</li></ul></py:otherwise> </py:choose> </div> </div> <script type="text/javascript"> $(function() { moveScroller(); }); </script>
comment:7 by , 11 years ago
The javascript solution is working like a charm. Totally solved the problem. Thx!
comment:8 by , 10 years ago
I see the JS workaround, and may use it. But is this still going to get fixed in trac core, so we don't have to workaround? Not trying to hurry, just checking it was still planned, and registering my interest.
by , 10 years ago
Attachment: | trac-warning-scroller.js added |
---|
comment:9 by , 10 years ago
I took the solution from comment:6 and turned it into a pure JS solution. Now you don't have to mess around with theme.html - simply include the attached javascript file and it does the rest.
comment:10 by , 10 years ago
Cc: | added |
---|
comment:11 by , 10 years ago
Another case I encountered today in which the warning is not visible is when the comment size exceeds max_comment_size
. The mechanism is the same as what is discussed in this ticket, just a different trigger.
comment:12 by , 8 years ago
Milestone: | next-stable-1.0.x → next-stable-1.2.x |
---|
Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.
follow-up: 20 comment:13 by , 8 years ago
Progress on the issue is being made in #12725 (changes targeted to 1.3.x). If those changes are committed, this ticket could still address:
- Visibility of notices on plugin admin page (comment:1)
- Display of general warnings in the ticket validation warning area (comment:4): replace the
add_warning
calls in _validate_ticket with a function that also creates a list of warnings to be displayed in our warning box above the ticket preview. - Possibly address this issue on 1.2-stable. An alternate approach for 1.2-stable might be to not scroll to the preview when there is a warning displayed.
follow-up: 15 comment:14 by , 7 years ago
Hello
A lot of discussion here is about ticket warnings when applying ticket comments. However, please consider also other ticket edits for example collisions of the ticket description body. This is (another) reason for why it may not be desirable to display the ticket warning above the "ticket comment" area.
My recommendation is to put such warnings near the "SUBMIT" button. Because we want to warn people before submitting ticket changes (not only comments) which provoke a collision. In other words: Hitting the "SUBMIT" button makes the actual ticket changes and collision, this is why we need the warning there and not on other places.
Clemens
comment:15 by , 7 years ago
I am still using TRAC 1.0 but noticed that in TRAC 1.2 the "COMMENT" field has moved below the "EDIT" field. This is a very good decision because then the "COMMENT" field (together with any WARNING boxes…) moves closes to the "SUBMIT" button.
TRAC 1.0 | TRAC 1.2 |
---|---|
|
|
Replying to c.feige@…:
My recommendation is to put such warnings near the "SUBMIT" button.
comment:16 by , 5 years ago
Milestone: | next-stable-1.2.x → 1.2.6 |
---|
I'd like to improve the behavior for the ticket page on 1.2-stable, without putting too much effort into it, and then create a new ticket for 1.4-stable if there are any remaining issues.
I'm considering the following to prevent scrolling when there is a warning. Thoughts?
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index 344507076..f4116e70e 100644
a b 28 28 jQuery(document).ready(function($) { 29 29 $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section")); 30 30 $(".foldable").enableFolding(false, true); 31 <py:if test="req.chrome['warnings']"> 32 location.hash = ''; 33 </py:if> 31 34 <py:when test="ticket.exists">/*<![CDATA[*/ 32 35 $("#attachments").toggleClass("collapsed"); 33 36 $("#trac-up-attachments").click(function () { … … ${value}</textarea> 323 326 324 327 <!--! Add comment --> 325 328 <div py:if="ticket.exists and can_append" id="trac-add-comment" 326 class="${classes('field', 'trac-scroll' if preview_mode else None)}"> 329 class="${classes('field', 'trac-scroll' if preview_mode and 330 not req.chrome['warnings'] 331 else None)}"> 327 332 <h3 class="foldable" id="edit">Add Comment</h3> 328 333 <div> 329 334 <div id="trac-edit-warning" class="warning system-message"
The downside is that the warning could be unrelated to the ticket, like Can't synchronize with repository. However, I think it's still an improvement. Also, we should consider whether Can't synchronize with repository should be displayed as a warning. It's a configuration issue and we should consider if only TRAC_ADMIN
should see it, or if it should be logged rather than displayed on the page.
comment:17 by , 5 years ago
Milestone: | 1.2.6 → 1.4.2 |
---|
The comment:16 change seems ugly. Will check if the issue still exists on 1.4-stable.
comment:18 by , 5 years ago
Replying to Ryan J Ollos:
We are displaying warnings in the ticket warning box that have nothing to do with the ticket.
I've been considering we should either remove these "Can't synchronize" warnings or only show them if the user has TRAC_ADMIN
(noted also in comment:16): #13301.
comment:19 by , 5 years ago
Cc: | removed |
---|---|
Milestone: | 1.4.2 → 1.4 |
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | new → closed |
This was fixed in 1.4. See comment:description:ticket:13260 for a list of template locations the warnings are added.
comment:20 by , 5 years ago
comment:21 by , 5 years ago
Replying to Ryan J Ollos:
Since you mentioned #11084, I started looking at the scrollToTop function. However, from what I see this code can be removed since it only appears when the user presses Preview, and when a preview is requested the scroll is handled by POSTing to the
href
#trac-add-comment
: tags/trac-1.0.1/trac/ticket/templates/ticket.html@:182#L180. ThescrollToTop
was added in [8753#file8]. It may have been intended to work in auto-preview mode, but if that is the case we'll have to add logic in the JavaScript code rather than the template code.
I will do some more testing, but looks like we can remove trac-scroll
class on 1.4-stable:
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index 9695b8420..6528a8b20 100644
a b 492 492 ## Add comment 493 493 494 494 # if ticket.exists and can_append: 495 <div id="trac-add-comment" 496 class="${classes('field', 'trac-scroll' if preview_mode)}"> 495 <div id="trac-add-comment" class="field"> 497 496 <h3 class="foldable" id="edit">${_("Add Comment")}</h3> 498 497 <div>
I think I have a note somewhere to remind myself to try and fix this, but I'd be happy if you produced a patch :) The necessary change might be similar to #11102.
There is also a similar issue on the Plugin admin panel. After enabling or disabling a plugin, there is a notice displayed in the standard location below the contextual navigation, but the page scrolls to the plugin for which the changes were just applied, so the notice is almost never visible (th:comment:25:ticket:10741).