commit 67683ef318d95530d81a73c4ab4f316a45ef416b
Author: Dominik Poch <dpoch@email.cz>
Date:   Fri May 6 09:35:01 2022 +0200

    Changed default tag color
    
    Default color in tag modal changed to color of a category

diff --git a/webapp/components/modals/CategoryModal.tsx b/webapp/components/modals/CategoryModal.tsx
index 34bd6b0..7e2fa91 100644
--- a/webapp/components/modals/CategoryModal.tsx
+++ b/webapp/components/modals/CategoryModal.tsx
@@ -5,10 +5,10 @@ import { Form, Input, Modal, Switch } from 'antd';
  * All values that the modal window can show.
  */
 export interface CategoryModalValues {
-    name: string;
-    color: string;
-    description: string;
-    disabledForAnnotators: boolean;
+    name?: string;
+    color?: string;
+    description?: string;
+    disabledForAnnotators?: boolean;
 }
 
 /**
@@ -23,15 +23,26 @@ function CategoryModal(props: {
     onSubmit: (val: CategoryModalValues) => void; // Method called when the modal is submitted
     defaultValues?: CategoryModalValues; // Default values of a form that contains properties of the category.
 }) {
-    /**
+    /*
      * Initialize default values if they were not set in props.
      */
-    const values = props.defaultValues ?? {
-        name: '',
-        color: 'black',
-        description: '',
-        disabledForAnnotators: false,
-    };
+    let values: CategoryModalValues;
+
+    if (props.defaultValues) {
+        values = {
+            name: props.defaultValues.name ?? '',
+            color: props.defaultValues.color ?? 'black',
+            description: props.defaultValues.description ?? '',
+            disabledForAnnotators: props.defaultValues.disabledForAnnotators ?? false,
+        };
+    } else {
+        values = {
+            name: '',
+            color: 'black',
+            description: '',
+            disabledForAnnotators: false,
+        };
+    }
 
     /**
      * The form.
diff --git a/webapp/components/modals/SubTagModal.tsx b/webapp/components/modals/SubTagModal.tsx
index 1f52147..766f6fa 100644
--- a/webapp/components/modals/SubTagModal.tsx
+++ b/webapp/components/modals/SubTagModal.tsx
@@ -5,8 +5,8 @@ import { Form, Input, Modal } from 'antd';
  * All values that the modal window can show.
  */
 export interface SubTagModalValues {
-    name: string;
-    description: string;
+    name?: string;
+    description?: string;
 }
 
 /**
@@ -24,10 +24,19 @@ function SubTagModal(props: {
     /**
      * Initialize default values if they were not set in props.
      */
-    const values = props.defaultValues ?? {
-        name: '',
-        description: '',
-    };
+    let values: SubTagModalValues;
+
+    if (props.defaultValues) {
+        values = {
+            name: props.defaultValues.name ?? '',
+            description: props.defaultValues.description ?? '',
+        };
+    } else {
+        values = {
+            name: '',
+            description: '',
+        };
+    }
 
     /**
      * The form.
diff --git a/webapp/components/modals/TagModal.tsx b/webapp/components/modals/TagModal.tsx
index 96d7882..5daef68 100644
--- a/webapp/components/modals/TagModal.tsx
+++ b/webapp/components/modals/TagModal.tsx
@@ -5,9 +5,9 @@ import { Form, Input, Modal } from 'antd';
  * All values that the modal window can show.
  */
 export interface TagModalValues {
-    name: string;
-    color: string;
-    description: string;
+    name?: string;
+    color?: string;
+    description?: string;
 }
 
 /**
@@ -25,12 +25,21 @@ function TagModal(props: {
     /**
      * Initialize default values if they were not set in props.
      */
-    const values = props.defaultValues ?? {
-        name: '',
-        color: 'black',
-        description: '',
-    };
+    let values: TagModalValues;
 
+    if (props.defaultValues) {
+        values = {
+            name: props.defaultValues.name ?? '',
+            color: props.defaultValues.color ?? 'black',
+            description: props.defaultValues.description ?? '',
+        };
+    } else {
+        values = {
+            name: '',
+            color: 'black',
+            description: '',
+        };
+    }
     /**
      * The form.
      */
diff --git a/webapp/pages/tags/index.tsx b/webapp/pages/tags/index.tsx
index 60c5e76..122ed09 100644
--- a/webapp/pages/tags/index.tsx
+++ b/webapp/pages/tags/index.tsx
@@ -394,6 +394,7 @@ function TagsPage() {
                     submitText="Přidat"
                     onCancel={cancelAddTagModal}
                     onSubmit={submitAddTagModal}
+                    defaultValues={{ color: selectedRecord.color }}
                 />
             )}
 
