#11027 closed enhancement (fixed)
Show numer of table entries in heading on ticket admin pages
Reported by: | 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 )
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)
Change History (19)
comment:1 by , 12 years ago
Cc: | added |
---|
follow-up: 13 comment:2 by , 12 years ago
comment:3 by , 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 , 12 years ago
Description: | modified (diff) |
---|
comment:5 by , 12 years ago
Milestone: | → 1.0.2 |
---|---|
Owner: | set to |
Status: | new → assigned |
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 , 11 years ago
Owner: | changed from | to
---|
Changes can be found in rjollos.git:t11027, including suggestions from comment:5.
comment:7 by , 11 years ago
API Changes: | modified (diff) |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | assigned → closed |
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 , 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 , 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.
comment:10 by , 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.
follow-up: 12 comment:11 by , 11 years ago
Proposed fix for visible count on the edit pages can be found in rjollos.git:t11027.2.
comment:12 by , 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.
comment:13 by , 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.
follow-up: 15 comment:14 by , 11 years ago
Full set of changes can now be found in log:rjollos.git:t11027.3.
follow-up: 16 comment:15 by , 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 11 11 </head> 12 12 13 13 <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> 16 18 17 19 <py:choose test="view"> 18 20 <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
.
comment:16 by , 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] andlist_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 , 11 years ago
API Changes: | modified (diff) |
---|
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:h2
line.Any ideas on what is best?