diff --git a/ccm-cms-default-theme/package.json b/ccm-cms-default-theme/package.json
index fcda5aec9..bff2e6b99 100644
--- a/ccm-cms-default-theme/package.json
+++ b/ccm-cms-default-theme/package.json
@@ -5,6 +5,7 @@
"build": "npm-run-all build:*",
"build:mkdir": "shx mkdir -p target/generated-resources/themes/librecms",
"build:theme": "shx cp -r src/main/resources/themes/librecms/* target/generated-resources/themes/librecms",
+ "build:icons": "shx cp node_modules/bootstrap-icons/bootstrap-icons.svg target/generated-resources/themes/librecms/images/",
"build:js": "webpack",
"build:css": "npm-run-all build:css:*",
"build:css:librecms": "sass src/main/scss/librecms.scss target/generated-resources/themes/librecms/styles/librecms.css",
diff --git a/ccm-cms-default-theme/src/main/resources/themes/librecms/templates/contentitems/org.librecms.contenttypes.MultiPartArticle.html.ftl b/ccm-cms-default-theme/src/main/resources/themes/librecms/templates/contentitems/org.librecms.contenttypes.MultiPartArticle.html.ftl
index 6ba7a2bbc..6a5f432f9 100644
--- a/ccm-cms-default-theme/src/main/resources/themes/librecms/templates/contentitems/org.librecms.contenttypes.MultiPartArticle.html.ftl
+++ b/ccm-cms-default-theme/src/main/resources/themes/librecms/templates/contentitems/org.librecms.contenttypes.MultiPartArticle.html.ftl
@@ -8,14 +8,54 @@
${CmsPagesMultiPartArticleModel.currentSectionText}
+
#macro>
\ No newline at end of file
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/MultiPartArticleModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/MultiPartArticleModel.java
index 65b00bea8..2d5e5f683 100644
--- a/ccm-cms/src/main/java/org/librecms/pages/models/MultiPartArticleModel.java
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/MultiPartArticleModel.java
@@ -18,6 +18,7 @@
*/
package org.librecms.pages.models;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -35,9 +36,6 @@ import org.librecms.contentsection.ContentItem;
import org.librecms.contenttypes.MultiPartArticle;
import org.librecms.contenttypes.MultiPartArticleSection;
-import java.net.URL;
-import java.util.ArrayList;
-
/**
*
* @author Jens Pelzetter
@@ -67,6 +65,12 @@ public class MultiPartArticleModel implements ProcessesContentItem {
private List sectionLinks;
+ private String prevSectionLink;
+
+ private String nextSectionLink;
+
+ private int currentSection;
+
private String currentSectionTitle;
private String currentSectionText;
@@ -105,6 +109,27 @@ public class MultiPartArticleModel implements ProcessesContentItem {
return Collections.unmodifiableList(sectionLinks);
}
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getPrevSectionLink() {
+ contentItemModel.init();
+
+ return prevSectionLink;
+ }
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getNextSectionLink() {
+ contentItemModel.init();
+
+ return nextSectionLink;
+ }
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public int getCurrentSection() {
+ contentItemModel.init();
+
+ return currentSection;
+ }
+
@Transactional(Transactional.TxType.REQUIRED)
public String getCurrentSectionTitle() {
contentItemModel.init();
@@ -156,9 +181,8 @@ public class MultiPartArticleModel implements ProcessesContentItem {
)
.orElse(Collections.emptyList());
- sectionLinks = buildSectionLinks();
-
- final int currentSection = readCurrentSection();
+ currentSection = readCurrentSection();
+
if (mpa.getSections().size() < currentSection) {
throw new WebApplicationException(
Response
@@ -189,6 +213,7 @@ public class MultiPartArticleModel implements ProcessesContentItem {
.orElse("");
}
+ sectionLinks = buildSectionLinks();
sections = mpa
.getSections()
.stream()
@@ -236,8 +261,26 @@ public class MultiPartArticleModel implements ProcessesContentItem {
final int size = sectionTitles.size();
final List sectionLinksList = new ArrayList<>();
for (int i = 0; i < size; i++) {
- sectionLinksList.add(
- String.format(
+ sectionLinksList.add(buildSectionLink(i));
+ }
+
+ if (currentSection == 0) {
+ prevSectionLink = "";
+ } else {
+ prevSectionLink = buildSectionLink(currentSection - 1);
+ }
+
+ if (currentSection < sectionLinksList.size() - 1) {
+ nextSectionLink = buildSectionLink(currentSection + 1);
+ } else {
+ nextSectionLink = "";
+ }
+
+ return sectionLinksList;
+ }
+
+ private String buildSectionLink(final int section) {
+ return String.format(
"?%s&%s=%d",
pageUrlModel
.getQueryParameters()
@@ -257,12 +300,8 @@ public class MultiPartArticleModel implements ProcessesContentItem {
)
.collect(Collectors.joining("&")),
MPA_SECTION_QUERY_PARAM,
- i
- )
- );
- }
-
- return sectionLinksList;
+ section
+ );
}
}