Maintaining a consistent layout using a single page: swapping tables with different content using panels.
This commit is contained in:
parent
f10e00bcff
commit
aa46f998b2
src/main/java/se/su/dsv/scipro
@ -6,11 +6,9 @@ import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
@ -19,6 +17,7 @@ import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao.SortableParams;
|
||||
import se.su.dsv.scipro.dataproviders.QueryableDataProvider;
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ExemptionDao;
|
||||
@ -34,19 +33,18 @@ public class AdminExemptionPanel extends Panel {
|
||||
private DataView<Exemption> dataView;
|
||||
private WebMarkupContainer container;
|
||||
|
||||
@SpringBean
|
||||
private ExemptionDao exemptionDao;
|
||||
|
||||
public AdminExemptionPanel(String id) {
|
||||
@SpringBean
|
||||
private ExemptionDao exemptionDao;
|
||||
|
||||
public AdminExemptionPanel(String id) {
|
||||
super(id);
|
||||
TextField<String> searchField =
|
||||
TextField<String> searchField =
|
||||
new TextField<String>("searchField", new PropertyModel<String>(
|
||||
this, "userSearch"));
|
||||
container = new WebMarkupContainer("container");
|
||||
container.setOutputMarkupId(true);
|
||||
|
||||
OnChangeAjaxBehavior userSearchTextBehaviour =
|
||||
new OnChangeAjaxBehavior() {
|
||||
OnChangeAjaxBehavior userSearchTextBehaviour = new OnChangeAjaxBehavior() {
|
||||
|
||||
private static final long serialVersionUID =
|
||||
-3243439315735164519L;
|
||||
@ -54,13 +52,12 @@ public class AdminExemptionPanel extends Panel {
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
updateListView(container);
|
||||
container.add(dataView);
|
||||
container.add(new PagingNavigator("pagingNavigator",
|
||||
container.add(dataView);
|
||||
container.add(new PagingNavigator("pagingNavigator",
|
||||
dataView));
|
||||
target.addComponent(container);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
final Dialog dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
@ -87,53 +84,50 @@ public class AdminExemptionPanel extends Panel {
|
||||
searchField.add(userSearchTextBehaviour);
|
||||
add(searchField);
|
||||
updateListView(container);
|
||||
|
||||
container.add(dataView);
|
||||
container.add(dataView);
|
||||
container.add(new PagingNavigator("pagingNavigator", dataView));
|
||||
add(container);
|
||||
container.add(new PagingNavigator("pagingNavigator", dataView));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateListView(final WebMarkupContainer container) {
|
||||
container.removeAll();
|
||||
ExemptionDaoParams exemptionDaoParams = new ExemptionDaoParams();
|
||||
if (userSearch != null) {
|
||||
ExemptionDaoParams exemptionDaoParams = new ExemptionDaoParams();
|
||||
exemptionDaoParams.setSortOn("dateCreated", SortableParams.Sort.DESCENDING);
|
||||
if (userSearch != null) {
|
||||
if (userSearch.length() >= 3) {
|
||||
exemptionDaoParams.setAuthorNameLike(userSearch);
|
||||
}
|
||||
}
|
||||
loadUserDataView(new QueryableDataProvider<Exemption, ExemptionDaoParams>(
|
||||
exemptionDao, exemptionDaoParams));
|
||||
loadUserDataView(new QueryableDataProvider<Exemption, ExemptionDaoParams>(
|
||||
exemptionDao,exemptionDaoParams));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void loadUserDataView(IDataProvider<Exemption> exemptionDataProvider) {
|
||||
dataView = new DataView<Exemption>("listView", exemptionDataProvider, 10) {
|
||||
public void loadUserDataView(IDataProvider<Exemption> exemptionDataProvider) {
|
||||
dataView = new DataView<Exemption>("listView", exemptionDataProvider, 8){
|
||||
|
||||
private static final long serialVersionUID =
|
||||
2828792237574112923L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(Item<Exemption> item) {
|
||||
final Exemption excemption = item.getModelObject();
|
||||
item.add(new Label("name", excemption.getAuthor().getUser()
|
||||
protected void populateItem(final Item<Exemption> item) {
|
||||
final Exemption exemption = item.getModelObject();
|
||||
item.add(new Label("name", exemption.getAuthor().getUser()
|
||||
.getFullName()));
|
||||
item.add(new Label("mail", excemption.getAuthor().getUser().getEmailAddress()));
|
||||
item.add(new Label("level", excemption.getProjectClass()
|
||||
item.add(new Label("mail", exemption.getAuthor().getUser().getEmailAddress()));
|
||||
item.add(new Label("level", exemption.getProjectClass()
|
||||
.getName()));
|
||||
item.add(new Label("comment", excemption.getComment()));
|
||||
item.add(new Label("grantedBy", excemption.getGrantedBy()
|
||||
item.add(new Label("comment", exemption.getComment()));
|
||||
item.add(new Label("grantedBy", exemption.getGrantedBy()
|
||||
.getFullName()));
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
item.add(new Label("dateOfGranting", formatter.format(excemption.getDateCreated())));
|
||||
|
||||
item.add(new Label("dateOfGranting", formatter.format(exemption.getDateCreated())));
|
||||
AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
exemptionDao.delete(exemptionDao.reLoad(excemption));
|
||||
exemptionDao.delete(exemptionDao.reLoad(exemption));
|
||||
info("Revoked exemption");
|
||||
target.addComponent(container);
|
||||
target.addComponent(getPage().get("feedbackPanel"));
|
||||
@ -142,10 +136,7 @@ public class AdminExemptionPanel extends Panel {
|
||||
item.add(removeLink);
|
||||
removeLink.add(new ImageObject("removeIcon", ImageObject.SIXTEEN + ImageObject.DELETE));
|
||||
removeLink.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to remove this?"));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractSortableQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.Query;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
@ -47,11 +47,11 @@ public class ExemptionDaoJPAImp extends QueryableDaoJPAImp<Exemption, ExemptionD
|
||||
});
|
||||
}
|
||||
|
||||
public AbstractQuerySet<Exemption> createQuerySet(ExemptionDaoParams exemptionDaoParams) {
|
||||
return new QuerySet().authorNameLike(exemptionDaoParams.getAuthorNameLike());
|
||||
public AbstractSortableQuerySet<Exemption> createQuerySet(ExemptionDaoParams exemptionDaoParams) {
|
||||
return new QuerySet().authorNameLike(exemptionDaoParams.getAuthorNameLike()).sort(exemptionDaoParams);
|
||||
}
|
||||
|
||||
public static class QuerySet extends AbstractQuerySet<Exemption> {
|
||||
public static class QuerySet extends AbstractSortableQuerySet<Exemption> {
|
||||
|
||||
public QuerySet() {
|
||||
super(Exemption.class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user