some improvements and additions to profile popup

This commit is contained in:
fred-fri 2013-05-17 13:01:20 +09:00
parent b200e9f108
commit d7b74c7c1c
3 changed files with 32 additions and 2 deletions
src
main/java/se/su/dsv/scipro/profile
test/java/se/su/dsv/scipro/profile

@ -32,6 +32,11 @@
<div wicket:id="language"></div>
</div>
<div wicket:id="nolanguages"></div>
<wicket:enclosure child="daisyprofile">
<b>Daisy profile:</b><br>
<div><a wicket:id="daisyprofile">Daisy profile</a></div>
</wicket:enclosure>
</div>
</wicket:panel>

@ -17,6 +17,7 @@ import se.su.dsv.scipro.data.dataobjects.*;
import se.su.dsv.scipro.security.auth.roles.Roles;
import se.su.dsv.scipro.settings.dataobjects.UserProfile;
import se.su.dsv.scipro.springdata.services.EmployeeService;
import se.su.dsv.scipro.springdata.services.GeneralSystemSettingsService;
import se.su.dsv.scipro.springdata.services.UserProfileService;
import java.util.ArrayList;
@ -32,6 +33,8 @@ public class DisplayUserProfilePanel extends Panel {
UserProfileService userProfileService;
@SpringBean
EmployeeService employeeService;
@SpringBean
GeneralSystemSettingsService generalSystemSettingsService;
private User user;
@ -91,7 +94,7 @@ public class DisplayUserProfilePanel extends Panel {
ArrayList<ResearchArea> ralist = new ArrayList<ResearchArea>();
if (e!=null && e.getResearchAreas()!=null){
ralist.addAll(e.getResearchAreas());
ralist.addAll(e.getActiveResearchAreas());
}
ListView<ResearchArea> areas = new ListView<ResearchArea>(AREAS, ralist) {
@Override
@ -108,7 +111,7 @@ public class DisplayUserProfilePanel extends Panel {
employeeWMC.add(new Label(NOAREAS, "None"){
@Override
protected void onConfigure() {
setVisibilityAllowed(e.getResearchAreas()==null || e.getResearchAreas().isEmpty());
setVisibilityAllowed(e.getActiveResearchAreas()==null || e.getActiveResearchAreas().isEmpty());
}
});
@ -134,6 +137,22 @@ public class DisplayUserProfilePanel extends Panel {
setVisibilityAllowed(e.getCapabilities()==null || e.getCapabilities().getLanguages()==null || e.getCapabilities().getLanguages().isEmpty());
}
});
/**
* This is a pain in the ass
*/
GeneralSystemSettings generalSystemSettings = generalSystemSettingsService.getGeneralSystemSettingsInstance();
String profile = "";
if (e!=null && generalSystemSettings.getDaisyProfileLinkBaseURL()!=null && !generalSystemSettings.getDaisyProfileLinkBaseURL().isEmpty() && e.getUser().getIdentifier()!=null){
profile = generalSystemSettings.getDaisyProfileLinkBaseURL()+e.getUser().getIdentifier();
}
final String finalProfile = profile;
employeeWMC.add(new ExternalLink(DAISYPROFILE, finalProfile){
@Override
protected void onConfigure() {
setVisibilityAllowed(!finalProfile.isEmpty());
}
});
}
public static final String NAME = "name";
@ -149,6 +168,7 @@ public class DisplayUserProfilePanel extends Panel {
public static final String LANGUAGES = "languages";
public static final String LANGUAGE = "language";
public static final String NOLANGUAGES = "nolanguages";
public static final String DAISYPROFILE = "daisyprofile";
private boolean hasProfile() {
return userProfileService.findByUser(user) != null;

@ -88,6 +88,11 @@ public class DisplayUserProfilePanelTest extends SciProTest {
tester.assertContains("["+path(DisplayUserProfilePanel.EMPLOYEE)+DisplayUserProfilePanel.LANGUAGES+"]");
}
@Test
public void testDaisyProfile() throws Exception {
tester.assertContains("["+path(DisplayUserProfilePanel.EMPLOYEE)+DisplayUserProfilePanel.DAISYPROFILE+"]");
}
@Override
protected String path(Object... parts) {
return super.path(panel.getId(), super.path(parts));