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
4 changed files with 13 additions and 49 deletions
Showing only changes of commit 4a9232dab0 - Show all commits

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<title></title>
</head>
<body>
<wicket:panel>
<span wicket:id="msgCount"></span>
</wicket:panel>
</body>
</html>

View File

@ -1,29 +0,0 @@
package se.su.dsv.scipro.forum.panels;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
public abstract class NumberOfMessagesPanel extends Panel {
private Model<String> model = Model.of("");
public NumberOfMessagesPanel(final String id) {
super(id);
add(new Label("msgCount", model));
}
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
long count = getMessageCount();
if (count > 0) {
model.setObject("(" + count + ")");
}
}
public abstract long getMessageCount();
}

View File

@ -44,7 +44,9 @@
<wicket:fragment wicket:id="readStateColumnMarkupId">
<span wicket:id="flag"></span>
<wicket:container wicket:id="counter"></wicket:container>
<wicket:enclosure child="counter">
(<wicket:container wicket:id="counter"></wicket:container>)
</wicket:enclosure>
</wicket:fragment>
</wicket:panel>
</body>

View File

@ -15,6 +15,7 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColu
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.LambdaColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.LambdaChoiceRenderer;
@ -257,7 +258,7 @@ public class SupervisorMyProjectsPanel extends Panel {
@Override
public void populateItem(Item<ICellPopulator<Project>> item, String id, IModel<Project> projectModel) {
// Since table cell only can contain one item, we use Wicket Fragment here. It will contains two components,
// Since table cell only can contain one item, we use Wicket Fragment here. It will contain two components,
// one for flag, one for unread messages counter.
Fragment fragment = new Fragment(id, "readStateColumnMarkupId", SupervisorMyProjectsPanel.this);
@ -289,14 +290,15 @@ public class SupervisorMyProjectsPanel extends Panel {
fragment.add(readStatePanel);
fragment.add(
new NumberOfMessagesPanel("counter") {
@Override
public long getMessageCount() {
return msgCount;
}
Label counterLabel = new Label("counter", msgCount) {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(msgCount > 0);
}
);
};
fragment.add(counterLabel);
item.add(fragment);
}