Skip to content

Commit bae485b

Browse files
authored
Merge pull request #144 from jenkinsci/right-align-number-columns
[JENKINS-62414] Make number columns right aligned
2 parents 47016b6 + f871079 commit bae485b

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<url>https://github.com/jenkinsci/data-tables-api-plugin</url>
1919

2020
<properties>
21-
<revision>1.10.21-4</revision>
21+
<revision>1.10.23-1</revision>
2222
<changelist>-SNAPSHOT</changelist>
2323
<datatables.version>1.10.23</datatables.version>
2424

src/main/java/io/jenkins/plugins/datatables/TableColumn.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,34 @@ public class TableColumn {
3131
private final String headerLabel;
3232
private final String definition;
3333

34+
/**
35+
* Renders a expandable details column with the specified text.
36+
*
37+
* @param detailsText
38+
* the text to show if the column has been expanded.
39+
*
40+
* @return the HTML div to create the details column
41+
*/
3442
public static String renderDetailsColumn(final String detailsText) {
3543
return renderDetailsColumn(detailsText, new JenkinsFacade());
3644
}
3745

46+
/**
47+
* Renders a expandable details column with the specified text.
48+
*
49+
* @param detailsText
50+
* the text to show if the column has been expanded.
51+
* @param jenkinsFacade
52+
* facade for Jenkins API calls
53+
*
54+
* @return the HTML div to create the details column
55+
*/
3856
public static String renderDetailsColumn(final String detailsText, final JenkinsFacade jenkinsFacade) {
3957
return div()
4058
.withClass("details-control")
4159
.attr("data-description", detailsText)
42-
.with(new UnescapedText(new SvgTag(DETAILS_COLUMN_ICON_NAME, jenkinsFacade).withClasses("details-icon").render()))
60+
.with(new UnescapedText(
61+
new SvgTag(DETAILS_COLUMN_ICON_NAME, jenkinsFacade).withClasses("details-icon").render()))
4362
.render();
4463
}
4564

@@ -101,8 +120,8 @@ public TableColumn setHeaderClass(final ColumnCss headerClass) {
101120
}
102121

103122
/**
104-
* Sets the width of the column. Will be expanded to the class {@code col-width-[width]}, see
105-
* {@code jenkins-style.css} for details about the actual percentages.
123+
* Sets the width of the column. Will be expanded to the class {@code col-width-[width]}, see {@code
124+
* jenkins-style.css} for details about the actual percentages.
106125
*
107126
* @param width
108127
* the width CSS class to select for the column
@@ -138,10 +157,14 @@ public enum ColumnCss {
138157
/** No special rendering, the display property will be shown as such. */
139158
NONE(""),
140159
/**
141-
* Dates will be shown using Luxon. The display value will be a human friendly relative time like
142-
* "two weeks ago", rather than an absolute time. A tooltip is available that shows the absolute time.
160+
* Dates will be shown using Luxon. The display value will be a human friendly relative time like "two weeks
161+
* ago", rather than an absolute time. A tooltip is available that shows the absolute time.
143162
*/
144163
DATE("date"),
164+
/**
165+
* Numbers will be shown right aligned so they can be compared more easily..
166+
*/
167+
NUMBER("text-right"),
145168
/** Disables sorting of the column. Rendering is the same as with {@code NONE}. */
146169
NO_SORT("nosort");
147170

src/main/webapp/css/jenkins-style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ table.dataTable {
66
border-collapse: collapse !important;
77
}
88

9+
tfoot {
10+
font-weight: bold;
11+
}
12+
913
/* Change color of active pagination, to fit to the material blue grey css */
1014
.pagination > .active > a, .pagination > .active > a:focus, .pagination > .active > a:hover, .pagination > .active > span, .pagination > .active > span:focus, .pagination > .active > span:hover {
1115
background-color: #b4b4b4;

src/main/webapp/js/table.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jQuery3(document).ready(function () {
2020
targets: 'nosort', // All columns with the '.nosort' class in the <th>
2121
orderable: false
2222
},
23+
{
24+
targets: 'text-right', // All columns with the '.text-right' class in the <th>
25+
className: 'text-right'
26+
},
2327
{
2428
targets: 'date', // All columns with the '.date' class in the <th>
2529
render: function (data, type, _row, _meta) {

0 commit comments

Comments
 (0)