Allow supervisors to write a note associated with their projects #8
@ -0,0 +1,5 @@
|
|||||||
|
package se.su.dsv.scipro.settings.dataobjects;
|
||||||
|
|
||||||
|
public enum SupervisorProjectNoteDisplay {
|
||||||
|
COMPACT, FULL
|
||||||
|
}
|
@ -58,6 +58,11 @@ public class UserProfile extends DomainObject {
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Roles selectedRole;
|
private Roles selectedRole;
|
||||||
|
|
||||||
|
@Basic
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "supervisor_project_note_display")
|
||||||
|
private SupervisorProjectNoteDisplay supervisorProjectNoteDisplay = SupervisorProjectNoteDisplay.COMPACT;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
@ -147,6 +152,14 @@ public class UserProfile extends DomainObject {
|
|||||||
this.selectedRole = selectedRole;
|
this.selectedRole = selectedRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SupervisorProjectNoteDisplay getSupervisorProjectNoteDisplay() {
|
||||||
|
return supervisorProjectNoteDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupervisorProjectNoteDisplay(SupervisorProjectNoteDisplay supervisorProjectNoteDisplay) {
|
||||||
|
this.supervisorProjectNoteDisplay = supervisorProjectNoteDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UserProfile(id=" + this.getId() + ", user=" + this.getUser() + ", skypeId=" + this.getSkypeId() + ", phoneNumber=" + this.getPhoneNumber() + ", otherInfo=" + this.getOtherInfo() + ", mailCompilation=" + this.isMailCompilation() + ", defaultProjectStatusFilter=" + this.getDefaultProjectStatusFilter() + ", defaultProjectTeamMemberRolesFilter=" + this.getDefaultProjectTeamMemberRolesFilter() + ", defaultSupervisorFilter=" + this.isDefaultSupervisorFilter() + ", defaultProjectTypeFilter=" + this.getDefaultProjectTypeFilter() + ", selectedRole=" + this.getSelectedRole() + ")";
|
return "UserProfile(id=" + this.getId() + ", user=" + this.getUser() + ", skypeId=" + this.getSkypeId() + ", phoneNumber=" + this.getPhoneNumber() + ", otherInfo=" + this.getOtherInfo() + ", mailCompilation=" + this.isMailCompilation() + ", defaultProjectStatusFilter=" + this.getDefaultProjectStatusFilter() + ", defaultProjectTeamMemberRolesFilter=" + this.getDefaultProjectTeamMemberRolesFilter() + ", defaultSupervisorFilter=" + this.isDefaultSupervisorFilter() + ", defaultProjectTypeFilter=" + this.getDefaultProjectTypeFilter() + ", selectedRole=" + this.getSelectedRole() + ")";
|
||||||
|
@ -6,3 +6,6 @@ CREATE TABLE IF NOT EXISTS `project_user_note` (
|
|||||||
CONSTRAINT `FK_project_user_note_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `FK_project_user_note_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `FK_project_user_note_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
CONSTRAINT `FK_project_user_note_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ALTER TABLE `user_profile`
|
||||||
|
ADD COLUMN `supervisor_project_note_display` VARCHAR(15) NOT NULL DEFAULT 'COMPACT';
|
||||||
|
@ -2,23 +2,16 @@ package se.su.dsv.scipro.components;
|
|||||||
|
|
||||||
import org.apache.wicket.markup.html.basic.Label;
|
import org.apache.wicket.markup.html.basic.Label;
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
import org.apache.wicket.util.convert.ConversionException;
|
|
||||||
import org.apache.wicket.util.convert.IConverter;
|
import org.apache.wicket.util.convert.IConverter;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class MaxLengthLabel extends Label {
|
public class MaxLengthLabel extends Label {
|
||||||
private static final int DEFAULT_MAX_LENGTH = 50;
|
private final IModel<Integer> maxLengthModel;
|
||||||
|
|
||||||
private final int maxLength;
|
public MaxLengthLabel(String id, IModel<String> dataModel, IModel<Integer> maxLength) {
|
||||||
|
|
||||||
public MaxLengthLabel(String id, IModel<String> dataModel) {
|
|
||||||
this(id, dataModel, DEFAULT_MAX_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaxLengthLabel(String id, IModel<String> dataModel, int maxLength) {
|
|
||||||
super(id, dataModel);
|
super(id, dataModel);
|
||||||
this.maxLength = maxLength;
|
this.maxLengthModel = maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,6 +27,7 @@ public class MaxLengthLabel extends Label {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertToString(String o, Locale locale) {
|
public String convertToString(String o, Locale locale) {
|
||||||
|
Integer maxLength = maxLengthModel.getObject();
|
||||||
if (o.length() > maxLength) {
|
if (o.length() > maxLength) {
|
||||||
return o.substring(0, maxLength) + "...";
|
return o.substring(0, maxLength) + "...";
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.apache.wicket.feedback.FencedFeedbackPanel;
|
|||||||
import org.apache.wicket.injection.Injector;
|
import org.apache.wicket.injection.Injector;
|
||||||
import org.apache.wicket.markup.html.form.Form;
|
import org.apache.wicket.markup.html.form.Form;
|
||||||
import org.apache.wicket.markup.html.form.TextArea;
|
import org.apache.wicket.markup.html.form.TextArea;
|
||||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
|
||||||
import org.apache.wicket.markup.html.panel.GenericPanel;
|
import org.apache.wicket.markup.html.panel.GenericPanel;
|
||||||
import org.apache.wicket.markup.repeater.Item;
|
import org.apache.wicket.markup.repeater.Item;
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
@ -21,6 +20,7 @@ import se.su.dsv.scipro.components.MaxLengthLabel;
|
|||||||
import se.su.dsv.scipro.components.ModalWindowPlus;
|
import se.su.dsv.scipro.components.ModalWindowPlus;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.project.ProjectNoteService;
|
import se.su.dsv.scipro.project.ProjectNoteService;
|
||||||
|
import se.su.dsv.scipro.settings.dataobjects.SupervisorProjectNoteDisplay;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@ -31,10 +31,13 @@ public class ProjectNoteColumn extends AbstractExportableColumn<Project, String>
|
|||||||
private ProjectNoteService projectNoteService;
|
private ProjectNoteService projectNoteService;
|
||||||
|
|
||||||
private final IModel<User> user;
|
private final IModel<User> user;
|
||||||
|
private final IModel<SupervisorProjectNoteDisplay> supervisorProjectNoteDisplayModel;
|
||||||
|
|
||||||
public ProjectNoteColumn(IModel<String> displayModel, IModel<User> user) {
|
public ProjectNoteColumn(IModel<String> displayModel, IModel<User> user,
|
||||||
|
IModel<SupervisorProjectNoteDisplay> supervisorProjectNoteDisplayModel) {
|
||||||
super(displayModel);
|
super(displayModel);
|
||||||
Injector.get().inject(this);
|
Injector.get().inject(this);
|
||||||
|
this.supervisorProjectNoteDisplayModel = supervisorProjectNoteDisplayModel;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +69,11 @@ public class ProjectNoteColumn extends AbstractExportableColumn<Project, String>
|
|||||||
setOutputMarkupId(true);
|
setOutputMarkupId(true);
|
||||||
modal.onClose(target -> target.add(this));
|
modal.onClose(target -> target.add(this));
|
||||||
|
|
||||||
add(new MaxLengthLabel("shortened_note", getDataModel(model)));
|
IModel<Integer> maxLength = supervisorProjectNoteDisplayModel.map(display -> switch (display) {
|
||||||
|
case FULL -> Integer.MAX_VALUE;
|
||||||
|
case COMPACT -> 100;
|
||||||
|
});
|
||||||
|
add(new MaxLengthLabel("shortened_note", getDataModel(model), maxLength));
|
||||||
|
|
||||||
AjaxLink<Object> noteLink = new AjaxLink<>("view_note") {
|
AjaxLink<Object> noteLink = new AjaxLink<>("view_note") {
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
</strong>
|
</strong>
|
||||||
<div wicket:id="projectTypes"></div>
|
<div wicket:id="projectTypes"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<fieldset class="col-6 col-md-3 col-lg-2">
|
||||||
|
<legend>Note</legend>
|
||||||
|
<div wicket:id="note_display"></div>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package se.su.dsv.scipro.supervisor.panels;
|
package se.su.dsv.scipro.supervisor.panels;
|
||||||
|
|
||||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||||
|
import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
|
||||||
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
|
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
|
||||||
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
|
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
|
||||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
|
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
|
||||||
@ -25,6 +26,7 @@ import se.su.dsv.scipro.project.ProjectService;
|
|||||||
import se.su.dsv.scipro.project.ProjectStatus;
|
import se.su.dsv.scipro.project.ProjectStatus;
|
||||||
import se.su.dsv.scipro.project.ProjectTeamMemberRoles;
|
import se.su.dsv.scipro.project.ProjectTeamMemberRoles;
|
||||||
import se.su.dsv.scipro.session.SciProSession;
|
import se.su.dsv.scipro.session.SciProSession;
|
||||||
|
import se.su.dsv.scipro.settings.dataobjects.SupervisorProjectNoteDisplay;
|
||||||
import se.su.dsv.scipro.settings.dataobjects.UserProfile;
|
import se.su.dsv.scipro.settings.dataobjects.UserProfile;
|
||||||
import se.su.dsv.scipro.springdata.services.UserProfileService;
|
import se.su.dsv.scipro.springdata.services.UserProfileService;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
@ -55,6 +57,7 @@ public class SupervisorMyProjectsPanel extends Panel {
|
|||||||
|
|
||||||
private ExportableDataPanel dataPanel;
|
private ExportableDataPanel dataPanel;
|
||||||
private ProjectService.Filter filter = new ProjectService.Filter();
|
private ProjectService.Filter filter = new ProjectService.Filter();
|
||||||
|
private IModel<SupervisorProjectNoteDisplay> supervisorProjectNoteDisplayModel = new Model<>();
|
||||||
|
|
||||||
public SupervisorMyProjectsPanel(String id) {
|
public SupervisorMyProjectsPanel(String id) {
|
||||||
super(id);
|
super(id);
|
||||||
@ -82,7 +85,7 @@ public class SupervisorMyProjectsPanel extends Panel {
|
|||||||
return new ListAdapterModel<>(rowModel.map(Project::getProjectParticipants));
|
return new ListAdapterModel<>(rowModel.map(Project::getProjectParticipants));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
columns.add(new ProjectNoteColumn(Model.of("Note"), LoadableDetachableModel.of(this::currentUser)));
|
columns.add(new ProjectNoteColumn(Model.of("Note"), LoadableDetachableModel.of(this::currentUser), supervisorProjectNoteDisplayModel));
|
||||||
columns.add(new UserColumn<>(Model.of("Head supervisor"), "headSupervisor.fullName", Project::getHeadSupervisor));
|
columns.add(new UserColumn<>(Model.of("Head supervisor"), "headSupervisor.fullName", Project::getHeadSupervisor));
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
@ -105,6 +108,7 @@ public class SupervisorMyProjectsPanel extends Panel {
|
|||||||
filter.setRoles(userProfile.getDefaultProjectTeamMemberRolesFilter());
|
filter.setRoles(userProfile.getDefaultProjectTeamMemberRolesFilter());
|
||||||
filter.setFilterSupervisor(userProfile.isDefaultSupervisorFilter());
|
filter.setFilterSupervisor(userProfile.isDefaultSupervisorFilter());
|
||||||
filter.setProjectTypes(userProfile.getDefaultProjectTypeFilter());
|
filter.setProjectTypes(userProfile.getDefaultProjectTypeFilter());
|
||||||
|
supervisorProjectNoteDisplayModel.setObject(userProfile.getSupervisorProjectNoteDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
private User currentUser() {
|
private User currentUser() {
|
||||||
@ -148,6 +152,19 @@ public class SupervisorMyProjectsPanel extends Panel {
|
|||||||
updateProfileWithCurrentFilter();
|
updateProfileWithCurrentFilter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
BootstrapRadioChoice<SupervisorProjectNoteDisplay> noteDisplay = new BootstrapRadioChoice<>(
|
||||||
|
"note_display",
|
||||||
|
supervisorProjectNoteDisplayModel,
|
||||||
|
List.of(SupervisorProjectNoteDisplay.values()),
|
||||||
|
new EnumChoiceRenderer<>(this));
|
||||||
|
noteDisplay.add(new AjaxFormChoiceComponentUpdatingBehavior() {
|
||||||
|
@Override
|
||||||
|
public void onUpdate(AjaxRequestTarget target) {
|
||||||
|
target.add(dataPanel);
|
||||||
|
updateProfileWithCurrentFilter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(noteDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProfileWithCurrentFilter() {
|
private void updateProfileWithCurrentFilter() {
|
||||||
@ -156,6 +173,7 @@ public class SupervisorMyProjectsPanel extends Panel {
|
|||||||
userProfile.setDefaultProjectTeamMemberRolesFilter(filter.getRoles());
|
userProfile.setDefaultProjectTeamMemberRolesFilter(filter.getRoles());
|
||||||
userProfile.setDefaultSupervisorFilter(filter.isFilterSupervisor());
|
userProfile.setDefaultSupervisorFilter(filter.isFilterSupervisor());
|
||||||
userProfile.setDefaultProjectTypeFilter(filter.getProjectTypes());
|
userProfile.setDefaultProjectTypeFilter(filter.getProjectTypes());
|
||||||
|
userProfile.setSupervisorProjectNoteDisplay(supervisorProjectNoteDisplayModel.getObject());
|
||||||
profileService.save(userProfile);
|
profileService.save(userProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,6 @@ ProjectTeamMemberRoles.CO_SUPERVISOR= Co-Supervisor
|
|||||||
ProjectStatus.ACTIVE= Active
|
ProjectStatus.ACTIVE= Active
|
||||||
ProjectStatus.INACTIVE= Inactive
|
ProjectStatus.INACTIVE= Inactive
|
||||||
ProjectStatus.COMPLETED= Completed
|
ProjectStatus.COMPLETED= Completed
|
||||||
|
|
||||||
|
SupervisorProjectNoteDisplay.COMPACT=Compact
|
||||||
|
SupervisorProjectNoteDisplay.FULL=Full
|
||||||
|
Loading…
x
Reference in New Issue
Block a user