From f337e8868ffc6c0193c6fe290c15215e79825597 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrgen=20Voskuhl?= <juergen.voskuhl@itcv-software.com>
Date: Fri, 29 Sep 2023 07:41:42 +0200
Subject: [PATCH] Infobox comb. standards

---
 components/it-standards/LifecyclePicture.tsx |  3 +-
 pages/standards/[serviceName].tsx            | 10 +++---
 types/ServiceContent.ts                      |  6 ++++
 types/content/SlugMasterTag.ts               |  4 +--
 views/it-standards/InfoBoxes.tsx             | 32 +++++++++++++++-----
 views/it-standards/Service.tsx               |  1 -
 6 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/components/it-standards/LifecyclePicture.tsx b/components/it-standards/LifecyclePicture.tsx
index 75a818a..ba5977b 100644
--- a/components/it-standards/LifecyclePicture.tsx
+++ b/components/it-standards/LifecyclePicture.tsx
@@ -22,8 +22,7 @@ export default ({ status } : LifecylceOptions) => {
                 />
             </div>
         )
-    }
-    else {
+    } else {
         return (
             <div className="border border-gray-300 rounded-lg overflow-hidden p-2">
                 #INVALID! (tags.status)
diff --git a/pages/standards/[serviceName].tsx b/pages/standards/[serviceName].tsx
index 3e956c1..3369385 100644
--- a/pages/standards/[serviceName].tsx
+++ b/pages/standards/[serviceName].tsx
@@ -8,14 +8,13 @@ import { InfoBoxes } from '@/views/it-standards/InfoBoxes'
 import useContent from 'shared/use-content'
 import useImgPath from 'shared/use-img-path'
 
-import { translateStatusLableValue } from '@/lib/utils/labelHelper'
 const initializedUsedContent = useContent('standards')
 const { getImgPath } = useImgPath()
 
 export default function ({ contentString }) {
     const content: ServiceContent = JSON.parse(contentString)
-    console.log(content.status)
-    console.log('statusLabel = ' + translateStatusLableValue(content.status))
+    console.log(content)
+
     return (
         <div className={'mx-auto max-w-screen-xl it-standard'}>
             <div className="col-start-1 col-span-12 ">
@@ -74,8 +73,9 @@ export default function ({ contentString }) {
                         }}
                         supportInfo={ [] }
                         artefacts={ [] }
-                        combinedStandards={ [] }
-                        // combinedStandards={ content.childResources }
+                        combinedStandards={content.childResources}
+                        slugMaster={content.slugMaster}
+                        currentSlug={content.slug}
                         lastUpdate={content.dateLastUpdate}
                     />
 
diff --git a/types/ServiceContent.ts b/types/ServiceContent.ts
index cb11a07..588509d 100644
--- a/types/ServiceContent.ts
+++ b/types/ServiceContent.ts
@@ -13,6 +13,7 @@ class ServiceContent {
     initialized: boolean = false
     text: string = ''
     childResources: ChildResource[] = []
+    slugMaster = ''
     logo: Logo = new Logo()
     slug: string = ''
     dateLastUpdate: string = ''
@@ -41,6 +42,11 @@ class ServiceContent {
         if (statusTags.length > 0) {
             this.status = statusTags[0].status
         }
+        const slugMasterTags:any = (this.tags?.filter((tag: Tag) => tag.name == 'slug_master'))
+        if (slugMasterTags.length > 0) {
+            this.slugMaster = slugMasterTags[0].value
+        }
+
         this.dateLastUpdate = newContent.dateLastUpdate || ''
     }
 }
diff --git a/types/content/SlugMasterTag.ts b/types/content/SlugMasterTag.ts
index 3ff81ea..0b196c8 100644
--- a/types/content/SlugMasterTag.ts
+++ b/types/content/SlugMasterTag.ts
@@ -1,13 +1,13 @@
 import { Tag } from './Tag'
 
 export class SlugMasterTag extends Tag {
-    type: string
+    slug: string
     name: string = 'slug_master'
     value: string
 
     constructor(type: string) {
         super()
-        this.type = type
+        this.slug = type
         this.value = type
     }
 }
diff --git a/views/it-standards/InfoBoxes.tsx b/views/it-standards/InfoBoxes.tsx
index c17d87e..b5489ae 100644
--- a/views/it-standards/InfoBoxes.tsx
+++ b/views/it-standards/InfoBoxes.tsx
@@ -1,5 +1,6 @@
 import MY_CONSTANTS from '@/lib/constants-standards.js'
 import { ChildResource } from 'types/content'
+import Link from 'next/link'
 
 type Contact = {
     name: string
@@ -19,7 +20,9 @@ type InfoboxOptions = {
     contact: Contact
     supportInfo: LinkItem[]
     artefacts: LinkItem[]
-    combinedStandards: LinkItem[]
+    combinedStandards: ChildResource[]
+    slugMaster: string
+    currentSlug: string
     lastUpdate: string
 }
 
@@ -48,10 +51,13 @@ export function InfoBoxes({
     supportInfo,
     artefacts,
     combinedStandards,
+    slugMaster,
+    currentSlug,
     lastUpdate,
 }: InfoboxOptions) {
+    console.log(combinedStandards, slugMaster)
     return (
-        <div>
+        <div className="infoboxes">
             {/* Dummy to ensure Tailwind classes are imported */}
             <div className="hidden w-20 bg-red-100 bg-yellow-100 bg-slate-100">
                 &nbsp;
@@ -93,19 +99,29 @@ export function InfoBoxes({
                 </div>
             )}
 
-            {combinedStandards.length > 0 && combinedStandards[0].link != '' && (
+            {/* COMBINED STANDARDS */}
+            {combinedStandards.length > 0 && combinedStandards[0].name != '' && (
                 <div className="w-80 border-2 mb-4 rounded-md">
                     <div className={`${MY_CONSTANTS.BG_COLORS.COMBINED_STANDARDS} p-1 font-bold`}>Verbundene IT-Standards</div>
                     <div className="text-sm p-1">
-                        {combinedStandards.map((myItem: LinkItem, key) => (
-                            <div className="flex" key={`${key}`}>
-                                <div className={`${myItem.name}`}></div>
-                            </div>
-                        ))}
+                        {
+                            (combinedStandards.filter((item) => item.slug != currentSlug))
+                                .map((myItem: ChildResource, key) => {
+                                    return (
+                                        <div className="flex" key={`${key}`}>
+                                            {myItem.slug == slugMaster ?
+                                                <div className={'leading-7 ' + 'font-bold ' + `${myItem.name}`}><a href={'/standards/' + myItem.slug}>{myItem.name}</a></div>
+                                                : <div className={'leading-7 ' + `${myItem.name}`}><a href={'/standards/' + myItem.slug}>{myItem.name}&nbsp;{slugMaster}</a></div>
+                                            }
+                                        </div>
+                                    )
+                                })
+                        }
                     </div>
                 </div>
             )}
 
+            {/* LAST UPDATE */}
             {lastUpdate && (
                 <div className="w-80 border-2 mb-4 rounded-md">
                     <div className={`${MY_CONSTANTS.BG_COLORS.DEFAULT} p-1 font-bold`}>Letzte Aktualisierung</div>
diff --git a/views/it-standards/Service.tsx b/views/it-standards/Service.tsx
index 349ae8f..8c10ba4 100644
--- a/views/it-standards/Service.tsx
+++ b/views/it-standards/Service.tsx
@@ -42,7 +42,6 @@ export function Header({
     issuesURL,
     resources,
 }: HeaderOptions) {
-    console.log(statusLabel)
     return (
         <PageHeaderCard title={title} description={description} img={img} status={statusLabel} >
             {developer && (
-- 
GitLab