diff --git a/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.html b/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.html index 16f8162004..2daa9f1a33 100644 --- a/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.html +++ b/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.html @@ -3,7 +3,6 @@ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> <body> <wicket:panel> - <form wicket:id="keywordDetails"> <table wicket:id="table" class="rounded-corner"> <thead> <tr> @@ -23,9 +22,8 @@ </tr> </tfoot> </table> - <div wicket:id="navigator"></div> - <div class="prepend-top"><input wicket:id="closeButton" type="submit" value="Close" /></div> - </form> + <div class="append-bottom" wicket:id="navigator"></div> + <button wicket:id="closeButton">Close</button> </wicket:panel> </body> </html> \ No newline at end of file diff --git a/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.java b/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.java index 6e67de6423..5202bd5ac8 100644 --- a/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.java +++ b/src/main/java/se/su/dsv/scipro/admin/panels/match/KeywordDetailsPanel.java @@ -2,11 +2,11 @@ package se.su.dsv.scipro.admin.panels.match; import java.util.List; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator; 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.Form; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.PageableListView; import org.apache.wicket.markup.html.panel.Panel; @@ -16,7 +16,7 @@ import se.su.dsv.scipro.data.dataobjects.Employee; import se.su.dsv.scipro.match.dao.interfaces.SupervisorDao; import se.su.dsv.scipro.match.dataobject.Keyword; -public class KeywordDetailsPanel extends Panel { +public abstract class KeywordDetailsPanel extends Panel { private static final long serialVersionUID = 1L; @SpringBean @@ -24,45 +24,44 @@ public class KeywordDetailsPanel extends Panel { public KeywordDetailsPanel(String str, Keyword keyword) { super(str); - add(new KeywordDetailsForm("keywordDetails", keyword)); + + List<Employee> listOfSupervisors = supervisorDao.getSupervisorsByKeyword(keyword); + + Label emptyLabel = new Label("emptyLabel","No supervisors attached to the selected keyword"); + Label totalNumberLabel = new Label("totalLabel", "Total: " + listOfSupervisors.size()); + emptyLabel.setVisible(listOfSupervisors.isEmpty()); + WebMarkupContainer container = new WebMarkupContainer("table"); + container.setOutputMarkupId(true); + + PageableListView<Employee> listView = new PageableListView<Employee>("listView", listOfSupervisors, 12) { + + private static final long serialVersionUID = 2191181676642843499L; + + @Override + protected void populateItem(ListItem<Employee> item) { + Employee e = item.getModelObject(); + item.add(new Label("name", e.getNameAsString())); + } + }; + container.add(listView); + container.add(totalNumberLabel); + container.add(emptyLabel); + AjaxPagingNavigator navigator = new AjaxPagingNavigator("navigator", listView); + navigator.setVisible(!listOfSupervisors.isEmpty()); + add(navigator); + add(container); + + add(new AjaxLink<Void>("closeButton") { + + private static final long serialVersionUID = -8473625184915176333L; + + @Override + public void onClick(AjaxRequestTarget target) { + onCloseButton(target); + } + + }); } - private class KeywordDetailsForm extends Form<Keyword>{ - - private static final long serialVersionUID = 1L; - - public KeywordDetailsForm(String id, final Keyword keyword) { - super(id); - this.setOutputMarkupId(true); - List<Employee> listOfSupervisors = supervisorDao.getSupervisorsByKeyword(keyword); - - Label emptyLabel = new Label("emptyLabel","No supervisors attached to the selected keyword"); - Label totalNumberLabel = new Label("totalLabel", "Total: " + listOfSupervisors.size()); - emptyLabel.setVisible(listOfSupervisors.isEmpty()); - WebMarkupContainer container = new WebMarkupContainer("table"); - container.setOutputMarkupId(true); - - PageableListView<Employee> listView = new PageableListView<Employee>("listView", listOfSupervisors, 12) { - - private static final long serialVersionUID = 2191181676642843499L; - - @Override - protected void populateItem(ListItem<Employee> item) { - Employee e = item.getModelObject(); - item.add(new Label("name", e.getNameAsString())); - } - }; - container.add(listView); - container.add(totalNumberLabel); - container.add(emptyLabel); - AjaxPagingNavigator navigator = new AjaxPagingNavigator("navigator", listView); - navigator.setVisible(!listOfSupervisors.isEmpty()); - add(navigator); - add(container); - Button closeButton = new Button("closeButton"); - - add(closeButton); - } - - } -} \ No newline at end of file + public abstract void onCloseButton(AjaxRequestTarget target); +} diff --git a/src/main/java/se/su/dsv/scipro/admin/panels/match/ManageKeywordPanel.java b/src/main/java/se/su/dsv/scipro/admin/panels/match/ManageKeywordPanel.java index 91f7fee9da..cbf8ccc789 100644 --- a/src/main/java/se/su/dsv/scipro/admin/panels/match/ManageKeywordPanel.java +++ b/src/main/java/se/su/dsv/scipro/admin/panels/match/ManageKeywordPanel.java @@ -122,7 +122,15 @@ public class ManageKeywordPanel extends Panel { dialog.setWidth(500); dialog.setHeight(580); dialog.setTitle(keyword.getKeyword()); - dialog.replace(new KeywordDetailsPanel("dialogContent", keyword)); + dialog.replace(new KeywordDetailsPanel("dialogContent", keyword) { + + private static final long serialVersionUID = 8439790560385286282L; + + @Override + public void onCloseButton(AjaxRequestTarget target) { + dialog.close(target); + } + }); dialog.open(target); }