diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-24 15:16:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-01 16:14:15 -0400 |
commit | 4062e46eb07c4202d8872ecc02eb246304dda01e (patch) | |
tree | abda5847197f14a1ab7de86198c5b2f8ffd04005 /src/main/java/com/gitblit/wicket/pages | |
parent | b3f70e7ed4b4c59fc578f529411f41e3fd6b192f (diff) | |
download | gitblit-4062e46eb07c4202d8872ecc02eb246304dda01e.tar.gz gitblit-4062e46eb07c4202d8872ecc02eb246304dda01e.zip |
Revise My Tickets layout and styling
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages')
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html | 183 | ||||
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java | 209 |
2 files changed, 290 insertions, 102 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html index 459d2551..9ecc4b6e 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.html @@ -8,94 +8,123 @@ <wicket:extend> <div class="container"> - <!-- search tickets form --> - <div class="hidden-phone pull-right"> - <form class="form-search" style="margin: 0px;" wicket:id="ticketSearchForm"> - <div class="input-append"> - <input type="text" class="search-query" style="width: 170px;border-radius: 14px 0 0 14px; padding-left: 14px;" id="ticketSearchBox" wicket:id="ticketSearchBox" value=""/> - <button class="btn" style="border-radius: 0 14px 14px 0px;margin-left:-5px;" type="submit"><i class="icon-search"></i></button> + <div class="row" style="padding-top:15px;min-height:500px;" > + <div class="tab-pane active" id="tickets"> + <!-- query controls --> + <div class="span3"> + <div class="hidden-phone"> + <div> + <div style="display:inline-block;vertical-align:top;padding-right:2px;"><img wicket:id="userGravatar"></img></div> + <div style="display:inline-block;"> + <div style="font-size:1.5em;" wicket:id="userDisplayName"></div> + <div style="color:#888;font-size:1.2em;"><wicket:message key="gb.mytickets"></wicket:message></div> + </div> + </div> + + <!-- query list --> + <ul class="nav nav-list"> + <li class="nav-header"><wicket:message key="gb.queries"></wicket:message></li> + <li><a wicket:id="changesQuery"><i class="fa fa-code-fork"></i> <wicket:message key="gb.proposalTickets"></wicket:message></a></li> + <li><a wicket:id="bugsQuery"><i class="fa fa-bug"></i> <wicket:message key="gb.bugTickets"></wicket:message></a></li> + <li><a wicket:id="enhancementsQuery"><i class="fa fa-magic"></i> <wicket:message key="gb.enhancementTickets"></wicket:message></a></li> + <li><a wicket:id="tasksQuery"><i class="fa fa-ticket"></i> <wicket:message key="gb.taskTickets"></wicket:message></a></li> + <li><a wicket:id="questionsQuery"><i class="fa fa-question"></i> <wicket:message key="gb.questionTickets"></wicket:message></a></li> + <li wicket:id="userDivider" class="divider"></li> + <li><a wicket:id="createdQuery"><i class="fa fa-user"></i> <wicket:message key="gb.yourCreatedTickets"></wicket:message></a></li> + <li><a wicket:id="watchedQuery"><i class="fa fa-eye"></i> <wicket:message key="gb.yourWatchedTickets"></wicket:message></a></li> + <li><a wicket:id="mentionsQuery"><i class="fa fa-comment"></i> <wicket:message key="gb.mentionsMeTickets"></wicket:message></a></li> + <li class="divider"></li> + <li><a wicket:id="resetQuery"><i class="fa fa-bolt"></i> <wicket:message key="gb.reset"></wicket:message></a></li> + </ul> + + <!-- search tickets form --> + <form class="form-search" style="margin: 0px;" wicket:id="ticketSearchForm"> + <div class="input-append"> + <input type="text" class="search-query" style="width: 170px;border-radius: 14px 0 0 14px; padding-left: 14px;" id="ticketSearchBox" wicket:id="ticketSearchBox" value=""/> + <button class="btn" style="border-radius: 0 14px 14px 0px;margin-left:-5px;" type="submit"><i class="icon-search"></i></button> + </div> + </form> + </div> </div> - </form> - </div> - <ul class="nav nav-tabs"></ul> - - <div class="tab-content"> - <div class="row" style="min-height:400px;" > - <div class="tab-pane active" id="tickets"> - <!-- query controls --> - <div class="span3"> - <div class="hidden-phone"> - <ul class="nav nav-list"> - <li class="nav-header"><wicket:message key="gb.queries"></wicket:message></li> - <li><a wicket:id="changesQuery"><i class="fa fa-code-fork"></i> <wicket:message key="gb.proposalTickets"></wicket:message></a></li> - <li><a wicket:id="bugsQuery"><i class="fa fa-bug"></i> <wicket:message key="gb.bugTickets"></wicket:message></a></li> - <li><a wicket:id="enhancementsQuery"><i class="fa fa-magic"></i> <wicket:message key="gb.enhancementTickets"></wicket:message></a></li> - <li><a wicket:id="tasksQuery"><i class="fa fa-ticket"></i> <wicket:message key="gb.taskTickets"></wicket:message></a></li> - <li><a wicket:id="questionsQuery"><i class="fa fa-question"></i> <wicket:message key="gb.questionTickets"></wicket:message></a></li> - <li wicket:id="userDivider" class="divider"></li> - <li><a wicket:id="createdQuery"><i class="fa fa-user"></i> <wicket:message key="gb.yourCreatedTickets"></wicket:message></a></li> - <li><a wicket:id="watchedQuery"><i class="fa fa-eye"></i> <wicket:message key="gb.yourWatchedTickets"></wicket:message></a></li> - <li><a wicket:id="mentionsQuery"><i class="fa fa-comment"></i> <wicket:message key="gb.mentionsMeTickets"></wicket:message></a></li> + + <!-- tickets --> + <div class="span9"> + <div class="btn-toolbar" style="margin-top: 0px;"> + <div class="btn-group"> + <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><wicket:message key="gb.status"></wicket:message>: <span style="font-weight:bold;" wicket:id="selectedStatii"></span> <span class="caret"></span></a> + <ul class="dropdown-menu"> + <li><a wicket:id="openTickets"><wicket:message key="gb.open"></wicket:message></a></li> + <li><a wicket:id="closedTickets"><wicket:message key="gb.closed"></wicket:message></a></li> + <li><a wicket:id="allTickets"><wicket:message key="gb.all"></wicket:message></a></li> <li class="divider"></li> - <li><a wicket:id="resetQuery"><i class="fa fa-bolt"></i> <wicket:message key="gb.reset"></wicket:message></a></li> + <li wicket:id="statii"><span wicket:id="statusLink"></span></li> + </ul> + </div> + <div class="btn-group"> + <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-sort"></i> <wicket:message key="gb.sort"></wicket:message>: <span style="font-weight:bold;" wicket:id="currentSort"></span> <span class="caret"></span></a> + <ul class="dropdown-menu"> + <li wicket:id="sort"><span wicket:id="sortLink"></span></li> </ul> </div> - </div> - - <!-- tickets --> - <div class="span9"> - <div class="btn-toolbar" style="margin-top: 0px;"> - <div class="btn-group"> - <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><wicket:message key="gb.status"></wicket:message>: <span style="font-weight:bold;" wicket:id="selectedStatii"></span> <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a wicket:id="openTickets"><wicket:message key="gb.open"></wicket:message></a></li> - <li><a wicket:id="closedTickets"><wicket:message key="gb.closed"></wicket:message></a></li> - <li><a wicket:id="allTickets"><wicket:message key="gb.all"></wicket:message></a></li> - <li class="divider"></li> - <li wicket:id="statii"><span wicket:id="statusLink"></span></li> - </ul> - </div> - - <div class="btn-group"> - <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-sort"></i> <wicket:message key="gb.sort"></wicket:message>: <span style="font-weight:bold;" wicket:id="currentSort"></span> <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li wicket:id="sort"><span wicket:id="sortLink"></span></li> - </ul> - </div> - <div class="btn-group pull-right"> - <div class="pagination pagination-right pagination-small"> - <ul> - <li><a wicket:id="prevLink"><i class="fa fa-angle-double-left"></i></a></li> - <li wicket:id="pageLink"><span wicket:id="page"></span></li> - <li><a wicket:id="nextLink"><i class="fa fa-angle-double-right"></i></a></li> - </ul> - </div> + <div class="btn-group pull-right"> + <div class="pagination pagination-right pagination-small"> + <ul> + <li><a wicket:id="prevLink"><i class="fa fa-angle-double-left"></i></a></li> + <li wicket:id="pageLink"><span wicket:id="page"></span></li> + <li><a wicket:id="nextLink"><i class="fa fa-angle-double-right"></i></a></li> + </ul> </div> </div> - <table class="table tickets"> - <tbody> - <tr wicket:id="row"> - <td class="left" style="padding-left:3px;"> - <b><span class="repositorySwatch" wicket:id="repositorySwatch"></span></b> - <span style="padding-left:3px;" wicket:id="repositoryName">[repository name]</span> - </td> - <td class="hidden-phone"> - <span wicket:id="ticketIcon">[ticket icon]</span> - <span class="list" wicket:id="ticketTitle">[ticket title]</span> - <span style="color:#888;"> (#<span wicket:id="ticketNumber">[ticket number]</span>)</span> - </td> - <td><span class="badge badge-info" wicket:id="ticketVotes"></span></td> - <td><span wicket:id="ticketStatus"></span></td> - <td class="hidden-tablet hidden-phone author right"><span wicket:id="ticketResponsibleImg"></span><span wicket:id="ticketResponsible">[ticket responsible]</span></td> - </tr> - </tbody> - </table> </div> + <table class="table tickets"> + <tbody> + <tr wicket:id="row"> + <td class="ticket-list-icon"> + <i wicket:id="state"></i> + </td> + <td> + <span wicket:id="title">[title]</span> <span wicket:id="labels" style="font-weight: normal;color:white;"><span class="label" wicket:id="label"></span></span> + <div class="ticket-list-details"> + <span style="padding-right: 10px;" class="hidden-phone"> + <wicket:message key="gb.createdBy"></wicket:message> + <span style="padding: 0px 2px" wicket:id="createdBy">[createdBy]</span> <span class="date" wicket:id="createDate">[create date]</span> + </span> + <span wicket:id="indicators" style="white-space:nowrap;"><i wicket:id="icon"></i> <span style="padding-right:10px;" wicket:id="count"></span></span> + </div> + <div class="hidden-phone" wicket:id="updated"></div> + <div class="ticket-list-details" wicket:id="repositoryLink">[repository link]</div> + </td> + <td class="ticket-list-state"> + <span class="badge badge-info" wicket:id="votes"></span> + </td> + <td class="hidden-phone ticket-list-state"> + <i wicket:message="title:gb.watching" style="color:#888;" class="fa fa-eye" wicket:id="watching"></i> + </td> + <td class="ticket-list-state"> + <div wicket:id="status"></div> + </td> + <td class="indicators"> + <div> + <b>#<span wicket:id="id">[id]</span></b> + </div> + <div wicket:id="responsible"></div> + </td> + </tr> + </tbody> + </table> </div> </div> </div> </div> - </wicket:extend> + +<wicket:fragment wicket:id="updatedFragment"> + <div class="ticket-list-details"> + <wicket:message key="gb.updatedBy"></wicket:message> + <span style="padding: 0px 2px" wicket:id="updatedBy">[updatedBy]</span> <span class="date" wicket:id="updateDate">[update date]</span> + </div> +</wicket:fragment> + +</wicket:extend> </body> </html>
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java index 083526b6..7e988a22 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -6,18 +6,21 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.wicket.Component; import org.apache.wicket.PageParameters; +import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.request.target.basic.RedirectRequestTarget; +import org.eclipse.jgit.lib.Repository; +import com.gitblit.Constants; import com.gitblit.Keys; import com.gitblit.models.RepositoryModel; import com.gitblit.models.TicketModel; @@ -28,7 +31,9 @@ import com.gitblit.tickets.ITicketService; import com.gitblit.tickets.QueryBuilder; import com.gitblit.tickets.QueryResult; import com.gitblit.tickets.TicketIndexer.Lucene; +import com.gitblit.tickets.TicketLabel; import com.gitblit.utils.ArrayUtils; +import com.gitblit.utils.BugtraqProcessor; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.GitBlitWebSession; @@ -69,6 +74,9 @@ public class MyTicketsPage extends RootPage { final String sortBy = (params == null) ? "" : Lucene.fromString(params.getString("sort", Lucene.created.name())).name(); final boolean desc = (params == null) ? true : !"asc".equals(params.getString("direction", "desc")); + add(new GravatarImage("userGravatar", currentUser, "gravatar", 36, false)); + add(new Label("userDisplayName", currentUser.getDisplayName())); + // add search form TicketSearchForm searchForm = new TicketSearchForm("ticketSearchForm", searchParam); add(searchForm); @@ -280,6 +288,7 @@ public class MyTicketsPage extends RootPage { int totalResults = results.size() == 0 ? 0 : results.get(0).totalResults; buildPager(queryParam, milestoneParam, statiiParam, assignedToParam, sortBy, desc, page, pageSize, results.size(), totalResults); + final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true); final ListDataProvider<QueryResult> dp = new ListDataProvider<QueryResult>(results); DataView<QueryResult> dataView = new DataView<QueryResult>("row", dp) { @@ -287,43 +296,168 @@ public class MyTicketsPage extends RootPage { @Override protected void populateItem(Item<QueryResult> item) { - QueryResult ticket = item.getModelObject(); - RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository); + final QueryResult ticket = item.getModelObject(); + final RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository); - Component swatch = new Label("repositorySwatch", " ").setEscapeModelStrings(false); - WicketUtils.setCssBackground(swatch, repository.toString()); - item.add(swatch); + if (showSwatch) { + // set repository color + String color = StringUtils.getColor(StringUtils.stripDotGit(repository.name)); + WicketUtils.setCssStyle(item, MessageFormat.format("border-left: 2px solid {0};", color)); + } PageParameters rp = WicketUtils.newRepositoryParameter(ticket.repository); PageParameters tp = WicketUtils.newObjectParameter(ticket.repository, "" + ticket.number); - item.add(new LinkPanel("repositoryName", "list", StringUtils.stripDotGit(ticket.repository), SummaryPage.class, rp)); + item.add(new LinkPanel("repositoryLink", null, StringUtils.stripDotGit(ticket.repository), SummaryPage.class, rp)); + + item.add(getStateIcon("state", ticket.type, ticket.status)); + item.add(new Label("id", "" + ticket.number)); + UserModel creator = app().users().getUserModel(ticket.createdBy); + if (creator != null) { + item.add(new LinkPanel("createdBy", null, creator.getDisplayName(), + UserPage.class, WicketUtils.newUsernameParameter(ticket.createdBy))); + } else { + item.add(new Label("createdBy", ticket.createdBy)); + } + item.add(WicketUtils.createDateLabel("createDate", ticket.createdAt, GitBlitWebSession + .get().getTimezone(), getTimeUtils(), false)); + + if (ticket.updatedAt == null) { + item.add(new Label("updated").setVisible(false)); + } else { + Fragment updated = new Fragment("updated", "updatedFragment", this); + UserModel updater = app().users().getUserModel(ticket.updatedBy); + if (updater != null) { + updated.add(new LinkPanel("updatedBy", null, updater.getDisplayName(), + UserPage.class, WicketUtils.newUsernameParameter(ticket.updatedBy))); + } else { + updated.add(new Label("updatedBy", ticket.updatedBy)); + } + updated.add(WicketUtils.createDateLabel("updateDate", ticket.updatedAt, GitBlitWebSession + .get().getTimezone(), getTimeUtils(), false)); + item.add(updated); + } - item.add(getStateIcon("ticketIcon", ticket.type, ticket.status)); - item.add(new Label("ticketNumber", "" + ticket.number)); - item.add(new LinkPanel("ticketTitle", "list", ticket.title, TicketsPage.class, tp)); + item.add(new LinkPanel("title", "list subject", StringUtils.trimString( + ticket.title, Constants.LEN_SHORTLOG), TicketsPage.class, tp)); + + ListDataProvider<String> labelsProvider = new ListDataProvider<String>(ticket.getLabels()); + DataView<String> labelsView = new DataView<String>("labels", labelsProvider) { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final Item<String> labelItem) { + BugtraqProcessor btp = new BugtraqProcessor(app().settings()); + Repository db = app().repositories().getRepository(repository.name); + String content = btp.processPlainCommitMessage(db, repository.name, labelItem.getModelObject()); + db.close(); + Label label = new Label("label", content); + label.setEscapeModelStrings(false); + TicketLabel tLabel = app().tickets().getLabel(repository, labelItem.getModelObject()); + String background = MessageFormat.format("background-color:{0};", tLabel.color); + label.add(new SimpleAttributeModifier("style", background)); + labelItem.add(label); + } + }; + item.add(labelsView); + + if (StringUtils.isEmpty(ticket.responsible)) { + item.add(new Label("responsible").setVisible(false)); + } else { + UserModel responsible = app().users().getUserModel(ticket.responsible); + if (responsible == null) { + responsible = new UserModel(ticket.responsible); + } + GravatarImage avatar = new GravatarImage("responsible", responsible.getDisplayName(), + responsible.emailAddress, null, 16, true); + avatar.setTooltip(getString("gb.responsible") + ": " + responsible.getDisplayName()); + item.add(avatar); + } // votes indicator - Label v = new Label("ticketVotes", "" + ticket.votesCount); + Label v = new Label("votes", "" + ticket.votesCount); WicketUtils.setHtmlTooltip(v, getString("gb.votes")); item.add(v.setVisible(ticket.votesCount > 0)); - Label ticketStatus = new Label("ticketStatus", ticket.status.toString()); - String statusClass = getStatusClass(ticket.status); - WicketUtils.setCssClass(ticketStatus, statusClass); - item.add(ticketStatus); + // watching indicator + item.add(new Label("watching").setVisible(ticket.isWatching(GitBlitWebSession.get().getUsername()))); - UserModel responsible = app().users().getUserModel(ticket.responsible); - if (responsible == null) { - if (ticket.responsible == null) { - item.add(new Label("ticketResponsibleImg").setVisible(false)); - } else { - item.add(new GravatarImage("ticketResponsibleImg", ticket.responsible, ticket.responsible, null, 16, true)); + // status indicator + String css = getLozengeClass(ticket.status, true); + Label l = new Label("status", ticket.status.toString()); + WicketUtils.setCssClass(l, css); + item.add(l); + + // add the ticket indicators/icons + List<Indicator> indicators = new ArrayList<Indicator>(); + + // comments + if (ticket.commentsCount > 0) { + int count = ticket.commentsCount; + String pattern = "gb.nComments"; + if (count == 1) { + pattern = "gb.oneComment"; } - item.add(new Label("ticketResponsible", ticket.responsible)); - } else { - item.add(new GravatarImage("ticketResponsibleImg", responsible, null, 16, true)); - item.add(new LinkPanel("ticketResponsible", null, responsible.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(ticket.responsible))); + indicators.add(new Indicator("fa fa-comment", count, pattern)); + } + + // participants + if (!ArrayUtils.isEmpty(ticket.participants)) { + int count = ticket.participants.size(); + if (count > 1) { + String pattern = "gb.nParticipants"; + indicators.add(new Indicator("fa fa-user", count, pattern)); + } + } + + // attachments + if (!ArrayUtils.isEmpty(ticket.attachments)) { + int count = ticket.attachments.size(); + String pattern = "gb.nAttachments"; + if (count == 1) { + pattern = "gb.oneAttachment"; + } + indicators.add(new Indicator("fa fa-file", count, pattern)); + } + + // patchset revisions + if (ticket.patchset != null) { + int count = ticket.patchset.commits; + String pattern = "gb.nCommits"; + if (count == 1) { + pattern = "gb.oneCommit"; + } + indicators.add(new Indicator("fa fa-code", count, pattern)); + } + + // milestone + if (!StringUtils.isEmpty(ticket.milestone)) { + indicators.add(new Indicator("fa fa-bullseye", ticket.milestone)); } + + ListDataProvider<Indicator> indicatorsDp = new ListDataProvider<Indicator>(indicators); + DataView<Indicator> indicatorsView = new DataView<Indicator>("indicators", indicatorsDp) { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final Item<Indicator> item) { + Indicator indicator = item.getModelObject(); + String tooltip = indicator.getTooltip(); + + Label icon = new Label("icon"); + WicketUtils.setCssClass(icon, indicator.css); + item.add(icon); + + if (indicator.count > 0) { + Label count = new Label("count", "" + indicator.count); + item.add(count.setVisible(!StringUtils.isEmpty(tooltip))); + } else { + item.add(new Label("count").setVisible(false)); + } + + WicketUtils.setHtmlTooltip(item, tooltip); + } + }; + item.add(indicatorsView); } }; @@ -570,4 +704,29 @@ public class MyTicketsPage extends RootPage { }; add(pagesView); } + + private class Indicator implements Serializable { + + private static final long serialVersionUID = 1L; + + final String css; + final int count; + final String tooltip; + + Indicator(String css, String tooltip) { + this.css = css; + this.tooltip = tooltip; + this.count = 0; + } + + Indicator(String css, int count, String pattern) { + this.css = css; + this.count = count; + this.tooltip = StringUtils.isEmpty(pattern) ? "" : MessageFormat.format(getString(pattern), count); + } + + String getTooltip() { + return tooltip; + } + } } |