Change change = new Change(user.username);
change.setField(Field.status, status);
if (!ticket.isWatching(user.username)) {
change.watch(user.username);
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
setResponsePage(TicketsPage.class, getPageParameters());
}
};
String css = getStatusClass(item.getModel().getObject());
WicketUtils.setCssClass(link, css);
item.add(link);
}
};
controls.add(statusView);
/*
* RESPONSIBLE LIST
*/
Set<String> userlist = new TreeSet<String>(ticket.getParticipants());
for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) {
if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) {
userlist.add(rp.registrant);
}
}
List<TicketResponsible> responsibles = new ArrayList<TicketResponsible>();
if (!StringUtils.isEmpty(ticket.responsible)) {
// exclude the current responsible
userlist.remove(ticket.responsible);
}
for (String username : userlist) {
UserModel u = app().users().getUserModel(username);
if (u != null) {
responsibles.add(new TicketResponsible(u));
}
}
Collections.sort(responsibles);
responsibles.add(new TicketResponsible(ESC_NIL, "", ""));
ListDataProvider<TicketResponsible> responsibleDp = new ListDataProvider<TicketResponsible>(responsibles);
DataView<TicketResponsible> responsibleView = new DataView<TicketResponsible>("newResponsible", responsibleDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<TicketResponsible> item) {
SimpleAjaxLink<TicketResponsible> link = new SimpleAjaxLink<TicketResponsible>("link", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
TicketResponsible responsible = getModel().getObject();
Change change = new Change(user.username);
change.setField(Field.responsible, responsible.username);
if (!StringUtils.isEmpty(responsible.username)) {
if (!ticket.isWatching(responsible.username)) {
change.watch(responsible.username);
}
}
if (!ticket.isWatching(user.username)) {
change.watch(user.username);
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
setResponsePage(TicketsPage.class, getPageParameters());
}
};
item.add(link);
}
};
controls.add(responsibleView);
/*
* MILESTONE LIST
*/
List<TicketMilestone> milestones = app().tickets().getMilestones(repository, Status.Open);
if (!StringUtils.isEmpty(ticket.milestone)) {
for (TicketMilestone milestone : milestones) {
if (milestone.name.equals(ticket.milestone)) {
milestones.remove(milestone);
break;
}
}
}
milestones.add(new TicketMilestone(ESC_NIL));
ListDataProvider<TicketMilestone> milestoneDp = new ListDataProvider<TicketMilestone>(milestones);
DataView<TicketMilestone> milestoneView = new DataView<TicketMilestone>("newMilestone", milestoneDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<TicketMilestone> item) {
SimpleAjaxLink<TicketMilestone> link = new SimpleAjaxLink<TicketMilestone>("link", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
TicketMilestone milestone = getModel().getObject();
Change change = new Change(user.username);
if (NIL.equals(milestone.name) || ESC_NIL.equals(milestone.name)) {
change.setField(Field.milestone, "");
} else {
change.setField(Field.milestone, milestone.name);
}
if (!ticket.isWatching(user.username)) {
change.watch(user.username);
}
TicketModel update = app().tickets().updateTicket(repository, ticket.number, change);
app().tickets().createNotifier().sendMailing(update);
setResponsePage(TicketsPage.class, getPageParameters());
}
};
item.add(link);