The no active project page should use the panel in the settings package instead of the deprecated panel.
This commit is contained in:
parent
9ceea3ca60
commit
af41fcea82
src/main/java/se/su/dsv/scipro/basepanels
@ -1,15 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<p>Logged in as: <span wicket:id="loggedInAs"></span> <a href=# wicket:id="userSettingsLink">
|
||||
<img wicket:id="gears" alt="User Settings"/>
|
||||
</a>
|
||||
<span wicket:id="logoutSection">| <a href=# wicket:id="logoutLink">Logout</a></span></p>
|
||||
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="dialogContent"></div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<p>Logged in as: <span wicket:id="loggedInAs"></span>
|
||||
<span wicket:id="logoutSection">| <a href=# wicket:id="logoutLink">Logout</a></span></p>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,65 +1,34 @@
|
||||
package se.su.dsv.scipro.basepanels;
|
||||
|
||||
import org.apache.wicket.MarkupContainer;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
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.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
|
||||
public class UserLinksPanel extends Panel {
|
||||
@SpringBean
|
||||
transient ApplicationSettings applicationSettings;
|
||||
private static final long serialVersionUID = 4874973667648883012L;
|
||||
|
||||
private Dialog dialog;
|
||||
|
||||
public UserLinksPanel(String id) {
|
||||
super(id);
|
||||
|
||||
add(new Label("loggedInAs", SciProSession.get().getUser() != null ? SciProSession.get().getUser().getFirstName() + " " + SciProSession.get().getUser().getLastName(): "ERROR: NO USER!"));
|
||||
|
||||
final MarkupContainer logoutSection = new WebMarkupContainer("logoutSection");
|
||||
logoutSection.add(new BookmarkablePageLink<Void>("logoutLink", LogoutPage.class));
|
||||
logoutSection.setVisible(!applicationSettings.isAcceptExternalAuthentication());
|
||||
add(logoutSection);
|
||||
|
||||
dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.add(new EmptyPanel("dialogContent"));
|
||||
dialog.setWidth(500);
|
||||
dialog.setHeight(500);
|
||||
add(dialog);
|
||||
|
||||
AjaxLink<Void> userSettingsLink = new AjaxLink<Void>("userSettingsLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
dialog.replace(new UserSettingsPanel("dialogContent"));
|
||||
target.addComponent(dialog);
|
||||
dialog.setTitle("User settings");
|
||||
dialog.open(target);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return SciProSession.get().isLoggedIn();
|
||||
}
|
||||
};
|
||||
|
||||
add(userSettingsLink);
|
||||
userSettingsLink.add(new ImageObject("gears", ImageObject.SIXTEEN + ImageObject.GEAR));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package se.su.dsv.scipro.basepanels;
|
||||
|
||||
import org.apache.wicket.MarkupContainer;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
|
||||
public class UserLinksPanel extends Panel {
|
||||
@SpringBean
|
||||
transient ApplicationSettings applicationSettings;
|
||||
private static final long serialVersionUID = 4874973667648883012L;
|
||||
|
||||
private Dialog dialog;
|
||||
|
||||
public UserLinksPanel(String id) {
|
||||
super(id);
|
||||
|
||||
add(new Label("loggedInAs", SciProSession.get().getUser() != null ? SciProSession.get().getUser().getFirstName() + " " + SciProSession.get().getUser().getLastName(): "ERROR: NO USER!"));
|
||||
|
||||
final MarkupContainer logoutSection = new WebMarkupContainer("logoutSection");
|
||||
logoutSection.add(new BookmarkablePageLink<Void>("logoutLink", LogoutPage.class));
|
||||
logoutSection.setVisible(!applicationSettings.isAcceptExternalAuthentication());
|
||||
add(logoutSection);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<form wicket:id="userSettingsForm">
|
||||
|
||||
<div class="span-10 last">
|
||||
<div class="span-10 last append-bottom prepend-top">
|
||||
<wicket:enclosure child="activeProject">
|
||||
<label for="activeProject">Selected project for author section</label> <select
|
||||
name="Active project" wicket:id="activeProject" id="activeProject"></select>
|
||||
</wicket:enclosure>
|
||||
<i><span wicket:id="noProjectLabel">No projects available..</span></i>
|
||||
</div>
|
||||
<div class="span-10 last append-bottom">
|
||||
<div>What mail do you want mail notifications for?</div>
|
||||
<div wicket:id="notificationPriority"><input type="radio" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="span-10 last">
|
||||
<button type="submit" > Save changes</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,153 +0,0 @@
|
||||
package se.su.dsv.scipro.basepanels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.DropDownChoice;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.IChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.UserSettings;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class UserSettingsPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private ProjectDao projectDao;
|
||||
@SpringBean
|
||||
private UserSettingsDao userSettingsDao;
|
||||
|
||||
UserSettings userSettings;
|
||||
|
||||
public UserSettingsPanel(String id) {
|
||||
super(id);
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(SciProSession.get().getUser());
|
||||
if(userSettings == null){
|
||||
userSettings = new UserSettings(SciProSession.get().getUser());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
}
|
||||
add(new UserSettingsForm("userSettingsForm", new CompoundPropertyModel<UserSettings>(userSettings)));
|
||||
}
|
||||
|
||||
private class UserSettingsForm extends Form<UserSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Project activeProject;
|
||||
|
||||
public UserSettingsForm(String id, IModel<UserSettings> model) {
|
||||
super(id, model);
|
||||
userSettings = userSettingsDao.reLoad(getModelObject());
|
||||
if (userSettings==null){
|
||||
userSettings = new UserSettings(SciProSession.get().getUser());
|
||||
}
|
||||
|
||||
activeProject = SciProSession.get().getActiveProject();
|
||||
|
||||
List<Project> userProjects = new ArrayList<Project>();
|
||||
List<Project> existingProjects = projectDao.getProjectsByParticipant(SciProSession.get().getUser(), null);
|
||||
|
||||
//use an iterator to remove inactive projects from the list
|
||||
Iterator<Project> iterator = existingProjects.iterator();
|
||||
while(iterator.hasNext()){
|
||||
if (iterator.next().getProjectStatus() == ProjectStatus.INACTIVE){
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
userProjects.addAll(existingProjects);
|
||||
DropDownChoice<Project> projectChoice = new DropDownChoice<Project>("activeProject", new PropertyModel<Project>(this, "activeProject"), userProjects);
|
||||
projectChoice.setChoiceRenderer(new ProjectChoiceRenderer());
|
||||
projectChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
// UserSettings userSettings = userSettingsDao.getUserSettings(SciProSession.get().getUser());
|
||||
if(userSettings == null)
|
||||
userSettings = new UserSettings(SciProSession.get().getUser());
|
||||
userSettings.setActiveProject(activeProject);
|
||||
// userSettings = userSettingsDao.save(userSettings);
|
||||
// SciProSession.get().setActiveProject(activeProject);
|
||||
}
|
||||
});
|
||||
//projectChoice.setNullValid(true);
|
||||
add(projectChoice);
|
||||
projectChoice.setVisible(!userProjects.isEmpty());
|
||||
|
||||
Label noProjectLabel = new Label("noProjectLabel","You are not registered as an author on any projects");
|
||||
add(noProjectLabel);
|
||||
noProjectLabel.setVisible(userProjects.isEmpty());
|
||||
|
||||
NotificationPriority[] array = NotificationPriority.values();
|
||||
List<NotificationPriority> notificationPriorities = new ArrayList<NotificationPriority>(Arrays.asList(array));
|
||||
|
||||
final RadioChoice<NotificationPriority> radioChoice = new RadioChoice<NotificationPriority>("notificationPriority", new PropertyModel<NotificationPriority>(userSettings, "notificationPriority"), notificationPriorities );
|
||||
radioChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
// UserSettings userSettings = userSettingsDao.getUserSettings(SciProSession.get().getUser());
|
||||
if(userSettings == null){
|
||||
userSettings = new UserSettings(SciProSession.get().getUser());
|
||||
userSettings.setNotificationPriority(NotificationPriority.LOW);
|
||||
}
|
||||
else{
|
||||
userSettings.setNotificationPriority(radioChoice.getModelObject());
|
||||
}
|
||||
|
||||
// userSettings = userSettingsDao.save(userSettings);
|
||||
}
|
||||
});
|
||||
|
||||
add(radioChoice);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmit(){
|
||||
// UserSettings userSettings = userSettingsDao.reLoad(getModelObject());
|
||||
SciProSession.get().setActiveProject(userSettings.getActiveProject());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
setResponsePage(this.getPage().getClass(),this.getPage().getPageParameters());
|
||||
}
|
||||
}//UserSettingsForm
|
||||
|
||||
private static class ProjectChoiceRenderer implements IChoiceRenderer<Project> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Object getDisplayValue(Project project) {
|
||||
String result = "Title: \"";
|
||||
String title = project.getTitle(30);
|
||||
result = result + title + "\" [" + project.getProjectStatus() + "]";
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdValue(Project object, int index) {
|
||||
return object.getId().toString();
|
||||
}
|
||||
|
||||
}//ProjectChoiceRenderer
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user