docspell/modules/webapp/src/main/elm/Util/Person.elm

28 lines
685 B
Elm
Raw Normal View History

2021-07-04 08:24:49 +00:00
{-
2021-07-25 12:00:11 +00:00
Copyright 2020 Docspell Contributors
2021-07-04 08:24:49 +00:00
2021-07-25 12:00:11 +00:00
SPDX-License-Identifier: GPL-3.0-or-later
2021-07-04 08:24:49 +00:00
-}
2021-07-25 12:00:11 +00:00
2021-04-02 13:54:02 +00:00
module Util.Person exposing (mkPersonOption)
import Api.Model.IdName exposing (IdName)
import Api.Model.Person exposing (Person)
import Comp.Dropdown
import Dict exposing (Dict)
import Util.String
mkPersonOption : IdName -> Dict String Person -> Comp.Dropdown.Option
mkPersonOption idref personDict =
let
org =
Dict.get idref.id personDict
|> Maybe.andThen .organization
|> Maybe.map .name
|> Maybe.map (Util.String.ellipsis 15)
|> Maybe.withDefault ""
in
Comp.Dropdown.Option idref.name org