• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 27622930007

16 Jun 2026 01:58PM UTC coverage: 26.963% (+6.3%) from 20.697%
27622930007

push

github

web-flow
Merge pull request #483 from knowledgepixels/feat/spaces-about-and-ref-identity

Space/resource About pages, ref-aware spaces, and magic query params

1542 of 6717 branches covered (22.96%)

Branch coverage included in aggregate %.

3407 of 11638 relevant lines covered (29.27%)

4.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/QueryResultPlainParagraph.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.FilteredQueryResultDataProvider;
4
import com.knowledgepixels.nanodash.QueryResult;
5
import com.knowledgepixels.nanodash.QueryResultDataProvider;
6
import com.knowledgepixels.nanodash.Utils;
7
import com.knowledgepixels.nanodash.ViewDisplay;
8
import com.knowledgepixels.nanodash.component.menu.EntryActionMenu;
9
import com.knowledgepixels.nanodash.page.ExplorePage;
10
import org.apache.wicket.ajax.AjaxRequestTarget;
11
import org.apache.wicket.behavior.AttributeAppender;
12
import org.apache.wicket.markup.html.WebMarkupContainer;
13
import org.apache.wicket.markup.html.basic.Label;
14
import org.apache.wicket.markup.html.form.TextField;
15
import org.apache.wicket.markup.html.link.AbstractLink;
16
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
17
import org.apache.wicket.markup.html.list.ListItem;
18
import org.apache.wicket.markup.html.list.ListView;
19
import org.apache.wicket.model.Model;
20
import org.apache.wicket.request.mapper.parameter.PageParameters;
21
import org.nanopub.extra.services.ApiResponse;
22
import org.nanopub.extra.services.ApiResponseEntry;
23
import org.nanopub.extra.services.QueryRef;
24

25
import java.util.ArrayList;
26
import java.util.List;
27

28
/**
29
 * Component for displaying query results in a list format.
30
 */
31
public class QueryResultPlainParagraph extends QueryResult {
32

33
    private FilteredQueryResultDataProvider filteredDataProvider;
34
    private Model<String> filterModel = Model.of("");
×
35
    private WebMarkupContainer paragraphsContainer;
36

37
    /**
38
     * Constructor for QueryResultList.
39
     *
40
     * @param markupId    the markup ID
41
     * @param queryRef    the query reference
42
     * @param response    the API response
43
     * @param viewDisplay the view display
44
     */
45
    QueryResultPlainParagraph(String markupId, QueryRef queryRef, ApiResponse response, ViewDisplay viewDisplay) {
46
        super(markupId, queryRef, response, viewDisplay);
×
47

48
        String label = grlcQuery.getLabel();
×
49
        if (viewDisplay.getTitle() != null) {
×
50
            label = viewDisplay.getTitle();
×
51
        }
52
        add(new Label("label", label));
×
53
        setOutputMarkupId(true);
×
54

55
        TextField<String> filterField = new TextField<>("filter", filterModel);
×
56
        filterField.setOutputMarkupId(true);
×
57
        filterField.add(new FilterUpdatingBehavior() {
×
58
            @Override
59
            protected void onUpdate(AjaxRequestTarget target) {
60
                if (filteredDataProvider != null && paragraphsContainer != null) {
×
61
                    filteredDataProvider.setFilterText(filterModel.getObject());
×
62
                    paragraphsContainer.addOrReplace(buildParagraphsView());
×
63
                    target.add(paragraphsContainer);
×
64
                }
65
            }
×
66
        });
67
        filterField.setVisible(!fitsOnFirstPage());
×
68
        add(filterField);
×
69

70
        populateComponent();
×
71
    }
×
72

73
    @Override
74
    protected void populateComponent() {
75
        filteredDataProvider = new FilteredQueryResultDataProvider(new QueryResultDataProvider(response.getData()), response);
×
76

77
        paragraphsContainer = new WebMarkupContainer("paragraphs-container");
×
78
        paragraphsContainer.setOutputMarkupId(true);
×
79
        paragraphsContainer.add(buildParagraphsView());
×
80
        paragraphsContainer.add(new Label("no-records", "(nothing found)") {
×
81
            @Override
82
            protected void onConfigure() {
83
                super.onConfigure();
×
84
                setVisible(filteredDataProvider.getFilteredData().isEmpty());
×
85
            }
×
86
        });
87
        add(paragraphsContainer);
×
88
    }
×
89

90
    private ListView<ApiResponseEntry> buildParagraphsView() {
91
        return new ListView<>("paragraphs", filteredDataProvider.getFilteredData()) {
×
92
            @Override
93
            protected void populateItem(ListItem<ApiResponseEntry> item) {
94
                String title = item.getModelObject().get("title");
×
95
                boolean hasTitle = title != null && !title.isBlank();
×
96
                // For a title-less paragraph (e.g. a space description) hide the
97
                // empty heading and float the source link into the corner (via
98
                // the "no-title" class) so the header takes no vertical line.
99
                WebMarkupContainer header = new WebMarkupContainer("header");
×
100
                if (!hasTitle) header.add(new AttributeAppender("class", " no-title"));
×
101
                header.add(new Label("title", title).setVisible(hasTitle));
×
102
                String npId = item.getModelObject().get("np");
×
103
                if (npId != null && !npId.isBlank()) {
×
104
                    // The former "^" source link is now the single "source" entry of a
105
                    // per-paragraph dropdown, matching the other view types.
106
                    List<AbstractLink> links = new ArrayList<>();
×
107
                    BookmarkablePageLink<Void> sourceLink = new BookmarkablePageLink<>("link", ExplorePage.class,
×
108
                            new PageParameters().set("id", npId));
×
109
                    sourceLink.setBody(Model.of("<span class=\"actionmenu-icon\">↗︎</span>source")).setEscapeModelStrings(false);
×
110
                    links.add(sourceLink);
×
111
                    header.add(new EntryActionMenu("pnp", links));
×
112
                } else {
×
113
                    header.add(new Label("pnp").setVisible(false));
×
114
                }
115
                item.add(header);
×
116
                String content = item.getModelObject().get("content");
×
117
                item.add(new Label("content", content == null ? null : Utils.sanitizeHtml(content)).setEscapeModelStrings(false));
×
118
            }
×
119
        };
120
    }
121

122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc