From 54be29eadbaf02591bafd148185c6f0ce7252cc7 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Wed, 29 Jun 2016 17:35:11 +0200 Subject: [PATCH] OO-2057: add binder and section title in the list of owned entries --- .../org/olat/modules/portfolio/Section.java | 7 +++++++ .../modules/portfolio/manager/PageDAO.java | 4 ++-- .../olat/modules/portfolio/model/PageRow.java | 18 +++++++++++++++++- .../portfolio/ui/MyPageListController.java | 11 ++++++++++- .../portfolio/ui/_content/page_row.html | 6 ++++++ .../ui/_i18n/LocalStrings_de.properties | 1 + .../ui/_i18n/LocalStrings_en.properties | 1 + 7 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/olat/modules/portfolio/Section.java b/src/main/java/org/olat/modules/portfolio/Section.java index 4afd094baa9..7cb823ea0f8 100644 --- a/src/main/java/org/olat/modules/portfolio/Section.java +++ b/src/main/java/org/olat/modules/portfolio/Section.java @@ -65,5 +65,12 @@ public interface Section extends SectionRef, PortfolioElement { * @return */ public List<Page> getPages(); + + /** + * The binder is lazily loaded. + * + * @return + */ + public Binder getBinder(); } diff --git a/src/main/java/org/olat/modules/portfolio/manager/PageDAO.java b/src/main/java/org/olat/modules/portfolio/manager/PageDAO.java index 99e52da4169..5ce7030e8b1 100644 --- a/src/main/java/org/olat/modules/portfolio/manager/PageDAO.java +++ b/src/main/java/org/olat/modules/portfolio/manager/PageDAO.java @@ -143,8 +143,8 @@ public class PageDAO { StringBuilder sb = new StringBuilder(); sb.append("select page from pfpage as page") .append(" inner join fetch page.body as body") - .append(" left join page.section as section") - .append(" left join section.binder as binder") + .append(" left join fetch page.section as section") + .append(" left join fetch section.binder as binder") .append(" where exists (select pageMember from bgroupmember as pageMember") .append(" inner join pageMember.identity as ident on (ident.key=:ownerKey and pageMember.role='").append(GroupRoles.owner.name()).append("')") .append(" where pageMember.group.key=page.baseGroup.key or pageMember.group.key=binder.baseGroup.key") diff --git a/src/main/java/org/olat/modules/portfolio/model/PageRow.java b/src/main/java/org/olat/modules/portfolio/model/PageRow.java index bd6a187c222..c18f8c9c917 100644 --- a/src/main/java/org/olat/modules/portfolio/model/PageRow.java +++ b/src/main/java/org/olat/modules/portfolio/model/PageRow.java @@ -24,6 +24,7 @@ import java.util.Date; import org.olat.core.gui.components.form.flexible.elements.FormLink; import org.olat.core.gui.components.link.Link; +import org.olat.core.util.StringHelper; import org.olat.course.assessment.AssessmentHelper; import org.olat.modules.portfolio.AssessmentSection; import org.olat.modules.portfolio.Page; @@ -56,6 +57,9 @@ public class PageRow { private Link commentLink; private FormLink commentFormLink; + private String metaSectionTitle; + private String metaBinderTitle; + public PageRow(Page page, Section section, AssessmentSection assessmentSection, boolean firstPageOfSection, boolean assessable) { this.page = page; @@ -256,7 +260,19 @@ public class PageRow { this.commentFormLink = commentFormLink; } - + public boolean hasMetaBinderAndSectionTitle() { + return StringHelper.containsNonWhitespace(metaSectionTitle) || StringHelper.containsNonWhitespace(metaBinderTitle); + } + public String[] getMetaBinderAndSectionTitles() { + return new String[]{ metaSectionTitle, metaBinderTitle }; + } + public void setMetaSectionTitle(String metaSectionTitle) { + this.metaSectionTitle = metaSectionTitle; + } + + public void setMetaBinderTitle(String metaBinderTitle) { + this.metaBinderTitle = metaBinderTitle; + } } diff --git a/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java index 8c7e8bf0d3a..51ab41af6b4 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java @@ -40,6 +40,7 @@ import org.olat.modules.portfolio.BinderSecurityCallback; import org.olat.modules.portfolio.Category; import org.olat.modules.portfolio.CategoryToElement; import org.olat.modules.portfolio.Page; +import org.olat.modules.portfolio.Section; import org.olat.modules.portfolio.model.PageRow; /** @@ -88,7 +89,15 @@ public class MyPageListController extends AbstractPageListController { List<Page> pages = portfolioService.searchOwnedPages(getIdentity()); List<PageRow> rows = new ArrayList<>(pages.size()); for (Page page : pages) { - rows.add(forgeRow(page, null, false, categorizedElementMap, numberOfCommentsMap)); + PageRow row = forgeRow(page, null, false, categorizedElementMap, numberOfCommentsMap); + rows.add(row); + if(page.getSection() != null) { + Section section = page.getSection(); + row.setMetaSectionTitle(section.getTitle()); + if(section.getBinder() != null) { + row.setMetaBinderTitle(section.getBinder().getTitle()); + } + } } model.setObjects(rows); tableEl.reset(); diff --git a/src/main/java/org/olat/modules/portfolio/ui/_content/page_row.html b/src/main/java/org/olat/modules/portfolio/ui/_content/page_row.html index b351986581b..e5ed7c1da57 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/_content/page_row.html +++ b/src/main/java/org/olat/modules/portfolio/ui/_content/page_row.html @@ -71,6 +71,12 @@ <span class="o_portfolio_page_meta text-muted o_small"> $r.translate("meta.last.modified", $r.formatDateAndTime($row.lastModified)) </span> + #if(${row.hasMetaBinderAndSectionTitle()}) + <div class="o_portfolio_page_meta text-muted o_small"> + $r.translate("meta.binder.section.titles", ${row.getMetaBinderAndSectionTitles()}) + </div> + #end + <div class="o_portfolio_page_summary o_block"> $r.xssScan($row.summary) </div> diff --git a/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_de.properties index 66c47c0ca4f..ac17cbeccac 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_de.properties @@ -92,6 +92,7 @@ meta.categories=Kategorien meta.last.modified=zuletzt bearbeitet am {0} meta.last.publication=ver\u00F6ffentlich am {0} meta.section.categories=<strong>Kategorien</strong> in diesem Bereich +meta.binder.section.titles=in Mappe "{0}", Bereich "{1}" my.entries=Meine Beitr\u00E4ge my.entries.text=Liste aller Beitr\u00E4ge in chronologischer Reihenfolge unabh\u00E4ngig von ihrem Kontext. Dies ist das Herzst\u00FCck Ihrer Portfolioarbeit. my.portfolio.binders=Meine Portfolio Mappen diff --git a/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_en.properties index e6351599797..5608a6278a4 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/modules/portfolio/ui/_i18n/LocalStrings_en.properties @@ -93,6 +93,7 @@ media.center.text=Search, create, add media files or other artefacts that you wa meta.last.modified=last modified {0} meta.last.publication=published at {0} meta.section.categories=<strong>Categories</strong> in this section +meta.binder.section.titles=in binder "{0}", section "{1}" my.entries=My entries my.entries.text=List all your portfolio entries regardless of their context. This is the heart of your portfolio work. my.portfolio.binders=My portfolio binders -- GitLab