super(id);
setOutputMarkupId(true);
final Space space = usr.getSpace();
final User user = usr.getUser();
WebMarkupContainer spaceCell = new WebMarkupContainer("space");
add(spaceCell);
spaceCell.add(new Label("name", space.getName()));
spaceCell.add(new Label("prefixCode", space.getPrefixCode()));
if(usr.isAbleToCreateNewItem()) {
add(new Link("new") {
public void onClick() {
setCurrentSpace(space);
setResponsePage(ItemFormPage.class);
}
});
} else {
add(new Label("new").setVisible(false));
}
add(new Link("search") {
public void onClick() {
setCurrentSpace(space);
ItemSearch itemSearch = new ItemSearch(space);
setResponsePage(ItemSearchFormPage.class, itemSearch.getAsQueryString());
}
});
add(new IndicatingAjaxLink("link") {
public void onClick(AjaxRequestTarget target) {
Counts tempCounts = counts;
// avoid hitting the database again if re-expanding
if (!tempCounts.isDetailed()) {
tempCounts = getJtrac().loadCountsForUserSpace(user, space);
}
DashboardRowExpandedPanel dashboardRow = new DashboardRowExpandedPanel("dashboardRow", usr, tempCounts);
DashboardRowPanel.this.replaceWith(dashboardRow);
target.addComponent(dashboardRow);
}
});
if(user.getId() > 0) {
add(new Link("loggedByMe") {
public void onClick() {
setCurrentSpace(space);
ItemSearch itemSearch = new ItemSearch(space);
itemSearch.setLoggedBy(user);