Edgewall Software
Modify

Opened 11 years ago

Closed 4 years ago

Last modified 4 years ago

#11269 closed enhancement (fixed)

Ticket validation warnings are difficult to notice

Reported by: thomas.akesson@… 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)

WarningAboveCommentBox.png (49.6 KB ) - added by Ryan J Ollos 11 years ago.
trac-warning-scroller.js (916 bytes ) - added by martin@… 10 years ago.

Download all attachments as: .zip

Change History (24)

comment:1 by Ryan J Ollos, 11 years ago

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).

comment:2 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos added

I'm not sure if this will make it into 1.0.2, but I plan to do something about it.

comment:3 by thomas.akesson@…, 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 Ryan J Ollos, 11 years ago

Attachment: WarningAboveCommentBox.png added

in reply to:  3 ; comment:4 by Ryan J Ollos, 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  
    182182        <div py:if="ticket.exists and can_append" id="trac-add-comment" class="
    183183          <h3 class="foldable" id="edit">Add Comment</h3>
    184184          <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>
    185192            <div id="trac-edit-warning" class="warning system-message"
    186193                 style="${'display: none' if start_time == ticket['changetime']
    187194                 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 Ryan J Ollos, 11 years ago

Milestone: next-stable-1.0.x

comment:6 by ImPortugueseButNotRonaldo, 10 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:

  1. Create a father div for the warning box div and give it the style 1margin-top:10px; width: 100%; z-index: 9991
  2. Create a div before the one in 1) that will serve as an anchor
  3. 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>
Last edited 10 years ago by Ryan J Ollos (previous) (diff)

in reply to:  6 comment:7 by Thomas Schiefer, 10 years ago

The javascript solution is working like a charm. Totally solved the problem. Thx!

comment:8 by martin@…, 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 martin@…, 10 years ago

Attachment: trac-warning-scroller.js added

comment:9 by martin@…, 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 martin@…, 10 years ago

Cc: martin@… added

comment:11 by Ryan J Ollos, 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 Ryan J Ollos, 7 years ago

Milestone: next-stable-1.0.xnext-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.

comment:13 by Ryan J Ollos, 7 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.

comment:14 by c.feige@…, 6 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

in reply to:  14 comment:15 by anonymous, 6 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

  1. attachments
  2. change history
  3. add comments (+ possible WARNING box)
  4. modify ticket
  5. SUBMIT button
  1. attachments
  2. change history
  3. modify ticket
  4. add comments (+ possible WARNING box)
  5. SUBMIT button

Replying to c.feige@…:

My recommendation is to put such warnings near the "SUBMIT" button.

comment:16 by Ryan J Ollos, 4 years ago

Milestone: next-stable-1.2.x1.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  
    2828      jQuery(document).ready(function($) {
    2929        $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
    3030        $(".foldable").enableFolding(false, true);
     31      <py:if test="req.chrome['warnings']">
     32        location.hash = '';
     33      </py:if>
    3134      <py:when test="ticket.exists">/*<![CDATA[*/
    3235        $("#attachments").toggleClass("collapsed");
    3336        $("#trac-up-attachments").click(function () {
    ${value}</textarea>  
    323326
    324327        <!--! Add comment -->
    325328        <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)}">
    327332          <h3 class="foldable" id="edit">Add Comment</h3>
    328333          <div>
    329334            <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 Ryan J Ollos, 4 years ago

Milestone: 1.2.61.4.2

The comment:16 change seems ugly. Will check if the issue still exists on 1.4-stable.

in reply to:  4 comment:18 by Ryan J Ollos, 4 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.

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

comment:19 by Ryan J Ollos, 4 years ago

Cc: Ryan J Ollos removed
Milestone: 1.4.21.4
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

This was fixed in 1.4. See comment:description:ticket:13260 for a list of template locations the warnings are added.

in reply to:  13 comment:20 by Ryan J Ollos, 4 years ago

Replying to Ryan J Ollos:

  • Visibility of notices on plugin admin page (comment:1)

#13302.

in reply to:  4 comment:21 by Ryan J Ollos, 4 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. 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.

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  
    492492        ## Add comment
    493493
    494494        # 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">
    497496          <h3 class="foldable" id="edit">${_("Add Comment")}</h3>
    498497          <div>

comment:22 by Ryan J Ollos, 4 years ago

comment:21 patch applied in r17360.

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.