Edgewall Software
Modify

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#11027 closed enhancement (fixed)

Show numer of table entries in heading on ticket admin pages

Reported by: Ryan J Ollos <ryan.j.ollos@…> Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: admin/web Version: 1.0-stable
Severity: normal Keywords:
Cc: Steffen Hoffmann Branch:
Release Notes:

Number of table entries is shown next to heading on applicable admin pages.

API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos <ryan.j.ollos@…>)

It can be useful to see at a glance the number of entries in the Components or Milestones tables, for instance. The attachment sections nicely show the number of attachments (added in #10743), using the trac-count class for styling. This is also done other places in Trac, and we recently added the feature to tables in the th:AccountManagerPlugin as well (th:#7426).

I propose to add a table entry count to the heading of the following admin panels:

  • General: Plugins
  • Ticket System: Components
  • Ticket System: Milestones
  • Ticket System: enums
    • Ticket System: Priorities
    • Ticket System: Resolutions
    • Ticket System: Severities
    • Ticket System: Ticket Types
  • Ticket System: Versions
  • Version Control: Repositories

Attachments (2)

t11027-r11682-1.patch (4.0 KB ) - added by Ryan J Ollos <ryan.j.ollos@…> 12 years ago.
Patch against r11682 of the trunk.
edit-component.png (9.1 KB ) - added by Jun Omae 11 years ago.
(0) in h2 tag

Download all attachments as: .zip

Change History (19)

comment:1 by Steffen Hoffmann, 12 years ago

Cc: Steffen Hoffmann added

comment:2 by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

It looks like the best option may be to implement this in JavaScript. The problem with implementing it in the template is that variables such as components are generators, so it's not possible to know the number of items in the table until the table is constructed. In order to implement this in the template, it looks like we'd need to either:

  • Iterate over the generator twice.
  • Extract the generator to a list, either in the python code or at the top of the template before the h2 line.

Any ideas on what is best?

by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

Attachment: t11027-r11682-1.patch added

Patch against r11682 of the trunk.

comment:3 by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

t11027-r11682-1.patch implements the feature in JavaScript, in the way described in comment:1. I couldn't find a way to put lightweight generic code in admin.html without a count being added to the Logging page, Permissions page, etc.., but maybe someone will have a clever way to accomplish that. Also, the selector for the Plugins page is slightly different anyway.

Side note: For the trac-count class, the text in the span seems to align better with the text outside the span if I change vertical-align: baseline;vertical-align: top;. I first tried vertical-align: middle;, thinking that would produce the best results, but the result appeared to be the same as vertical-align: baseline;. This is true for the Attachment and Change History count numbers on the ticket page as well (Chrome 22 on Debian, Iceweasel 10 on Debian). I'm not sure why that is the case though, so I haven't included the change in the patch.

comment:4 by Ryan J Ollos <ryan.j.ollos@…>, 12 years ago

Description: modified (diff)

comment:5 by Christian Boos, 12 years ago

Milestone: 1.0.2
Owner: set to Christian Boos
Status: newassigned

Well, we'd need two Javascript helper functions (in trac.js?).

Something like:

  • $("h2").add_counter(n)
  • $("h2").add_row_counter($("table.listing")) (using the above)

comment:6 by Ryan J Ollos, 11 years ago

Owner: changed from Christian Boos to Ryan J Ollos

Changes can be found in rjollos.git:t11027, including suggestions from comment:5.

comment:7 by Ryan J Ollos, 11 years ago

API Changes: modified (diff)
Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Tested with Chrome 28, Firefox 23 and Opera 12.16. Fixed some indentation issues with rjollos.git:t11027 and committed to 1.0-stable in [12015]. Merged to trunk in [12016].

comment:8 by Remy Blank, 11 years ago

Looks good! I'm wondering, why did you choose to implement this in JavaScript (as opposed to adding the count "statically" in Genshi, using a len(items))? That would have made the feature available to users with JavaScript disabled (not that we care that much nowadays).

comment:9 by Ryan J Ollos, 11 years ago

I considered going the Genshi route, and made some notes about this in comment:1. I realize now that iterating over the generator twice probably wouldn't work, but I could have just generated a list at the top of the template. It seemed ugly, but thinking about it now, it is probably not a big deal and I like having the no-JavaScript fallback. I could revisit this; it wouldn't take long to redo it in Genshi.

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

by Jun Omae, 11 years ago

Attachment: edit-component.png added

(0) in h2 tag

comment:10 by Jun Omae, 11 years ago

In edit component page and edit repository page, (0) as number of entries is shown in heading, edit-component.png. I don't think that the number should be shown in heading on edit page.

comment:11 by Ryan J Ollos, 11 years ago

Proposed fix for visible count on the edit pages can be found in rjollos.git:t11027.2.

in reply to:  11 comment:12 by Ryan J Ollos, 11 years ago

Replying to rjollos:

Proposed fix for visible count on the edit pages can be found in rjollos.git:t11027.2.

Committed to 1.0-stable in [12024] and merged to trunk in [12025]. Thanks Jun!

I'll investigate the Genshi-based solution in the near future.

in reply to:  2 comment:13 by Ryan J Ollos, 11 years ago

Replying to Ryan J Ollos <ryan.j.ollos@…>:

It looks like the best option may be to implement this in JavaScript. The problem with implementing it in the template is that variables such as components are generators, so it's not possible to know the number of items in the table until the table is constructed.

Since #11103 / [11919] the components variable is a list rather than a generator.

It looks like it makes sense to implement this in the template code rather than in JavaScript. The proposed changes can be found in log:rjollos.git:t11027.3, implemented for just the Admin Components page thus far.

comment:14 by Ryan J Ollos, 11 years ago

Full set of changes can now be found in log:rjollos.git:t11027.3.

in reply to:  14 ; comment:15 by Jun Omae, 11 years ago

Replying to rjollos:

Full set of changes can now be found in log:rjollos.git:t11027.3.

I like the use of Genshi template rather than Javascript ;) Also, it works fine.

I have one thing. I think that admin_enums.html should be the following.

  • trac/ticket/templates/admin_enums.html

    diff --git a/trac/ticket/templates/admin_enums.html b/trac/ticket/templates/admin_enums.html
    index 3683946..b7b9e40 100644
    a b  
    1111  </head>
    1212
    1313  <body>
    14     <h2 i18n:msg="label_plural, count">Manage $label_plural <!--!
    15     --><span py:if="view == 'list'" class="trac-count">(${len(enums)})</span></h2>
     14    <h2>
     15      <i18n:msg params="label_plural">Manage $label_plural</i18n:msg>
     16      <span py:if="view == 'list'" class="trac-count">(${len(enums)})</span>
     17    </h2>
    1618
    1719    <py:choose test="view">
    1820      <form py:when="'detail'" class="mod" id="modenum" method="post" action="">

Because the label and the number are separated in tags/trac-1.0.1/trac/templates/list_of_attachments.html#L28 and that is inconsistent. If you don't want to separate, we should use i18n:msg in order to extract as one for all headings in [bbf16363/rjollos.git], [2bb2fb80/rjollos.git] and list_of_attachments.html.

in reply to:  15 comment:16 by Ryan J Ollos, 11 years ago

Replying to jomae:

Because the label and the number are separated in tags/trac-1.0.1/trac/templates/list_of_attachments.html#L28 and that is inconsistent. If you don't want to separate, we should use i18n:msg in order to extract as one for all headings in [bbf16363/rjollos.git], [2bb2fb80/rjollos.git] and list_of_attachments.html.

Thanks Jun. As far as I know, it make sense to keep them separate.

Committed to 1.0-stable in [12180] and merged to trunk in [12181].

comment:17 by Ryan J Ollos, 11 years ago

API Changes: modified (diff)

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'.
to The owner will be changed from Ryan J Ollos 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.