mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-03 18:00:11 +00:00 
			
		
		
		
	@@ -17,7 +17,6 @@ import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.AttachmentMeta exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
@@ -29,7 +28,7 @@ type alias Model =
 | 
			
		||||
type DataResult a
 | 
			
		||||
    = NotAvailable
 | 
			
		||||
    | Success a
 | 
			
		||||
    | Failure String
 | 
			
		||||
    | HttpFailure Http.Error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
@@ -57,7 +56,7 @@ update msg model =
 | 
			
		||||
            { model | meta = Success am }
 | 
			
		||||
 | 
			
		||||
        MetaResp (Err err) ->
 | 
			
		||||
            { model | meta = Failure (Util.Http.errorToString err) }
 | 
			
		||||
            { model | meta = HttpFailure err }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -77,9 +76,9 @@ view2 texts attrs model =
 | 
			
		||||
                    , label = texts.basics.loading
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
            Failure msg ->
 | 
			
		||||
            HttpFailure err ->
 | 
			
		||||
                div [ class S.errorMessage ]
 | 
			
		||||
                    [ text msg
 | 
			
		||||
                    [ text (texts.httpError err)
 | 
			
		||||
                    ]
 | 
			
		||||
 | 
			
		||||
            Success data ->
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ module Comp.CalEventInput exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    , Msg
 | 
			
		||||
    , init
 | 
			
		||||
    , initDefault
 | 
			
		||||
    , update
 | 
			
		||||
    , view2
 | 
			
		||||
    )
 | 
			
		||||
@@ -19,12 +18,25 @@ import Html.Events exposing (onInput)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.CalEventInput exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { checkResult : Maybe CalEventCheckResult
 | 
			
		||||
    { checkResult : CheckResult
 | 
			
		||||
    , inner : CalEvent
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type CheckResult
 | 
			
		||||
    = CheckResultOk EventData
 | 
			
		||||
    | CheckResultFailed String
 | 
			
		||||
    | CheckResultHttpError Http.Error
 | 
			
		||||
    | CheckResultInitial
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias EventData =
 | 
			
		||||
    { nextEvents : List Int
 | 
			
		||||
    , eventString : Maybe String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -38,14 +50,23 @@ type Msg
 | 
			
		||||
    | CheckInputMsg CalEvent (Result Http.Error CalEventCheckResult)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initDefault : Model
 | 
			
		||||
initDefault =
 | 
			
		||||
    Model Nothing
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
init : Flags -> CalEvent -> ( Model, Cmd Msg )
 | 
			
		||||
init flags ev =
 | 
			
		||||
    ( Model Nothing, checkInput flags ev )
 | 
			
		||||
    ( { checkResult = CheckResultInitial
 | 
			
		||||
      , inner = ev
 | 
			
		||||
      }
 | 
			
		||||
    , checkInput flags ev
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
eventData : Model -> Maybe EventData
 | 
			
		||||
eventData model =
 | 
			
		||||
    case model.checkResult of
 | 
			
		||||
        CheckResultOk data ->
 | 
			
		||||
            Just data
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            Nothing
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
checkInput : Flags -> CalEvent -> Cmd Msg
 | 
			
		||||
@@ -60,20 +81,33 @@ checkInput flags ev =
 | 
			
		||||
    Api.checkCalEvent flags input (CheckInputMsg ev)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
withCheckInput : Flags -> CalEvent -> Model -> ( Model, Cmd Msg, Validated CalEvent )
 | 
			
		||||
withCheckInput : Flags -> CalEvent -> Model -> ( Model, Cmd Msg, Maybe CalEvent )
 | 
			
		||||
withCheckInput flags ev model =
 | 
			
		||||
    ( model, checkInput flags ev, Unknown ev )
 | 
			
		||||
    ( model, checkInput flags ev, Nothing )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isCheckError : Model -> Bool
 | 
			
		||||
isCheckError model =
 | 
			
		||||
    Maybe.map .success model.checkResult
 | 
			
		||||
        |> Maybe.withDefault True
 | 
			
		||||
        |> not
 | 
			
		||||
    case model.checkResult of
 | 
			
		||||
        CheckResultOk _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        CheckResultFailed _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        CheckResultHttpError _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        CheckResultInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Validated CalEvent )
 | 
			
		||||
update flags ev msg model =
 | 
			
		||||
update : Flags -> Maybe CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Maybe CalEvent )
 | 
			
		||||
update flags mev msg model =
 | 
			
		||||
    let
 | 
			
		||||
        ev =
 | 
			
		||||
            Maybe.withDefault model.inner mev
 | 
			
		||||
    in
 | 
			
		||||
    case msg of
 | 
			
		||||
        SetYear str ->
 | 
			
		||||
            withCheckInput flags { ev | year = str } model
 | 
			
		||||
@@ -96,42 +130,49 @@ update flags ev msg model =
 | 
			
		||||
        CheckInputMsg event (Ok res) ->
 | 
			
		||||
            let
 | 
			
		||||
                m =
 | 
			
		||||
                    { model | checkResult = Just res }
 | 
			
		||||
                    { model
 | 
			
		||||
                        | checkResult =
 | 
			
		||||
                            if res.success then
 | 
			
		||||
                                CheckResultOk
 | 
			
		||||
                                    { nextEvents = res.next
 | 
			
		||||
                                    , eventString = res.event
 | 
			
		||||
                                    }
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                CheckResultFailed res.message
 | 
			
		||||
                        , inner = event
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            ( m
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , if res.success then
 | 
			
		||||
                Valid event
 | 
			
		||||
                Just event
 | 
			
		||||
 | 
			
		||||
              else
 | 
			
		||||
                Invalid [ res.message ] event
 | 
			
		||||
                Nothing
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        CheckInputMsg event (Err err) ->
 | 
			
		||||
            let
 | 
			
		||||
                emptyResult =
 | 
			
		||||
                    Api.Model.CalEventCheckResult.empty
 | 
			
		||||
 | 
			
		||||
                m =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | checkResult =
 | 
			
		||||
                            Just
 | 
			
		||||
                                { emptyResult
 | 
			
		||||
                                    | success = False
 | 
			
		||||
                                    , message = Util.Http.errorToString err
 | 
			
		||||
                                }
 | 
			
		||||
                        | checkResult = CheckResultHttpError err
 | 
			
		||||
                        , inner = event
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            ( m, Cmd.none, Unknown event )
 | 
			
		||||
            ( m, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--- View2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
view2 : Texts -> String -> CalEvent -> Model -> Html Msg
 | 
			
		||||
view2 texts extraClasses ev model =
 | 
			
		||||
view2 : Texts -> String -> Maybe CalEvent -> Model -> Html Msg
 | 
			
		||||
view2 texts extraClasses mev model =
 | 
			
		||||
    let
 | 
			
		||||
        ev =
 | 
			
		||||
            Maybe.withDefault model.inner mev
 | 
			
		||||
 | 
			
		||||
        yearLen =
 | 
			
		||||
            Basics.max 4 (String.length ev.year)
 | 
			
		||||
 | 
			
		||||
@@ -255,17 +296,21 @@ view2 texts extraClasses ev model =
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            ]
 | 
			
		||||
            [ text (texts.error ++ ": ")
 | 
			
		||||
            , Maybe.map .message model.checkResult
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            , case model.checkResult of
 | 
			
		||||
                CheckResultOk _ ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                CheckResultFailed str ->
 | 
			
		||||
                    text str
 | 
			
		||||
 | 
			
		||||
                CheckResultHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                CheckResultInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
            ]
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden1"
 | 
			
		||||
                  , model.checkResult == Nothing || isCheckError model
 | 
			
		||||
                  )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "px-2 pt-4 pb-2 border-0 border-l border-b border-r bg-gray-50 dark:bg-bluegray-700"
 | 
			
		||||
            [ class "px-2 pt-4 pb-2 border-0 border-l border-b border-r bg-gray-50 dark:bg-bluegray-700"
 | 
			
		||||
            , class S.border
 | 
			
		||||
            ]
 | 
			
		||||
            [ div []
 | 
			
		||||
@@ -273,7 +318,8 @@ view2 texts extraClasses ev model =
 | 
			
		||||
                    [ text (texts.schedule ++ ": ")
 | 
			
		||||
                    ]
 | 
			
		||||
                , div [ class "px-12 font-mono " ]
 | 
			
		||||
                    [ Maybe.andThen .event model.checkResult
 | 
			
		||||
                    [ eventData model
 | 
			
		||||
                        |> Maybe.andThen .eventString
 | 
			
		||||
                        |> Maybe.withDefault ""
 | 
			
		||||
                        |> text
 | 
			
		||||
                    ]
 | 
			
		||||
@@ -281,7 +327,8 @@ view2 texts extraClasses ev model =
 | 
			
		||||
                    [ text (texts.next ++ ": ")
 | 
			
		||||
                    ]
 | 
			
		||||
                , ul [ class "list-decimal list-inside text-sm" ]
 | 
			
		||||
                    (Maybe.map .next model.checkResult
 | 
			
		||||
                    (eventData model
 | 
			
		||||
                        |> Maybe.map .nextEvents
 | 
			
		||||
                        |> Maybe.withDefault []
 | 
			
		||||
                        |> List.map texts.formatDateTime
 | 
			
		||||
                        |> List.map (\s -> li [ class "" ] [ text s ])
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ import Html.Events exposing (onClick)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.ChangePasswordForm exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
@@ -28,12 +27,20 @@ type alias Model =
 | 
			
		||||
    , newPass1 : Maybe String
 | 
			
		||||
    , pass2Model : Comp.PasswordInput.Model
 | 
			
		||||
    , newPass2 : Maybe String
 | 
			
		||||
    , errors : List String
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , successMsg : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateNone
 | 
			
		||||
    | FormStateHttpError Http.Error
 | 
			
		||||
    | FormStateSubmitOk
 | 
			
		||||
    | FormStateRequiredMissing
 | 
			
		||||
    | FormStatePasswordMismatch
 | 
			
		||||
    | FormStateSubmitError String
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    validateModel
 | 
			
		||||
@@ -43,9 +50,8 @@ emptyModel =
 | 
			
		||||
        , pass1Model = Comp.PasswordInput.init
 | 
			
		||||
        , newPass2 = Nothing
 | 
			
		||||
        , pass2Model = Comp.PasswordInput.init
 | 
			
		||||
        , errors = []
 | 
			
		||||
        , loading = False
 | 
			
		||||
        , successMsg = ""
 | 
			
		||||
        , formState = FormStateNone
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -57,37 +63,21 @@ type Msg
 | 
			
		||||
    | SubmitResp (Result Http.Error BasicResult)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
validate : Model -> List String
 | 
			
		||||
validate : Model -> FormState
 | 
			
		||||
validate model =
 | 
			
		||||
    List.concat
 | 
			
		||||
        [ if model.newPass1 /= Nothing && model.newPass2 /= Nothing && model.newPass1 /= model.newPass2 then
 | 
			
		||||
            [ "New passwords do not match." ]
 | 
			
		||||
    if model.newPass1 /= Nothing && model.newPass2 /= Nothing && model.newPass1 /= model.newPass2 then
 | 
			
		||||
        FormStatePasswordMismatch
 | 
			
		||||
 | 
			
		||||
          else
 | 
			
		||||
            []
 | 
			
		||||
        , if model.newPass1 == Nothing || model.newPass2 == Nothing || model.current == Nothing then
 | 
			
		||||
            [ "Please fill in required fields." ]
 | 
			
		||||
    else if model.newPass1 == Nothing || model.newPass2 == Nothing || model.current == Nothing then
 | 
			
		||||
        FormStateRequiredMissing
 | 
			
		||||
 | 
			
		||||
          else
 | 
			
		||||
            []
 | 
			
		||||
        ]
 | 
			
		||||
    else
 | 
			
		||||
        FormStateNone
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
validateModel : Model -> Model
 | 
			
		||||
validateModel model =
 | 
			
		||||
    let
 | 
			
		||||
        err =
 | 
			
		||||
            validate model
 | 
			
		||||
    in
 | 
			
		||||
    { model
 | 
			
		||||
        | errors = err
 | 
			
		||||
        , successMsg =
 | 
			
		||||
            if err == [] then
 | 
			
		||||
                model.successMsg
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ""
 | 
			
		||||
    }
 | 
			
		||||
    { model | formState = validate model }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -126,7 +116,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        Submit ->
 | 
			
		||||
            let
 | 
			
		||||
                valid =
 | 
			
		||||
                state =
 | 
			
		||||
                    validate model
 | 
			
		||||
 | 
			
		||||
                cp =
 | 
			
		||||
@@ -134,43 +124,34 @@ update flags msg model =
 | 
			
		||||
                        (Maybe.withDefault "" model.current)
 | 
			
		||||
                        (Maybe.withDefault "" model.newPass1)
 | 
			
		||||
            in
 | 
			
		||||
            if List.isEmpty valid then
 | 
			
		||||
                ( { model | loading = True, errors = [], successMsg = "" }
 | 
			
		||||
            if state == FormStateNone then
 | 
			
		||||
                ( { model | loading = True, formState = state }
 | 
			
		||||
                , Api.changePassword flags cp SubmitResp
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( model, Cmd.none )
 | 
			
		||||
                ( { model | formState = state }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            let
 | 
			
		||||
                em =
 | 
			
		||||
                    { emptyModel
 | 
			
		||||
                        | errors = []
 | 
			
		||||
                        , successMsg = "Password has been changed."
 | 
			
		||||
                    }
 | 
			
		||||
                    { emptyModel | formState = FormStateSubmitOk }
 | 
			
		||||
            in
 | 
			
		||||
            if res.success then
 | 
			
		||||
                ( em, Cmd.none )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | errors = [ res.message ]
 | 
			
		||||
                    | formState = FormStateSubmitError res.message
 | 
			
		||||
                    , loading = False
 | 
			
		||||
                    , successMsg = ""
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            let
 | 
			
		||||
                str =
 | 
			
		||||
                    Util.Http.errorToString err
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | errors = [ str ]
 | 
			
		||||
                | formState = FormStateHttpError err
 | 
			
		||||
                , loading = False
 | 
			
		||||
                , successMsg = ""
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
@@ -235,29 +216,7 @@ view2 texts model =
 | 
			
		||||
                    model.pass2Model
 | 
			
		||||
                )
 | 
			
		||||
            ]
 | 
			
		||||
        , div
 | 
			
		||||
            [ class S.successMessage
 | 
			
		||||
            , classList [ ( "hidden", model.successMsg == "" ) ]
 | 
			
		||||
            ]
 | 
			
		||||
            [ text model.successMsg
 | 
			
		||||
            ]
 | 
			
		||||
        , div
 | 
			
		||||
            [ class S.errorMessage
 | 
			
		||||
            , classList
 | 
			
		||||
                [ ( "hidden"
 | 
			
		||||
                  , List.isEmpty model.errors
 | 
			
		||||
                        || (currentEmpty && pass1Empty && pass2Empty)
 | 
			
		||||
                  )
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
            [ case model.errors of
 | 
			
		||||
                a :: [] ->
 | 
			
		||||
                    text a
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                    ul [ class "list-disc" ]
 | 
			
		||||
                        (List.map (\em -> li [] [ text em ]) model.errors)
 | 
			
		||||
            ]
 | 
			
		||||
        , renderResultMessage texts model
 | 
			
		||||
        , div [ class "flex flex-row" ]
 | 
			
		||||
            [ button
 | 
			
		||||
                [ class S.primaryButton
 | 
			
		||||
@@ -272,3 +231,33 @@ view2 texts model =
 | 
			
		||||
            , label = texts.basics.loading
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderResultMessage : Texts -> Model -> Html msg
 | 
			
		||||
renderResultMessage texts model =
 | 
			
		||||
    div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( S.errorMessage, model.formState /= FormStateSubmitOk )
 | 
			
		||||
            , ( S.successMessage, model.formState == FormStateSubmitOk )
 | 
			
		||||
            , ( "hidden", model.formState == FormStateNone )
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        [ case model.formState of
 | 
			
		||||
            FormStateNone ->
 | 
			
		||||
                text ""
 | 
			
		||||
 | 
			
		||||
            FormStateHttpError err ->
 | 
			
		||||
                text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
            FormStateSubmitError m ->
 | 
			
		||||
                text m
 | 
			
		||||
 | 
			
		||||
            FormStatePasswordMismatch ->
 | 
			
		||||
                text texts.passwordMismatch
 | 
			
		||||
 | 
			
		||||
            FormStateRequiredMissing ->
 | 
			
		||||
                text texts.fillRequiredFields
 | 
			
		||||
 | 
			
		||||
            FormStateSubmitOk ->
 | 
			
		||||
                text texts.passwordChangeSuccessful
 | 
			
		||||
        ]
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ import Data.DropdownStyle as DS
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Data.ListType exposing (ListType)
 | 
			
		||||
import Data.UiSettings exposing (UiSettings)
 | 
			
		||||
import Data.Validated exposing (Validated(..))
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
@@ -31,7 +30,7 @@ import Util.Tag
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { scheduleModel : Comp.CalEventInput.Model
 | 
			
		||||
    , schedule : Validated CalEvent
 | 
			
		||||
    , schedule : Maybe CalEvent
 | 
			
		||||
    , itemCountModel : Comp.IntField.Model
 | 
			
		||||
    , itemCount : Maybe Int
 | 
			
		||||
    , categoryListModel : Comp.Dropdown.Model String
 | 
			
		||||
@@ -59,7 +58,7 @@ init flags sett =
 | 
			
		||||
            Comp.CalEventInput.init flags newSchedule
 | 
			
		||||
    in
 | 
			
		||||
    ( { scheduleModel = cem
 | 
			
		||||
      , schedule = Data.Validated.Unknown newSchedule
 | 
			
		||||
      , schedule = Just newSchedule
 | 
			
		||||
      , itemCountModel = Comp.IntField.init (Just 0) Nothing True
 | 
			
		||||
      , itemCount = Just sett.itemCount
 | 
			
		||||
      , categoryListModel =
 | 
			
		||||
@@ -90,12 +89,12 @@ init flags sett =
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
getSettings : Model -> Validated ClassifierSetting
 | 
			
		||||
getSettings : Model -> Maybe ClassifierSetting
 | 
			
		||||
getSettings model =
 | 
			
		||||
    Data.Validated.map
 | 
			
		||||
        (\sch ->
 | 
			
		||||
    Maybe.map
 | 
			
		||||
        (\s ->
 | 
			
		||||
            { schedule =
 | 
			
		||||
                Data.CalEvent.makeEvent sch
 | 
			
		||||
                Data.CalEvent.makeEvent s
 | 
			
		||||
            , itemCount = Maybe.withDefault 0 model.itemCount
 | 
			
		||||
            , listType = Data.ListType.toString model.categoryListType
 | 
			
		||||
            , categoryList = Comp.Dropdown.getSelected model.categoryListModel
 | 
			
		||||
@@ -126,7 +125,7 @@ update flags msg model =
 | 
			
		||||
                ( cm, cc, ce ) =
 | 
			
		||||
                    Comp.CalEventInput.update
 | 
			
		||||
                        flags
 | 
			
		||||
                        (Data.Validated.value model.schedule)
 | 
			
		||||
                        model.schedule
 | 
			
		||||
                        lmsg
 | 
			
		||||
                        model.scheduleModel
 | 
			
		||||
            in
 | 
			
		||||
@@ -240,7 +239,7 @@ view2 texts settings model =
 | 
			
		||||
                (Comp.CalEventInput.view2
 | 
			
		||||
                    texts.calEventInput
 | 
			
		||||
                    ""
 | 
			
		||||
                    (Data.Validated.value model.schedule)
 | 
			
		||||
                    model.schedule
 | 
			
		||||
                    model.scheduleModel
 | 
			
		||||
                )
 | 
			
		||||
            ]
 | 
			
		||||
 
 | 
			
		||||
@@ -18,14 +18,12 @@ import Data.DropdownStyle as DS
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Data.Language exposing (Language)
 | 
			
		||||
import Data.UiSettings exposing (UiSettings)
 | 
			
		||||
import Data.Validated exposing (Validated)
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onCheck, onClick, onInput)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.CollectiveSettingsForm exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
@@ -33,12 +31,27 @@ type alias Model =
 | 
			
		||||
    , intEnabled : Bool
 | 
			
		||||
    , initSettings : CollectiveSettings
 | 
			
		||||
    , fullTextConfirmText : String
 | 
			
		||||
    , fullTextReIndexResult : Maybe BasicResult
 | 
			
		||||
    , fullTextReIndexResult : FulltextReindexResult
 | 
			
		||||
    , classifierModel : Comp.ClassifierSettingsForm.Model
 | 
			
		||||
    , startClassifierResult : Maybe BasicResult
 | 
			
		||||
    , startClassifierResult : ClassifierResult
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ClassifierResult
 | 
			
		||||
    = ClassifierResultInitial
 | 
			
		||||
    | ClassifierResultHttpError Http.Error
 | 
			
		||||
    | ClassifierResultSubmitError String
 | 
			
		||||
    | ClassifierResultOk
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FulltextReindexResult
 | 
			
		||||
    = FulltextReindexInitial
 | 
			
		||||
    | FulltextReindexHttpError Http.Error
 | 
			
		||||
    | FulltextReindexSubmitError String
 | 
			
		||||
    | FulltextReindexSubmitOk
 | 
			
		||||
    | FulltextReindexOKMissing
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
init : Flags -> CollectiveSettings -> ( Model, Cmd Msg )
 | 
			
		||||
init flags settings =
 | 
			
		||||
    let
 | 
			
		||||
@@ -57,17 +70,17 @@ init flags settings =
 | 
			
		||||
      , intEnabled = settings.integrationEnabled
 | 
			
		||||
      , initSettings = settings
 | 
			
		||||
      , fullTextConfirmText = ""
 | 
			
		||||
      , fullTextReIndexResult = Nothing
 | 
			
		||||
      , fullTextReIndexResult = FulltextReindexInitial
 | 
			
		||||
      , classifierModel = cm
 | 
			
		||||
      , startClassifierResult = Nothing
 | 
			
		||||
      , startClassifierResult = ClassifierResultInitial
 | 
			
		||||
      }
 | 
			
		||||
    , Cmd.map ClassifierSettingMsg cc
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
getSettings : Model -> Validated CollectiveSettings
 | 
			
		||||
getSettings : Model -> Maybe CollectiveSettings
 | 
			
		||||
getSettings model =
 | 
			
		||||
    Data.Validated.map
 | 
			
		||||
    Maybe.map
 | 
			
		||||
        (\cls ->
 | 
			
		||||
            { language =
 | 
			
		||||
                Comp.Dropdown.getSelected model.langModel
 | 
			
		||||
@@ -121,31 +134,36 @@ update flags msg model =
 | 
			
		||||
        TriggerReIndex ->
 | 
			
		||||
            case String.toLower model.fullTextConfirmText of
 | 
			
		||||
                "ok" ->
 | 
			
		||||
                    ( { model | fullTextReIndexResult = Nothing }
 | 
			
		||||
                    ( { model | fullTextReIndexResult = FulltextReindexInitial }
 | 
			
		||||
                    , Api.startReIndex flags TriggerReIndexResult
 | 
			
		||||
                    , Nothing
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | fullTextReIndexResult =
 | 
			
		||||
                            Just
 | 
			
		||||
                                (BasicResult False <|
 | 
			
		||||
                                    "Please type OK in the field if you really "
 | 
			
		||||
                                        ++ "want to start re-indexing your data."
 | 
			
		||||
                                )
 | 
			
		||||
                        | fullTextReIndexResult = FulltextReindexOKMissing
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.none
 | 
			
		||||
                    , Nothing
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
        TriggerReIndexResult (Ok br) ->
 | 
			
		||||
            ( { model | fullTextReIndexResult = Just br }, Cmd.none, Nothing )
 | 
			
		||||
            ( { model
 | 
			
		||||
                | fullTextReIndexResult =
 | 
			
		||||
                    if br.success then
 | 
			
		||||
                        FulltextReindexSubmitOk
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        FulltextReindexSubmitError br.message
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        TriggerReIndexResult (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | fullTextReIndexResult =
 | 
			
		||||
                    Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                    FulltextReindexHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
@@ -165,26 +183,30 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        SaveSettings ->
 | 
			
		||||
            case getSettings model of
 | 
			
		||||
                Data.Validated.Valid s ->
 | 
			
		||||
                Just s ->
 | 
			
		||||
                    ( model, Cmd.none, Just s )
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                Nothing ->
 | 
			
		||||
                    ( model, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
        StartClassifierTask ->
 | 
			
		||||
            ( model, Api.startClassifier flags StartClassifierResp, Nothing )
 | 
			
		||||
 | 
			
		||||
        StartClassifierResp (Ok br) ->
 | 
			
		||||
            ( { model | startClassifierResult = Just br }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | startClassifierResult =
 | 
			
		||||
                    if br.success then
 | 
			
		||||
                        ClassifierResultOk
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ClassifierResultSubmitError br.message
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        StartClassifierResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | startClassifierResult =
 | 
			
		||||
                    Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
              }
 | 
			
		||||
            ( { model | startClassifierResult = ClassifierResultHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
@@ -209,12 +231,7 @@ view2 flags texts settings model =
 | 
			
		||||
            }
 | 
			
		||||
    in
 | 
			
		||||
    div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( "ui form error success", True )
 | 
			
		||||
            , ( "error", Maybe.map .success model.fullTextReIndexResult == Just False )
 | 
			
		||||
            , ( "success", Maybe.map .success model.fullTextReIndexResult == Just True )
 | 
			
		||||
            ]
 | 
			
		||||
        , class "flex flex-col relative"
 | 
			
		||||
        [ class "flex flex-col relative"
 | 
			
		||||
        ]
 | 
			
		||||
        [ MB.view
 | 
			
		||||
            { start =
 | 
			
		||||
@@ -227,7 +244,7 @@ view2 flags texts settings model =
 | 
			
		||||
                            [ title texts.saveSettings
 | 
			
		||||
                            , href "#"
 | 
			
		||||
                            ]
 | 
			
		||||
                        , disabled = getSettings model |> Data.Validated.isInvalid
 | 
			
		||||
                        , disabled = getSettings model == Nothing
 | 
			
		||||
                        }
 | 
			
		||||
                ]
 | 
			
		||||
            , end = []
 | 
			
		||||
@@ -263,13 +280,13 @@ view2 flags texts settings model =
 | 
			
		||||
            , div [ class "mb-4" ]
 | 
			
		||||
                [ label
 | 
			
		||||
                    [ class "inline-flex items-center"
 | 
			
		||||
                    , for "intendpoint-enabled"
 | 
			
		||||
                    , for "int-endpoint-enabled"
 | 
			
		||||
                    ]
 | 
			
		||||
                    [ input
 | 
			
		||||
                        [ type_ "checkbox"
 | 
			
		||||
                        , onCheck (\_ -> ToggleIntegrationEndpoint)
 | 
			
		||||
                        , checked model.intEnabled
 | 
			
		||||
                        , id "intendpoint-enabled"
 | 
			
		||||
                        , id "int-endpoint-enabled"
 | 
			
		||||
                        , class S.checkboxInput
 | 
			
		||||
                        ]
 | 
			
		||||
                        []
 | 
			
		||||
@@ -316,7 +333,7 @@ view2 flags texts settings model =
 | 
			
		||||
                , div [ class "opacity-50 text-sm" ]
 | 
			
		||||
                    [ text texts.reindexAllDataHelp
 | 
			
		||||
                    ]
 | 
			
		||||
                , renderResultMessage2 model.fullTextReIndexResult
 | 
			
		||||
                , renderFulltextReindexResultMessage texts model.fullTextReIndexResult
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        , div
 | 
			
		||||
@@ -340,26 +357,66 @@ view2 flags texts settings model =
 | 
			
		||||
                        { handler = onClick StartClassifierTask
 | 
			
		||||
                        , icon = "fa fa-play"
 | 
			
		||||
                        , label = texts.startNow
 | 
			
		||||
                        , disabled = Data.Validated.isInvalid model.classifierModel.schedule
 | 
			
		||||
                        , disabled = model.classifierModel.schedule == Nothing
 | 
			
		||||
                        , attrs = [ href "#" ]
 | 
			
		||||
                        }
 | 
			
		||||
                    , renderResultMessage2 model.startClassifierResult
 | 
			
		||||
                    , renderClassifierResultMessage texts model.startClassifierResult
 | 
			
		||||
                    ]
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderResultMessage2 : Maybe BasicResult -> Html msg
 | 
			
		||||
renderResultMessage2 result =
 | 
			
		||||
renderClassifierResultMessage : Texts -> ClassifierResult -> Html msg
 | 
			
		||||
renderClassifierResultMessage texts result =
 | 
			
		||||
    let
 | 
			
		||||
        isSuccess =
 | 
			
		||||
            case result of
 | 
			
		||||
                ClassifierResultOk ->
 | 
			
		||||
                    True
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                    False
 | 
			
		||||
 | 
			
		||||
        isError =
 | 
			
		||||
            not isSuccess
 | 
			
		||||
    in
 | 
			
		||||
    div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( S.errorMessage, Maybe.map .success result == Just False )
 | 
			
		||||
            , ( S.successMessage, Maybe.map .success result == Just True )
 | 
			
		||||
            , ( "hidden", result == Nothing )
 | 
			
		||||
            [ ( S.errorMessage, isError )
 | 
			
		||||
            , ( S.successMessage, isSuccess )
 | 
			
		||||
            , ( "hidden", result == ClassifierResultInitial )
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        [ Maybe.map .message result
 | 
			
		||||
            |> Maybe.withDefault ""
 | 
			
		||||
            |> text
 | 
			
		||||
        [ case result of
 | 
			
		||||
            ClassifierResultInitial ->
 | 
			
		||||
                text ""
 | 
			
		||||
 | 
			
		||||
            ClassifierResultOk ->
 | 
			
		||||
                text texts.classifierTaskStarted
 | 
			
		||||
 | 
			
		||||
            ClassifierResultHttpError err ->
 | 
			
		||||
                text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
            ClassifierResultSubmitError m ->
 | 
			
		||||
                text m
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderFulltextReindexResultMessage : Texts -> FulltextReindexResult -> Html msg
 | 
			
		||||
renderFulltextReindexResultMessage texts result =
 | 
			
		||||
    case result of
 | 
			
		||||
        FulltextReindexInitial ->
 | 
			
		||||
            text ""
 | 
			
		||||
 | 
			
		||||
        FulltextReindexSubmitOk ->
 | 
			
		||||
            text texts.fulltextReindexSubmitted
 | 
			
		||||
 | 
			
		||||
        FulltextReindexHttpError err ->
 | 
			
		||||
            text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
        FulltextReindexOKMissing ->
 | 
			
		||||
            text texts.fulltextReindexOkMissing
 | 
			
		||||
 | 
			
		||||
        FulltextReindexSubmitError m ->
 | 
			
		||||
            text m
 | 
			
		||||
 
 | 
			
		||||
@@ -20,19 +20,17 @@ import Comp.YesNoDimmer
 | 
			
		||||
import Data.CustomFieldType exposing (CustomFieldType)
 | 
			
		||||
import Data.DropdownStyle as DS
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Data.Validated exposing (Validated)
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onInput)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.CustomFieldForm exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { result : Maybe BasicResult
 | 
			
		||||
    { formState : FormState
 | 
			
		||||
    , field : CustomField
 | 
			
		||||
    , name : Maybe String
 | 
			
		||||
    , label : Maybe String
 | 
			
		||||
@@ -43,20 +41,67 @@ type alias Model =
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormStateHttp Http.Error
 | 
			
		||||
    | FormStateNameRequired
 | 
			
		||||
    | FormStateTypeRequired
 | 
			
		||||
    | FormStateUpdateFailed UpdateType String
 | 
			
		||||
    | FormStateUpdateOk UpdateType
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type UpdateType
 | 
			
		||||
    = UpdateCreate
 | 
			
		||||
    | UpdateChange
 | 
			
		||||
    | UpdateDelete
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isFormError : FormState -> Bool
 | 
			
		||||
isFormError state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateHttp _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateNameRequired ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateTypeRequired ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateUpdateFailed _ _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateUpdateOk _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isFormSuccess : FormState -> Bool
 | 
			
		||||
isFormSuccess state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            not (isFormError state)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Msg
 | 
			
		||||
    = SetName String
 | 
			
		||||
    | SetLabel String
 | 
			
		||||
    | FTypeMsg (Comp.FixedDropdown.Msg CustomFieldType)
 | 
			
		||||
    | RequestDelete
 | 
			
		||||
    | DeleteMsg Comp.YesNoDimmer.Msg
 | 
			
		||||
    | UpdateResp (Result Http.Error BasicResult)
 | 
			
		||||
    | UpdateResp UpdateType (Result Http.Error BasicResult)
 | 
			
		||||
    | GoBack
 | 
			
		||||
    | SubmitForm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
init : CustomField -> Model
 | 
			
		||||
init field =
 | 
			
		||||
    { result = Nothing
 | 
			
		||||
    { formState = FormStateInitial
 | 
			
		||||
    , field = field
 | 
			
		||||
    , name = Util.Maybe.fromString field.name
 | 
			
		||||
    , label = field.label
 | 
			
		||||
@@ -77,22 +122,22 @@ initEmpty =
 | 
			
		||||
--- Update
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
makeField : Model -> Validated NewCustomField
 | 
			
		||||
makeField : Model -> Result FormState NewCustomField
 | 
			
		||||
makeField model =
 | 
			
		||||
    let
 | 
			
		||||
        name =
 | 
			
		||||
            Maybe.map Data.Validated.Valid model.name
 | 
			
		||||
                |> Maybe.withDefault (Data.Validated.Invalid [ "A name is required." ] "")
 | 
			
		||||
            Maybe.map Ok model.name
 | 
			
		||||
                |> Maybe.withDefault (Err FormStateNameRequired)
 | 
			
		||||
 | 
			
		||||
        ftype =
 | 
			
		||||
            Maybe.map Data.CustomFieldType.asString model.ftype
 | 
			
		||||
                |> Maybe.map Data.Validated.Valid
 | 
			
		||||
                |> Maybe.withDefault (Data.Validated.Invalid [ "A field type is required." ] "")
 | 
			
		||||
                |> Maybe.map Ok
 | 
			
		||||
                |> Maybe.withDefault (Err FormStateTypeRequired)
 | 
			
		||||
 | 
			
		||||
        make n ft =
 | 
			
		||||
            NewCustomField n model.label ft
 | 
			
		||||
    in
 | 
			
		||||
    Data.Validated.map2 make name ftype
 | 
			
		||||
    Result.map2 make name ftype
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Bool )
 | 
			
		||||
@@ -129,29 +174,22 @@ update flags msg model =
 | 
			
		||||
                    makeField model
 | 
			
		||||
            in
 | 
			
		||||
            case newField of
 | 
			
		||||
                Data.Validated.Valid f ->
 | 
			
		||||
                Ok f ->
 | 
			
		||||
                    ( model
 | 
			
		||||
                    , if model.field.id == "" then
 | 
			
		||||
                        Api.postCustomField flags f UpdateResp
 | 
			
		||||
                        Api.postCustomField flags f (UpdateResp UpdateCreate)
 | 
			
		||||
 | 
			
		||||
                      else
 | 
			
		||||
                        Api.putCustomField flags model.field.id f UpdateResp
 | 
			
		||||
                        Api.putCustomField flags model.field.id f (UpdateResp UpdateChange)
 | 
			
		||||
                    , False
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                Data.Validated.Invalid msgs _ ->
 | 
			
		||||
                    let
 | 
			
		||||
                        combined =
 | 
			
		||||
                            String.join "; " msgs
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model | result = Just (BasicResult False combined) }
 | 
			
		||||
                Err fe ->
 | 
			
		||||
                    ( { model | formState = fe }
 | 
			
		||||
                    , Cmd.none
 | 
			
		||||
                    , False
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                Data.Validated.Unknown _ ->
 | 
			
		||||
                    ( model, Cmd.none, False )
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            let
 | 
			
		||||
                ( dm, _ ) =
 | 
			
		||||
@@ -166,18 +204,28 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
                cmd =
 | 
			
		||||
                    if flag then
 | 
			
		||||
                        Api.deleteCustomField flags model.field.id UpdateResp
 | 
			
		||||
                        Api.deleteCustomField flags model.field.id (UpdateResp UpdateDelete)
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Cmd.none
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | deleteDimmer = dm }, cmd, False )
 | 
			
		||||
 | 
			
		||||
        UpdateResp (Ok r) ->
 | 
			
		||||
            ( { model | result = Just r }, Cmd.none, r.success )
 | 
			
		||||
        UpdateResp updateType (Ok r) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if r.success then
 | 
			
		||||
                        FormStateUpdateOk updateType
 | 
			
		||||
 | 
			
		||||
        UpdateResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
                    else
 | 
			
		||||
                        FormStateUpdateFailed updateType r.message
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , r.success
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        UpdateResp _ (Err err) ->
 | 
			
		||||
            ( { model | formState = FormStateHttp err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , False
 | 
			
		||||
            )
 | 
			
		||||
@@ -230,15 +278,30 @@ view2 texts viewSettings model =
 | 
			
		||||
                    )
 | 
			
		||||
                , div
 | 
			
		||||
                    [ classList
 | 
			
		||||
                        [ ( "hidden", model.result == Nothing )
 | 
			
		||||
                        , ( S.errorMessage, Maybe.map .success model.result == Just False )
 | 
			
		||||
                        , ( S.successMessage, Maybe.map .success model.result == Just True )
 | 
			
		||||
                        [ ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                        , ( S.errorMessage, isFormError model.formState )
 | 
			
		||||
                        , ( S.successMessage, isFormSuccess model.formState )
 | 
			
		||||
                        ]
 | 
			
		||||
                    , class "my-2"
 | 
			
		||||
                    ]
 | 
			
		||||
                    [ Maybe.map .message model.result
 | 
			
		||||
                        |> Maybe.withDefault ""
 | 
			
		||||
                        |> text
 | 
			
		||||
                    [ case model.formState of
 | 
			
		||||
                        FormStateInitial ->
 | 
			
		||||
                            text ""
 | 
			
		||||
 | 
			
		||||
                        FormStateHttp err ->
 | 
			
		||||
                            text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                        FormStateNameRequired ->
 | 
			
		||||
                            text texts.fieldNameRequired
 | 
			
		||||
 | 
			
		||||
                        FormStateTypeRequired ->
 | 
			
		||||
                            text texts.fieldTypeRequired
 | 
			
		||||
 | 
			
		||||
                        FormStateUpdateFailed _ m ->
 | 
			
		||||
                            text m
 | 
			
		||||
 | 
			
		||||
                        FormStateUpdateOk _ ->
 | 
			
		||||
                            text texts.updateSuccessful
 | 
			
		||||
                    ]
 | 
			
		||||
                , if model.field.id == "" then
 | 
			
		||||
                    div [ class "py-2 text-lg opacity-75" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -42,14 +42,12 @@ import Comp.TagForm
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Data.Icons as Icons
 | 
			
		||||
import Data.UiSettings exposing (UiSettings)
 | 
			
		||||
import Data.Validated
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onClick)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.DetailEdit exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
@@ -57,10 +55,47 @@ type alias Model =
 | 
			
		||||
    , itemId : String
 | 
			
		||||
    , submitting : Bool
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , result : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormStateHttpError Http.Error
 | 
			
		||||
    | FormStateSubmitSuccessful
 | 
			
		||||
    | FormStateSubmitError String
 | 
			
		||||
    | FormStateMissingRequiredFields
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isError : FormState -> Bool
 | 
			
		||||
isError state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateHttpError _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateSubmitSuccessful ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateSubmitError _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateMissingRequiredFields ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isSuccess : FormState -> Bool
 | 
			
		||||
isSuccess state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            not (isError state)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormModel
 | 
			
		||||
    = TM Comp.TagForm.Model
 | 
			
		||||
    | PMR Comp.PersonForm.Model
 | 
			
		||||
@@ -105,7 +140,7 @@ init itemId fm =
 | 
			
		||||
    , itemId = itemId
 | 
			
		||||
    , submitting = False
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , result = Nothing
 | 
			
		||||
    , formState = FormStateInitial
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -125,7 +160,7 @@ editOrg flags orgId om =
 | 
			
		||||
      , itemId = ""
 | 
			
		||||
      , submitting = False
 | 
			
		||||
      , loading = True
 | 
			
		||||
      , result = Nothing
 | 
			
		||||
      , formState = FormStateInitial
 | 
			
		||||
      }
 | 
			
		||||
    , Api.getOrgFull orgId flags GetOrgResp
 | 
			
		||||
    )
 | 
			
		||||
@@ -137,7 +172,7 @@ editPerson flags persId pm =
 | 
			
		||||
      , itemId = ""
 | 
			
		||||
      , submitting = False
 | 
			
		||||
      , loading = True
 | 
			
		||||
      , result = Nothing
 | 
			
		||||
      , formState = FormStateInitial
 | 
			
		||||
      }
 | 
			
		||||
    , Cmd.batch
 | 
			
		||||
        [ Api.getPersonFull persId flags GetPersonResp
 | 
			
		||||
@@ -152,7 +187,7 @@ editEquip flags equipId em =
 | 
			
		||||
      , itemId = ""
 | 
			
		||||
      , submitting = False
 | 
			
		||||
      , loading = True
 | 
			
		||||
      , result = Nothing
 | 
			
		||||
      , formState = FormStateInitial
 | 
			
		||||
      }
 | 
			
		||||
    , Api.getEquipment flags equipId GetEquipResp
 | 
			
		||||
    )
 | 
			
		||||
@@ -246,10 +281,10 @@ makeValue fm =
 | 
			
		||||
                    Comp.CustomFieldForm.makeField fieldModel
 | 
			
		||||
            in
 | 
			
		||||
            case cfield of
 | 
			
		||||
                Data.Validated.Valid field ->
 | 
			
		||||
                Ok field ->
 | 
			
		||||
                    SubmitCustomField field
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                Err _ ->
 | 
			
		||||
                    CancelForm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -285,7 +320,10 @@ update flags msg model =
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
        GetOrgResp (Err err) ->
 | 
			
		||||
            ( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
@@ -312,7 +350,10 @@ update flags msg model =
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
        GetPersonResp (Err err) ->
 | 
			
		||||
            ( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
@@ -349,7 +390,10 @@ update flags msg model =
 | 
			
		||||
                    ( { model | loading = False }, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
        GetOrgsResp (Err err) ->
 | 
			
		||||
            ( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
@@ -376,7 +420,10 @@ update flags msg model =
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
        GetEquipResp (Err err) ->
 | 
			
		||||
            ( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , Nothing
 | 
			
		||||
            )
 | 
			
		||||
@@ -391,7 +438,12 @@ update flags msg model =
 | 
			
		||||
                        Nothing
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | result = Just res
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if res.success then
 | 
			
		||||
                        FormStateSubmitSuccessful
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        FormStateSubmitError res.message
 | 
			
		||||
                , submitting = False
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -400,7 +452,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | result = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                | formState = FormStateHttpError err
 | 
			
		||||
                , submitting = False
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -408,10 +460,6 @@ update flags msg model =
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Submit ->
 | 
			
		||||
            let
 | 
			
		||||
                failMsg =
 | 
			
		||||
                    Just (BasicResult False "Please fill required fields.")
 | 
			
		||||
            in
 | 
			
		||||
            case model.form of
 | 
			
		||||
                TM tm ->
 | 
			
		||||
                    let
 | 
			
		||||
@@ -425,7 +473,7 @@ update flags msg model =
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( { model | result = failMsg }
 | 
			
		||||
                        ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                        , Cmd.none
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
@@ -446,7 +494,7 @@ update flags msg model =
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( { model | result = failMsg }
 | 
			
		||||
                        ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                        , Cmd.none
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
@@ -467,7 +515,7 @@ update flags msg model =
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( { model | result = failMsg }
 | 
			
		||||
                        ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                        , Cmd.none
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
@@ -488,7 +536,7 @@ update flags msg model =
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( { model | result = failMsg }
 | 
			
		||||
                        ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                        , Cmd.none
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
@@ -509,7 +557,7 @@ update flags msg model =
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( { model | result = failMsg }
 | 
			
		||||
                        ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                        , Cmd.none
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
@@ -520,14 +568,14 @@ update flags msg model =
 | 
			
		||||
                            Comp.CustomFieldForm.makeField fm
 | 
			
		||||
                    in
 | 
			
		||||
                    case cfield of
 | 
			
		||||
                        Data.Validated.Valid newField ->
 | 
			
		||||
                        Ok newField ->
 | 
			
		||||
                            ( { model | submitting = True }
 | 
			
		||||
                            , Api.postCustomField flags newField SubmitResp
 | 
			
		||||
                            , Nothing
 | 
			
		||||
                            )
 | 
			
		||||
 | 
			
		||||
                        _ ->
 | 
			
		||||
                            ( { model | result = failMsg }
 | 
			
		||||
                        Err _ ->
 | 
			
		||||
                            ( { model | formState = FormStateMissingRequiredFields }
 | 
			
		||||
                            , Cmd.none
 | 
			
		||||
                            , Nothing
 | 
			
		||||
                            )
 | 
			
		||||
@@ -541,7 +589,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = TM tm_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map TagMsg tc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -559,7 +607,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = PMR pm_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map PersonMsg pc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -572,7 +620,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = PMC pm_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map PersonMsg pc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -590,7 +638,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = OM om_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map OrgMsg oc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -608,7 +656,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = EM em_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map EquipMsg ec_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -626,7 +674,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | form = CFM fm_
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map CustomFieldMsg fc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
@@ -756,14 +804,26 @@ viewIntern2 : Texts -> UiSettings -> Bool -> Model -> List (Html Msg)
 | 
			
		||||
viewIntern2 texts settings withButtons model =
 | 
			
		||||
    [ div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( S.errorMessage, Maybe.map .success model.result == Just False )
 | 
			
		||||
            , ( S.successMessage, Maybe.map .success model.result == Just True )
 | 
			
		||||
            , ( "hidden", model.result == Nothing )
 | 
			
		||||
            [ ( S.errorMessage, isError model.formState )
 | 
			
		||||
            , ( S.successMessage, isSuccess model.formState )
 | 
			
		||||
            , ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        [ Maybe.map .message model.result
 | 
			
		||||
            |> Maybe.withDefault ""
 | 
			
		||||
            |> text
 | 
			
		||||
        [ case model.formState of
 | 
			
		||||
            FormStateInitial ->
 | 
			
		||||
                text ""
 | 
			
		||||
 | 
			
		||||
            FormStateHttpError err ->
 | 
			
		||||
                text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
            FormStateSubmitSuccessful ->
 | 
			
		||||
                text texts.submitSuccessful
 | 
			
		||||
 | 
			
		||||
            FormStateSubmitError m ->
 | 
			
		||||
                text m
 | 
			
		||||
 | 
			
		||||
            FormStateMissingRequiredFields ->
 | 
			
		||||
                text texts.missingRequiredFields
 | 
			
		||||
        ]
 | 
			
		||||
    , case model.form of
 | 
			
		||||
        TM tm ->
 | 
			
		||||
 
 | 
			
		||||
@@ -23,26 +23,32 @@ import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.EmailSettingsManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { tableModel : Comp.EmailSettingsTable.Model
 | 
			
		||||
    , formModel : Comp.EmailSettingsForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , query : String
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorFillRequired
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    { tableModel = Comp.EmailSettingsTable.emptyModel
 | 
			
		||||
    , formModel = Comp.EmailSettingsForm.emptyModel
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , query = ""
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
@@ -84,7 +90,7 @@ update flags msg model =
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | viewMode = Form
 | 
			
		||||
                        , formError = Nothing
 | 
			
		||||
                        , formError = FormErrorNone
 | 
			
		||||
                        , formModel = Comp.EmailSettingsForm.init ems
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
@@ -101,7 +107,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if tm.selected /= Nothing then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -166,7 +172,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.createMailSettings flags mid ems SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please fill required fields." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorFillRequired }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        LoadSettings ->
 | 
			
		||||
            ( { model | loading = True }, Api.getMailSettings flags model.query MailSettingsResp )
 | 
			
		||||
@@ -183,10 +189,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        MailSettingsResp (Ok ems) ->
 | 
			
		||||
            let
 | 
			
		||||
@@ -286,12 +292,23 @@ viewForm2 texts settings model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", model.formError == Nothing )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorFillRequired ->
 | 
			
		||||
                    text texts.fillRequiredFields
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg
 | 
			
		||||
            (Comp.EmailSettingsForm.view2 texts.settingsForm
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,6 @@ import Html.Events exposing (onSubmit)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.EquipmentManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -30,13 +29,20 @@ type alias Model =
 | 
			
		||||
    { tableModel : Comp.EquipmentTable.Model
 | 
			
		||||
    , formModel : Comp.EquipmentForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    , query : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ViewMode
 | 
			
		||||
    = Table
 | 
			
		||||
    | Form
 | 
			
		||||
@@ -47,7 +53,7 @@ emptyModel =
 | 
			
		||||
    { tableModel = Comp.EquipmentTable.emptyModel
 | 
			
		||||
    , formModel = Comp.EquipmentForm.emptyModel
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
    , query = ""
 | 
			
		||||
@@ -82,7 +88,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if Util.Maybe.nonEmpty tm.selected then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -135,7 +141,7 @@ update flags msg model =
 | 
			
		||||
        InitNewEquipment ->
 | 
			
		||||
            let
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model | viewMode = Form, formError = Nothing }
 | 
			
		||||
                    { model | viewMode = Form, formError = FormErrorNone }
 | 
			
		||||
 | 
			
		||||
                equipment =
 | 
			
		||||
                    Api.Model.Equipment.empty
 | 
			
		||||
@@ -154,7 +160,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.postEquipment flags equipment SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorInvalid }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
@@ -168,10 +174,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            update flags (YesNoMsg Comp.YesNoDimmer.activate) model
 | 
			
		||||
@@ -316,12 +322,23 @@ viewForm2 texts model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", Util.Maybe.isEmpty model.formError )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.correctFormErrors
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg (Comp.EquipmentForm.view2 texts.equipmentForm model.formModel)
 | 
			
		||||
        , B.loadingDimmer
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										60
									
								
								modules/webapp/src/main/elm/Comp/ExpandCollapse.elm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								modules/webapp/src/main/elm/Comp/ExpandCollapse.elm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
module Comp.ExpandCollapse exposing
 | 
			
		||||
    ( collapseToggle
 | 
			
		||||
    , expandToggle
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onClick)
 | 
			
		||||
import Messages.Comp.ExpandCollapse exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { max : Int
 | 
			
		||||
    , all : Int
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--- View2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
expandToggle : Texts -> Model -> msg -> List (Html msg)
 | 
			
		||||
expandToggle texts model m =
 | 
			
		||||
    if model.max >= model.all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class S.link
 | 
			
		||||
            , class "flex flex-row items-center"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "fa fa-angle-down" ] []
 | 
			
		||||
            , div [ class "font-italics text-sm ml-2" ]
 | 
			
		||||
                [ text texts.showMoreLabel
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
collapseToggle : Texts -> Model -> msg -> List (Html msg)
 | 
			
		||||
collapseToggle texts model m =
 | 
			
		||||
    if model.max >= model.all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class S.link
 | 
			
		||||
            , class "flex flex-row items-center"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "fa fa-angle-up" ] []
 | 
			
		||||
            , div [ class "font-italics text-sm ml-2" ]
 | 
			
		||||
                [ text texts.showLessLabel
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
@@ -26,12 +26,11 @@ import Html.Events exposing (onClick, onInput)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.FolderDetail exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { result : Maybe BasicResult
 | 
			
		||||
    { formState : FormState
 | 
			
		||||
    , folder : FolderDetail
 | 
			
		||||
    , name : Maybe String
 | 
			
		||||
    , members : List IdName
 | 
			
		||||
@@ -43,6 +42,59 @@ type alias Model =
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormStateHttpError Http.Error
 | 
			
		||||
    | FormStateFolderCreated
 | 
			
		||||
    | FormStateGenericError String
 | 
			
		||||
    | FormStateNameChangeSuccessful
 | 
			
		||||
    | FormStateDeleteSuccessful
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isError : FormState -> Bool
 | 
			
		||||
isError state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateHttpError _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateGenericError _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateFolderCreated ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateNameChangeSuccessful ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateDeleteSuccessful ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isSuccess : FormState -> Bool
 | 
			
		||||
isSuccess state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateHttpError _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateGenericError _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        FormStateFolderCreated ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateNameChangeSuccessful ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        FormStateDeleteSuccessful ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Msg
 | 
			
		||||
    = SetName String
 | 
			
		||||
    | MemberDropdownMsg (Comp.FixedDropdown.Msg IdName)
 | 
			
		||||
@@ -61,7 +113,7 @@ type Msg
 | 
			
		||||
 | 
			
		||||
init : List User -> FolderDetail -> Model
 | 
			
		||||
init users folder =
 | 
			
		||||
    { result = Nothing
 | 
			
		||||
    { formState = FormStateInitial
 | 
			
		||||
    , folder = folder
 | 
			
		||||
    , name = Util.Maybe.fromString folder.name
 | 
			
		||||
    , members = folder.members
 | 
			
		||||
@@ -143,7 +195,7 @@ update flags msg model =
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model
 | 
			
		||||
                        | loading = True
 | 
			
		||||
                        , result = Nothing
 | 
			
		||||
                        , formState = FormStateInitial
 | 
			
		||||
                      }
 | 
			
		||||
                    , cmd
 | 
			
		||||
                    , False
 | 
			
		||||
@@ -159,7 +211,12 @@ update flags msg model =
 | 
			
		||||
            else
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | loading = False
 | 
			
		||||
                    , result = Just (BasicResult ir.success ir.message)
 | 
			
		||||
                    , formState =
 | 
			
		||||
                        if ir.success then
 | 
			
		||||
                            FormStateFolderCreated
 | 
			
		||||
 | 
			
		||||
                        else
 | 
			
		||||
                            FormStateGenericError ir.message
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                , False
 | 
			
		||||
@@ -168,7 +225,7 @@ update flags msg model =
 | 
			
		||||
        NewFolderResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , result = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , False
 | 
			
		||||
@@ -182,7 +239,7 @@ update flags msg model =
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | loading = False, result = Just r }
 | 
			
		||||
                ( { model | loading = False, formState = FormStateGenericError r.message }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                , False
 | 
			
		||||
                )
 | 
			
		||||
@@ -190,7 +247,7 @@ update flags msg model =
 | 
			
		||||
        ChangeFolderResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , result = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , False
 | 
			
		||||
@@ -199,13 +256,21 @@ update flags msg model =
 | 
			
		||||
        ChangeNameResp (Ok r) ->
 | 
			
		||||
            let
 | 
			
		||||
                model_ =
 | 
			
		||||
                    { model | result = Just r, loading = False }
 | 
			
		||||
                    { model
 | 
			
		||||
                        | formState =
 | 
			
		||||
                            if r.success then
 | 
			
		||||
                                FormStateNameChangeSuccessful
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                FormStateGenericError r.message
 | 
			
		||||
                        , loading = False
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            ( model_, Cmd.none, False )
 | 
			
		||||
 | 
			
		||||
        ChangeNameResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | result = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                | formState = FormStateHttpError err
 | 
			
		||||
                , loading = False
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -218,7 +283,7 @@ update flags msg model =
 | 
			
		||||
        FolderDetailResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = False
 | 
			
		||||
                , result = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , False
 | 
			
		||||
@@ -263,10 +328,20 @@ update flags msg model =
 | 
			
		||||
            ( { model | deleteDimmer = dm }, cmd, False )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Ok r) ->
 | 
			
		||||
            ( { model | result = Just r }, Cmd.none, r.success )
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if r.success then
 | 
			
		||||
                        FormStateDeleteSuccessful
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        FormStateGenericError r.message
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , r.success
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model | formState = FormStateHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , False
 | 
			
		||||
            )
 | 
			
		||||
@@ -350,15 +425,30 @@ view2 texts flags model =
 | 
			
		||||
                    ]
 | 
			
		||||
               , div
 | 
			
		||||
                    [ classList
 | 
			
		||||
                        [ ( "hidden", model.result == Nothing )
 | 
			
		||||
                        , ( S.errorMessage, Maybe.map .success model.result == Just False )
 | 
			
		||||
                        , ( S.successMessage, Maybe.map .success model.result == Just True )
 | 
			
		||||
                        [ ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                        , ( S.errorMessage, isError model.formState )
 | 
			
		||||
                        , ( S.successMessage, isSuccess model.formState )
 | 
			
		||||
                        ]
 | 
			
		||||
                    , class "my-4"
 | 
			
		||||
                    ]
 | 
			
		||||
                    [ Maybe.map .message model.result
 | 
			
		||||
                        |> Maybe.withDefault ""
 | 
			
		||||
                        |> text
 | 
			
		||||
                    [ case model.formState of
 | 
			
		||||
                        FormStateInitial ->
 | 
			
		||||
                            text ""
 | 
			
		||||
 | 
			
		||||
                        FormStateHttpError err ->
 | 
			
		||||
                            text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                        FormStateGenericError m ->
 | 
			
		||||
                            text m
 | 
			
		||||
 | 
			
		||||
                        FormStateFolderCreated ->
 | 
			
		||||
                            text texts.folderCreated
 | 
			
		||||
 | 
			
		||||
                        FormStateNameChangeSuccessful ->
 | 
			
		||||
                            text texts.nameChangeSuccessful
 | 
			
		||||
 | 
			
		||||
                        FormStateDeleteSuccessful ->
 | 
			
		||||
                            text texts.deleteSuccessful
 | 
			
		||||
                    ]
 | 
			
		||||
               ]
 | 
			
		||||
            ++ viewMembers2 texts model
 | 
			
		||||
 
 | 
			
		||||
@@ -11,11 +11,12 @@ module Comp.FolderSelect exposing
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Api.Model.FolderStats exposing (FolderStats)
 | 
			
		||||
import Comp.ExpandCollapse
 | 
			
		||||
import Dict
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onClick)
 | 
			
		||||
import Util.ExpandCollapse
 | 
			
		||||
import Messages.Comp.FolderSelect exposing (Texts)
 | 
			
		||||
import Util.ItemDragDrop as DD
 | 
			
		||||
import Util.List
 | 
			
		||||
 | 
			
		||||
@@ -134,24 +135,28 @@ selectedFolder model =
 | 
			
		||||
--- View2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
expandToggle : Int -> Model -> List (Html Msg)
 | 
			
		||||
expandToggle max model =
 | 
			
		||||
    Util.ExpandCollapse.expandToggle
 | 
			
		||||
        max
 | 
			
		||||
        (List.length model.all)
 | 
			
		||||
expandToggle : Texts -> Int -> Model -> List (Html Msg)
 | 
			
		||||
expandToggle texts max model =
 | 
			
		||||
    Comp.ExpandCollapse.expandToggle
 | 
			
		||||
        texts.expandCollapse
 | 
			
		||||
        { max = max
 | 
			
		||||
        , all = List.length model.all
 | 
			
		||||
        }
 | 
			
		||||
        ToggleExpand
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
collapseToggle : Int -> Model -> List (Html Msg)
 | 
			
		||||
collapseToggle max model =
 | 
			
		||||
    Util.ExpandCollapse.collapseToggle
 | 
			
		||||
        max
 | 
			
		||||
        (List.length model.all)
 | 
			
		||||
collapseToggle : Texts -> Int -> Model -> List (Html Msg)
 | 
			
		||||
collapseToggle texts max model =
 | 
			
		||||
    Comp.ExpandCollapse.collapseToggle
 | 
			
		||||
        texts.expandCollapse
 | 
			
		||||
        { max = max
 | 
			
		||||
        , all = List.length model.all
 | 
			
		||||
        }
 | 
			
		||||
        ToggleExpand
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewDrop2 : DD.Model -> Int -> Model -> Html Msg
 | 
			
		||||
viewDrop2 dropModel constr model =
 | 
			
		||||
viewDrop2 : Texts -> DD.Model -> Int -> Model -> Html Msg
 | 
			
		||||
viewDrop2 texts dropModel constr model =
 | 
			
		||||
    let
 | 
			
		||||
        highlightDrop =
 | 
			
		||||
            DD.getDropId dropModel == Just DD.FolderRemove
 | 
			
		||||
@@ -169,20 +174,20 @@ viewDrop2 dropModel constr model =
 | 
			
		||||
            [ text "Folders"
 | 
			
		||||
            ]
 | 
			
		||||
        , div [ class "flex flex-col space-y-2 md:space-y-1" ]
 | 
			
		||||
            (renderItems2 dropModel constr model)
 | 
			
		||||
            (renderItems2 texts dropModel constr model)
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderItems2 : DD.Model -> Int -> Model -> List (Html Msg)
 | 
			
		||||
renderItems2 dropModel constr model =
 | 
			
		||||
renderItems2 : Texts -> DD.Model -> Int -> Model -> List (Html Msg)
 | 
			
		||||
renderItems2 texts dropModel constr model =
 | 
			
		||||
    if constr <= 0 then
 | 
			
		||||
        List.map (viewItem2 dropModel model) model.all
 | 
			
		||||
 | 
			
		||||
    else if model.expanded then
 | 
			
		||||
        List.map (viewItem2 dropModel model) model.all ++ collapseToggle constr model
 | 
			
		||||
        List.map (viewItem2 dropModel model) model.all ++ collapseToggle texts constr model
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        List.map (viewItem2 dropModel model) (List.take constr model.all) ++ expandToggle constr model
 | 
			
		||||
        List.map (viewItem2 dropModel model) (List.take constr model.all) ++ expandToggle texts constr model
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewItem2 : DD.Model -> Model -> FolderStats -> Html Msg
 | 
			
		||||
 
 | 
			
		||||
@@ -23,26 +23,32 @@ import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.ImapSettingsManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { tableModel : Comp.ImapSettingsTable.Model
 | 
			
		||||
    , formModel : Comp.ImapSettingsForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , query : String
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorFillRequired
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    { tableModel = Comp.ImapSettingsTable.emptyModel
 | 
			
		||||
    , formModel = Comp.ImapSettingsForm.emptyModel
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , query = ""
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
@@ -84,7 +90,7 @@ update flags msg model =
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | viewMode = Form
 | 
			
		||||
                        , formError = Nothing
 | 
			
		||||
                        , formError = FormErrorNone
 | 
			
		||||
                        , formModel = Comp.ImapSettingsForm.init ems
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
@@ -101,7 +107,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if tm.selected /= Nothing then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -166,7 +172,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.createImapSettings flags mid ems SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please fill required fields." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorFillRequired }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        LoadSettings ->
 | 
			
		||||
            ( { model | loading = True }, Api.getImapSettings flags model.query MailSettingsResp )
 | 
			
		||||
@@ -183,10 +189,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        MailSettingsResp (Ok ems) ->
 | 
			
		||||
            let
 | 
			
		||||
@@ -287,12 +293,23 @@ viewForm2 texts settings model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", model.formError == Nothing )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorFillRequired ->
 | 
			
		||||
                    text texts.fillRequiredFields
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg
 | 
			
		||||
            (Comp.ImapSettingsForm.view2
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,60 @@
 | 
			
		||||
module Comp.ItemDetail.ConfirmModalView exposing (view)
 | 
			
		||||
 | 
			
		||||
import Comp.ConfirmModal
 | 
			
		||||
import Comp.ItemDetail.Model exposing (..)
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Messages.Comp.ItemDetail.ConfirmModal exposing (Texts)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
view : Texts -> ConfirmModalValue -> Model -> Html Msg
 | 
			
		||||
view texts modal itemModel =
 | 
			
		||||
    case modal of
 | 
			
		||||
        ConfirmModalReprocessItem msg ->
 | 
			
		||||
            Comp.ConfirmModal.view
 | 
			
		||||
                (makeSettings texts
 | 
			
		||||
                    msg
 | 
			
		||||
                    ItemModalCancelled
 | 
			
		||||
                    (texts.confirmReprocessItem itemModel.item.state)
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        ConfirmModalReprocessFile msg ->
 | 
			
		||||
            Comp.ConfirmModal.view
 | 
			
		||||
                (makeSettings texts
 | 
			
		||||
                    msg
 | 
			
		||||
                    AttachModalCancelled
 | 
			
		||||
                    (texts.confirmReprocessFile itemModel.item.state)
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        ConfirmModalDeleteItem msg ->
 | 
			
		||||
            Comp.ConfirmModal.view
 | 
			
		||||
                (makeSettings texts
 | 
			
		||||
                    msg
 | 
			
		||||
                    ItemModalCancelled
 | 
			
		||||
                    texts.confirmDeleteItem
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        ConfirmModalDeleteFile msg ->
 | 
			
		||||
            Comp.ConfirmModal.view
 | 
			
		||||
                (makeSettings texts
 | 
			
		||||
                    msg
 | 
			
		||||
                    AttachModalCancelled
 | 
			
		||||
                    texts.confirmDeleteFile
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        ConfirmModalDeleteAllFiles msg ->
 | 
			
		||||
            Comp.ConfirmModal.view
 | 
			
		||||
                (makeSettings texts
 | 
			
		||||
                    msg
 | 
			
		||||
                    AttachModalCancelled
 | 
			
		||||
                    texts.confirmDeleteAllFiles
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
makeSettings : Texts -> Msg -> Msg -> String -> Comp.ConfirmModal.Settings Msg
 | 
			
		||||
makeSettings texts confirm cancel confirmMsg =
 | 
			
		||||
    Comp.ConfirmModal.defaultSettings
 | 
			
		||||
        confirm
 | 
			
		||||
        cancel
 | 
			
		||||
        texts.basics.ok
 | 
			
		||||
        texts.basics.cancel
 | 
			
		||||
        confirmMsg
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
module Comp.ItemDetail.Model exposing
 | 
			
		||||
    ( AttachmentRename
 | 
			
		||||
    , ConfirmModalValue(..)
 | 
			
		||||
    , MailSendResult(..)
 | 
			
		||||
    , Model
 | 
			
		||||
    , Msg(..)
 | 
			
		||||
    , NotesField(..)
 | 
			
		||||
@@ -75,7 +77,7 @@ type alias Model =
 | 
			
		||||
    , nameSaveThrottle : Throttle Msg
 | 
			
		||||
    , notesModel : Maybe String
 | 
			
		||||
    , notesField : NotesField
 | 
			
		||||
    , itemModal : Maybe (Comp.ConfirmModal.Settings Msg)
 | 
			
		||||
    , itemModal : Maybe ConfirmModalValue
 | 
			
		||||
    , itemDatePicker : DatePicker
 | 
			
		||||
    , itemDate : Maybe Int
 | 
			
		||||
    , itemProposals : ItemProposals
 | 
			
		||||
@@ -84,13 +86,13 @@ type alias Model =
 | 
			
		||||
    , itemMail : Comp.ItemMail.Model
 | 
			
		||||
    , mailOpen : Bool
 | 
			
		||||
    , mailSending : Bool
 | 
			
		||||
    , mailSendResult : Maybe BasicResult
 | 
			
		||||
    , mailSendResult : MailSendResult
 | 
			
		||||
    , sentMails : Comp.SentMails.Model
 | 
			
		||||
    , sentMailsOpen : Bool
 | 
			
		||||
    , attachMeta : Dict String Comp.AttachmentMeta.Model
 | 
			
		||||
    , attachMetaOpen : Bool
 | 
			
		||||
    , pdfNativeView : Maybe Bool
 | 
			
		||||
    , attachModal : Maybe (Comp.ConfirmModal.Settings Msg)
 | 
			
		||||
    , attachModal : Maybe ConfirmModalValue
 | 
			
		||||
    , addFilesOpen : Bool
 | 
			
		||||
    , addFilesModel : Comp.Dropzone.Model
 | 
			
		||||
    , selectedFiles : List File
 | 
			
		||||
@@ -112,6 +114,14 @@ type alias Model =
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ConfirmModalValue
 | 
			
		||||
    = ConfirmModalReprocessItem Msg
 | 
			
		||||
    | ConfirmModalReprocessFile Msg
 | 
			
		||||
    | ConfirmModalDeleteItem Msg
 | 
			
		||||
    | ConfirmModalDeleteFile Msg
 | 
			
		||||
    | ConfirmModalDeleteAllFiles Msg
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ViewMode
 | 
			
		||||
    = SimpleView
 | 
			
		||||
    | SelectView SelectViewModel
 | 
			
		||||
@@ -128,6 +138,13 @@ type SelectActionMode
 | 
			
		||||
    | DeleteSelected
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type MailSendResult
 | 
			
		||||
    = MailSendSuccessful
 | 
			
		||||
    | MailSendHttpError Http.Error
 | 
			
		||||
    | MailSendFailed String
 | 
			
		||||
    | MailSendResultInitial
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type NotesField
 | 
			
		||||
    = ViewNotes
 | 
			
		||||
    | EditNotes Comp.MarkdownInput.Model
 | 
			
		||||
@@ -181,7 +198,7 @@ emptyModel =
 | 
			
		||||
    , itemMail = Comp.ItemMail.emptyModel
 | 
			
		||||
    , mailOpen = False
 | 
			
		||||
    , mailSending = False
 | 
			
		||||
    , mailSendResult = Nothing
 | 
			
		||||
    , mailSendResult = MailSendResultInitial
 | 
			
		||||
    , sentMails = Comp.SentMails.init
 | 
			
		||||
    , sentMailsOpen = False
 | 
			
		||||
    , attachMeta = Dict.empty
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ module Comp.ItemDetail.SingleAttachment exposing (view)
 | 
			
		||||
import Api
 | 
			
		||||
import Api.Model.Attachment exposing (Attachment)
 | 
			
		||||
import Comp.AttachmentMeta
 | 
			
		||||
import Comp.ConfirmModal
 | 
			
		||||
import Comp.ItemDetail.ConfirmModalView
 | 
			
		||||
import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..), ViewMode(..))
 | 
			
		||||
import Comp.MenuBar as MB
 | 
			
		||||
import Data.UiSettings exposing (UiSettings)
 | 
			
		||||
@@ -32,7 +32,7 @@ view texts settings model pos attach =
 | 
			
		||||
            [ ( "hidden", not (attachmentVisible model pos) )
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        [ renderModal model
 | 
			
		||||
        [ renderModal texts model
 | 
			
		||||
        , div
 | 
			
		||||
            [ class "flex flex-row px-2 py-2 text-sm"
 | 
			
		||||
            , class S.border
 | 
			
		||||
@@ -420,11 +420,11 @@ menuItem texts model pos attach =
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderModal : Model -> Html Msg
 | 
			
		||||
renderModal model =
 | 
			
		||||
renderModal : Texts -> Model -> Html Msg
 | 
			
		||||
renderModal texts model =
 | 
			
		||||
    case model.attachModal of
 | 
			
		||||
        Just confirmModal ->
 | 
			
		||||
            Comp.ConfirmModal.view confirmModal
 | 
			
		||||
        Just mm ->
 | 
			
		||||
            Comp.ItemDetail.ConfirmModalView.view texts.confirmModal mm model
 | 
			
		||||
 | 
			
		||||
        Nothing ->
 | 
			
		||||
            span [ class "hidden" ] []
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,24 @@ import Comp.Dropdown exposing (isDropdownChangeMsg)
 | 
			
		||||
import Comp.Dropzone
 | 
			
		||||
import Comp.EquipmentForm
 | 
			
		||||
import Comp.ItemDetail.FieldTabState as FTabState
 | 
			
		||||
import Comp.ItemDetail.Model exposing (AttachmentRename, Model, Msg(..), NotesField(..), SaveNameState(..), SelectActionMode(..), UpdateResult, ViewMode(..), initSelectViewModel, isEditNotes, resultModel, resultModelCmd, resultModelCmdSub)
 | 
			
		||||
import Comp.ItemDetail.Model
 | 
			
		||||
    exposing
 | 
			
		||||
        ( AttachmentRename
 | 
			
		||||
        , ConfirmModalValue(..)
 | 
			
		||||
        , MailSendResult(..)
 | 
			
		||||
        , Model
 | 
			
		||||
        , Msg(..)
 | 
			
		||||
        , NotesField(..)
 | 
			
		||||
        , SaveNameState(..)
 | 
			
		||||
        , SelectActionMode(..)
 | 
			
		||||
        , UpdateResult
 | 
			
		||||
        , ViewMode(..)
 | 
			
		||||
        , initSelectViewModel
 | 
			
		||||
        , isEditNotes
 | 
			
		||||
        , resultModel
 | 
			
		||||
        , resultModelCmd
 | 
			
		||||
        , resultModelCmdSub
 | 
			
		||||
        )
 | 
			
		||||
import Comp.ItemMail
 | 
			
		||||
import Comp.KeyInput
 | 
			
		||||
import Comp.LinkTarget
 | 
			
		||||
@@ -48,7 +65,6 @@ import Set exposing (Set)
 | 
			
		||||
import Throttle
 | 
			
		||||
import Time
 | 
			
		||||
import Util.File exposing (makeFileId)
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.List
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
import Util.String
 | 
			
		||||
@@ -545,19 +561,7 @@ update key flags inav settings msg model =
 | 
			
		||||
            resultModel { model | itemModal = Nothing }
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            let
 | 
			
		||||
                confirmMsg =
 | 
			
		||||
                    "Really delete this item? This cannot be undone."
 | 
			
		||||
 | 
			
		||||
                confirm =
 | 
			
		||||
                    Comp.ConfirmModal.defaultSettings
 | 
			
		||||
                        DeleteItemConfirmed
 | 
			
		||||
                        ItemModalCancelled
 | 
			
		||||
                        "Ok"
 | 
			
		||||
                        "Cancel"
 | 
			
		||||
                        confirmMsg
 | 
			
		||||
            in
 | 
			
		||||
            resultModel { model | itemModal = Just confirm }
 | 
			
		||||
            resultModel { model | itemModal = Just (ConfirmModalDeleteItem DeleteItemConfirmed) }
 | 
			
		||||
 | 
			
		||||
        SetCorrOrgSuggestion idname ->
 | 
			
		||||
            resultModelCmd ( model, setCorrOrg flags model (Just idname) )
 | 
			
		||||
@@ -750,7 +754,7 @@ update key flags inav settings msg model =
 | 
			
		||||
                        ( { model
 | 
			
		||||
                            | itemMail = Comp.ItemMail.clear im
 | 
			
		||||
                            , mailOpen = False
 | 
			
		||||
                            , mailSendResult = Nothing
 | 
			
		||||
                            , mailSendResult = MailSendResultInitial
 | 
			
		||||
                          }
 | 
			
		||||
                        , Cmd.map ItemMailMsg ic
 | 
			
		||||
                        )
 | 
			
		||||
@@ -788,7 +792,7 @@ update key flags inav settings msg model =
 | 
			
		||||
                        model.mailSendResult
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Nothing
 | 
			
		||||
                        MailSendResultInitial
 | 
			
		||||
            in
 | 
			
		||||
            resultModel
 | 
			
		||||
                { model
 | 
			
		||||
@@ -810,7 +814,12 @@ update key flags inav settings msg model =
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | itemMail = mm
 | 
			
		||||
                    , mailSending = False
 | 
			
		||||
                    , mailSendResult = Just br
 | 
			
		||||
                    , mailSendResult =
 | 
			
		||||
                        if br.success then
 | 
			
		||||
                            MailSendSuccessful
 | 
			
		||||
 | 
			
		||||
                        else
 | 
			
		||||
                            MailSendFailed br.message
 | 
			
		||||
                  }
 | 
			
		||||
                , if br.success then
 | 
			
		||||
                    Api.itemDetail flags model.item.id GetItemResp
 | 
			
		||||
@@ -820,13 +829,9 @@ update key flags inav settings msg model =
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        SendMailResp (Err err) ->
 | 
			
		||||
            let
 | 
			
		||||
                errmsg =
 | 
			
		||||
                    Util.Http.errorToString err
 | 
			
		||||
            in
 | 
			
		||||
            resultModel
 | 
			
		||||
                { model
 | 
			
		||||
                    | mailSendResult = Just (BasicResult False errmsg)
 | 
			
		||||
                    | mailSendResult = MailSendHttpError err
 | 
			
		||||
                    , mailSending = False
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -924,18 +929,10 @@ update key flags inav settings msg model =
 | 
			
		||||
 | 
			
		||||
        RequestDeleteAttachment id ->
 | 
			
		||||
            let
 | 
			
		||||
                confirmModal =
 | 
			
		||||
                    Comp.ConfirmModal.defaultSettings
 | 
			
		||||
                        (DeleteAttachConfirmed id)
 | 
			
		||||
                        AttachModalCancelled
 | 
			
		||||
                        "Ok"
 | 
			
		||||
                        "Cancel"
 | 
			
		||||
                        "Really delete this file?"
 | 
			
		||||
 | 
			
		||||
                model_ =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | attachmentDropdownOpen = False
 | 
			
		||||
                        , attachModal = Just confirmModal
 | 
			
		||||
                        , attachModal = Just (ConfirmModalDeleteFile (DeleteAttachConfirmed id))
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            resultModel model_
 | 
			
		||||
@@ -948,14 +945,6 @@ update key flags inav settings msg model =
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        let
 | 
			
		||||
                            confirmModal =
 | 
			
		||||
                                Comp.ConfirmModal.defaultSettings
 | 
			
		||||
                                    DeleteSelectedConfirmed
 | 
			
		||||
                                    AttachModalCancelled
 | 
			
		||||
                                    "Ok"
 | 
			
		||||
                                    "Cancel"
 | 
			
		||||
                                    "Really delete these files?"
 | 
			
		||||
 | 
			
		||||
                            model_ =
 | 
			
		||||
                                { model
 | 
			
		||||
                                    | viewMode =
 | 
			
		||||
@@ -963,7 +952,7 @@ update key flags inav settings msg model =
 | 
			
		||||
                                            { svm
 | 
			
		||||
                                                | action = DeleteSelected
 | 
			
		||||
                                            }
 | 
			
		||||
                                    , attachModal = Just confirmModal
 | 
			
		||||
                                    , attachModal = Just (ConfirmModalDeleteAllFiles DeleteSelectedConfirmed)
 | 
			
		||||
                                }
 | 
			
		||||
                        in
 | 
			
		||||
                        resultModel model_
 | 
			
		||||
@@ -1551,27 +1540,10 @@ update key flags inav settings msg model =
 | 
			
		||||
 | 
			
		||||
        RequestReprocessFile id ->
 | 
			
		||||
            let
 | 
			
		||||
                confirmMsg =
 | 
			
		||||
                    if model.item.state == "created" then
 | 
			
		||||
                        "Reprocessing this file may change metadata of "
 | 
			
		||||
                            ++ "this item, since it is unconfirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        "Reprocessing this file will not change metadata of "
 | 
			
		||||
                            ++ "this item, since it has been confirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
                confirmModal =
 | 
			
		||||
                    Comp.ConfirmModal.defaultSettings
 | 
			
		||||
                        (ReprocessFileConfirmed id)
 | 
			
		||||
                        AttachModalCancelled
 | 
			
		||||
                        "Ok"
 | 
			
		||||
                        "Cancel"
 | 
			
		||||
                        confirmMsg
 | 
			
		||||
 | 
			
		||||
                model_ =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | attachmentDropdownOpen = False
 | 
			
		||||
                        , attachModal = Just confirmModal
 | 
			
		||||
                        , attachModal = Just (ConfirmModalReprocessFile (ReprocessFileConfirmed id))
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            resultModel model_
 | 
			
		||||
@@ -1588,27 +1560,10 @@ update key flags inav settings msg model =
 | 
			
		||||
 | 
			
		||||
        RequestReprocessItem ->
 | 
			
		||||
            let
 | 
			
		||||
                confirmMsg =
 | 
			
		||||
                    if model.item.state == "created" then
 | 
			
		||||
                        "Reprocessing this item may change its metadata, "
 | 
			
		||||
                            ++ "since it is unconfirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        "Reprocessing this item will not change its metadata, "
 | 
			
		||||
                            ++ "since it has been confirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
                confirmModal =
 | 
			
		||||
                    Comp.ConfirmModal.defaultSettings
 | 
			
		||||
                        ReprocessItemConfirmed
 | 
			
		||||
                        ItemModalCancelled
 | 
			
		||||
                        "Ok"
 | 
			
		||||
                        "Cancel"
 | 
			
		||||
                        confirmMsg
 | 
			
		||||
 | 
			
		||||
                model_ =
 | 
			
		||||
                    { model
 | 
			
		||||
                        | attachmentDropdownOpen = False
 | 
			
		||||
                        , itemModal = Just confirmModal
 | 
			
		||||
                        , itemModal = Just (ConfirmModalReprocessItem ReprocessItemConfirmed)
 | 
			
		||||
                    }
 | 
			
		||||
            in
 | 
			
		||||
            resultModel model_
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,14 @@
 | 
			
		||||
module Comp.ItemDetail.View2 exposing (view)
 | 
			
		||||
 | 
			
		||||
import Comp.Basic as B
 | 
			
		||||
import Comp.ConfirmModal
 | 
			
		||||
import Comp.DetailEdit
 | 
			
		||||
import Comp.ItemDetail.AddFilesForm
 | 
			
		||||
import Comp.ItemDetail.ConfirmModalView
 | 
			
		||||
import Comp.ItemDetail.ItemInfoHeader
 | 
			
		||||
import Comp.ItemDetail.Model
 | 
			
		||||
    exposing
 | 
			
		||||
        ( Model
 | 
			
		||||
        ( MailSendResult(..)
 | 
			
		||||
        , Model
 | 
			
		||||
        , Msg(..)
 | 
			
		||||
        , NotesField(..)
 | 
			
		||||
        , SaveNameState(..)
 | 
			
		||||
@@ -26,7 +27,6 @@ import Html.Events exposing (onClick)
 | 
			
		||||
import Messages.Comp.ItemDetail exposing (Texts)
 | 
			
		||||
import Page exposing (Page(..))
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Time
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
view : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
 | 
			
		||||
@@ -35,15 +35,15 @@ view texts inav settings model =
 | 
			
		||||
        [ header texts settings model
 | 
			
		||||
        , menuBar texts inav settings model
 | 
			
		||||
        , body texts inav settings model
 | 
			
		||||
        , itemModal model
 | 
			
		||||
        , itemModal texts model
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
itemModal : Model -> Html Msg
 | 
			
		||||
itemModal model =
 | 
			
		||||
itemModal : Texts -> Model -> Html Msg
 | 
			
		||||
itemModal texts model =
 | 
			
		||||
    case model.itemModal of
 | 
			
		||||
        Just confirm ->
 | 
			
		||||
            Comp.ConfirmModal.view confirm
 | 
			
		||||
            Comp.ItemDetail.ConfirmModalView.view texts.confirmModal confirm model
 | 
			
		||||
 | 
			
		||||
        Nothing ->
 | 
			
		||||
            span [ class "hidden" ] []
 | 
			
		||||
@@ -257,22 +257,24 @@ sendMailForm texts settings model =
 | 
			
		||||
        , Html.map ItemMailMsg (Comp.ItemMail.view2 texts.itemMail settings model.itemMail)
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.errorMessage
 | 
			
		||||
                  , Maybe.map .success model.mailSendResult
 | 
			
		||||
                        |> Maybe.map not
 | 
			
		||||
                        |> Maybe.withDefault False
 | 
			
		||||
                  )
 | 
			
		||||
                , ( S.successMessage
 | 
			
		||||
                  , Maybe.map .success model.mailSendResult
 | 
			
		||||
                        |> Maybe.withDefault False
 | 
			
		||||
                  )
 | 
			
		||||
                , ( "hidden", model.mailSendResult == Nothing )
 | 
			
		||||
                [ ( S.errorMessage, model.mailSendResult /= MailSendSuccessful )
 | 
			
		||||
                , ( S.successMessage, model.mailSendResult == MailSendSuccessful )
 | 
			
		||||
                , ( "hidden", model.mailSendResult == MailSendResultInitial )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "mt-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.map .message model.mailSendResult
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            [ case model.mailSendResult of
 | 
			
		||||
                MailSendSuccessful ->
 | 
			
		||||
                    text texts.mailSendSuccessful
 | 
			
		||||
 | 
			
		||||
                MailSendHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                MailSendFailed m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                MailSendResultInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,6 @@ import Html.Events exposing (onClick, onInput)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.ItemMail exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
@@ -39,10 +38,16 @@ type alias Model =
 | 
			
		||||
    , bccRecipientsModel : Comp.EmailInput.Model
 | 
			
		||||
    , body : String
 | 
			
		||||
    , attachAll : Bool
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorNoConnection
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Msg
 | 
			
		||||
    = SetSubject String
 | 
			
		||||
    | RecipientMsg Comp.EmailInput.Msg
 | 
			
		||||
@@ -80,7 +85,7 @@ emptyModel =
 | 
			
		||||
    , bccRecipientsModel = Comp.EmailInput.init
 | 
			
		||||
    , body = ""
 | 
			
		||||
    , attachAll = True
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -111,7 +116,10 @@ update flags msg model =
 | 
			
		||||
                ( em, ec, rec ) =
 | 
			
		||||
                    Comp.EmailInput.update flags model.recipients m model.recipientsModel
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | recipients = rec, recipientsModel = em }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | recipients = rec
 | 
			
		||||
                , recipientsModel = em
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.map RecipientMsg ec
 | 
			
		||||
            , FormNone
 | 
			
		||||
            )
 | 
			
		||||
@@ -121,7 +129,10 @@ update flags msg model =
 | 
			
		||||
                ( em, ec, rec ) =
 | 
			
		||||
                    Comp.EmailInput.update flags model.ccRecipients m model.ccRecipientsModel
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | ccRecipients = rec, ccRecipientsModel = em }
 | 
			
		||||
            ( { model
 | 
			
		||||
                | ccRecipients = rec
 | 
			
		||||
                , ccRecipientsModel = em
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.map CCRecipientMsg ec
 | 
			
		||||
            , FormNone
 | 
			
		||||
            )
 | 
			
		||||
@@ -165,24 +176,24 @@ update flags msg model =
 | 
			
		||||
                | connectionModel = cm
 | 
			
		||||
                , formError =
 | 
			
		||||
                    if names == [] then
 | 
			
		||||
                        Just "No E-Mail connections configured. Goto user settings to add one."
 | 
			
		||||
                        FormErrorNoConnection
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Nothing
 | 
			
		||||
                        FormErrorNone
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            , FormNone
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        ConnResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err) }, Cmd.none, FormNone )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err }, Cmd.none, FormNone )
 | 
			
		||||
 | 
			
		||||
        Cancel ->
 | 
			
		||||
            ( model, Cmd.none, FormCancel )
 | 
			
		||||
 | 
			
		||||
        Send ->
 | 
			
		||||
            case ( model.formError, Comp.Dropdown.getSelected model.connectionModel ) of
 | 
			
		||||
                ( Nothing, conn :: [] ) ->
 | 
			
		||||
                ( FormErrorNone, conn :: [] ) ->
 | 
			
		||||
                    let
 | 
			
		||||
                        emptyMail =
 | 
			
		||||
                            Api.Model.SimpleMail.empty
 | 
			
		||||
@@ -212,7 +223,9 @@ isValid model =
 | 
			
		||||
        && model.body
 | 
			
		||||
        /= ""
 | 
			
		||||
        && model.formError
 | 
			
		||||
        == Nothing
 | 
			
		||||
        == FormErrorNone
 | 
			
		||||
        && Comp.Dropdown.getSelected model.connectionModel
 | 
			
		||||
        /= []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -249,9 +262,17 @@ view2 texts settings model =
 | 
			
		||||
            ]
 | 
			
		||||
        , div
 | 
			
		||||
            [ class S.errorMessage
 | 
			
		||||
            , classList [ ( "hidden", model.formError == Nothing ) ]
 | 
			
		||||
            , classList [ ( "hidden", model.formError == FormErrorNone ) ]
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorNoConnection ->
 | 
			
		||||
                    text texts.connectionMissing
 | 
			
		||||
            ]
 | 
			
		||||
        , div [ class "mb-4" ]
 | 
			
		||||
            [ label
 | 
			
		||||
@@ -320,7 +341,7 @@ view2 texts settings model =
 | 
			
		||||
                }
 | 
			
		||||
        , div [ class "flex flex-row space-x-2" ]
 | 
			
		||||
            [ B.primaryButton
 | 
			
		||||
                { label = "Send"
 | 
			
		||||
                { label = texts.sendLabel
 | 
			
		||||
                , icon = "fa fa-paper-plane font-thin"
 | 
			
		||||
                , handler = onClick Send
 | 
			
		||||
                , attrs = [ href "#" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,7 @@ makeCustomFieldLink :
 | 
			
		||||
    -> (LinkTarget -> msg)
 | 
			
		||||
    -> Html msg
 | 
			
		||||
makeCustomFieldLink cv classes tagger =
 | 
			
		||||
    Util.CustomField.renderValue1
 | 
			
		||||
    Util.CustomField.renderValue2
 | 
			
		||||
        classes
 | 
			
		||||
        (tagger (LinkCustomField cv) |> Just)
 | 
			
		||||
        cv
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ module Comp.NotificationForm exposing
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Api
 | 
			
		||||
import Api.Model.BasicResult exposing (BasicResult)
 | 
			
		||||
import Api.Model.EmailSettingsList exposing (EmailSettingsList)
 | 
			
		||||
import Api.Model.NotificationSettings exposing (NotificationSettings)
 | 
			
		||||
import Api.Model.Tag exposing (Tag)
 | 
			
		||||
@@ -33,7 +32,6 @@ import Http
 | 
			
		||||
import Markdown
 | 
			
		||||
import Messages.Comp.NotificationForm exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
import Util.Tag
 | 
			
		||||
import Util.Update
 | 
			
		||||
@@ -50,15 +48,28 @@ type alias Model =
 | 
			
		||||
    , remindDaysModel : Comp.IntField.Model
 | 
			
		||||
    , capOverdue : Bool
 | 
			
		||||
    , enabled : Bool
 | 
			
		||||
    , schedule : Validated CalEvent
 | 
			
		||||
    , schedule : Maybe CalEvent
 | 
			
		||||
    , scheduleModel : Comp.CalEventInput.Model
 | 
			
		||||
    , formMsg : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    , loading : Int
 | 
			
		||||
    , yesNoDelete : Comp.YesNoDimmer.Model
 | 
			
		||||
    , summary : Maybe String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormStateHttpError Http.Error
 | 
			
		||||
    | FormStateInvalid ValidateError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ValidateError
 | 
			
		||||
    = ValidateConnectionMissing
 | 
			
		||||
    | ValidateRemindDaysRequired
 | 
			
		||||
    | ValidateRecipientsRequired
 | 
			
		||||
    | ValidateCalEventInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Action
 | 
			
		||||
    = SubmitAction NotificationSettings
 | 
			
		||||
    | StartOnceAction NotificationSettings
 | 
			
		||||
@@ -121,9 +132,9 @@ initWith flags s =
 | 
			
		||||
        , remindDays = Just s.remindDays
 | 
			
		||||
        , enabled = s.enabled
 | 
			
		||||
        , capOverdue = s.capOverdue
 | 
			
		||||
        , schedule = Data.Validated.Unknown newSchedule
 | 
			
		||||
        , schedule = Just newSchedule
 | 
			
		||||
        , scheduleModel = sm
 | 
			
		||||
        , formMsg = Nothing
 | 
			
		||||
        , formState = FormStateInitial
 | 
			
		||||
        , loading = im.loading
 | 
			
		||||
        , yesNoDelete = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
        , summary = s.summary
 | 
			
		||||
@@ -140,10 +151,10 @@ init : Flags -> ( Model, Cmd Msg )
 | 
			
		||||
init flags =
 | 
			
		||||
    let
 | 
			
		||||
        initialSchedule =
 | 
			
		||||
            Data.Validated.Valid Data.CalEvent.everyMonth
 | 
			
		||||
            Data.CalEvent.everyMonth
 | 
			
		||||
 | 
			
		||||
        sm =
 | 
			
		||||
            Comp.CalEventInput.initDefault
 | 
			
		||||
        ( sm, scmd ) =
 | 
			
		||||
            Comp.CalEventInput.init flags initialSchedule
 | 
			
		||||
    in
 | 
			
		||||
    ( { settings = Api.Model.NotificationSettings.empty
 | 
			
		||||
      , connectionModel = Comp.Dropdown.makeSingle
 | 
			
		||||
@@ -155,9 +166,9 @@ init flags =
 | 
			
		||||
      , remindDaysModel = Comp.IntField.init (Just 1) Nothing True
 | 
			
		||||
      , enabled = False
 | 
			
		||||
      , capOverdue = False
 | 
			
		||||
      , schedule = initialSchedule
 | 
			
		||||
      , schedule = Just initialSchedule
 | 
			
		||||
      , scheduleModel = sm
 | 
			
		||||
      , formMsg = Nothing
 | 
			
		||||
      , formState = FormStateInitial
 | 
			
		||||
      , loading = 2
 | 
			
		||||
      , yesNoDelete = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
      , summary = Nothing
 | 
			
		||||
@@ -165,6 +176,7 @@ init flags =
 | 
			
		||||
    , Cmd.batch
 | 
			
		||||
        [ Api.getMailSettings flags "" ConnResp
 | 
			
		||||
        , Api.getTags flags "" GetTagsResp
 | 
			
		||||
        , Cmd.map CalEventMsg scmd
 | 
			
		||||
        ]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@@ -173,7 +185,7 @@ init flags =
 | 
			
		||||
--- Update
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
makeSettings : Model -> Validated NotificationSettings
 | 
			
		||||
makeSettings : Model -> Result ValidateError NotificationSettings
 | 
			
		||||
makeSettings model =
 | 
			
		||||
    let
 | 
			
		||||
        prev =
 | 
			
		||||
@@ -182,19 +194,27 @@ makeSettings model =
 | 
			
		||||
        conn =
 | 
			
		||||
            Comp.Dropdown.getSelected model.connectionModel
 | 
			
		||||
                |> List.head
 | 
			
		||||
                |> Maybe.map Valid
 | 
			
		||||
                |> Maybe.withDefault (Invalid [ "Connection missing" ] "")
 | 
			
		||||
                |> Maybe.map Ok
 | 
			
		||||
                |> Maybe.withDefault (Err ValidateConnectionMissing)
 | 
			
		||||
 | 
			
		||||
        recp =
 | 
			
		||||
            if List.isEmpty model.recipients then
 | 
			
		||||
                Invalid [ "No recipients" ] []
 | 
			
		||||
                Err ValidateRecipientsRequired
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                Valid model.recipients
 | 
			
		||||
                Ok model.recipients
 | 
			
		||||
 | 
			
		||||
        rmdays =
 | 
			
		||||
            Maybe.map Valid model.remindDays
 | 
			
		||||
                |> Maybe.withDefault (Invalid [ "Remind Days is required" ] 0)
 | 
			
		||||
            Maybe.map Ok model.remindDays
 | 
			
		||||
                |> Maybe.withDefault (Err ValidateRemindDaysRequired)
 | 
			
		||||
 | 
			
		||||
        schedule_ =
 | 
			
		||||
            case model.schedule of
 | 
			
		||||
                Just s ->
 | 
			
		||||
                    Ok s
 | 
			
		||||
 | 
			
		||||
                Nothing ->
 | 
			
		||||
                    Err ValidateCalEventInvalid
 | 
			
		||||
 | 
			
		||||
        make smtp rec days timer =
 | 
			
		||||
            { prev
 | 
			
		||||
@@ -209,34 +229,24 @@ makeSettings model =
 | 
			
		||||
                , summary = model.summary
 | 
			
		||||
            }
 | 
			
		||||
    in
 | 
			
		||||
    Data.Validated.map4 make
 | 
			
		||||
    Result.map4 make
 | 
			
		||||
        conn
 | 
			
		||||
        recp
 | 
			
		||||
        rmdays
 | 
			
		||||
        model.schedule
 | 
			
		||||
        schedule_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
withValidSettings : (NotificationSettings -> Action) -> Model -> ( Model, Action, Cmd Msg )
 | 
			
		||||
withValidSettings mkcmd model =
 | 
			
		||||
    case makeSettings model of
 | 
			
		||||
        Valid set ->
 | 
			
		||||
            ( { model | formMsg = Nothing }
 | 
			
		||||
        Ok set ->
 | 
			
		||||
            ( { model | formState = FormStateInitial }
 | 
			
		||||
            , mkcmd set
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Invalid errs _ ->
 | 
			
		||||
            let
 | 
			
		||||
                errMsg =
 | 
			
		||||
                    String.join ", " errs
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | formMsg = Just (BasicResult False errMsg) }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Unknown _ ->
 | 
			
		||||
            ( { model | formMsg = Just (BasicResult False "An unknown error occured") }
 | 
			
		||||
        Err errs ->
 | 
			
		||||
            ( { model | formState = FormStateInvalid errs }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
@@ -249,14 +259,14 @@ update flags msg model =
 | 
			
		||||
            let
 | 
			
		||||
                ( cm, cc, cs ) =
 | 
			
		||||
                    Comp.CalEventInput.update flags
 | 
			
		||||
                        (Data.Validated.value model.schedule)
 | 
			
		||||
                        model.schedule
 | 
			
		||||
                        lmsg
 | 
			
		||||
                        model.scheduleModel
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | schedule = cs
 | 
			
		||||
                , scheduleModel = cm
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map CalEventMsg cc
 | 
			
		||||
@@ -270,7 +280,7 @@ update flags msg model =
 | 
			
		||||
            ( { model
 | 
			
		||||
                | recipients = rec
 | 
			
		||||
                , recipientsModel = em
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map RecipientMsg ec
 | 
			
		||||
@@ -283,7 +293,7 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | connectionModel = cm
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map ConnMsg cc
 | 
			
		||||
@@ -303,15 +313,12 @@ update flags msg model =
 | 
			
		||||
            ( { model
 | 
			
		||||
                | connectionModel = cm
 | 
			
		||||
                , loading = model.loading - 1
 | 
			
		||||
                , formMsg =
 | 
			
		||||
                , formState =
 | 
			
		||||
                    if names == [] then
 | 
			
		||||
                        Just
 | 
			
		||||
                            (BasicResult False
 | 
			
		||||
                                "No E-Mail connections configured. Goto E-Mail Settings to add one."
 | 
			
		||||
                            )
 | 
			
		||||
                        FormStateInvalid ValidateConnectionMissing
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Nothing
 | 
			
		||||
                        FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -319,7 +326,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        ConnResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formMsg = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                | formState = FormStateHttpError err
 | 
			
		||||
                , loading = model.loading - 1
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
@@ -333,7 +340,7 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | tagInclModel = m2
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map TagIncMsg c2
 | 
			
		||||
@@ -346,7 +353,7 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | tagExclModel = m2
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map TagExcMsg c2
 | 
			
		||||
@@ -372,7 +379,7 @@ update flags msg model =
 | 
			
		||||
        GetTagsResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | loading = model.loading - 1
 | 
			
		||||
                , formMsg = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                , formState = FormStateHttpError err
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -386,7 +393,7 @@ update flags msg model =
 | 
			
		||||
            ( { model
 | 
			
		||||
                | remindDaysModel = pm
 | 
			
		||||
                , remindDays = val
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -395,7 +402,7 @@ update flags msg model =
 | 
			
		||||
        ToggleEnabled ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | enabled = not model.enabled
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -404,7 +411,7 @@ update flags msg model =
 | 
			
		||||
        ToggleCapOverdue ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | capOverdue = not model.capOverdue
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -465,15 +472,17 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
isFormError : Model -> Bool
 | 
			
		||||
isFormError model =
 | 
			
		||||
    Maybe.map .success model.formMsg
 | 
			
		||||
        |> Maybe.map not
 | 
			
		||||
        |> Maybe.withDefault False
 | 
			
		||||
    case model.formState of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isFormSuccess : Model -> Bool
 | 
			
		||||
isFormSuccess model =
 | 
			
		||||
    Maybe.map .success model.formMsg
 | 
			
		||||
        |> Maybe.withDefault False
 | 
			
		||||
    not (isFormError model)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
view2 : Texts -> String -> UiSettings -> Model -> Html Msg
 | 
			
		||||
@@ -547,13 +556,28 @@ view2 texts extraClasses settings model =
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.successMessage, isFormSuccess model )
 | 
			
		||||
                , ( S.errorMessage, isFormError model )
 | 
			
		||||
                , ( "hidden", model.formMsg == Nothing )
 | 
			
		||||
                , ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "mb-4"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.map .message model.formMsg
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            [ case model.formState of
 | 
			
		||||
                FormStateInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormStateHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateConnectionMissing ->
 | 
			
		||||
                    text texts.connectionMissing
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateCalEventInvalid ->
 | 
			
		||||
                    text texts.invalidCalEvent
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateRemindDaysRequired ->
 | 
			
		||||
                    text texts.remindDaysRequired
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateRecipientsRequired ->
 | 
			
		||||
                    text texts.recipientsRequired
 | 
			
		||||
            ]
 | 
			
		||||
        , div [ class "mb-4" ]
 | 
			
		||||
            [ MB.viewItem <|
 | 
			
		||||
@@ -678,7 +702,7 @@ view2 texts extraClasses settings model =
 | 
			
		||||
                (Comp.CalEventInput.view2
 | 
			
		||||
                    texts.calEventInput
 | 
			
		||||
                    ""
 | 
			
		||||
                    (Data.Validated.value model.schedule)
 | 
			
		||||
                    model.schedule
 | 
			
		||||
                    model.scheduleModel
 | 
			
		||||
                )
 | 
			
		||||
            , span [ class "opacity-50 text-sm" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -20,24 +20,36 @@ import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.NotificationManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { listModel : Comp.NotificationList.Model
 | 
			
		||||
    , detailModel : Maybe Comp.NotificationForm.Model
 | 
			
		||||
    , items : List NotificationSettings
 | 
			
		||||
    , result : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type SubmitType
 | 
			
		||||
    = SubmitDelete
 | 
			
		||||
    | SubmitUpdate
 | 
			
		||||
    | SubmitCreate
 | 
			
		||||
    | SubmitStartOnce
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormHttpError Http.Error
 | 
			
		||||
    | FormSubmitSuccessful SubmitType
 | 
			
		||||
    | FormSubmitFailed String
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Msg
 | 
			
		||||
    = ListMsg Comp.NotificationList.Msg
 | 
			
		||||
    | DetailMsg Comp.NotificationForm.Msg
 | 
			
		||||
    | GetDataResp (Result Http.Error NotificationSettingsList)
 | 
			
		||||
    | NewTask
 | 
			
		||||
    | SubmitResp Bool (Result Http.Error BasicResult)
 | 
			
		||||
    | DeleteResp (Result Http.Error BasicResult)
 | 
			
		||||
    | SubmitResp SubmitType (Result Http.Error BasicResult)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initModel : Model
 | 
			
		||||
@@ -45,7 +57,7 @@ initModel =
 | 
			
		||||
    { listModel = Comp.NotificationList.init
 | 
			
		||||
    , detailModel = Nothing
 | 
			
		||||
    , items = []
 | 
			
		||||
    , result = Nothing
 | 
			
		||||
    , formState = FormStateInitial
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -69,13 +81,13 @@ update flags msg model =
 | 
			
		||||
        GetDataResp (Ok res) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | items = res.items
 | 
			
		||||
                , result = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        GetDataResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model | formState = FormHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
@@ -113,26 +125,29 @@ update flags msg model =
 | 
			
		||||
                        ( model_, cmd_ ) =
 | 
			
		||||
                            case action of
 | 
			
		||||
                                Comp.NotificationForm.NoAction ->
 | 
			
		||||
                                    ( { model | detailModel = Just mm }
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Cmd.none
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.NotificationForm.SubmitAction settings ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , if settings.id == "" then
 | 
			
		||||
                                        Api.createNotifyDueItems flags settings (SubmitResp True)
 | 
			
		||||
                                        Api.createNotifyDueItems flags settings (SubmitResp SubmitCreate)
 | 
			
		||||
 | 
			
		||||
                                      else
 | 
			
		||||
                                        Api.updateNotifyDueItems flags settings (SubmitResp True)
 | 
			
		||||
                                        Api.updateNotifyDueItems flags settings (SubmitResp SubmitUpdate)
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.NotificationForm.CancelAction ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Nothing
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , initCmd flags
 | 
			
		||||
                                    )
 | 
			
		||||
@@ -140,17 +155,17 @@ update flags msg model =
 | 
			
		||||
                                Comp.NotificationForm.StartOnceAction settings ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Api.startOnceNotifyDueItems flags settings (SubmitResp False)
 | 
			
		||||
                                    , Api.startOnceNotifyDueItems flags settings (SubmitResp SubmitStartOnce)
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.NotificationForm.DeleteAction id ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Api.deleteNotifyDueItems flags id DeleteResp
 | 
			
		||||
                                    , Api.deleteNotifyDueItems flags id (SubmitResp SubmitDelete)
 | 
			
		||||
                                    )
 | 
			
		||||
                    in
 | 
			
		||||
                    ( model_
 | 
			
		||||
@@ -170,17 +185,22 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc )
 | 
			
		||||
 | 
			
		||||
        SubmitResp close (Ok res) ->
 | 
			
		||||
        SubmitResp submitType (Ok res) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | result = Just res
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if res.success then
 | 
			
		||||
                        FormSubmitSuccessful submitType
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        FormSubmitFailed res.message
 | 
			
		||||
                , detailModel =
 | 
			
		||||
                    if close then
 | 
			
		||||
                    if submitType == SubmitDelete then
 | 
			
		||||
                        Nothing
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        model.detailModel
 | 
			
		||||
              }
 | 
			
		||||
            , if close then
 | 
			
		||||
            , if submitType == SubmitDelete then
 | 
			
		||||
                initCmd flags
 | 
			
		||||
 | 
			
		||||
              else
 | 
			
		||||
@@ -188,23 +208,7 @@ update flags msg model =
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        SubmitResp _ (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
                ( { model | result = Nothing, detailModel = Nothing }
 | 
			
		||||
                , initCmd flags
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | result = Just res }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model | formState = FormHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
@@ -218,15 +222,33 @@ view2 texts settings model =
 | 
			
		||||
    div [ class "flex flex-col" ]
 | 
			
		||||
        (div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.errorMessage, Maybe.map .success model.result == Just False )
 | 
			
		||||
                , ( S.successMessage, Maybe.map .success model.result == Just True )
 | 
			
		||||
                , ( "hidden", model.result == Nothing )
 | 
			
		||||
                [ ( S.errorMessage, model.formState /= FormStateInitial )
 | 
			
		||||
                , ( S.successMessage, isSuccess model.formState )
 | 
			
		||||
                , ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "mb-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.map .message model.result
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            [ case model.formState of
 | 
			
		||||
                FormStateInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitCreate ->
 | 
			
		||||
                    text texts.taskCreated
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitUpdate ->
 | 
			
		||||
                    text texts.taskUpdated
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitStartOnce ->
 | 
			
		||||
                    text texts.taskStarted
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitDelete ->
 | 
			
		||||
                    text texts.taskDeleted
 | 
			
		||||
 | 
			
		||||
                FormSubmitFailed m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
            ]
 | 
			
		||||
            :: (case model.detailModel of
 | 
			
		||||
                    Just msett ->
 | 
			
		||||
@@ -238,6 +260,16 @@ view2 texts settings model =
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isSuccess : FormState -> Bool
 | 
			
		||||
isSuccess state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormSubmitSuccessful _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewForm2 : Texts -> UiSettings -> Comp.NotificationForm.Model -> List (Html Msg)
 | 
			
		||||
viewForm2 texts settings model =
 | 
			
		||||
    [ Html.map DetailMsg
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ import Html.Events exposing (onSubmit)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.OrgManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -31,13 +30,20 @@ type alias Model =
 | 
			
		||||
    { tableModel : Comp.OrgTable.Model
 | 
			
		||||
    , formModel : Comp.OrgForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    , query : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ViewMode
 | 
			
		||||
    = Table
 | 
			
		||||
    | Form
 | 
			
		||||
@@ -48,7 +54,7 @@ emptyModel =
 | 
			
		||||
    { tableModel = Comp.OrgTable.emptyModel
 | 
			
		||||
    , formModel = Comp.OrgForm.emptyModel
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
    , query = ""
 | 
			
		||||
@@ -83,7 +89,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if Util.Maybe.nonEmpty tm.selected then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -136,7 +142,7 @@ update flags msg model =
 | 
			
		||||
        InitNewOrg ->
 | 
			
		||||
            let
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model | viewMode = Form, formError = Nothing }
 | 
			
		||||
                    { model | viewMode = Form, formError = FormErrorNone }
 | 
			
		||||
 | 
			
		||||
                org =
 | 
			
		||||
                    Api.Model.Organization.empty
 | 
			
		||||
@@ -155,7 +161,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.postOrg flags org SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorInvalid }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
@@ -169,10 +175,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            update flags (YesNoMsg Comp.YesNoDimmer.activate) model
 | 
			
		||||
@@ -310,12 +316,23 @@ viewForm2 texts settings model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", Util.Maybe.isEmpty model.formError )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.correctFormErrors
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg
 | 
			
		||||
            (Comp.OrgForm.view2
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@ import Html.Events exposing (onSubmit)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.PersonManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -32,13 +31,20 @@ type alias Model =
 | 
			
		||||
    { tableModel : Comp.PersonTable.Model
 | 
			
		||||
    , formModel : Comp.PersonForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Int
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    , query : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ViewMode
 | 
			
		||||
    = Table
 | 
			
		||||
    | Form
 | 
			
		||||
@@ -49,7 +55,7 @@ emptyModel =
 | 
			
		||||
    { tableModel = Comp.PersonTable.emptyModel
 | 
			
		||||
    , formModel = Comp.PersonForm.emptyModel
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = 0
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
    , query = ""
 | 
			
		||||
@@ -85,7 +91,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if Util.Maybe.nonEmpty tm.selected then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -156,7 +162,7 @@ update flags msg model =
 | 
			
		||||
        InitNewPerson ->
 | 
			
		||||
            let
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model | viewMode = Form, formError = Nothing }
 | 
			
		||||
                    { model | viewMode = Form, formError = FormErrorNone }
 | 
			
		||||
 | 
			
		||||
                org =
 | 
			
		||||
                    Api.Model.Person.empty
 | 
			
		||||
@@ -177,7 +183,7 @@ update flags msg model =
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorInvalid }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
@@ -192,7 +198,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | formError = Just res.message
 | 
			
		||||
                    | formError = FormErrorSubmit res.message
 | 
			
		||||
                    , loading = Basics.max 0 (model.loading - 1)
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
@@ -200,7 +206,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formError = Just (Util.Http.errorToString err)
 | 
			
		||||
                | formError = FormErrorHttp err
 | 
			
		||||
                , loading = Basics.max 0 (model.loading - 1)
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -347,12 +353,23 @@ viewForm2 texts settings model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", Util.Maybe.isEmpty model.formError )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.correctFormErrors
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg
 | 
			
		||||
            (Comp.PersonForm.view2 texts.personForm
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ module Comp.ScanMailboxForm exposing
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Api
 | 
			
		||||
import Api.Model.BasicResult exposing (BasicResult)
 | 
			
		||||
import Api.Model.FolderItem exposing (FolderItem)
 | 
			
		||||
import Api.Model.FolderList exposing (FolderList)
 | 
			
		||||
import Api.Model.IdName exposing (IdName)
 | 
			
		||||
@@ -44,7 +43,6 @@ import Messages.Data.Language
 | 
			
		||||
import Set exposing (Set)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Folder exposing (mkFolderOption)
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.List
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
import Util.Tag
 | 
			
		||||
@@ -62,9 +60,9 @@ type alias Model =
 | 
			
		||||
    , foldersModel : Comp.StringListInput.Model
 | 
			
		||||
    , folders : List String
 | 
			
		||||
    , direction : Maybe Direction
 | 
			
		||||
    , schedule : Validated CalEvent
 | 
			
		||||
    , schedule : Maybe CalEvent
 | 
			
		||||
    , scheduleModel : Comp.CalEventInput.Model
 | 
			
		||||
    , formMsg : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    , loading : Int
 | 
			
		||||
    , yesNoDelete : Comp.YesNoDimmer.Model
 | 
			
		||||
    , folderModel : Comp.Dropdown.Model IdName
 | 
			
		||||
@@ -82,6 +80,18 @@ type alias Model =
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormStateHttpError Http.Error
 | 
			
		||||
    | FormStateInvalid ValidateError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ValidateError
 | 
			
		||||
    = ValidateNoProcessingFolders
 | 
			
		||||
    | ValidateConnectionMissing
 | 
			
		||||
    | ValidateCalEventInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Action
 | 
			
		||||
    = SubmitAction ScanMailboxSettings
 | 
			
		||||
    | StartOnceAction ScanMailboxSettings
 | 
			
		||||
@@ -179,10 +189,10 @@ initWith flags s =
 | 
			
		||||
        , receivedHours = s.receivedSinceHours
 | 
			
		||||
        , targetFolder = s.targetFolder
 | 
			
		||||
        , folders = s.folders
 | 
			
		||||
        , schedule = Data.Validated.Unknown newSchedule
 | 
			
		||||
        , schedule = Just newSchedule
 | 
			
		||||
        , direction = Maybe.andThen Data.Direction.fromString s.direction
 | 
			
		||||
        , scheduleModel = sm
 | 
			
		||||
        , formMsg = Nothing
 | 
			
		||||
        , formState = FormStateInitial
 | 
			
		||||
        , yesNoDelete = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
        , itemFolderId = s.itemFolder
 | 
			
		||||
        , tagModel = Util.Tag.makeDropdownModel
 | 
			
		||||
@@ -211,10 +221,10 @@ init : Flags -> ( Model, Cmd Msg )
 | 
			
		||||
init flags =
 | 
			
		||||
    let
 | 
			
		||||
        initialSchedule =
 | 
			
		||||
            Data.Validated.Valid Data.CalEvent.everyMonth
 | 
			
		||||
            Data.CalEvent.everyMonth
 | 
			
		||||
 | 
			
		||||
        sm =
 | 
			
		||||
            Comp.CalEventInput.initDefault
 | 
			
		||||
        ( sm, scmd ) =
 | 
			
		||||
            Comp.CalEventInput.init flags initialSchedule
 | 
			
		||||
    in
 | 
			
		||||
    ( { settings = Api.Model.ScanMailboxSettings.empty
 | 
			
		||||
      , connectionModel = Comp.Dropdown.makeSingle
 | 
			
		||||
@@ -226,9 +236,9 @@ init flags =
 | 
			
		||||
      , folders = []
 | 
			
		||||
      , targetFolder = Nothing
 | 
			
		||||
      , direction = Nothing
 | 
			
		||||
      , schedule = initialSchedule
 | 
			
		||||
      , schedule = Just initialSchedule
 | 
			
		||||
      , scheduleModel = sm
 | 
			
		||||
      , formMsg = Nothing
 | 
			
		||||
      , formState = FormStateInitial
 | 
			
		||||
      , loading = 3
 | 
			
		||||
      , yesNoDelete = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
      , folderModel = Comp.Dropdown.makeSingle
 | 
			
		||||
@@ -249,6 +259,7 @@ init flags =
 | 
			
		||||
        [ Api.getImapSettings flags "" ConnResp
 | 
			
		||||
        , Api.getFolders flags "" False GetFolderResp
 | 
			
		||||
        , Api.getTags flags "" GetTagResp
 | 
			
		||||
        , Cmd.map CalEventMsg scmd
 | 
			
		||||
        ]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@@ -257,7 +268,7 @@ init flags =
 | 
			
		||||
--- Update
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
makeSettings : Model -> Validated ScanMailboxSettings
 | 
			
		||||
makeSettings : Model -> Result ValidateError ScanMailboxSettings
 | 
			
		||||
makeSettings model =
 | 
			
		||||
    let
 | 
			
		||||
        prev =
 | 
			
		||||
@@ -266,15 +277,23 @@ makeSettings model =
 | 
			
		||||
        conn =
 | 
			
		||||
            Comp.Dropdown.getSelected model.connectionModel
 | 
			
		||||
                |> List.head
 | 
			
		||||
                |> Maybe.map Valid
 | 
			
		||||
                |> Maybe.withDefault (Invalid [ "Connection missing" ] "")
 | 
			
		||||
                |> Maybe.map Ok
 | 
			
		||||
                |> Maybe.withDefault (Err ValidateConnectionMissing)
 | 
			
		||||
 | 
			
		||||
        infolders =
 | 
			
		||||
            if model.folders == [] then
 | 
			
		||||
                Invalid [ "No processing folders given" ] []
 | 
			
		||||
                Err ValidateNoProcessingFolders
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                Valid model.folders
 | 
			
		||||
                Ok model.folders
 | 
			
		||||
 | 
			
		||||
        schedule_ =
 | 
			
		||||
            case model.schedule of
 | 
			
		||||
                Just s ->
 | 
			
		||||
                    Ok s
 | 
			
		||||
 | 
			
		||||
                Nothing ->
 | 
			
		||||
                    Err ValidateCalEventInvalid
 | 
			
		||||
 | 
			
		||||
        make imap timer folders =
 | 
			
		||||
            { prev
 | 
			
		||||
@@ -303,33 +322,20 @@ makeSettings model =
 | 
			
		||||
                , summary = model.summary
 | 
			
		||||
            }
 | 
			
		||||
    in
 | 
			
		||||
    Data.Validated.map3 make
 | 
			
		||||
        conn
 | 
			
		||||
        model.schedule
 | 
			
		||||
        infolders
 | 
			
		||||
    Result.map3 make conn schedule_ infolders
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
withValidSettings : (ScanMailboxSettings -> Action) -> Model -> ( Model, Action, Cmd Msg )
 | 
			
		||||
withValidSettings mkAction model =
 | 
			
		||||
    case makeSettings model of
 | 
			
		||||
        Valid set ->
 | 
			
		||||
            ( { model | formMsg = Nothing }
 | 
			
		||||
        Ok set ->
 | 
			
		||||
            ( { model | formState = FormStateInitial }
 | 
			
		||||
            , mkAction set
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Invalid errs _ ->
 | 
			
		||||
            let
 | 
			
		||||
                errMsg =
 | 
			
		||||
                    String.join ", " errs
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | formMsg = Just (BasicResult False errMsg) }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Unknown _ ->
 | 
			
		||||
            ( { model | formMsg = Just (BasicResult False "An unknown error occured") }
 | 
			
		||||
        Err errs ->
 | 
			
		||||
            ( { model | formState = FormStateInvalid errs }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
@@ -342,14 +348,14 @@ update flags msg model =
 | 
			
		||||
            let
 | 
			
		||||
                ( cm, cc, cs ) =
 | 
			
		||||
                    Comp.CalEventInput.update flags
 | 
			
		||||
                        (Data.Validated.value model.schedule)
 | 
			
		||||
                        model.schedule
 | 
			
		||||
                        lmsg
 | 
			
		||||
                        model.scheduleModel
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | schedule = cs
 | 
			
		||||
                , scheduleModel = cm
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map CalEventMsg cc
 | 
			
		||||
@@ -362,7 +368,7 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model
 | 
			
		||||
                | connectionModel = cm
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.map ConnMsg cc
 | 
			
		||||
@@ -394,15 +400,12 @@ update flags msg model =
 | 
			
		||||
            ( { model
 | 
			
		||||
                | connectionModel = cm
 | 
			
		||||
                , loading = model.loading - 1
 | 
			
		||||
                , formMsg =
 | 
			
		||||
                , formState =
 | 
			
		||||
                    if names == [] then
 | 
			
		||||
                        Just
 | 
			
		||||
                            (BasicResult False
 | 
			
		||||
                                "No E-Mail connections configured. Goto E-Mail Settings to add one."
 | 
			
		||||
                            )
 | 
			
		||||
                        FormStateInvalid ValidateConnectionMissing
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Nothing
 | 
			
		||||
                        FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -410,7 +413,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        ConnResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formMsg = Just (BasicResult False (Util.Http.errorToString err))
 | 
			
		||||
                | formState = FormStateHttpError err
 | 
			
		||||
                , loading = model.loading - 1
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
@@ -420,7 +423,7 @@ update flags msg model =
 | 
			
		||||
        ToggleEnabled ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | enabled = not model.enabled
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -429,7 +432,7 @@ update flags msg model =
 | 
			
		||||
        ToggleDeleteMail ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | deleteMail = not model.deleteMail
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -443,7 +446,7 @@ update flags msg model =
 | 
			
		||||
            ( { model
 | 
			
		||||
                | receivedHoursModel = pm
 | 
			
		||||
                , receivedHours = val
 | 
			
		||||
                , formMsg = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , NoAction
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -714,15 +717,17 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
isFormError : Model -> Bool
 | 
			
		||||
isFormError model =
 | 
			
		||||
    Maybe.map .success model.formMsg
 | 
			
		||||
        |> Maybe.map not
 | 
			
		||||
        |> Maybe.withDefault False
 | 
			
		||||
    case model.formState of
 | 
			
		||||
        FormStateInitial ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isFormSuccess : Model -> Bool
 | 
			
		||||
isFormSuccess model =
 | 
			
		||||
    Maybe.map .success model.formMsg
 | 
			
		||||
        |> Maybe.withDefault False
 | 
			
		||||
    not (isFormError model)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isFolderMember : Model -> Bool
 | 
			
		||||
@@ -796,12 +801,24 @@ view2 texts flags extraClasses settings model =
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.successMessage, isFormSuccess model )
 | 
			
		||||
                , ( S.errorMessage, isFormError model )
 | 
			
		||||
                , ( "hidden", model.formMsg == Nothing )
 | 
			
		||||
                , ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.map .message model.formMsg
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            [ case model.formState of
 | 
			
		||||
                FormStateInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormStateHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateConnectionMissing ->
 | 
			
		||||
                    text texts.connectionMissing
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateNoProcessingFolders ->
 | 
			
		||||
                    text texts.noProcessingFolders
 | 
			
		||||
 | 
			
		||||
                FormStateInvalid ValidateCalEventInvalid ->
 | 
			
		||||
                    text texts.invalidCalEvent
 | 
			
		||||
            ]
 | 
			
		||||
        , Comp.Tabs.akkordion
 | 
			
		||||
            Comp.Tabs.defaultStyle
 | 
			
		||||
@@ -1172,7 +1189,7 @@ viewSchedule2 texts model =
 | 
			
		||||
            (Comp.CalEventInput.view2
 | 
			
		||||
                texts.calEventInput
 | 
			
		||||
                ""
 | 
			
		||||
                (Data.Validated.value model.schedule)
 | 
			
		||||
                model.schedule
 | 
			
		||||
                model.scheduleModel
 | 
			
		||||
            )
 | 
			
		||||
        , span [ class "opacity-50 text-sm" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -20,24 +20,36 @@ import Html.Attributes exposing (..)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.ScanMailboxManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { listModel : Comp.ScanMailboxList.Model
 | 
			
		||||
    , detailModel : Maybe Comp.ScanMailboxForm.Model
 | 
			
		||||
    , items : List ScanMailboxSettings
 | 
			
		||||
    , result : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type SubmitType
 | 
			
		||||
    = SubmitDelete
 | 
			
		||||
    | SubmitUpdate
 | 
			
		||||
    | SubmitCreate
 | 
			
		||||
    | SubmitStartOnce
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = FormStateInitial
 | 
			
		||||
    | FormHttpError Http.Error
 | 
			
		||||
    | FormSubmitSuccessful SubmitType
 | 
			
		||||
    | FormSubmitFailed String
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Msg
 | 
			
		||||
    = ListMsg Comp.ScanMailboxList.Msg
 | 
			
		||||
    | DetailMsg Comp.ScanMailboxForm.Msg
 | 
			
		||||
    | GetDataResp (Result Http.Error ScanMailboxSettingsList)
 | 
			
		||||
    | NewTask
 | 
			
		||||
    | SubmitResp Bool (Result Http.Error BasicResult)
 | 
			
		||||
    | DeleteResp (Result Http.Error BasicResult)
 | 
			
		||||
    | SubmitResp SubmitType (Result Http.Error BasicResult)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initModel : Model
 | 
			
		||||
@@ -45,7 +57,7 @@ initModel =
 | 
			
		||||
    { listModel = Comp.ScanMailboxList.init
 | 
			
		||||
    , detailModel = Nothing
 | 
			
		||||
    , items = []
 | 
			
		||||
    , result = Nothing
 | 
			
		||||
    , formState = FormStateInitial
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -69,13 +81,13 @@ update flags msg model =
 | 
			
		||||
        GetDataResp (Ok res) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | items = res.items
 | 
			
		||||
                , result = Nothing
 | 
			
		||||
                , formState = FormStateInitial
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        GetDataResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model | formState = FormHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
@@ -113,26 +125,29 @@ update flags msg model =
 | 
			
		||||
                        ( model_, cmd_ ) =
 | 
			
		||||
                            case action of
 | 
			
		||||
                                Comp.ScanMailboxForm.NoAction ->
 | 
			
		||||
                                    ( { model | detailModel = Just mm }
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Cmd.none
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.ScanMailboxForm.SubmitAction settings ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , if settings.id == "" then
 | 
			
		||||
                                        Api.createScanMailbox flags settings (SubmitResp True)
 | 
			
		||||
                                        Api.createScanMailbox flags settings (SubmitResp SubmitCreate)
 | 
			
		||||
 | 
			
		||||
                                      else
 | 
			
		||||
                                        Api.updateScanMailbox flags settings (SubmitResp True)
 | 
			
		||||
                                        Api.updateScanMailbox flags settings (SubmitResp SubmitUpdate)
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.ScanMailboxForm.CancelAction ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Nothing
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , initCmd flags
 | 
			
		||||
                                    )
 | 
			
		||||
@@ -140,17 +155,17 @@ update flags msg model =
 | 
			
		||||
                                Comp.ScanMailboxForm.StartOnceAction settings ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Api.startOnceScanMailbox flags settings (SubmitResp False)
 | 
			
		||||
                                    , Api.startOnceScanMailbox flags settings (SubmitResp SubmitStartOnce)
 | 
			
		||||
                                    )
 | 
			
		||||
 | 
			
		||||
                                Comp.ScanMailboxForm.DeleteAction id ->
 | 
			
		||||
                                    ( { model
 | 
			
		||||
                                        | detailModel = Just mm
 | 
			
		||||
                                        , result = Nothing
 | 
			
		||||
                                        , formState = FormStateInitial
 | 
			
		||||
                                      }
 | 
			
		||||
                                    , Api.deleteScanMailbox flags id DeleteResp
 | 
			
		||||
                                    , Api.deleteScanMailbox flags id (SubmitResp SubmitDelete)
 | 
			
		||||
                                    )
 | 
			
		||||
                    in
 | 
			
		||||
                    ( model_
 | 
			
		||||
@@ -170,17 +185,22 @@ update flags msg model =
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc )
 | 
			
		||||
 | 
			
		||||
        SubmitResp close (Ok res) ->
 | 
			
		||||
        SubmitResp submitType (Ok res) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | result = Just res
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if res.success then
 | 
			
		||||
                        FormSubmitSuccessful submitType
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        FormSubmitFailed res.message
 | 
			
		||||
                , detailModel =
 | 
			
		||||
                    if close then
 | 
			
		||||
                    if submitType == SubmitDelete then
 | 
			
		||||
                        Nothing
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        model.detailModel
 | 
			
		||||
              }
 | 
			
		||||
            , if close then
 | 
			
		||||
            , if submitType == SubmitDelete then
 | 
			
		||||
                initCmd flags
 | 
			
		||||
 | 
			
		||||
              else
 | 
			
		||||
@@ -188,23 +208,7 @@ update flags msg model =
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        SubmitResp _ (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
                ( { model | result = Nothing, detailModel = Nothing }
 | 
			
		||||
                , initCmd flags
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | result = Just res }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        DeleteResp (Err err) ->
 | 
			
		||||
            ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) }
 | 
			
		||||
            ( { model | formState = FormHttpError err }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
@@ -218,14 +222,33 @@ view2 texts flags settings model =
 | 
			
		||||
    div [ class "flex flex-col" ]
 | 
			
		||||
        (div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.errorMessage, Maybe.map .success model.result == Just False )
 | 
			
		||||
                , ( S.successMessage, Maybe.map .success model.result == Just True )
 | 
			
		||||
                , ( "hidden", model.result == Nothing )
 | 
			
		||||
                [ ( S.errorMessage, model.formState /= FormStateInitial )
 | 
			
		||||
                , ( S.successMessage, isSuccess model.formState )
 | 
			
		||||
                , ( "hidden", model.formState == FormStateInitial )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "mb-2"
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.map .message model.result
 | 
			
		||||
                |> Maybe.withDefault ""
 | 
			
		||||
                |> text
 | 
			
		||||
            [ case model.formState of
 | 
			
		||||
                FormStateInitial ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitCreate ->
 | 
			
		||||
                    text texts.taskCreated
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitUpdate ->
 | 
			
		||||
                    text texts.taskUpdated
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitStartOnce ->
 | 
			
		||||
                    text texts.taskStarted
 | 
			
		||||
 | 
			
		||||
                FormSubmitSuccessful SubmitDelete ->
 | 
			
		||||
                    text texts.taskDeleted
 | 
			
		||||
 | 
			
		||||
                FormSubmitFailed m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormHttpError err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
            ]
 | 
			
		||||
            :: (case model.detailModel of
 | 
			
		||||
                    Just msett ->
 | 
			
		||||
@@ -237,6 +260,16 @@ view2 texts flags settings model =
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isSuccess : FormState -> Bool
 | 
			
		||||
isSuccess state =
 | 
			
		||||
    case state of
 | 
			
		||||
        FormSubmitSuccessful _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewForm2 : Texts -> Flags -> UiSettings -> Comp.ScanMailboxForm.Model -> List (Html Msg)
 | 
			
		||||
viewForm2 texts flags settings model =
 | 
			
		||||
    [ Html.map DetailMsg
 | 
			
		||||
 
 | 
			
		||||
@@ -1223,6 +1223,7 @@ searchTabs texts ddd flags settings model =
 | 
			
		||||
      , body =
 | 
			
		||||
            [ Html.map TagSelectMsg
 | 
			
		||||
                (Comp.TagSelect.viewCats2
 | 
			
		||||
                    texts.tagSelect
 | 
			
		||||
                    settings
 | 
			
		||||
                    tagSelectWM
 | 
			
		||||
                    model.tagSelectModel
 | 
			
		||||
@@ -1235,7 +1236,8 @@ searchTabs texts ddd flags settings model =
 | 
			
		||||
      , info = Nothing
 | 
			
		||||
      , body =
 | 
			
		||||
            [ Html.map FolderSelectMsg
 | 
			
		||||
                (Comp.FolderSelect.viewDrop2 ddd.model
 | 
			
		||||
                (Comp.FolderSelect.viewDrop2 texts.folderSelect
 | 
			
		||||
                    ddd.model
 | 
			
		||||
                    settings.searchMenuFolderCount
 | 
			
		||||
                    model.folderList
 | 
			
		||||
                )
 | 
			
		||||
 
 | 
			
		||||
@@ -25,20 +25,25 @@ import Messages.Comp.SourceManage exposing (Texts)
 | 
			
		||||
import Ports
 | 
			
		||||
import QRCode
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { formModel : Comp.SourceForm.Model
 | 
			
		||||
    , viewMode : SelectMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    , sources : List SourceAndTags
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
init : Flags -> ( Model, Cmd Msg )
 | 
			
		||||
init flags =
 | 
			
		||||
    let
 | 
			
		||||
@@ -47,7 +52,7 @@ init flags =
 | 
			
		||||
    in
 | 
			
		||||
    ( { formModel = fm
 | 
			
		||||
      , viewMode = None
 | 
			
		||||
      , formError = Nothing
 | 
			
		||||
      , formError = FormErrorNone
 | 
			
		||||
      , loading = False
 | 
			
		||||
      , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
      , sources = []
 | 
			
		||||
@@ -103,7 +108,7 @@ update flags msg model =
 | 
			
		||||
                                model.formError
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
                      }
 | 
			
		||||
                    , Cmd.map TableMsg tc
 | 
			
		||||
                    )
 | 
			
		||||
@@ -152,7 +157,7 @@ update flags msg model =
 | 
			
		||||
                    Api.Model.SourceAndTags.empty
 | 
			
		||||
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model | viewMode = Edit source, formError = Nothing }
 | 
			
		||||
                    { model | viewMode = Edit source, formError = FormErrorNone }
 | 
			
		||||
            in
 | 
			
		||||
            update flags (FormMsg (Comp.SourceForm.SetSource source)) nm
 | 
			
		||||
 | 
			
		||||
@@ -168,7 +173,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.postSource flags source SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorInvalid }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
@@ -182,10 +187,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            update flags (YesNoMsg Comp.YesNoDimmer.activate) model
 | 
			
		||||
@@ -444,10 +449,21 @@ viewForm2 texts flags settings model =
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( S.errorMessage, True )
 | 
			
		||||
                , ( "hidden", Util.Maybe.isEmpty model.formError )
 | 
			
		||||
                , ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.correctFormErrors
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map YesNoMsg
 | 
			
		||||
            (Comp.YesNoDimmer.viewN True
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,6 @@ import Html.Events exposing (onSubmit)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.TagManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
import Util.Tag
 | 
			
		||||
import Util.Update
 | 
			
		||||
@@ -32,13 +31,20 @@ type alias Model =
 | 
			
		||||
    { tagTableModel : Comp.TagTable.Model
 | 
			
		||||
    , tagFormModel : Comp.TagForm.Model
 | 
			
		||||
    , viewMode : ViewMode
 | 
			
		||||
    , formError : Maybe String
 | 
			
		||||
    , formError : FormError
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , deleteConfirm : Comp.YesNoDimmer.Model
 | 
			
		||||
    , query : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type ViewMode
 | 
			
		||||
    = Table
 | 
			
		||||
    | Form
 | 
			
		||||
@@ -49,7 +55,7 @@ emptyModel =
 | 
			
		||||
    { tagTableModel = Comp.TagTable.emptyModel
 | 
			
		||||
    , tagFormModel = Comp.TagForm.emptyModel []
 | 
			
		||||
    , viewMode = Table
 | 
			
		||||
    , formError = Nothing
 | 
			
		||||
    , formError = FormErrorNone
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , deleteConfirm = Comp.YesNoDimmer.emptyModel
 | 
			
		||||
    , query = ""
 | 
			
		||||
@@ -84,7 +90,7 @@ update flags msg model =
 | 
			
		||||
                        , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
 | 
			
		||||
                        , formError =
 | 
			
		||||
                            if Util.Maybe.nonEmpty tm.selected then
 | 
			
		||||
                                Nothing
 | 
			
		||||
                                FormErrorNone
 | 
			
		||||
 | 
			
		||||
                            else
 | 
			
		||||
                                model.formError
 | 
			
		||||
@@ -144,7 +150,7 @@ update flags msg model =
 | 
			
		||||
        InitNewTag ->
 | 
			
		||||
            let
 | 
			
		||||
                nm =
 | 
			
		||||
                    { model | viewMode = Form, formError = Nothing }
 | 
			
		||||
                    { model | viewMode = Form, formError = FormErrorNone }
 | 
			
		||||
 | 
			
		||||
                tag =
 | 
			
		||||
                    Api.Model.Tag.empty
 | 
			
		||||
@@ -163,7 +169,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | loading = True }, Api.postTag flags tag SubmitResp )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just "Please correct the errors in the form." }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorInvalid }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            if res.success then
 | 
			
		||||
@@ -177,10 +183,10 @@ update flags msg model =
 | 
			
		||||
                ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | formError = Just res.message, loading = False }, Cmd.none )
 | 
			
		||||
                ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none )
 | 
			
		||||
            ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        RequestDelete ->
 | 
			
		||||
            update flags (YesNoMsg Comp.YesNoDimmer.activate) model
 | 
			
		||||
@@ -322,12 +328,23 @@ viewForm2 texts model =
 | 
			
		||||
            }
 | 
			
		||||
        , div
 | 
			
		||||
            [ classList
 | 
			
		||||
                [ ( "hidden", Util.Maybe.isEmpty model.formError )
 | 
			
		||||
                [ ( "hidden", model.formError == FormErrorNone )
 | 
			
		||||
                ]
 | 
			
		||||
            , class "my-2"
 | 
			
		||||
            , class S.errorMessage
 | 
			
		||||
            ]
 | 
			
		||||
            [ Maybe.withDefault "" model.formError |> text
 | 
			
		||||
            [ case model.formError of
 | 
			
		||||
                FormErrorNone ->
 | 
			
		||||
                    text ""
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.correctFormErrors
 | 
			
		||||
 | 
			
		||||
                FormErrorSubmit m ->
 | 
			
		||||
                    text m
 | 
			
		||||
            ]
 | 
			
		||||
        , Html.map FormMsg (Comp.TagForm.view2 texts.tagForm model.tagFormModel)
 | 
			
		||||
        , B.loadingDimmer
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ module Comp.TagSelect exposing
 | 
			
		||||
import Api.Model.NameCount exposing (NameCount)
 | 
			
		||||
import Api.Model.Tag exposing (Tag)
 | 
			
		||||
import Api.Model.TagCount exposing (TagCount)
 | 
			
		||||
import Comp.ExpandCollapse
 | 
			
		||||
import Data.Icons as I
 | 
			
		||||
import Data.UiSettings exposing (UiSettings)
 | 
			
		||||
import Dict exposing (Dict)
 | 
			
		||||
@@ -32,7 +33,6 @@ import Set
 | 
			
		||||
import Simple.Fuzzy
 | 
			
		||||
import String as S
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.ExpandCollapse
 | 
			
		||||
import Util.ItemDragDrop as DD
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
@@ -405,7 +405,7 @@ viewAll2 texts ddm settings sel model =
 | 
			
		||||
        wm =
 | 
			
		||||
            makeWorkModel sel model
 | 
			
		||||
    in
 | 
			
		||||
    viewTagsDrop2 texts ddm wm settings model ++ [ viewCats2 settings wm model ]
 | 
			
		||||
    viewTagsDrop2 texts ddm wm settings model ++ [ viewCats2 texts settings wm model ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewTagsDrop2 : Texts -> DD.Model -> WorkModel -> UiSettings -> Model -> List (Html Msg)
 | 
			
		||||
@@ -440,20 +440,20 @@ viewTagsDrop2 texts ddm wm settings model =
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
    , div [ class "flex flex-col space-y-2 md:space-y-1" ]
 | 
			
		||||
        (renderTagItems2 ddm settings model wm)
 | 
			
		||||
        (renderTagItems2 texts ddm settings model wm)
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
viewCats2 : UiSettings -> WorkModel -> Model -> Html Msg
 | 
			
		||||
viewCats2 settings wm model =
 | 
			
		||||
viewCats2 : Texts -> UiSettings -> WorkModel -> Model -> Html Msg
 | 
			
		||||
viewCats2 texts settings wm model =
 | 
			
		||||
    div [ class "flex flex-col" ]
 | 
			
		||||
        [ div [ class "flex flex-col space-y-2 md:space-y-1" ]
 | 
			
		||||
            (renderCatItems2 settings model wm)
 | 
			
		||||
            (renderCatItems2 texts settings model wm)
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderTagItems2 : DD.Model -> UiSettings -> Model -> WorkModel -> List (Html Msg)
 | 
			
		||||
renderTagItems2 ddm settings model wm =
 | 
			
		||||
renderTagItems2 : Texts -> DD.Model -> UiSettings -> Model -> WorkModel -> List (Html Msg)
 | 
			
		||||
renderTagItems2 texts ddm settings model wm =
 | 
			
		||||
    let
 | 
			
		||||
        tags =
 | 
			
		||||
            wm.filteredTags
 | 
			
		||||
@@ -462,15 +462,19 @@ renderTagItems2 ddm settings model wm =
 | 
			
		||||
            settings.searchMenuTagCount
 | 
			
		||||
 | 
			
		||||
        expLink =
 | 
			
		||||
            Util.ExpandCollapse.expandToggle2
 | 
			
		||||
                max
 | 
			
		||||
                (List.length tags)
 | 
			
		||||
            Comp.ExpandCollapse.expandToggle
 | 
			
		||||
                texts.expandCollapse
 | 
			
		||||
                { max = max
 | 
			
		||||
                , all = List.length tags
 | 
			
		||||
                }
 | 
			
		||||
                ToggleExpandTags
 | 
			
		||||
 | 
			
		||||
        cpsLink =
 | 
			
		||||
            Util.ExpandCollapse.collapseToggle2
 | 
			
		||||
                max
 | 
			
		||||
                (List.length tags)
 | 
			
		||||
            Comp.ExpandCollapse.collapseToggle
 | 
			
		||||
                texts.expandCollapse
 | 
			
		||||
                { max = max
 | 
			
		||||
                , all = List.length tags
 | 
			
		||||
                }
 | 
			
		||||
                ToggleExpandTags
 | 
			
		||||
    in
 | 
			
		||||
    if max <= 0 then
 | 
			
		||||
@@ -557,8 +561,8 @@ viewCategoryItem2 settings model cat =
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderCatItems2 : UiSettings -> Model -> WorkModel -> List (Html Msg)
 | 
			
		||||
renderCatItems2 settings model wm =
 | 
			
		||||
renderCatItems2 : Texts -> UiSettings -> Model -> WorkModel -> List (Html Msg)
 | 
			
		||||
renderCatItems2 texts settings model wm =
 | 
			
		||||
    let
 | 
			
		||||
        cats =
 | 
			
		||||
            wm.filteredCats
 | 
			
		||||
@@ -567,15 +571,19 @@ renderCatItems2 settings model wm =
 | 
			
		||||
            settings.searchMenuTagCatCount
 | 
			
		||||
 | 
			
		||||
        expLink =
 | 
			
		||||
            Util.ExpandCollapse.expandToggle2
 | 
			
		||||
                max
 | 
			
		||||
                (List.length cats)
 | 
			
		||||
            Comp.ExpandCollapse.expandToggle
 | 
			
		||||
                texts.expandCollapse
 | 
			
		||||
                { max = max
 | 
			
		||||
                , all = List.length cats
 | 
			
		||||
                }
 | 
			
		||||
                ToggleExpandCats
 | 
			
		||||
 | 
			
		||||
        cpsLink =
 | 
			
		||||
            Util.ExpandCollapse.collapseToggle2
 | 
			
		||||
                max
 | 
			
		||||
                (List.length cats)
 | 
			
		||||
            Comp.ExpandCollapse.collapseToggle
 | 
			
		||||
                texts.expandCollapse
 | 
			
		||||
                { max = max
 | 
			
		||||
                , all = List.length cats
 | 
			
		||||
                }
 | 
			
		||||
                ToggleExpandCats
 | 
			
		||||
    in
 | 
			
		||||
    if max <= 0 then
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ import Html.Events exposing (onSubmit)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.UserManage exposing (Texts)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Http
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -45,6 +44,7 @@ type ViewMode
 | 
			
		||||
type FormError
 | 
			
		||||
    = FormErrorNone
 | 
			
		||||
    | FormErrorSubmit String
 | 
			
		||||
    | FormErrorHttp Http.Error
 | 
			
		||||
    | FormErrorInvalid
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -183,7 +183,7 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formError = FormErrorSubmit (Util.Http.errorToString err)
 | 
			
		||||
                | formError = FormErrorHttp err
 | 
			
		||||
                , loading = False
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
@@ -319,6 +319,9 @@ viewForm2 texts settings model =
 | 
			
		||||
                FormErrorSubmit err ->
 | 
			
		||||
                    text err
 | 
			
		||||
 | 
			
		||||
                FormErrorHttp err ->
 | 
			
		||||
                    text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
                FormErrorInvalid ->
 | 
			
		||||
                    text texts.pleaseCorrectErrors
 | 
			
		||||
            ]
 | 
			
		||||
 
 | 
			
		||||
@@ -5,9 +5,12 @@ module Data.Validated exposing
 | 
			
		||||
    , map2
 | 
			
		||||
    , map3
 | 
			
		||||
    , map4
 | 
			
		||||
    , toResult
 | 
			
		||||
    , value
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
-- TODO Remove this, use Result
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type Validated a
 | 
			
		||||
    = Valid a
 | 
			
		||||
@@ -15,6 +18,19 @@ type Validated a
 | 
			
		||||
    | Unknown a
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
toResult : Validated a -> Result String a
 | 
			
		||||
toResult va =
 | 
			
		||||
    case va of
 | 
			
		||||
        Valid a ->
 | 
			
		||||
            Ok a
 | 
			
		||||
 | 
			
		||||
        Invalid errs _ ->
 | 
			
		||||
            Err (String.join ", " errs)
 | 
			
		||||
 | 
			
		||||
        Unknown a ->
 | 
			
		||||
            Ok a
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
isInvalid : Validated a -> Bool
 | 
			
		||||
isInvalid v =
 | 
			
		||||
    case v of
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,15 @@
 | 
			
		||||
module Messages.Comp.AttachmentMeta exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.DateFormat as DF
 | 
			
		||||
import Messages.UiLanguage
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , extractedMetadata : String
 | 
			
		||||
    , content : String
 | 
			
		||||
    , labels : String
 | 
			
		||||
@@ -24,6 +27,7 @@ type alias Texts =
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , extractedMetadata = "Extracted Meta Data"
 | 
			
		||||
    , content = "Content"
 | 
			
		||||
    , labels = "Labels"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
module Messages.Comp.CalEventInput exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.DateFormat as DF
 | 
			
		||||
import Messages.UiLanguage
 | 
			
		||||
 | 
			
		||||
@@ -15,6 +17,7 @@ type alias Texts =
 | 
			
		||||
    , schedule : String
 | 
			
		||||
    , next : String
 | 
			
		||||
    , formatDateTime : Int -> String
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -30,4 +33,5 @@ gb =
 | 
			
		||||
    , schedule = "Schedule"
 | 
			
		||||
    , next = "Next"
 | 
			
		||||
    , formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,26 +1,36 @@
 | 
			
		||||
module Messages.Comp.ChangePasswordForm exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , currentPassword : String
 | 
			
		||||
    , newPassword : String
 | 
			
		||||
    , repeatPassword : String
 | 
			
		||||
    , currentPasswordPlaceholder : String
 | 
			
		||||
    , newPasswordPlaceholder : String
 | 
			
		||||
    , repeatPasswordPlaceholder : String
 | 
			
		||||
    , passwordMismatch : String
 | 
			
		||||
    , fillRequiredFields : String
 | 
			
		||||
    , passwordChangeSuccessful : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , currentPassword = "Current Password"
 | 
			
		||||
    , newPassword = "New Password"
 | 
			
		||||
    , repeatPassword = "New Password (repeat)"
 | 
			
		||||
    , currentPasswordPlaceholder = "Password"
 | 
			
		||||
    , newPasswordPlaceholder = "Password"
 | 
			
		||||
    , repeatPasswordPlaceholder = "Password"
 | 
			
		||||
    , passwordMismatch = "The passwords do not match."
 | 
			
		||||
    , fillRequiredFields = "Please fill required fields."
 | 
			
		||||
    , passwordChangeSuccessful = "Password has been changed."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,17 @@
 | 
			
		||||
module Messages.Comp.CollectiveSettingsForm exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Data.Language exposing (Language)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.ClassifierSettingsForm
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Data.Language
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , classifierSettingsForm : Messages.Comp.ClassifierSettingsForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , save : String
 | 
			
		||||
    , saveSettings : String
 | 
			
		||||
    , documentLanguage : String
 | 
			
		||||
@@ -22,6 +25,9 @@ type alias Texts =
 | 
			
		||||
    , autoTagging : String
 | 
			
		||||
    , startNow : String
 | 
			
		||||
    , languageLabel : Language -> String
 | 
			
		||||
    , classifierTaskStarted : String
 | 
			
		||||
    , fulltextReindexSubmitted : String
 | 
			
		||||
    , fulltextReindexOkMissing : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -29,6 +35,7 @@ gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , classifierSettingsForm = Messages.Comp.ClassifierSettingsForm.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , save = "Save"
 | 
			
		||||
    , saveSettings = "Save Settings"
 | 
			
		||||
    , documentLanguage = "Document Language"
 | 
			
		||||
@@ -46,4 +53,8 @@ gb =
 | 
			
		||||
    , autoTagging = "Auto-Tagging"
 | 
			
		||||
    , startNow = "Start now"
 | 
			
		||||
    , languageLabel = Messages.Data.Language.gb
 | 
			
		||||
    , classifierTaskStarted = "Classifier task started."
 | 
			
		||||
    , fulltextReindexSubmitted = "Fulltext Re-Index started."
 | 
			
		||||
    , fulltextReindexOkMissing =
 | 
			
		||||
        "Please type OK in the field if you really want to start re-indexing your data."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
module Messages.Comp.CustomFieldForm exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Data.CustomFieldType exposing (CustomFieldType)
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Data.CustomFieldType
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -9,6 +11,7 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , reallyDeleteField : String
 | 
			
		||||
    , fieldTypeLabel : CustomFieldType -> String
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , createCustomField : String
 | 
			
		||||
    , modifyTypeWarning : String
 | 
			
		||||
    , nameInfo : String
 | 
			
		||||
@@ -17,6 +20,9 @@ type alias Texts =
 | 
			
		||||
    , label : String
 | 
			
		||||
    , labelInfo : String
 | 
			
		||||
    , deleteThisField : String
 | 
			
		||||
    , fieldNameRequired : String
 | 
			
		||||
    , fieldTypeRequired : String
 | 
			
		||||
    , updateSuccessful : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -25,6 +31,7 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , reallyDeleteField = "Really delete this custom field?"
 | 
			
		||||
    , fieldTypeLabel = Messages.Data.CustomFieldType.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , createCustomField = "Create a new custom field."
 | 
			
		||||
    , modifyTypeWarning =
 | 
			
		||||
        "Note that changing the format may "
 | 
			
		||||
@@ -41,4 +48,7 @@ gb =
 | 
			
		||||
        "The user defined label for this field. This is used to represent "
 | 
			
		||||
            ++ "this field in the ui. If not present, the name is used."
 | 
			
		||||
    , deleteThisField = "Delete this field"
 | 
			
		||||
    , fieldNameRequired = "A name is required."
 | 
			
		||||
    , fieldTypeRequired = "A type is required."
 | 
			
		||||
    , updateSuccessful = "Field has been saved."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,10 @@
 | 
			
		||||
module Messages.Comp.DetailEdit exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.CustomFieldForm
 | 
			
		||||
import Messages.Comp.EquipmentForm
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.OrgForm
 | 
			
		||||
import Messages.Comp.PersonForm
 | 
			
		||||
import Messages.Comp.TagForm
 | 
			
		||||
@@ -15,6 +17,9 @@ type alias Texts =
 | 
			
		||||
    , orgForm : Messages.Comp.OrgForm.Texts
 | 
			
		||||
    , equipmentForm : Messages.Comp.EquipmentForm.Texts
 | 
			
		||||
    , customFieldForm : Messages.Comp.CustomFieldForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , submitSuccessful : String
 | 
			
		||||
    , missingRequiredFields : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -26,4 +31,7 @@ gb =
 | 
			
		||||
    , orgForm = Messages.Comp.OrgForm.gb
 | 
			
		||||
    , equipmentForm = Messages.Comp.EquipmentForm.gb
 | 
			
		||||
    , customFieldForm = Messages.Comp.CustomFieldForm.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , submitSuccessful = "Successfully saved."
 | 
			
		||||
    , missingRequiredFields = "Please fill required fields."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,22 @@
 | 
			
		||||
module Messages.Comp.EmailSettingsManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.EmailSettingsForm
 | 
			
		||||
import Messages.Comp.EmailSettingsTable
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , settingsForm : Messages.Comp.EmailSettingsForm.Texts
 | 
			
		||||
    , settingsTable : Messages.Comp.EmailSettingsTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , newSettings : String
 | 
			
		||||
    , addNewSmtpSettings : String
 | 
			
		||||
    , reallyDeleteConnection : String
 | 
			
		||||
    , deleteThisEntry : String
 | 
			
		||||
    , fillRequiredFields : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , settingsForm = Messages.Comp.EmailSettingsForm.gb
 | 
			
		||||
    , settingsTable = Messages.Comp.EmailSettingsTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , newSettings = "New Settings"
 | 
			
		||||
    , addNewSmtpSettings = "Add new SMTP settings"
 | 
			
		||||
    , reallyDeleteConnection = "Really delete these connection?"
 | 
			
		||||
    , deleteThisEntry = "Delete this connection"
 | 
			
		||||
    , fillRequiredFields = "Please fill required fields."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,22 @@
 | 
			
		||||
module Messages.Comp.EquipmentManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.EquipmentForm
 | 
			
		||||
import Messages.Comp.EquipmentTable
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , equipmentTable : Messages.Comp.EquipmentTable.Texts
 | 
			
		||||
    , equipmentForm : Messages.Comp.EquipmentForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , createNewEquipment : String
 | 
			
		||||
    , newEquipment : String
 | 
			
		||||
    , reallyDeleteEquipment : String
 | 
			
		||||
    , deleteThisEquipment : String
 | 
			
		||||
    , correctFormErrors : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , equipmentTable = Messages.Comp.EquipmentTable.gb
 | 
			
		||||
    , equipmentForm = Messages.Comp.EquipmentForm.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , createNewEquipment = "Create a new equipment"
 | 
			
		||||
    , newEquipment = "New Equipment"
 | 
			
		||||
    , reallyDeleteEquipment = "Really delete this equipment?"
 | 
			
		||||
    , deleteThisEquipment = "Delete this equipment"
 | 
			
		||||
    , correctFormErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								modules/webapp/src/main/elm/Messages/Comp/ExpandCollapse.elm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/webapp/src/main/elm/Messages/Comp/ExpandCollapse.elm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
module Messages.Comp.ExpandCollapse exposing
 | 
			
		||||
    ( Texts
 | 
			
		||||
    , gb
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { showMoreLabel : String
 | 
			
		||||
    , showLessLabel : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { showMoreLabel = "Show More …"
 | 
			
		||||
    , showLessLabel = "Show Less …"
 | 
			
		||||
    }
 | 
			
		||||
@@ -1,10 +1,13 @@
 | 
			
		||||
module Messages.Comp.FolderDetail exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , reallyDeleteThisFolder : String
 | 
			
		||||
    , autoOwnerInfo : String
 | 
			
		||||
    , modifyInfo : String
 | 
			
		||||
@@ -14,12 +17,16 @@ type alias Texts =
 | 
			
		||||
    , add : String
 | 
			
		||||
    , removeMember : String
 | 
			
		||||
    , deleteThisFolder : String
 | 
			
		||||
    , folderCreated : String
 | 
			
		||||
    , nameChangeSuccessful : String
 | 
			
		||||
    , deleteSuccessful : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , reallyDeleteThisFolder = "Really delete this folder?"
 | 
			
		||||
    , autoOwnerInfo = "You are automatically set as owner of this new folder."
 | 
			
		||||
    , modifyInfo = "Modify this folder by changing the name or add/remove members."
 | 
			
		||||
@@ -29,4 +36,7 @@ gb =
 | 
			
		||||
    , add = "Add"
 | 
			
		||||
    , removeMember = "Remove this member"
 | 
			
		||||
    , deleteThisFolder = "Delete this folder"
 | 
			
		||||
    , folderCreated = "Folder has been created."
 | 
			
		||||
    , nameChangeSuccessful = "Name has been changed."
 | 
			
		||||
    , deleteSuccessful = "Folder has been deleted."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								modules/webapp/src/main/elm/Messages/Comp/FolderSelect.elm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/webapp/src/main/elm/Messages/Comp/FolderSelect.elm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
module Messages.Comp.FolderSelect exposing
 | 
			
		||||
    ( Texts
 | 
			
		||||
    , gb
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Messages.Comp.ExpandCollapse
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { expandCollapse : Messages.Comp.ExpandCollapse.Texts
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { expandCollapse = Messages.Comp.ExpandCollapse.gb
 | 
			
		||||
    }
 | 
			
		||||
							
								
								
									
										71
									
								
								modules/webapp/src/main/elm/Messages/Comp/HttpError.elm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								modules/webapp/src/main/elm/Messages/Comp/HttpError.elm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
			
		||||
module Messages.Comp.HttpError exposing (gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Http.Error -> String
 | 
			
		||||
gb err =
 | 
			
		||||
    let
 | 
			
		||||
        texts =
 | 
			
		||||
            { badUrl = \url -> "There is something wrong with this url: " ++ url
 | 
			
		||||
            , timeout = "There was a network timeout."
 | 
			
		||||
            , networkError = "There was a network error."
 | 
			
		||||
            , invalidResponseStatus =
 | 
			
		||||
                \status ->
 | 
			
		||||
                    "There was an invalid response status: " ++ String.fromInt status ++ "."
 | 
			
		||||
            , invalidInput = "Invalid input when processing the request."
 | 
			
		||||
            , notFound = "The requested resource doesn't exist."
 | 
			
		||||
            , invalidBody = \str -> "There was an error decoding the response: " ++ str
 | 
			
		||||
            }
 | 
			
		||||
    in
 | 
			
		||||
    errorToString texts err
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Error Utilities
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { badUrl : String -> String
 | 
			
		||||
    , timeout : String
 | 
			
		||||
    , networkError : String
 | 
			
		||||
    , invalidResponseStatus : Int -> String
 | 
			
		||||
    , invalidInput : String
 | 
			
		||||
    , notFound : String
 | 
			
		||||
    , invalidBody : String -> String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
errorToStringStatus : Texts -> Http.Error -> (Int -> String) -> String
 | 
			
		||||
errorToStringStatus texts error statusString =
 | 
			
		||||
    case error of
 | 
			
		||||
        Http.BadUrl url ->
 | 
			
		||||
            texts.badUrl url
 | 
			
		||||
 | 
			
		||||
        Http.Timeout ->
 | 
			
		||||
            texts.timeout
 | 
			
		||||
 | 
			
		||||
        Http.NetworkError ->
 | 
			
		||||
            texts.networkError
 | 
			
		||||
 | 
			
		||||
        Http.BadStatus status ->
 | 
			
		||||
            statusString status
 | 
			
		||||
 | 
			
		||||
        Http.BadBody str ->
 | 
			
		||||
            texts.invalidBody str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
errorToString : Texts -> Http.Error -> String
 | 
			
		||||
errorToString texts error =
 | 
			
		||||
    let
 | 
			
		||||
        f sc =
 | 
			
		||||
            if sc == 404 then
 | 
			
		||||
                texts.notFound
 | 
			
		||||
 | 
			
		||||
            else if sc >= 400 && sc < 500 then
 | 
			
		||||
                texts.invalidInput
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                texts.invalidResponseStatus sc
 | 
			
		||||
    in
 | 
			
		||||
    errorToStringStatus texts error f
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.ImapSettingsManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.ImapSettingsForm
 | 
			
		||||
import Messages.Comp.ImapSettingsTable
 | 
			
		||||
 | 
			
		||||
@@ -9,10 +11,12 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , imapForm : Messages.Comp.ImapSettingsForm.Texts
 | 
			
		||||
    , imapTable : Messages.Comp.ImapSettingsTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , addNewImapSettings : String
 | 
			
		||||
    , newSettings : String
 | 
			
		||||
    , reallyDeleteSettings : String
 | 
			
		||||
    , deleteThisEntry : String
 | 
			
		||||
    , fillRequiredFields : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , imapForm = Messages.Comp.ImapSettingsForm.gb
 | 
			
		||||
    , imapTable = Messages.Comp.ImapSettingsTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , addNewImapSettings = "Add new IMAP settings"
 | 
			
		||||
    , newSettings = "New Settings"
 | 
			
		||||
    , reallyDeleteSettings = "Really delete this mail-box connection?"
 | 
			
		||||
    , deleteThisEntry = "Delete this settings entry"
 | 
			
		||||
    , fillRequiredFields = "Please fill required fields."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
module Messages.Comp.ItemDetail exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.DetailEdit
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.ItemDetail.AddFilesForm
 | 
			
		||||
import Messages.Comp.ItemDetail.ConfirmModal
 | 
			
		||||
import Messages.Comp.ItemDetail.ItemInfoHeader
 | 
			
		||||
import Messages.Comp.ItemDetail.Notes
 | 
			
		||||
import Messages.Comp.ItemDetail.SingleAttachment
 | 
			
		||||
@@ -19,6 +22,8 @@ type alias Texts =
 | 
			
		||||
    , notes : Messages.Comp.ItemDetail.Notes.Texts
 | 
			
		||||
    , itemMail : Messages.Comp.ItemMail.Texts
 | 
			
		||||
    , detailEdit : Messages.Comp.DetailEdit.Texts
 | 
			
		||||
    , confirmModal : Messages.Comp.ItemDetail.ConfirmModal.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , key : String
 | 
			
		||||
    , backToSearchResults : String
 | 
			
		||||
    , previousItem : String
 | 
			
		||||
@@ -37,6 +42,7 @@ type alias Texts =
 | 
			
		||||
    , lastUpdateOn : String
 | 
			
		||||
    , sendingMailNow : String
 | 
			
		||||
    , formatDateTime : Int -> String
 | 
			
		||||
    , mailSendSuccessful : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -49,6 +55,8 @@ gb =
 | 
			
		||||
    , notes = Messages.Comp.ItemDetail.Notes.gb
 | 
			
		||||
    , itemMail = Messages.Comp.ItemMail.gb
 | 
			
		||||
    , detailEdit = Messages.Comp.DetailEdit.gb
 | 
			
		||||
    , confirmModal = Messages.Comp.ItemDetail.ConfirmModal.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , key = "Key"
 | 
			
		||||
    , backToSearchResults = "Back to search results"
 | 
			
		||||
    , previousItem = "Previous item."
 | 
			
		||||
@@ -67,4 +75,5 @@ gb =
 | 
			
		||||
    , lastUpdateOn = "Last update on"
 | 
			
		||||
    , sendingMailNow = "Sending e-mail…"
 | 
			
		||||
    , formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
 | 
			
		||||
    , mailSendSuccessful = "Mail sent."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,44 @@
 | 
			
		||||
module Messages.Comp.ItemDetail.ConfirmModal exposing
 | 
			
		||||
    ( Texts
 | 
			
		||||
    , gb
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , confirmReprocessItem : String -> String
 | 
			
		||||
    , confirmReprocessFile : String -> String
 | 
			
		||||
    , confirmDeleteItem : String
 | 
			
		||||
    , confirmDeleteFile : String
 | 
			
		||||
    , confirmDeleteAllFiles : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , confirmReprocessItem =
 | 
			
		||||
        \state ->
 | 
			
		||||
            if state == "created" then
 | 
			
		||||
                "Reprocessing this item may change its metadata, "
 | 
			
		||||
                    ++ "since it is unconfirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                "Reprocessing this item will not change its metadata, "
 | 
			
		||||
                    ++ "since it has been confirmed. Do you want to proceed?"
 | 
			
		||||
    , confirmReprocessFile =
 | 
			
		||||
        \state ->
 | 
			
		||||
            if state == "created" then
 | 
			
		||||
                "Reprocessing this file may change metadata of "
 | 
			
		||||
                    ++ "this item, since it is unconfirmed. Do you want to proceed?"
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                "Reprocessing this file will not change metadata of "
 | 
			
		||||
                    ++ "this item, since it has been confirmed. Do you want to proceed?"
 | 
			
		||||
    , confirmDeleteItem =
 | 
			
		||||
        "Really delete this item? This cannot be undone."
 | 
			
		||||
    , confirmDeleteFile = "Really delete this file?"
 | 
			
		||||
    , confirmDeleteAllFiles = "Really delete these files?"
 | 
			
		||||
    }
 | 
			
		||||
@@ -1,10 +1,12 @@
 | 
			
		||||
module Messages.Comp.ItemDetail.SingleAttachment exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Messages.Comp.AttachmentMeta
 | 
			
		||||
import Messages.Comp.ItemDetail.ConfirmModal
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { attachmentMeta : Messages.Comp.AttachmentMeta.Texts
 | 
			
		||||
    , confirmModal : Messages.Comp.ItemDetail.ConfirmModal.Texts
 | 
			
		||||
    , noName : String
 | 
			
		||||
    , openFileInNewTab : String
 | 
			
		||||
    , downloadFile : String
 | 
			
		||||
@@ -24,6 +26,7 @@ type alias Texts =
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { attachmentMeta = Messages.Comp.AttachmentMeta.gb
 | 
			
		||||
    , confirmModal = Messages.Comp.ItemDetail.ConfirmModal.gb
 | 
			
		||||
    , noName = "No name"
 | 
			
		||||
    , openFileInNewTab = "Open file in new tab"
 | 
			
		||||
    , downloadFile = "Download file"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,13 @@
 | 
			
		||||
module Messages.Comp.ItemMail exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , selectConnection : String
 | 
			
		||||
    , sendVia : String
 | 
			
		||||
    , recipients : String
 | 
			
		||||
@@ -13,12 +16,15 @@ type alias Texts =
 | 
			
		||||
    , subject : String
 | 
			
		||||
    , body : String
 | 
			
		||||
    , includeAllAttachments : String
 | 
			
		||||
    , connectionMissing : String
 | 
			
		||||
    , sendLabel : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , selectConnection = "Select connection..."
 | 
			
		||||
    , sendVia = "Send via"
 | 
			
		||||
    , recipients = "Recipient(s)"
 | 
			
		||||
@@ -27,4 +33,6 @@ gb =
 | 
			
		||||
    , subject = "Subject"
 | 
			
		||||
    , body = "Body"
 | 
			
		||||
    , includeAllAttachments = "Include all item attachments"
 | 
			
		||||
    , connectionMissing = "No E-Mail connections configured. Goto user settings to add one."
 | 
			
		||||
    , sendLabel = "Send"
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,15 @@
 | 
			
		||||
module Messages.Comp.NotificationForm exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.CalEventInput
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , calEventInput : Messages.Comp.CalEventInput.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , reallyDeleteTask : String
 | 
			
		||||
    , startOnce : String
 | 
			
		||||
    , startTaskNow : String
 | 
			
		||||
@@ -30,6 +33,10 @@ type alias Texts =
 | 
			
		||||
    , schedule : String
 | 
			
		||||
    , scheduleClickForHelp : String
 | 
			
		||||
    , scheduleInfo : String
 | 
			
		||||
    , connectionMissing : String
 | 
			
		||||
    , invalidCalEvent : String
 | 
			
		||||
    , remindDaysRequired : String
 | 
			
		||||
    , recipientsRequired : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -37,6 +44,7 @@ gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , calEventInput = Messages.Comp.CalEventInput.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , reallyDeleteTask = "Really delete this notification task?"
 | 
			
		||||
    , startOnce = "Start Once"
 | 
			
		||||
    , startTaskNow = "Start this task now"
 | 
			
		||||
@@ -64,4 +72,8 @@ gb =
 | 
			
		||||
            ++ "Use English 3-letter weekdays. Either a single value, "
 | 
			
		||||
            ++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) "
 | 
			
		||||
            ++ "is allowed for each part."
 | 
			
		||||
    , connectionMissing = "No E-Mail connections configured. Goto E-Mail Settings to add one."
 | 
			
		||||
    , invalidCalEvent = "The calendar event is not valid."
 | 
			
		||||
    , remindDaysRequired = "Remind-Days is required."
 | 
			
		||||
    , recipientsRequired = "At least one recipient is required."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.NotificationManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.NotificationForm
 | 
			
		||||
import Messages.Comp.NotificationTable
 | 
			
		||||
 | 
			
		||||
@@ -9,8 +11,13 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , notificationForm : Messages.Comp.NotificationForm.Texts
 | 
			
		||||
    , notificationTable : Messages.Comp.NotificationTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , newTask : String
 | 
			
		||||
    , createNewTask : String
 | 
			
		||||
    , taskCreated : String
 | 
			
		||||
    , taskUpdated : String
 | 
			
		||||
    , taskStarted : String
 | 
			
		||||
    , taskDeleted : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +26,11 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , notificationForm = Messages.Comp.NotificationForm.gb
 | 
			
		||||
    , notificationTable = Messages.Comp.NotificationTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , newTask = "New Task"
 | 
			
		||||
    , createNewTask = "Create a new notification task"
 | 
			
		||||
    , taskCreated = "Task created."
 | 
			
		||||
    , taskUpdated = "Task updated."
 | 
			
		||||
    , taskStarted = "Task started."
 | 
			
		||||
    , taskDeleted = "Task deleted."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.OrgManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.OrgForm
 | 
			
		||||
import Messages.Comp.OrgTable
 | 
			
		||||
 | 
			
		||||
@@ -9,10 +11,12 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , orgForm : Messages.Comp.OrgForm.Texts
 | 
			
		||||
    , orgTable : Messages.Comp.OrgTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , newOrganization : String
 | 
			
		||||
    , createNewOrganization : String
 | 
			
		||||
    , reallyDeleteOrg : String
 | 
			
		||||
    , deleteThisOrg : String
 | 
			
		||||
    , correctFormErrors : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , orgForm = Messages.Comp.OrgForm.gb
 | 
			
		||||
    , orgTable = Messages.Comp.OrgTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , newOrganization = "New Organization"
 | 
			
		||||
    , createNewOrganization = "Create a new organization"
 | 
			
		||||
    , reallyDeleteOrg = "Really delete this organization?"
 | 
			
		||||
    , deleteThisOrg = "Delete this organization"
 | 
			
		||||
    , correctFormErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.PersonManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.PersonForm
 | 
			
		||||
import Messages.Comp.PersonTable
 | 
			
		||||
 | 
			
		||||
@@ -9,10 +11,12 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , personForm : Messages.Comp.PersonForm.Texts
 | 
			
		||||
    , personTable : Messages.Comp.PersonTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , newPerson : String
 | 
			
		||||
    , createNewPerson : String
 | 
			
		||||
    , reallyDeletePerson : String
 | 
			
		||||
    , deleteThisPerson : String
 | 
			
		||||
    , correctFormErrors : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , personForm = Messages.Comp.PersonForm.gb
 | 
			
		||||
    , personTable = Messages.Comp.PersonTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , newPerson = "New Person"
 | 
			
		||||
    , createNewPerson = "Create a new person"
 | 
			
		||||
    , reallyDeletePerson = "Really delete this person?"
 | 
			
		||||
    , deleteThisPerson = "Delete this person"
 | 
			
		||||
    , correctFormErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,15 @@
 | 
			
		||||
module Messages.Comp.ScanMailboxForm exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.CalEventInput
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , calEventInput : Messages.Comp.CalEventInput.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , reallyDeleteTask : String
 | 
			
		||||
    , startOnce : String
 | 
			
		||||
    , startNow : String
 | 
			
		||||
@@ -54,6 +57,9 @@ type alias Texts =
 | 
			
		||||
    , schedule : String
 | 
			
		||||
    , scheduleClickForHelp : String
 | 
			
		||||
    , scheduleInfo : String
 | 
			
		||||
    , connectionMissing : String
 | 
			
		||||
    , noProcessingFolders : String
 | 
			
		||||
    , invalidCalEvent : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -61,6 +67,7 @@ gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , calEventInput = Messages.Comp.CalEventInput.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , reallyDeleteTask = "Really delete this scan mailbox task?"
 | 
			
		||||
    , startOnce = "Start Once"
 | 
			
		||||
    , startNow = "Start this task now"
 | 
			
		||||
@@ -135,4 +142,7 @@ disappear then.
 | 
			
		||||
            ++ "Use English 3-letter weekdays. Either a single value, "
 | 
			
		||||
            ++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) "
 | 
			
		||||
            ++ "is allowed for each part."
 | 
			
		||||
    , connectionMissing = "No E-Mail connections configured. Goto E-Mail Settings to add one."
 | 
			
		||||
    , noProcessingFolders = "No processing folders given."
 | 
			
		||||
    , invalidCalEvent = "The calendar event is not valid."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.ScanMailboxManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.ScanMailboxForm
 | 
			
		||||
import Messages.Comp.ScanMailboxTable
 | 
			
		||||
 | 
			
		||||
@@ -9,8 +11,13 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , form : Messages.Comp.ScanMailboxForm.Texts
 | 
			
		||||
    , table : Messages.Comp.ScanMailboxTable.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , newTask : String
 | 
			
		||||
    , createNewTask : String
 | 
			
		||||
    , taskCreated : String
 | 
			
		||||
    , taskUpdated : String
 | 
			
		||||
    , taskStarted : String
 | 
			
		||||
    , taskDeleted : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +26,11 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , form = Messages.Comp.ScanMailboxForm.gb
 | 
			
		||||
    , table = Messages.Comp.ScanMailboxTable.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , newTask = "New Task"
 | 
			
		||||
    , createNewTask = "Create a new scan mailbox task"
 | 
			
		||||
    , taskCreated = "Task created."
 | 
			
		||||
    , taskUpdated = "Task updated."
 | 
			
		||||
    , taskStarted = "Task started."
 | 
			
		||||
    , taskDeleted = "Task deleted."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ module Messages.Comp.SearchMenu exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.CustomFieldMultiInput
 | 
			
		||||
import Messages.Comp.FolderSelect
 | 
			
		||||
import Messages.Comp.TagSelect
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -9,6 +10,7 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts
 | 
			
		||||
    , tagSelect : Messages.Comp.TagSelect.Texts
 | 
			
		||||
    , folderSelect : Messages.Comp.FolderSelect.Texts
 | 
			
		||||
    , chooseDirection : String
 | 
			
		||||
    , choosePerson : String
 | 
			
		||||
    , chooseEquipment : String
 | 
			
		||||
@@ -38,6 +40,7 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb
 | 
			
		||||
    , tagSelect = Messages.Comp.TagSelect.gb
 | 
			
		||||
    , folderSelect = Messages.Comp.FolderSelect.gb
 | 
			
		||||
    , chooseDirection = "Choose a direction…"
 | 
			
		||||
    , choosePerson = "Choose a person"
 | 
			
		||||
    , chooseEquipment = "Choose an equipment"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.SourceManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.SourceForm
 | 
			
		||||
import Messages.Comp.SourceTable
 | 
			
		||||
 | 
			
		||||
@@ -9,6 +11,7 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , sourceTable : Messages.Comp.SourceTable.Texts
 | 
			
		||||
    , sourceForm : Messages.Comp.SourceForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , addSourceUrl : String
 | 
			
		||||
    , newSource : String
 | 
			
		||||
    , publicUploads : String
 | 
			
		||||
@@ -22,6 +25,7 @@ type alias Texts =
 | 
			
		||||
    , createNewSource : String
 | 
			
		||||
    , deleteThisSource : String
 | 
			
		||||
    , errorGeneratingQR : String
 | 
			
		||||
    , correctFormErrors : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -30,6 +34,7 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , sourceTable = Messages.Comp.SourceTable.gb
 | 
			
		||||
    , sourceForm = Messages.Comp.SourceForm.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , addSourceUrl = "Add a source url"
 | 
			
		||||
    , newSource = "New source"
 | 
			
		||||
    , publicUploads = "Public Uploads"
 | 
			
		||||
@@ -50,4 +55,5 @@ gb =
 | 
			
		||||
    , createNewSource = "Create new source"
 | 
			
		||||
    , deleteThisSource = "Delete this source"
 | 
			
		||||
    , errorGeneratingQR = "Error generating QR Code"
 | 
			
		||||
    , correctFormErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.TagManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.TagForm
 | 
			
		||||
import Messages.Comp.TagTable
 | 
			
		||||
 | 
			
		||||
@@ -9,10 +11,12 @@ type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , tagTable : Messages.Comp.TagTable.Texts
 | 
			
		||||
    , tagForm : Messages.Comp.TagForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , createNewTag : String
 | 
			
		||||
    , newTag : String
 | 
			
		||||
    , reallyDeleteTag : String
 | 
			
		||||
    , deleteThisTag : String
 | 
			
		||||
    , correctFormErrors : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -21,8 +25,10 @@ gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , tagTable = Messages.Comp.TagTable.gb
 | 
			
		||||
    , tagForm = Messages.Comp.TagForm.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , createNewTag = "Create a new tag"
 | 
			
		||||
    , newTag = "New Tag"
 | 
			
		||||
    , reallyDeleteTag = "Really delete this tag?"
 | 
			
		||||
    , deleteThisTag = "Delete this tag"
 | 
			
		||||
    , correctFormErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,11 @@
 | 
			
		||||
module Messages.Comp.TagSelect exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Messages.Comp.ExpandCollapse
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { hideEmpty : String
 | 
			
		||||
    { expandCollapse : Messages.Comp.ExpandCollapse.Texts
 | 
			
		||||
    , hideEmpty : String
 | 
			
		||||
    , showEmpty : String
 | 
			
		||||
    , filterPlaceholder : String
 | 
			
		||||
    }
 | 
			
		||||
@@ -10,7 +13,8 @@ type alias Texts =
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { hideEmpty = "Hide empty"
 | 
			
		||||
    { expandCollapse = Messages.Comp.ExpandCollapse.gb
 | 
			
		||||
    , hideEmpty = "Hide empty"
 | 
			
		||||
    , showEmpty = "Show empty"
 | 
			
		||||
    , filterPlaceholder = "Filter …"
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
module Messages.Comp.UserManage exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.UserForm
 | 
			
		||||
import Messages.Comp.UserTable
 | 
			
		||||
 | 
			
		||||
@@ -8,6 +10,7 @@ import Messages.Comp.UserTable
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { userTable : Messages.Comp.UserTable.Texts
 | 
			
		||||
    , userForm : Messages.Comp.UserForm.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , users : String
 | 
			
		||||
    , newUser : String
 | 
			
		||||
    , addNewUser : String
 | 
			
		||||
@@ -24,6 +27,7 @@ gb =
 | 
			
		||||
    { userTable = Messages.Comp.UserTable.gb
 | 
			
		||||
    , userForm = Messages.Comp.UserForm.gb
 | 
			
		||||
    , basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , users = "Users"
 | 
			
		||||
    , newUser = "New user"
 | 
			
		||||
    , addNewUser = "Add new user"
 | 
			
		||||
@@ -32,8 +36,3 @@ gb =
 | 
			
		||||
    , deleteThisUser = "Delete this user"
 | 
			
		||||
    , pleaseCorrectErrors = "Please correct the errors in the form."
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
de : Texts
 | 
			
		||||
de =
 | 
			
		||||
    gb
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
module Messages.Page.CollectiveSettings exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.CollectiveSettingsForm
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.Comp.SourceManage
 | 
			
		||||
import Messages.Comp.UserManage
 | 
			
		||||
 | 
			
		||||
@@ -11,6 +13,7 @@ type alias Texts =
 | 
			
		||||
    , userManage : Messages.Comp.UserManage.Texts
 | 
			
		||||
    , collectiveSettingsForm : Messages.Comp.CollectiveSettingsForm.Texts
 | 
			
		||||
    , sourceManage : Messages.Comp.SourceManage.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , collectiveSettings : String
 | 
			
		||||
    , insights : String
 | 
			
		||||
    , sources : String
 | 
			
		||||
@@ -19,6 +22,7 @@ type alias Texts =
 | 
			
		||||
    , user : String
 | 
			
		||||
    , collective : String
 | 
			
		||||
    , size : String
 | 
			
		||||
    , submitSuccessful : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -28,6 +32,7 @@ gb =
 | 
			
		||||
    , userManage = Messages.Comp.UserManage.gb
 | 
			
		||||
    , collectiveSettingsForm = Messages.Comp.CollectiveSettingsForm.gb
 | 
			
		||||
    , sourceManage = Messages.Comp.SourceManage.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , collectiveSettings = "Collective Settings"
 | 
			
		||||
    , insights = "Insights"
 | 
			
		||||
    , sources = "Sources"
 | 
			
		||||
@@ -36,4 +41,5 @@ gb =
 | 
			
		||||
    , user = "User"
 | 
			
		||||
    , collective = "Collective"
 | 
			
		||||
    , size = "Size"
 | 
			
		||||
    , submitSuccessful = "Settings saved."
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,12 @@
 | 
			
		||||
module Messages.Page.Login exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { loginToDocspell : String
 | 
			
		||||
    { httpError : Http.Error -> String
 | 
			
		||||
    , loginToDocspell : String
 | 
			
		||||
    , username : String
 | 
			
		||||
    , collectiveSlashLogin : String
 | 
			
		||||
    , password : String
 | 
			
		||||
@@ -18,7 +22,8 @@ type alias Texts =
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { loginToDocspell = "Login to Docspell"
 | 
			
		||||
    { httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , loginToDocspell = "Login to Docspell"
 | 
			
		||||
    , username = "Username"
 | 
			
		||||
    , collectiveSlashLogin = "Collective / Login"
 | 
			
		||||
    , password = "Password"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,18 @@
 | 
			
		||||
module Messages.Page.NewInvite exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , createNewInvitations : String
 | 
			
		||||
    , invitationKey : String
 | 
			
		||||
    , password : String
 | 
			
		||||
    , reset : String
 | 
			
		||||
    , newInvitationCreated : String
 | 
			
		||||
    , inviteInfo : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -16,18 +20,22 @@ type alias Texts =
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , createNewInvitations = "Create new invitations"
 | 
			
		||||
    , invitationKey = "Invitation Key"
 | 
			
		||||
    , password = "Password"
 | 
			
		||||
    , reset = "Reset"
 | 
			
		||||
    , newInvitationCreated = "New invitation created."
 | 
			
		||||
    , inviteInfo =
 | 
			
		||||
        """Docspell requires an invite when signing up. You can
 | 
			
		||||
         create these invites here and send them to friends so
 | 
			
		||||
         they can signup with docspell.
 | 
			
		||||
        """
 | 
			
		||||
Docspell requires an invite when signing up. You can
 | 
			
		||||
create these invites here and send them to friends so
 | 
			
		||||
they can signup with docspell.
 | 
			
		||||
 | 
			
		||||
         Each invite can only be used once. You'll need to
 | 
			
		||||
         create one key for each person you want to invite.
 | 
			
		||||
Each invite can only be used once. You'll need to
 | 
			
		||||
create one key for each person you want to invite.
 | 
			
		||||
 | 
			
		||||
         Creating an invite requires providing the password
 | 
			
		||||
         from the configuration."""
 | 
			
		||||
Creating an invite requires providing the password
 | 
			
		||||
from the configuration.
 | 
			
		||||
"""
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,15 @@
 | 
			
		||||
module Messages.Page.Queue exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
import Messages.DateFormat as DF
 | 
			
		||||
import Messages.UiLanguage
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , currentlyRunning : String
 | 
			
		||||
    , queue : String
 | 
			
		||||
    , waiting : String
 | 
			
		||||
@@ -32,6 +35,7 @@ type alias Texts =
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , currentlyRunning = "Currently Running"
 | 
			
		||||
    , queue = "Queue"
 | 
			
		||||
    , waiting = "Waiting"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,13 @@
 | 
			
		||||
module Messages.Page.Register exposing (Texts, gb)
 | 
			
		||||
 | 
			
		||||
import Http
 | 
			
		||||
import Messages.Basics
 | 
			
		||||
import Messages.Comp.HttpError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Texts =
 | 
			
		||||
    { basics : Messages.Basics.Texts
 | 
			
		||||
    , httpError : Http.Error -> String
 | 
			
		||||
    , signupToDocspell : String
 | 
			
		||||
    , collectiveId : String
 | 
			
		||||
    , collective : String
 | 
			
		||||
@@ -16,12 +19,15 @@ type alias Texts =
 | 
			
		||||
    , alreadySignedUp : String
 | 
			
		||||
    , signIn : String
 | 
			
		||||
    , registrationSuccessful : String
 | 
			
		||||
    , passwordsDontMatch : String
 | 
			
		||||
    , allFieldsRequired : String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
gb : Texts
 | 
			
		||||
gb =
 | 
			
		||||
    { basics = Messages.Basics.gb
 | 
			
		||||
    , httpError = Messages.Comp.HttpError.gb
 | 
			
		||||
    , signupToDocspell = "Signup to Docspell"
 | 
			
		||||
    , collectiveId = "Collective ID"
 | 
			
		||||
    , collective = "Collective"
 | 
			
		||||
@@ -33,4 +39,6 @@ gb =
 | 
			
		||||
    , alreadySignedUp = "Already signed up?"
 | 
			
		||||
    , signIn = "Sign in"
 | 
			
		||||
    , registrationSuccessful = "Registration successful."
 | 
			
		||||
    , passwordsDontMatch = "The passwords do not match."
 | 
			
		||||
    , allFieldsRequired = "All fields are required!"
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
module Page.CollectiveSettings.Data exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    ( FormState(..)
 | 
			
		||||
    , Model
 | 
			
		||||
    , Msg(..)
 | 
			
		||||
    , Tab(..)
 | 
			
		||||
    , init
 | 
			
		||||
@@ -21,10 +22,17 @@ type alias Model =
 | 
			
		||||
    , userModel : Comp.UserManage.Model
 | 
			
		||||
    , settingsModel : Comp.CollectiveSettingsForm.Model
 | 
			
		||||
    , insights : ItemInsights
 | 
			
		||||
    , submitResult : Maybe BasicResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = InitialState
 | 
			
		||||
    | SubmitSuccessful
 | 
			
		||||
    | SubmitFailed String
 | 
			
		||||
    | SubmitError Http.Error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
init : Flags -> ( Model, Cmd Msg )
 | 
			
		||||
init flags =
 | 
			
		||||
    let
 | 
			
		||||
@@ -39,7 +47,7 @@ init flags =
 | 
			
		||||
      , userModel = Comp.UserManage.emptyModel
 | 
			
		||||
      , settingsModel = cm
 | 
			
		||||
      , insights = Api.Model.ItemInsights.empty
 | 
			
		||||
      , submitResult = Nothing
 | 
			
		||||
      , formState = InitialState
 | 
			
		||||
      }
 | 
			
		||||
    , Cmd.batch
 | 
			
		||||
        [ Cmd.map SourceMsg sc
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,11 @@
 | 
			
		||||
module Page.CollectiveSettings.Update exposing (update)
 | 
			
		||||
 | 
			
		||||
import Api
 | 
			
		||||
import Api.Model.BasicResult exposing (BasicResult)
 | 
			
		||||
import Comp.CollectiveSettingsForm
 | 
			
		||||
import Comp.SourceManage
 | 
			
		||||
import Comp.UserManage
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Page.CollectiveSettings.Data exposing (..)
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
 | 
			
		||||
@@ -58,12 +56,12 @@ update flags msg model =
 | 
			
		||||
                        Just sett ->
 | 
			
		||||
                            Api.setCollectiveSettings flags sett SubmitResp
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | settingsModel = m2, submitResult = Nothing }
 | 
			
		||||
            ( { model | settingsModel = m2, formState = InitialState }
 | 
			
		||||
            , Cmd.batch [ cmd, Cmd.map SettingsFormMsg c2 ]
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        Init ->
 | 
			
		||||
            ( { model | submitResult = Nothing }
 | 
			
		||||
            ( { model | formState = InitialState }
 | 
			
		||||
            , Cmd.batch
 | 
			
		||||
                [ Api.getInsights flags GetInsightsResp
 | 
			
		||||
                , Api.getCollectiveSettings flags CollectiveSettingsResp
 | 
			
		||||
@@ -89,11 +87,16 @@ update flags msg model =
 | 
			
		||||
            ( model, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Ok res) ->
 | 
			
		||||
            ( { model | submitResult = Just res }, Cmd.none )
 | 
			
		||||
            ( { model
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if res.success then
 | 
			
		||||
                        SubmitSuccessful
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        SubmitFailed res.message
 | 
			
		||||
              }
 | 
			
		||||
            , Cmd.none
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            let
 | 
			
		||||
                res =
 | 
			
		||||
                    BasicResult False (Util.Http.errorToString err)
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | submitResult = Just res }, Cmd.none )
 | 
			
		||||
            ( { model | formState = SubmitError err }, Cmd.none )
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,6 @@ import Html.Events exposing (onClick)
 | 
			
		||||
import Messages.Page.CollectiveSettings exposing (Texts)
 | 
			
		||||
import Page.CollectiveSettings.Data exposing (..)
 | 
			
		||||
import Styles as S
 | 
			
		||||
import Util.Maybe
 | 
			
		||||
import Util.Size
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -249,6 +248,27 @@ viewSettings texts flags settings model =
 | 
			
		||||
            [ text texts.collectiveSettings
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
    , div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( "hidden", model.formState == InitialState )
 | 
			
		||||
            , ( S.successMessage, model.formState == SubmitSuccessful )
 | 
			
		||||
            , ( S.errorMessage, model.formState /= SubmitSuccessful )
 | 
			
		||||
            ]
 | 
			
		||||
        , class "mb-2"
 | 
			
		||||
        ]
 | 
			
		||||
        [ case model.formState of
 | 
			
		||||
            SubmitSuccessful ->
 | 
			
		||||
                text texts.submitSuccessful
 | 
			
		||||
 | 
			
		||||
            SubmitError err ->
 | 
			
		||||
                text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
            SubmitFailed m ->
 | 
			
		||||
                text m
 | 
			
		||||
 | 
			
		||||
            InitialState ->
 | 
			
		||||
                text ""
 | 
			
		||||
        ]
 | 
			
		||||
    , Html.map SettingsFormMsg
 | 
			
		||||
        (Comp.CollectiveSettingsForm.view2
 | 
			
		||||
            flags
 | 
			
		||||
@@ -256,23 +276,4 @@ viewSettings texts flags settings model =
 | 
			
		||||
            settings
 | 
			
		||||
            model.settingsModel
 | 
			
		||||
        )
 | 
			
		||||
    , div
 | 
			
		||||
        [ classList
 | 
			
		||||
            [ ( "hidden", Util.Maybe.isEmpty model.submitResult )
 | 
			
		||||
            , ( S.successMessage
 | 
			
		||||
              , Maybe.map .success model.submitResult
 | 
			
		||||
                    |> Maybe.withDefault False
 | 
			
		||||
              )
 | 
			
		||||
            , ( S.errorMessage
 | 
			
		||||
              , Maybe.map .success model.submitResult
 | 
			
		||||
                    |> Maybe.map not
 | 
			
		||||
                    |> Maybe.withDefault False
 | 
			
		||||
              )
 | 
			
		||||
            ]
 | 
			
		||||
        , class "mt-2"
 | 
			
		||||
        ]
 | 
			
		||||
        [ Maybe.map .message model.submitResult
 | 
			
		||||
            |> Maybe.withDefault ""
 | 
			
		||||
            |> text
 | 
			
		||||
        ]
 | 
			
		||||
    ]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
module Page.Login.Data exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    ( FormState(..)
 | 
			
		||||
    , Model
 | 
			
		||||
    , Msg(..)
 | 
			
		||||
    , emptyModel
 | 
			
		||||
    )
 | 
			
		||||
@@ -13,16 +14,23 @@ type alias Model =
 | 
			
		||||
    { username : String
 | 
			
		||||
    , password : String
 | 
			
		||||
    , rememberMe : Bool
 | 
			
		||||
    , result : Maybe AuthResult
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = AuthSuccess AuthResult
 | 
			
		||||
    | AuthFailed AuthResult
 | 
			
		||||
    | HttpError Http.Error
 | 
			
		||||
    | FormInitial
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    { username = ""
 | 
			
		||||
    , password = ""
 | 
			
		||||
    , rememberMe = False
 | 
			
		||||
    , result = Nothing
 | 
			
		||||
    , formState = FormInitial
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,6 @@ import Data.Flags exposing (Flags)
 | 
			
		||||
import Page exposing (Page(..))
 | 
			
		||||
import Page.Login.Data exposing (..)
 | 
			
		||||
import Ports
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Maybe Page -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe AuthResult )
 | 
			
		||||
@@ -37,13 +36,13 @@ update referrer flags msg model =
 | 
			
		||||
                    Maybe.withDefault HomePage referrer |> Page.goto
 | 
			
		||||
            in
 | 
			
		||||
            if lr.success then
 | 
			
		||||
                ( { model | result = Just lr, password = "" }
 | 
			
		||||
                ( { model | formState = AuthSuccess lr, password = "" }
 | 
			
		||||
                , Cmd.batch [ setAccount lr, gotoRef ]
 | 
			
		||||
                , Just lr
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | result = Just lr, password = "" }
 | 
			
		||||
                ( { model | formState = AuthFailed lr, password = "" }
 | 
			
		||||
                , Ports.removeAccount ()
 | 
			
		||||
                , Just lr
 | 
			
		||||
                )
 | 
			
		||||
@@ -52,11 +51,11 @@ update referrer flags msg model =
 | 
			
		||||
            let
 | 
			
		||||
                empty =
 | 
			
		||||
                    Api.Model.AuthResult.empty
 | 
			
		||||
 | 
			
		||||
                lr =
 | 
			
		||||
                    { empty | message = Util.Http.errorToString err }
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | password = "", result = Just lr }, Ports.removeAccount (), Just empty )
 | 
			
		||||
            ( { model | password = "", formState = HttpError err }
 | 
			
		||||
            , Ports.removeAccount ()
 | 
			
		||||
            , Just empty
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
setAccount : AuthResult -> Cmd msg
 | 
			
		||||
 
 | 
			
		||||
@@ -158,17 +158,21 @@ viewContent texts flags versionInfo _ model =
 | 
			
		||||
 | 
			
		||||
resultMessage : Texts -> Model -> Html Msg
 | 
			
		||||
resultMessage texts model =
 | 
			
		||||
    case model.result of
 | 
			
		||||
        Just r ->
 | 
			
		||||
            if r.success then
 | 
			
		||||
                div [ class ("my-2" ++ S.successMessage) ]
 | 
			
		||||
                    [ text texts.loginSuccessful
 | 
			
		||||
                    ]
 | 
			
		||||
    case model.formState of
 | 
			
		||||
        AuthSuccess _ ->
 | 
			
		||||
            div [ class ("my-2" ++ S.successMessage) ]
 | 
			
		||||
                [ text texts.loginSuccessful
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                div [ class ("my-2" ++ S.errorMessage) ]
 | 
			
		||||
                    [ text r.message
 | 
			
		||||
                    ]
 | 
			
		||||
        AuthFailed r ->
 | 
			
		||||
            div [ class ("my-2" ++ S.errorMessage) ]
 | 
			
		||||
                [ text r.message
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
        Nothing ->
 | 
			
		||||
        HttpError err ->
 | 
			
		||||
            div [ class ("my-2" ++ S.errorMessage) ]
 | 
			
		||||
                [ text (texts.httpError err)
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
        FormInitial ->
 | 
			
		||||
            span [ class "hidden" ] []
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,8 @@ type alias Model =
 | 
			
		||||
 | 
			
		||||
type State
 | 
			
		||||
    = Empty
 | 
			
		||||
    | Failed String
 | 
			
		||||
    | Failed Http.Error
 | 
			
		||||
    | GenericFail String
 | 
			
		||||
    | Success InviteResult
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -29,6 +30,9 @@ isFailed state =
 | 
			
		||||
        Failed _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        GenericFail _ ->
 | 
			
		||||
            True
 | 
			
		||||
 | 
			
		||||
        _ ->
 | 
			
		||||
            False
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import Api
 | 
			
		||||
import Api.Model.GenInvite exposing (GenInvite)
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Page.NewInvite.Data exposing (..)
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
 | 
			
		||||
@@ -24,7 +23,7 @@ update flags msg model =
 | 
			
		||||
                ( { model | result = Success res }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                ( { model | result = Failed res.message }, Cmd.none )
 | 
			
		||||
                ( { model | result = GenericFail res.message }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        InviteResp (Err err) ->
 | 
			
		||||
            ( { model | result = Failed (Util.Http.errorToString err) }, Cmd.none )
 | 
			
		||||
            ( { model | result = Failed err }, Cmd.none )
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,11 @@ viewContent texts flags _ model =
 | 
			
		||||
                        [ text texts.invitationKey
 | 
			
		||||
                        ]
 | 
			
		||||
                    , div [ class "relative" ]
 | 
			
		||||
                        [ div [ class "inline-flex items-center justify-center absolute left-0 top-0 h-full w-10 text-gray-400 dark:text-bluegray-400  " ]
 | 
			
		||||
                        [ div
 | 
			
		||||
                            [ class "inline-flex items-center justify-center"
 | 
			
		||||
                            , class "absolute left-0 top-0 h-full w-10"
 | 
			
		||||
                            , class "text-gray-400 dark:text-bluegray-400"
 | 
			
		||||
                            ]
 | 
			
		||||
                            [ i [ class "fa fa-key" ] []
 | 
			
		||||
                            ]
 | 
			
		||||
                        , input
 | 
			
		||||
@@ -93,13 +97,16 @@ resultMessage texts model =
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        [ case model.result of
 | 
			
		||||
            Failed m ->
 | 
			
		||||
                p [] [ text m ]
 | 
			
		||||
            Failed err ->
 | 
			
		||||
                text (texts.httpError err)
 | 
			
		||||
 | 
			
		||||
            GenericFail m ->
 | 
			
		||||
                text m
 | 
			
		||||
 | 
			
		||||
            Success r ->
 | 
			
		||||
                div [ class "" ]
 | 
			
		||||
                    [ p []
 | 
			
		||||
                        [ text r.message
 | 
			
		||||
                        [ text texts.newInvitationCreated
 | 
			
		||||
                        , text (" " ++ texts.invitationKey ++ ":")
 | 
			
		||||
                        ]
 | 
			
		||||
                    , pre [ class "text-center font-mono mt-4" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
module Page.Queue.Data exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    ( FormState(..)
 | 
			
		||||
    , Model
 | 
			
		||||
    , Msg(..)
 | 
			
		||||
    , QueueView(..)
 | 
			
		||||
    , emptyModel
 | 
			
		||||
@@ -20,7 +21,7 @@ import Util.Maybe
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { state : JobQueueState
 | 
			
		||||
    , error : String
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    , pollingInterval : Float
 | 
			
		||||
    , init : Bool
 | 
			
		||||
    , stopRefresh : Bool
 | 
			
		||||
@@ -32,6 +33,11 @@ type alias Model =
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = InitialForm
 | 
			
		||||
    | HttpError Http.Error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type QueueView
 | 
			
		||||
    = CurrentJobs
 | 
			
		||||
    | QueueAll
 | 
			
		||||
@@ -44,7 +50,7 @@ type QueueView
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    { state = Api.Model.JobQueueState.empty
 | 
			
		||||
    , error = ""
 | 
			
		||||
    , formState = InitialForm
 | 
			
		||||
    , pollingInterval = 1200
 | 
			
		||||
    , init = False
 | 
			
		||||
    , stopRefresh = False
 | 
			
		||||
 
 | 
			
		||||
@@ -4,10 +4,8 @@ import Api
 | 
			
		||||
import Comp.YesNoDimmer
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Page.Queue.Data exposing (..)
 | 
			
		||||
import Ports
 | 
			
		||||
import Task
 | 
			
		||||
import Time
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
 | 
			
		||||
@@ -42,7 +40,7 @@ update flags msg model =
 | 
			
		||||
            ( { model | state = s, stopRefresh = False }, refresh )
 | 
			
		||||
 | 
			
		||||
        StateResp (Err err) ->
 | 
			
		||||
            ( { model | error = Util.Http.errorToString err }, Cmd.none )
 | 
			
		||||
            ( { model | formState = HttpError err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        StopRefresh ->
 | 
			
		||||
            ( { model | stopRefresh = True, init = False }, Cmd.none )
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
module Page.Register.Data exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    ( FormState(..)
 | 
			
		||||
    , Model
 | 
			
		||||
    , Msg(..)
 | 
			
		||||
    , emptyModel
 | 
			
		||||
    )
 | 
			
		||||
@@ -9,31 +10,36 @@ import Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias Model =
 | 
			
		||||
    { result : Maybe BasicResult
 | 
			
		||||
    , collId : String
 | 
			
		||||
    { collId : String
 | 
			
		||||
    , login : String
 | 
			
		||||
    , pass1 : String
 | 
			
		||||
    , pass2 : String
 | 
			
		||||
    , showPass1 : Bool
 | 
			
		||||
    , showPass2 : Bool
 | 
			
		||||
    , errorMsg : List String
 | 
			
		||||
    , formState : FormState
 | 
			
		||||
    , loading : Bool
 | 
			
		||||
    , successMsg : String
 | 
			
		||||
    , invite : Maybe String
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type FormState
 | 
			
		||||
    = HttpError Http.Error
 | 
			
		||||
    | GenericError String
 | 
			
		||||
    | RegistrationSuccessful
 | 
			
		||||
    | PasswordMismatch
 | 
			
		||||
    | InputValid
 | 
			
		||||
    | FormEmpty
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
emptyModel : Model
 | 
			
		||||
emptyModel =
 | 
			
		||||
    { result = Nothing
 | 
			
		||||
    , collId = ""
 | 
			
		||||
    { collId = ""
 | 
			
		||||
    , login = ""
 | 
			
		||||
    , pass1 = ""
 | 
			
		||||
    , pass2 = ""
 | 
			
		||||
    , showPass1 = False
 | 
			
		||||
    , showPass2 = False
 | 
			
		||||
    , errorMsg = []
 | 
			
		||||
    , successMsg = ""
 | 
			
		||||
    , formState = FormEmpty
 | 
			
		||||
    , loading = False
 | 
			
		||||
    , invite = Nothing
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,17 @@
 | 
			
		||||
module Page.Register.Update exposing (update)
 | 
			
		||||
 | 
			
		||||
import Api
 | 
			
		||||
import Api.Model.BasicResult exposing (BasicResult)
 | 
			
		||||
import Data.Flags exposing (Flags)
 | 
			
		||||
import Page exposing (Page(..))
 | 
			
		||||
import Page.Register.Data exposing (..)
 | 
			
		||||
import Util.Http
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
 | 
			
		||||
update flags msg model =
 | 
			
		||||
    case msg of
 | 
			
		||||
        RegisterSubmit ->
 | 
			
		||||
            case model.errorMsg of
 | 
			
		||||
                [] ->
 | 
			
		||||
            case model.formState of
 | 
			
		||||
                InputValid ->
 | 
			
		||||
                    let
 | 
			
		||||
                        reg =
 | 
			
		||||
                            { collectiveName = model.collId
 | 
			
		||||
@@ -35,7 +33,7 @@ update flags msg model =
 | 
			
		||||
                err =
 | 
			
		||||
                    validateForm m
 | 
			
		||||
            in
 | 
			
		||||
            ( { m | errorMsg = err }, Cmd.none )
 | 
			
		||||
            ( { m | formState = err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SetLogin str ->
 | 
			
		||||
            let
 | 
			
		||||
@@ -45,7 +43,7 @@ update flags msg model =
 | 
			
		||||
                err =
 | 
			
		||||
                    validateForm m
 | 
			
		||||
            in
 | 
			
		||||
            ( { m | errorMsg = err }, Cmd.none )
 | 
			
		||||
            ( { m | formState = err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SetPass1 str ->
 | 
			
		||||
            let
 | 
			
		||||
@@ -55,7 +53,7 @@ update flags msg model =
 | 
			
		||||
                err =
 | 
			
		||||
                    validateForm m
 | 
			
		||||
            in
 | 
			
		||||
            ( { m | errorMsg = err }, Cmd.none )
 | 
			
		||||
            ( { m | formState = err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SetPass2 str ->
 | 
			
		||||
            let
 | 
			
		||||
@@ -65,7 +63,7 @@ update flags msg model =
 | 
			
		||||
                err =
 | 
			
		||||
                    validateForm m
 | 
			
		||||
            in
 | 
			
		||||
            ( { m | errorMsg = err }, Cmd.none )
 | 
			
		||||
            ( { m | formState = err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
        SetInvite str ->
 | 
			
		||||
            ( { model
 | 
			
		||||
@@ -98,29 +96,21 @@ update flags msg model =
 | 
			
		||||
                        Cmd.none
 | 
			
		||||
            in
 | 
			
		||||
            ( { m
 | 
			
		||||
                | result =
 | 
			
		||||
                | formState =
 | 
			
		||||
                    if r.success then
 | 
			
		||||
                        Nothing
 | 
			
		||||
                        RegistrationSuccessful
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        Just r
 | 
			
		||||
                        GenericError r.message
 | 
			
		||||
              }
 | 
			
		||||
            , cmd
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        SubmitResp (Err err) ->
 | 
			
		||||
            let
 | 
			
		||||
                errMsg =
 | 
			
		||||
                    Util.Http.errorToString err
 | 
			
		||||
 | 
			
		||||
                res =
 | 
			
		||||
                    BasicResult False
 | 
			
		||||
                        (errMsg ++ " Please check the form and try again.")
 | 
			
		||||
            in
 | 
			
		||||
            ( { model | result = Just res }, Cmd.none )
 | 
			
		||||
            ( { model | formState = HttpError err }, Cmd.none )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
validateForm : Model -> List String
 | 
			
		||||
validateForm : Model -> FormState
 | 
			
		||||
validateForm model =
 | 
			
		||||
    if
 | 
			
		||||
        model.collId
 | 
			
		||||
@@ -132,10 +122,10 @@ validateForm model =
 | 
			
		||||
            || model.pass2
 | 
			
		||||
            == ""
 | 
			
		||||
    then
 | 
			
		||||
        [ "All fields are required!" ]
 | 
			
		||||
        FormEmpty
 | 
			
		||||
 | 
			
		||||
    else if model.pass1 /= model.pass2 then
 | 
			
		||||
        [ "The passwords do not match." ]
 | 
			
		||||
        PasswordMismatch
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        []
 | 
			
		||||
        InputValid
 | 
			
		||||
 
 | 
			
		||||
@@ -239,22 +239,32 @@ viewContent texts flags _ model =
 | 
			
		||||
 | 
			
		||||
resultMessage : Texts -> Model -> Html Msg
 | 
			
		||||
resultMessage texts model =
 | 
			
		||||
    case model.result of
 | 
			
		||||
        Just r ->
 | 
			
		||||
            if r.success then
 | 
			
		||||
                div [ class S.successMessage ]
 | 
			
		||||
                    [ text texts.registrationSuccessful
 | 
			
		||||
                    ]
 | 
			
		||||
    case model.formState of
 | 
			
		||||
        InputValid ->
 | 
			
		||||
            div [ class "hidden" ]
 | 
			
		||||
                []
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                div [ class S.errorMessage ]
 | 
			
		||||
                    [ text r.message
 | 
			
		||||
                    ]
 | 
			
		||||
        RegistrationSuccessful ->
 | 
			
		||||
            div [ class S.successMessage ]
 | 
			
		||||
                [ text texts.registrationSuccessful
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
        Nothing ->
 | 
			
		||||
            if List.isEmpty model.errorMsg then
 | 
			
		||||
                span [ class "hidden" ] []
 | 
			
		||||
        PasswordMismatch ->
 | 
			
		||||
            div [ class S.errorMessage ]
 | 
			
		||||
                [ text texts.passwordsDontMatch
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                div [ class S.errorMessage ]
 | 
			
		||||
                    (List.map (\s -> div [] [ text s ]) model.errorMsg)
 | 
			
		||||
        GenericError m ->
 | 
			
		||||
            div [ class S.errorMessage ]
 | 
			
		||||
                [ text m
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
        FormEmpty ->
 | 
			
		||||
            div [ class S.errorMessage ]
 | 
			
		||||
                [ text texts.allFieldsRequired
 | 
			
		||||
                ]
 | 
			
		||||
 | 
			
		||||
        HttpError err ->
 | 
			
		||||
            div [ class S.errorMessage ]
 | 
			
		||||
                [ text (texts.httpError err)
 | 
			
		||||
                ]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
module Util.CustomField exposing
 | 
			
		||||
    ( nameOrLabel
 | 
			
		||||
    , renderValue
 | 
			
		||||
    , renderValue1
 | 
			
		||||
    , renderValue2
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
@@ -20,43 +19,7 @@ nameOrLabel fv =
 | 
			
		||||
 | 
			
		||||
renderValue : String -> ItemFieldValue -> Html msg
 | 
			
		||||
renderValue classes cv =
 | 
			
		||||
    renderValue1 [ ( classes, True ) ] Nothing cv
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderValue1 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg
 | 
			
		||||
renderValue1 classes tagger cv =
 | 
			
		||||
    let
 | 
			
		||||
        renderBool =
 | 
			
		||||
            if cv.value == "true" then
 | 
			
		||||
                i [ class "check icon" ] []
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                i [ class "minus icon" ] []
 | 
			
		||||
 | 
			
		||||
        el : List (Html msg) -> Html msg
 | 
			
		||||
        el =
 | 
			
		||||
            case tagger of
 | 
			
		||||
                Just t ->
 | 
			
		||||
                    a
 | 
			
		||||
                        [ classList classes
 | 
			
		||||
                        , onClick t
 | 
			
		||||
                        , href "#"
 | 
			
		||||
                        ]
 | 
			
		||||
 | 
			
		||||
                Nothing ->
 | 
			
		||||
                    div [ classList classes ]
 | 
			
		||||
    in
 | 
			
		||||
    el
 | 
			
		||||
        [ Icons.customFieldTypeIconString "" cv.ftype
 | 
			
		||||
        , nameOrLabel cv |> text
 | 
			
		||||
        , div [ class "detail" ]
 | 
			
		||||
            [ if Data.CustomFieldType.fromString cv.ftype == Just Data.CustomFieldType.Boolean then
 | 
			
		||||
                renderBool
 | 
			
		||||
 | 
			
		||||
              else
 | 
			
		||||
                text cv.value
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
    renderValue2 [ ( classes, True ) ] Nothing cv
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
renderValue2 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg
 | 
			
		||||
 
 | 
			
		||||
@@ -1,97 +0,0 @@
 | 
			
		||||
module Util.ExpandCollapse exposing
 | 
			
		||||
    ( collapseToggle
 | 
			
		||||
    , collapseToggle2
 | 
			
		||||
    , expandToggle
 | 
			
		||||
    , expandToggle2
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
import Html exposing (..)
 | 
			
		||||
import Html.Attributes exposing (..)
 | 
			
		||||
import Html.Events exposing (onClick)
 | 
			
		||||
import Styles as S
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
expandToggle : Int -> Int -> msg -> List (Html msg)
 | 
			
		||||
expandToggle max all m =
 | 
			
		||||
    if max >= all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class "item"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "angle down icon" ] []
 | 
			
		||||
            , div [ class "content" ]
 | 
			
		||||
                [ div [ class "description" ]
 | 
			
		||||
                    [ em [] [ text "Show More …" ]
 | 
			
		||||
                    ]
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
collapseToggle : Int -> Int -> msg -> List (Html msg)
 | 
			
		||||
collapseToggle max all m =
 | 
			
		||||
    if max >= all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class "item"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "angle up icon" ] []
 | 
			
		||||
            , div [ class "content" ]
 | 
			
		||||
                [ div [ class "description" ]
 | 
			
		||||
                    [ em [] [ text "Show Less …" ]
 | 
			
		||||
                    ]
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--- View2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
expandToggle2 : Int -> Int -> msg -> List (Html msg)
 | 
			
		||||
expandToggle2 max all m =
 | 
			
		||||
    if max >= all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class S.link
 | 
			
		||||
            , class "flex flex-row items-center"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "fa fa-angle-down" ] []
 | 
			
		||||
            , div [ class "font-italics text-sm ml-2" ]
 | 
			
		||||
                [ text "Show More …"
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
collapseToggle2 : Int -> Int -> msg -> List (Html msg)
 | 
			
		||||
collapseToggle2 max all m =
 | 
			
		||||
    if max >= all then
 | 
			
		||||
        []
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        [ a
 | 
			
		||||
            [ class S.link
 | 
			
		||||
            , class "flex flex-row items-center"
 | 
			
		||||
            , onClick m
 | 
			
		||||
            , href "#"
 | 
			
		||||
            ]
 | 
			
		||||
            [ i [ class "fa fa-angle-up" ] []
 | 
			
		||||
            , div [ class "font-italics text-sm ml-2" ]
 | 
			
		||||
                [ text "Show Less …"
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
module Util.Html exposing
 | 
			
		||||
    ( KeyCode(..)
 | 
			
		||||
    , checkbox
 | 
			
		||||
    , checkbox2
 | 
			
		||||
    , classActive
 | 
			
		||||
    , intToKeyCode
 | 
			
		||||
@@ -22,25 +21,6 @@ import Html.Events exposing (keyCode, on, preventDefaultOn)
 | 
			
		||||
import Json.Decode as D
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
checkboxChecked : Html msg
 | 
			
		||||
checkboxChecked =
 | 
			
		||||
    i [ class "ui check square outline icon" ] []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
checkboxUnchecked : Html msg
 | 
			
		||||
checkboxUnchecked =
 | 
			
		||||
    i [ class "ui square outline icon" ] []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
checkbox : Bool -> Html msg
 | 
			
		||||
checkbox flag =
 | 
			
		||||
    if flag then
 | 
			
		||||
        checkboxChecked
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
        checkboxUnchecked
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
checkbox2 : Bool -> Html msg
 | 
			
		||||
checkbox2 flag =
 | 
			
		||||
    if flag then
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ module Util.Http exposing
 | 
			
		||||
    , authPostTrack
 | 
			
		||||
    , authPut
 | 
			
		||||
    , authTask
 | 
			
		||||
    , errorToString
 | 
			
		||||
    , executeIn
 | 
			
		||||
    , jsonResolver
 | 
			
		||||
    )
 | 
			
		||||
@@ -138,45 +137,6 @@ authDelete req =
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Error Utilities
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
errorToStringStatus : Http.Error -> (Int -> String) -> String
 | 
			
		||||
errorToStringStatus error statusString =
 | 
			
		||||
    case error of
 | 
			
		||||
        Http.BadUrl url ->
 | 
			
		||||
            "There is something wrong with this url: " ++ url
 | 
			
		||||
 | 
			
		||||
        Http.Timeout ->
 | 
			
		||||
            "There was a network timeout."
 | 
			
		||||
 | 
			
		||||
        Http.NetworkError ->
 | 
			
		||||
            "There was a network error."
 | 
			
		||||
 | 
			
		||||
        Http.BadStatus status ->
 | 
			
		||||
            statusString status
 | 
			
		||||
 | 
			
		||||
        Http.BadBody str ->
 | 
			
		||||
            "There was an error decoding the response: " ++ str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
errorToString : Http.Error -> String
 | 
			
		||||
errorToString error =
 | 
			
		||||
    let
 | 
			
		||||
        f sc =
 | 
			
		||||
            if sc == 404 then
 | 
			
		||||
                "The requested resource doesn't exist."
 | 
			
		||||
 | 
			
		||||
            else if sc >= 400 && sc < 500 then
 | 
			
		||||
                "Invalid input when processing the request."
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                "There was an invalid response status: " ++ String.fromInt sc ++ "."
 | 
			
		||||
    in
 | 
			
		||||
    errorToStringStatus error f
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Http.Task Utilities
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								modules/webapp/src/main/elm/Util/Result.elm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								modules/webapp/src/main/elm/Util/Result.elm
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
module Util.Result exposing (fold)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fold : (a -> x) -> (b -> x) -> Result b a -> x
 | 
			
		||||
fold fa fb rba =
 | 
			
		||||
    case rba of
 | 
			
		||||
        Ok a ->
 | 
			
		||||
            fa a
 | 
			
		||||
 | 
			
		||||
        Err b ->
 | 
			
		||||
            fb b
 | 
			
		||||
		Reference in New Issue
	
	Block a user