commit ab68c8dac9e765bd1a6c3933710c7df1def49a56
Author: Dominik Poch <dpoch@email.cz>
Date:   Sat Apr 16 22:33:04 2022 +0200

    Tag selection
    
    Report when tag is selected

diff --git a/webapp/contexts/TagCategoryContext.tsx b/webapp/contexts/TagCategoryContext.tsx
index 77ec953..0baf8c7 100644
--- a/webapp/contexts/TagCategoryContext.tsx
+++ b/webapp/contexts/TagCategoryContext.tsx
@@ -1,5 +1,5 @@
 import React, { createContext, useEffect, useState } from 'react';
-import { TagCategoryInfo, TagInfo } from '../api';
+import { SubTagInfo, TagCategoryInfo, TagInfo } from '../api';
 import { tagController } from '../controllers';
 
 /**
@@ -7,15 +7,32 @@ import { tagController } from '../controllers';
  */
 interface ITagCategoryContextProvider {
     /**
-     * Tags managed by the context.
+     * Categories managed by the context.
      */
     tagCategories: TagCategoryInfo[] | null;
 
+    /**
+     * Selected tag managed by the context.
+     */
+    selectedTag: TagInfo | null;
+
+    /**
+     * Selected sub tag managed by the context.
+     */
+    selectedSubTag: SubTagInfo | null;
+
     /**
      * Sets new tags.
      * @param newTags An array of new tags.
      */
     setTagCategories: (newTagCategories: TagCategoryInfo[] | null) => void;
+
+    /**
+     * Selects a tag.
+     * @param tag Tag.
+     * @param subTag Sub tag.
+     */
+    selectTag: (tag: TagInfo, subTag: SubTagInfo | null) => void;
 }
 
 /**
@@ -23,17 +40,36 @@ interface ITagCategoryContextProvider {
  */
 export const TagCategoryContext = createContext<ITagCategoryContextProvider>({
     /**
-     * Default tags.
+     * Default categories.
      */
     tagCategories: null,
 
+    /**
+     * Default selected tag.
+     */
+    selectedTag: null,
+
+    /**
+     * Default selected sub tag.
+     */
+    selectedSubTag: null,
+
     /**
      * Default implementation of setTags method.
-     * @param v Array of new tags.
+     * @param c Array of new tags.
      */
     setTagCategories: (c) => {
         return;
     },
+
+    /**
+     * Default implementation of selectTag.
+     * @param t Tag.
+     * @param s Sub tag.
+     */
+    selectTag: (t: TagInfo, s: SubTagInfo | null) => {
+        return;
+    },
 });
 
 /**
@@ -46,6 +82,16 @@ const TagCategoryProvider = (props: { children: React.ReactNode }) => {
      * Tags managed by the context.
      */
     const [tagCategories, setTagCategories] = useState<TagCategoryInfo[] | null>(null);
+    const [selectedTag, setSelectedTag] = useState<TagInfo | null>(null);
+    const [selectedSubTag, setSelectedSubTag] = useState<SubTagInfo | null>(null);
+
+    /**
+     * Selects a tag.
+     */
+    const selectTag = (tag: TagInfo, subTag: SubTagInfo | null) => {
+        setSelectedTag(tag);
+        setSelectedSubTag(subTag);
+    };
 
     /**
      * Initializes the context.
@@ -62,7 +108,10 @@ const TagCategoryProvider = (props: { children: React.ReactNode }) => {
         <TagCategoryContext.Provider
             value={{
                 tagCategories,
+                selectedTag,
+                selectedSubTag,
                 setTagCategories,
+                selectTag,
             }}
         >
             {props.children}
diff --git a/webapp/pages/annotation/index.tsx b/webapp/pages/annotation/index.tsx
index 8afde00..2b9a096 100644
--- a/webapp/pages/annotation/index.tsx
+++ b/webapp/pages/annotation/index.tsx
@@ -5,6 +5,7 @@ import { MainLayout } from '../../layouts/MainLayout';
 import 'antd/dist/antd.css';
 import styles from '/styles/Annotation.module.scss';
 import AnnotationProvider from '../../contexts/AnnotationContext';
+import TagCategoryProvider from '../../contexts/TagCategoryContext';
 
 /**
  * Creates an annotation screen.
@@ -13,19 +14,21 @@ import AnnotationProvider from '../../contexts/AnnotationContext';
 function Annotation() {
     return (
         <AnnotationProvider>
-            <MainLayout>
-                <div className={styles.layoutWrapper}>
-                    <div className={styles.tags}>
-                        <TagPanel />
+            <TagCategoryProvider>
+                <MainLayout>
+                    <div className={styles.layoutWrapper}>
+                        <div className={styles.tags}>
+                            <TagPanel />
+                        </div>
+                        <div className={styles.document}>
+                            <DocumentAnnotationView />
+                        </div>
+                        <div className={styles.annotations}>
+                            <AnnotationPanel />
+                        </div>
                     </div>
-                    <div className={styles.document}>
-                        <DocumentAnnotationView />
-                    </div>
-                    <div className={styles.annotations}>
-                        <AnnotationPanel />
-                    </div>
-                </div>
-            </MainLayout>
+                </MainLayout>
+            </TagCategoryProvider>
         </AnnotationProvider>
     );
 }
