From d819878974c141b0426a91bf6f9bc311805396af Mon Sep 17 00:00:00 2001
From: Eike Kettner <eike.kettner@posteo.de>
Date: Fri, 19 Feb 2021 11:07:42 +0100
Subject: [PATCH] Re-add the button to create new tags in detail view

---
 .../src/main/elm/Comp/ItemDetail/EditForm.elm | 21 +++++++++-
 .../elm/Comp/ItemDetail/MultiEditMenu.elm     | 13 +++++-
 .../src/main/elm/Comp/ScanMailboxForm.elm     |  6 +++
 .../webapp/src/main/elm/Comp/SearchMenu.elm   | 11 +++++
 modules/webapp/src/main/elm/Comp/Tabs.elm     | 40 +++++++++++--------
 .../src/main/elm/Comp/UiSettingsForm.elm      |  7 ++++
 6 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/EditForm.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/EditForm.elm
index f9af0250..1793d875 100644
--- a/modules/webapp/src/main/elm/Comp/ItemDetail/EditForm.elm
+++ b/modules/webapp/src/main/elm/Comp/ItemDetail/EditForm.elm
@@ -108,6 +108,7 @@ formTabs settings model =
                 span [ class "invisible hidden" ] []
     in
     [ { title = "Name"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "relative mb-4" ]
@@ -133,6 +134,7 @@ formTabs settings model =
             ]
       }
     , { title = "Date"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -157,14 +159,26 @@ formTabs settings model =
             ]
       }
     , { title = "Tags"
+      , titleRight = []
       , info = Nothing
       , body =
-            [ div [ class "mb-4" ]
+            [ div [ class "mb-4 flex flex-col" ]
                 [ Html.map TagDropdownMsg (Comp.Dropdown.view2 dds settings model.tagModel)
+                , div [ class "flex flex-row items-center justify-end" ]
+                    [ a
+                        [ class S.secondaryButton
+                        , class "text-xs mt-2"
+                        , href "#"
+                        , onClick StartTagModal
+                        ]
+                        [ i [ class "fa fa-plus" ] []
+                        ]
+                    ]
                 ]
             ]
       }
     , { title = "Folder"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -190,6 +204,7 @@ item visible. This message will disappear then.
             ]
       }
     , { title = "Custom Fields"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -203,6 +218,7 @@ item visible. This message will disappear then.
             ]
       }
     , { title = "Due Date"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -227,6 +243,7 @@ item visible. This message will disappear then.
             ]
       }
     , { title = "Correspondent"
+      , titleRight = []
       , info = Nothing
       , body =
             [ optional [ Data.Fields.CorrOrg ] <|
@@ -266,6 +283,7 @@ item visible. This message will disappear then.
             ]
       }
     , { title = "Concerning"
+      , titleRight = []
       , info = Nothing
       , body =
             [ optional [ Data.Fields.ConcPerson ] <|
@@ -307,6 +325,7 @@ item visible. This message will disappear then.
             ]
       }
     , { title = "Direction"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/MultiEditMenu.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/MultiEditMenu.elm
index d20e697f..575d4607 100644
--- a/modules/webapp/src/main/elm/Comp/ItemDetail/MultiEditMenu.elm
+++ b/modules/webapp/src/main/elm/Comp/ItemDetail/MultiEditMenu.elm
@@ -952,6 +952,7 @@ renderEditForm2 cfg settings model =
             tabStyle
             (tabState settings model)
             [ { title = "Confirm/Unconfirm item metadata"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ div
@@ -975,6 +976,7 @@ renderEditForm2 cfg settings model =
                     ]
               }
             , { title = "Tags"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ div [ class "field" ]
@@ -997,6 +999,7 @@ renderEditForm2 cfg settings model =
                     ]
               }
             , { title = "Folder"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ Html.map FolderDropdownMsg (Comp.Dropdown.view2 dds settings model.folderModel)
@@ -1015,6 +1018,7 @@ item visible. This message will disappear then.
                     ]
               }
             , { title = "Custom Fields"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ Html.map CustomFieldMsg
@@ -1022,6 +1026,7 @@ item visible. This message will disappear then.
                     ]
               }
             , { title = "Date"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ div [ class "relative" ]
@@ -1043,6 +1048,7 @@ item visible. This message will disappear then.
                     ]
               }
             , { title = "Due Date"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ div [ class "relative" ]
@@ -1064,6 +1070,7 @@ item visible. This message will disappear then.
                     ]
               }
             , { title = "Correspondent"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ optional [ Data.Fields.CorrOrg ] <|
@@ -1088,8 +1095,8 @@ item visible. This message will disappear then.
                             ]
                     ]
               }
-            , { title =
-                    "Concerning"
+            , { title = "Concerning"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ optional [ Data.Fields.ConcPerson ] <|
@@ -1113,12 +1120,14 @@ item visible. This message will disappear then.
                     ]
               }
             , { title = "Direction"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ Html.map DirDropdownMsg (Comp.Dropdown.view2 dds settings model.directionModel)
                     ]
               }
             , { title = "Name"
+              , titleRight = []
               , info = Nothing
               , body =
                     [ div [ class "relative" ]
diff --git a/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm b/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm
index 35b2b1b5..dbee13c8 100644
--- a/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm
+++ b/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm
@@ -1255,26 +1255,32 @@ tabTitle tab =
 formTabs : UiSettings -> Model -> List (Comp.Tabs.Tab Msg)
 formTabs settings model =
     [ { title = tabTitle TabGeneral
+      , titleRight = []
       , info = Nothing
       , body = viewGeneral2 settings model
       }
     , { title = tabTitle TabProcessing
+      , titleRight = []
       , info = Just "These settings define which mails are fetched from the mail server."
       , body = viewProcessing2 model
       }
     , { title = tabTitle TabAdditionalFilter
+      , titleRight = []
       , info = Just "These filters are applied to mails that have been fetched from the mailbox to select those that should be imported."
       , body = viewAdditionalFilter2 model
       }
     , { title = tabTitle TabPostProcessing
+      , titleRight = []
       , info = Just "This defines what happens to mails that have been downloaded."
       , body = viewPostProcessing2 model
       }
     , { title = tabTitle TabMetadata
+      , titleRight = []
       , info = Just "Define metadata that should be attached to all items created by this task."
       , body = viewMetadata2 settings model
       }
     , { title = tabTitle TabSchedule
+      , titleRight = []
       , info = Just "Define when mails should be imported."
       , body = viewSchedule2 model
       }
diff --git a/modules/webapp/src/main/elm/Comp/SearchMenu.elm b/modules/webapp/src/main/elm/Comp/SearchMenu.elm
index 237c08e2..5a88fee6 100644
--- a/modules/webapp/src/main/elm/Comp/SearchMenu.elm
+++ b/modules/webapp/src/main/elm/Comp/SearchMenu.elm
@@ -1292,6 +1292,7 @@ searchTabs ddd flags settings model =
     in
     [ { title = "Inbox"
       , info = Nothing
+      , titleRight = []
       , body =
             [ MB.viewItem <|
                 MB.Checkbox
@@ -1349,6 +1350,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Tags"
+      , titleRight = []
       , info = Nothing
       , body =
             List.map (Html.map TagSelectMsg)
@@ -1360,6 +1362,7 @@ searchTabs ddd flags settings model =
                 )
       }
     , { title = "Tag Categories"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map TagSelectMsg
@@ -1371,6 +1374,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Folder"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map FolderSelectMsg
@@ -1381,6 +1385,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Correspondent"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div
@@ -1411,6 +1416,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Concerning"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div
@@ -1440,6 +1446,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Custom Fields"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map CustomFieldMsg
@@ -1451,6 +1458,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Date"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div
@@ -1489,6 +1497,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Due Date"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div
@@ -1531,6 +1540,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Source"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -1547,6 +1557,7 @@ searchTabs ddd flags settings model =
             ]
       }
     , { title = "Direction"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map DirectionMsg
diff --git a/modules/webapp/src/main/elm/Comp/Tabs.elm b/modules/webapp/src/main/elm/Comp/Tabs.elm
index 01d515cd..be5e99f0 100644
--- a/modules/webapp/src/main/elm/Comp/Tabs.elm
+++ b/modules/webapp/src/main/elm/Comp/Tabs.elm
@@ -11,10 +11,12 @@ module Comp.Tabs exposing
 import Html exposing (..)
 import Html.Attributes exposing (..)
 import Html.Events exposing (onClick)
+import Styles as S
 
 
 type alias Tab msg =
     { title : String
+    , titleRight : List (Html msg)
     , info : Maybe String
     , body : List (Html msg)
     }
@@ -73,28 +75,34 @@ akkordionTab : Style -> State -> msg -> Tab msg -> Html msg
 akkordionTab style state toggle tab =
     let
         tabTitle =
-            a
-                [ class "flex flex-row items-center"
+            div
+                [ class "flex flex-row"
                 , class style.titleClasses
-                , href "#"
-                , onClick toggle
                 ]
-                [ div [ class "inline-flex mr-2 w-2" ]
-                    [ if state == Open then
-                        i [ class "fa fa-caret-down" ] []
+                ([ a
+                    [ class "flex flex-row items-center flex-grow"
+                    , href "#"
+                    , onClick toggle
+                    ]
+                    [ div [ class "inline-flex mr-2 w-2" ]
+                        [ if state == Open then
+                            i [ class "fa fa-caret-down" ] []
 
-                      else
-                        i [ class "fa fa-caret-right" ] []
-                    ]
-                , div [ class "flex flex-col" ]
-                    [ div [ class "px-2 font-semibold" ]
-                        [ text tab.title
+                          else
+                            i [ class "fa fa-caret-right" ] []
                         ]
-                    , div [ class "px-2 opacity-50 text-sm" ]
-                        [ text (Maybe.withDefault "" tab.info)
+                    , div [ class "flex flex-col" ]
+                        [ div [ class "px-2 font-semibold" ]
+                            [ text tab.title
+                            ]
+                        , div [ class "px-2 opacity-50 text-sm" ]
+                            [ text (Maybe.withDefault "" tab.info)
+                            ]
                         ]
                     ]
-                ]
+                 ]
+                    ++ tab.titleRight
+                )
 
         tabContent =
             div
diff --git a/modules/webapp/src/main/elm/Comp/UiSettingsForm.elm b/modules/webapp/src/main/elm/Comp/UiSettingsForm.elm
index 17311238..9594c7e5 100644
--- a/modules/webapp/src/main/elm/Comp/UiSettingsForm.elm
+++ b/modules/webapp/src/main/elm/Comp/UiSettingsForm.elm
@@ -726,6 +726,7 @@ view2 flags settings model =
 settingFormTabs : Flags -> UiSettings -> Model -> List (Comp.Tabs.Tab Msg)
 settingFormTabs flags _ model =
     [ { title = "General"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4 " ]
@@ -740,6 +741,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Item Search"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map SearchPageSizeMsg
@@ -764,6 +766,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Item Cards"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map NoteLengthMsg
@@ -834,6 +837,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Search Menu"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map SearchMenuTagMsg
@@ -860,6 +864,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Item Detail"
+      , titleRight = []
       , info = Nothing
       , body =
             [ div [ class "mb-4" ]
@@ -892,6 +897,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Tag Category Colors"
+      , titleRight = []
       , info = Nothing
       , body =
             [ Html.map TagColorMsg
@@ -903,6 +909,7 @@ settingFormTabs flags _ model =
             ]
       }
     , { title = "Fields"
+      , titleRight = []
       , info = Nothing
       , body =
             [ span [ class "opacity-50 text-sm" ]