From 6e4aeb512da239a7e67c92a24cf2f67c1a44b00b Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sat, 13 Jun 2020 16:18:24 +0200 Subject: [PATCH] Reorganize search menu items --- .../webapp/src/main/elm/Comp/ItemCardList.elm | 2 +- .../webapp/src/main/elm/Comp/ItemDetail.elm | 4 +- .../webapp/src/main/elm/Comp/SearchMenu.elm | 53 +++++++++---------- modules/webapp/src/main/elm/Data/Icons.elm | 6 +-- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/ItemCardList.elm b/modules/webapp/src/main/elm/Comp/ItemCardList.elm index de2b36ae..1d4e9023 100644 --- a/modules/webapp/src/main/elm/Comp/ItemCardList.elm +++ b/modules/webapp/src/main/elm/Comp/ItemCardList.elm @@ -209,7 +209,7 @@ viewItem settings item = [ class "item" , title "Correspondent" ] - [ Icons.correspondentIcon + [ Icons.correspondentIcon "" , text " " , Util.String.withDefault "-" corr |> text ] diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail.elm b/modules/webapp/src/main/elm/Comp/ItemDetail.elm index ffe5c8d2..80463994 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail.elm @@ -1787,7 +1787,7 @@ renderItemInfo settings model = [ class "item" , title "Correspondent" ] - [ Icons.correspondentIcon + [ Icons.correspondentIcon "" , List.filterMap identity [ model.item.corrOrg, model.item.corrPerson ] |> List.map .name |> String.join ", " @@ -1994,7 +1994,7 @@ renderEditForm settings model = , renderDueDateSuggestions model ] , h4 [ class "ui dividing header" ] - [ Icons.correspondentIcon + [ Icons.correspondentIcon "" , text "Correspondent" ] , div [ class "field" ] diff --git a/modules/webapp/src/main/elm/Comp/SearchMenu.elm b/modules/webapp/src/main/elm/Comp/SearchMenu.elm index 0cabb8ab..f2f2e8b4 100644 --- a/modules/webapp/src/main/elm/Comp/SearchMenu.elm +++ b/modules/webapp/src/main/elm/Comp/SearchMenu.elm @@ -20,12 +20,14 @@ import Comp.DatePicker import Comp.Dropdown exposing (isDropdownChangeMsg) import Data.Direction exposing (Direction) import Data.Flags exposing (Flags) +import Data.Icons as Icons import Data.UiSettings exposing (UiSettings) import DatePicker exposing (DatePicker) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onCheck, onInput) import Http +import Util.Maybe import Util.Tag import Util.Update @@ -444,11 +446,7 @@ update flags settings msg model = SetName str -> let next = - if str == "" then - Nothing - - else - Just str + Util.Maybe.fromString str in NextState ( { model | nameModel = next } @@ -463,6 +461,15 @@ update flags settings msg model = view : UiSettings -> Model -> Html Msg view settings model = + let + formHeader icon headline = + div [ class "ui small dividing header" ] + [ icon + , div [ class "content" ] + [ text headline + ] + ] + in div [ class "ui form" ] [ div [ class "inline field" ] [ div [ class "ui checkbox" ] @@ -491,13 +498,7 @@ view settings model = , text " at beginning or end" ] ] - , div [ class "field" ] - [ label [] [ text "Direction" ] - , Html.map DirectionMsg (Comp.Dropdown.view settings model.directionModel) - ] - , h3 [ class "ui header" ] - [ text "Tags" - ] + , formHeader (Icons.tagsIcon "") "Tags" , div [ class "field" ] [ label [] [ text "Include (and)" ] , Html.map TagIncMsg (Comp.Dropdown.view settings model.tagInclModel) @@ -506,17 +507,17 @@ view settings model = [ label [] [ text "Exclude (or)" ] , Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel) ] - , h3 [ class "ui header" ] - [ case getDirection model of + , formHeader (Icons.correspondentIcon "") + (case getDirection model of Just Data.Direction.Incoming -> - text "Sender" + "Sender" Just Data.Direction.Outgoing -> - text "Recipient" + "Recipient" Nothing -> - text "Correspondent" - ] + "Correspondent" + ) , div [ class "field" ] [ label [] [ text "Organization" ] , Html.map OrgMsg (Comp.Dropdown.view settings model.orgModel) @@ -525,9 +526,7 @@ view settings model = [ label [] [ text "Person" ] , Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel) ] - , h3 [ class "ui header" ] - [ text "Concerned" - ] + , formHeader Icons.concernedIcon "Concerned" , div [ class "field" ] [ label [] [ text "Person" ] , Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel) @@ -536,9 +535,7 @@ view settings model = [ label [] [ text "Equipment" ] , Html.map ConcEquipmentMsg (Comp.Dropdown.view settings model.concEquipmentModel) ] - , h3 [ class "ui header" ] - [ text "Date" - ] + , formHeader (Icons.dateIcon "") "Date" , div [ class "fields" ] [ div [ class "field" ] [ label [] @@ -561,9 +558,7 @@ view settings model = ) ] ] - , h3 [ class "ui header" ] - [ text "Due Date" - ] + , formHeader (Icons.dueDateIcon "") "Due Date" , div [ class "fields" ] [ div [ class "field" ] [ label [] @@ -586,4 +581,8 @@ view settings model = ) ] ] + , formHeader (Icons.directionIcon "") "Direction" + , div [ class "field" ] + [ Html.map DirectionMsg (Comp.Dropdown.view settings model.directionModel) + ] ] diff --git a/modules/webapp/src/main/elm/Data/Icons.elm b/modules/webapp/src/main/elm/Data/Icons.elm index a52f0c4b..8d891221 100644 --- a/modules/webapp/src/main/elm/Data/Icons.elm +++ b/modules/webapp/src/main/elm/Data/Icons.elm @@ -44,9 +44,9 @@ correspondent = "address card outline icon" -correspondentIcon : Html msg -correspondentIcon = - i [ class correspondent ] [] +correspondentIcon : String -> Html msg +correspondentIcon classes = + i [ class (correspondent ++ " " ++ classes) ] [] date : String