Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KB: Improved Links (OX-11128) #2024

Merged
merged 13 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/resources/biz_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,11 @@ JournalEntry.username = Benutzer
KnowledgeBase.articlesLabel = Artikel
KnowledgeBase.chaptersLabel = Kapitel
KnowledgeBase.crossReferencesLabel = Siehe auch
KnowledgeBase.defaultLinkLabel = Link
KnowledgeBase.helpBtn = Hilfe
KnowledgeBase.kb = Knowledge Base
KnowledgeBase.missingPermission = Sie haben nicht die erforderlichen Berechtigungen um auf den gewählten Artikel anzusehen.
KnowledgeBase.missingArticleLabel = (Fehlender Artikel)
KnowledgeBase.missingPermission = Sie haben nicht die erforderlichen Berechtigungen, um auf den gewählten Artikel zuzugreifen.
KnowledgeBase.tableOfContent.heading = Inhaltsverzeichnis
KnowledgeBase.urlClipboardSuccess = Der Link wurde in die Zwischenablage kopiert
KnowledgeBase.urlCopyInfo = Diesen Link können Sie problemlos an andere weitergeben, da er für 30 Tage auch ohne Login funktioniert.
Expand Down
34 changes: 26 additions & 8 deletions src/main/resources/default/taglib/k/link.html.pasta
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
<i:arg type="String" name="id" default="" description="Defines the id."/>
<i:arg type="String" name="link" description="Defines a url or link."/>
<i:arg type="String" name="name" default="" description="Defines a speaking name or description."/>
<i:arg type="String" name="icon" default="fa-solid fa-external-link-alt" description="Defines the icon left to the link name."/>
<i:arg type="String" name="target" default="_self" description="Defines the target where to display the linked url or link."/>
<i:arg name="id" type="String" default="" description="Defines the id."/>
<i:arg name="link" type="String" description="Defines a url or link."/>
<i:arg name="name"
type="String"
default="@i18n('KnowledgeBase.defaultLinkLabel')"
description="Defines a speaking name or description."
deprecated="Use the `label` attribute instead, or nest the label as body."/>
<i:arg name="label"
type="String"
default="@renderToString('body')"
description="Defines a speaking label or description, defaults to the rendered child content of the element."/>
<i:arg name="icon"
type="String"
default="fa-solid fa-external-link-alt"
description="Defines the icon left to the label."/>
<i:arg name="target"
type="String"
default="_self"
description="Defines the target where to display the linked url or link."/>

<i:pragma name="description">
Renders a link uniformly with a speaking name or description.
Renders a link uniformly with a speaking label or description.
</i:pragma>

<i:local name="effectiveLabel" value="isFilled(label) ? label : name"/>

<a @if (isFilled(id)) { id="@id" } href="@link" class="text-decoration-none" target="@target">
<i class="@icon"></i>
<i:if test="isFilled(name)"><span class="text-decoration-underline">@name</span></i:if>
<i:if test="isFilled(icon)"><i class="@icon"></i></i:if>
<i:if test="isFilled(effectiveLabel)">
<span class="text-decoration-underline"><i:raw>@effectiveLabel</i:raw></span><!--@ (suppress whitespace)
--></i:if>
</a>
46 changes: 31 additions & 15 deletions src/main/resources/default/taglib/k/ref.html.pasta
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
<i:arg type="String" name="code"/>
<i:arg type="String" name="class" default=""/>
<i:arg name="code" type="String"/>
<i:arg name="anchor" type="String" default=""/>
<i:arg name="label"
type="String"
default="@renderToString('body')"
description="Defines a speaking label or description, defaults to the rendered child content of the element."/>
<i:arg name="icon" type="String" default="" description="Defines the icon left to the label."/>
<i:arg name="class" type="String" default=""/>

<i:pragma name="description">Provides a link which points to the given knowledge base article.</i:pragma>
<i:pragma name="description">Renders a link which points to the given knowledge base article.</i:pragma>

<i:local name="currentArticle" value="@helper(sirius.biz.tycho.kb.KBHelper.class).currentArticle()"/>
<i:local name="referencedArticle"
value="@part(sirius.biz.tycho.kb.KnowledgeBase.class).resolve(currentArticle != null ? currentArticle.getLanguage() : NLS.getCurrentLanguage(), code, true).orElse(null)"/>

<i:if test="referencedArticle != null">
<i:local name="effectiveIcon"
value="isFilled(icon) ? icon : (referencedArticle.isChapter() ? 'fa-solid fa-book' : 'fa-solid fa-file-alt')"/>
<i:local name="effectiveLabel" value="isFilled(label) ? label : referencedArticle.getTitle()"/>
<i:local name="effectiveAnchor" value="(isFilled(anchor) && !anchor.startsWith('#')) ? ('#' + anchor) : anchor"/>

<a class="@class text-decoration-none"
target="_blank"
href="/kba/@referencedArticle.getLanguage()/@code"
href="/kba/@referencedArticle.getLanguage()/@code@effectiveAnchor"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="@referencedArticle.getDescription()">
<i:if test="referencedArticle.isChapter()">
<i class="fa-solid fa-book"></i>
<i:else>
<i class="fa-solid fa-file-alt"></i>
</i:else>
</i:if>
<span class="text-decoration-underline">@referencedArticle.getTitle()</span>
</a>
<i:else>
<i>Missing KnowledgeBase article.</i>
</i:else>
<i class="@effectiveIcon"></i>
<span class="text-decoration-underline"><i:raw>@effectiveLabel</i:raw></span><!--@ (suppress whitespace)
--></a><!--@ (suppress whitespace)

--><i:else>
<i:local name="effectiveLabel" value="isFilled(label) ? label : i18n('KnowledgeBase.missingArticleLabel')"/>

<span class="text-danger"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="@i18n('KnowledgeBase.missingPermission')">
<i class="fa-solid fa-triangle-exclamation"></i>
<i>@effectiveLabel</i><!--@ (suppress whitespace)
--></span><!--@ (suppress whitespace)
--></i:else>
</i:if>