Forum Message UI Improvement (Thesis Board #3470) #61

Merged
tozh4728 merged 20 commits from 3470-forum-msg-ui-improvement into develop 2024-12-19 15:28:23 +01:00
5 changed files with 21 additions and 52 deletions
Showing only changes of commit 379b5c34fc - Show all commits

View File

@ -14,20 +14,8 @@ public abstract class AbstractReadStatePanel extends Panel {
public static final String TOGGLE = "toggle";
static final String ICON = "icon";
public enum ShowReadStateTooltip {
ENABLED,
DISABLED
}
private final ShowReadStateTooltip showReadStateTooltip;
public AbstractReadStatePanel(final String id) {
this(id, ShowReadStateTooltip.DISABLED);
}
public AbstractReadStatePanel(final String id, final ShowReadStateTooltip showReadStateTooltip) {
super(id);
this.showReadStateTooltip = showReadStateTooltip;
Component icon = new UpdatingImage(ICON);
icon.setOutputMarkupId(true);
@ -59,10 +47,6 @@ public abstract class AbstractReadStatePanel extends Panel {
super.onComponentTag(tag);
String state = isRead() ? "read" : "unread";
tag.append("class", state, " ");
if (showReadStateTooltip == ShowReadStateTooltip.ENABLED && !isRead()) {
tag.put("title", getString("unread.msg"));
}
}
}
}

View File

@ -1 +0,0 @@
unread.msg=There are unread messages.

View File

@ -42,9 +42,8 @@
<table class="table table-striped table-hover" wicket:id="dp"></table>
<!-- todo: reconsider name of this id, parentMarkupId, needs improvement. -->
<wicket:fragment wicket:id="parentMarkupId">
<wicket:container wicket:id="flag"></wicket:container>
<wicket:fragment wicket:id="readStateColumnMarkupId">
<span wicket:id="flag"></span>
<wicket:container wicket:id="counter"></wicket:container>
</wicket:fragment>
</wicket:panel>

View File

@ -4,6 +4,7 @@ import jakarta.inject.Inject;
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.AttributeModifier;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
@ -200,41 +201,19 @@ public class SupervisorMyProjectsPanel extends Panel {
@Override
public void populateItem(Item<ICellPopulator<Project>> item, String id, IModel<Project> projectModel) {
/*
item.add(new AbstractReadStatePanel(id, AbstractReadStatePanel.ShowReadStateTooltip.ENABLED) {
@Override
protected boolean isRead() {
return !projectForumService.hasUnreadThreads(projectModel.getObject(),
// Since table cell only can contain one item, we use Wicket Fragment here. It will contains two components,
// one for flag, one for unread messages counter.
Fragment fragment = new Fragment(id, "readStateColumnMarkupId", SupervisorMyProjectsPanel.this);
long msgCount = projectForumService.getUnreadThreadsCount(projectModel.getObject(),
SciProSession.get().getUser());
}
boolean isRead = msgCount == 0;
@Override
protected void onFlagClick(AjaxRequestTarget target) {
setResponsePage(SupervisorThreadedForumPage.class,
SupervisorThreadedForumPage.getPageParameters(projectModel.getObject()));
}
});
*/
// WebMarkupContainer container = new WebMarkupContainer(id);
// container.setOutputMarkupId(true);
/*
container
*/
//container.add(new NumberOfMessagesPanel("counter"));
//item.add(container);
//boolean hasUnreadThreads = projectForumService.hasUnreadThreads(projectModel.getObject(), SciProSession.get().getUser());
long msgCount = projectForumService.getUnreadThreadsCount(projectModel.getObject(), SciProSession.get().getUser());
// todo: reconsider name of this id, needs to be improved.
Fragment fragment = new Fragment(id, "parentMarkupId", SupervisorMyProjectsPanel.this);
fragment.add(new AbstractReadStatePanel("flag", AbstractReadStatePanel.ShowReadStateTooltip.ENABLED) {
AbstractReadStatePanel readStatePanel = new AbstractReadStatePanel("flag") {
@Override
protected boolean isRead() {
return msgCount == 0;
return isRead;
}
@Override
@ -242,7 +221,13 @@ public class SupervisorMyProjectsPanel extends Panel {
setResponsePage(SupervisorThreadedForumPage.class,
SupervisorThreadedForumPage.getPageParameters(projectModel.getObject()));
}
});
};
if (!isRead) {
readStatePanel.add(new AttributeModifier("title", getString("unread.msg")));
}
fragment.add(readStatePanel);
fragment.add(new NumberOfMessagesPanel("counter") {
@Override

View File

@ -12,3 +12,5 @@ ProjectStatus.COMPLETED= Completed
SupervisorProjectNoteDisplay.COMPACT=Compact
SupervisorProjectNoteDisplay.FULL=Full
unread.msg=There are unread messages.