Merge pull request #784 from eikek/missing-string

Missing string
This commit is contained in:
mergify[bot] 2021-04-26 20:33:26 +00:00 committed by GitHub
commit 8cfe9cd478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 1915 additions and 1027 deletions

View File

@ -17,7 +17,6 @@ import Html.Attributes exposing (..)
import Http import Http
import Messages.Comp.AttachmentMeta exposing (Texts) import Messages.Comp.AttachmentMeta exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
@ -29,7 +28,7 @@ type alias Model =
type DataResult a type DataResult a
= NotAvailable = NotAvailable
| Success a | Success a
| Failure String | HttpFailure Http.Error
emptyModel : Model emptyModel : Model
@ -57,7 +56,7 @@ update msg model =
{ model | meta = Success am } { model | meta = Success am }
MetaResp (Err err) -> 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 , label = texts.basics.loading
} }
Failure msg -> HttpFailure err ->
div [ class S.errorMessage ] div [ class S.errorMessage ]
[ text msg [ text (texts.httpError err)
] ]
Success data -> Success data ->

View File

@ -2,7 +2,6 @@ module Comp.CalEventInput exposing
( Model ( Model
, Msg , Msg
, init , init
, initDefault
, update , update
, view2 , view2
) )
@ -19,12 +18,25 @@ import Html.Events exposing (onInput)
import Http import Http
import Messages.Comp.CalEventInput exposing (Texts) import Messages.Comp.CalEventInput exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
type alias Model = 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) | CheckInputMsg CalEvent (Result Http.Error CalEventCheckResult)
initDefault : Model
initDefault =
Model Nothing
init : Flags -> CalEvent -> ( Model, Cmd Msg ) init : Flags -> CalEvent -> ( Model, Cmd Msg )
init flags ev = 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 checkInput : Flags -> CalEvent -> Cmd Msg
@ -60,20 +81,33 @@ checkInput flags ev =
Api.checkCalEvent flags input (CheckInputMsg 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 = withCheckInput flags ev model =
( model, checkInput flags ev, Unknown ev ) ( model, checkInput flags ev, Nothing )
isCheckError : Model -> Bool isCheckError : Model -> Bool
isCheckError model = isCheckError model =
Maybe.map .success model.checkResult case model.checkResult of
|> Maybe.withDefault True CheckResultOk _ ->
|> not False
CheckResultFailed _ ->
True
CheckResultHttpError _ ->
True
CheckResultInitial ->
False
update : Flags -> CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Validated CalEvent ) update : Flags -> Maybe CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Maybe CalEvent )
update flags ev msg model = update flags mev msg model =
let
ev =
Maybe.withDefault model.inner mev
in
case msg of case msg of
SetYear str -> SetYear str ->
withCheckInput flags { ev | year = str } model withCheckInput flags { ev | year = str } model
@ -96,42 +130,49 @@ update flags ev msg model =
CheckInputMsg event (Ok res) -> CheckInputMsg event (Ok res) ->
let let
m = 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 in
( m ( m
, Cmd.none , Cmd.none
, if res.success then , if res.success then
Valid event Just event
else else
Invalid [ res.message ] event Nothing
) )
CheckInputMsg event (Err err) -> CheckInputMsg event (Err err) ->
let let
emptyResult =
Api.Model.CalEventCheckResult.empty
m = m =
{ model { model
| checkResult = | checkResult = CheckResultHttpError err
Just , inner = event
{ emptyResult
| success = False
, message = Util.Http.errorToString err
}
} }
in in
( m, Cmd.none, Unknown event ) ( m, Cmd.none, Nothing )
--- View2 --- View2
view2 : Texts -> String -> CalEvent -> Model -> Html Msg view2 : Texts -> String -> Maybe CalEvent -> Model -> Html Msg
view2 texts extraClasses ev model = view2 texts extraClasses mev model =
let let
ev =
Maybe.withDefault model.inner mev
yearLen = yearLen =
Basics.max 4 (String.length ev.year) Basics.max 4 (String.length ev.year)
@ -255,17 +296,21 @@ view2 texts extraClasses ev model =
, class S.errorMessage , class S.errorMessage
] ]
[ text (texts.error ++ ": ") [ text (texts.error ++ ": ")
, Maybe.map .message model.checkResult , case model.checkResult of
|> Maybe.withDefault "" CheckResultOk _ ->
|> text text ""
CheckResultFailed str ->
text str
CheckResultHttpError err ->
text (texts.httpError err)
CheckResultInitial ->
text ""
] ]
, div , div
[ classList [ class "px-2 pt-4 pb-2 border-0 border-l border-b border-r bg-gray-50 dark:bg-bluegray-700"
[ ( "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 S.border , class S.border
] ]
[ div [] [ div []
@ -273,7 +318,8 @@ view2 texts extraClasses ev model =
[ text (texts.schedule ++ ": ") [ text (texts.schedule ++ ": ")
] ]
, div [ class "px-12 font-mono " ] , div [ class "px-12 font-mono " ]
[ Maybe.andThen .event model.checkResult [ eventData model
|> Maybe.andThen .eventString
|> Maybe.withDefault "" |> Maybe.withDefault ""
|> text |> text
] ]
@ -281,7 +327,8 @@ view2 texts extraClasses ev model =
[ text (texts.next ++ ": ") [ text (texts.next ++ ": ")
] ]
, ul [ class "list-decimal list-inside text-sm" ] , ul [ class "list-decimal list-inside text-sm" ]
(Maybe.map .next model.checkResult (eventData model
|> Maybe.map .nextEvents
|> Maybe.withDefault [] |> Maybe.withDefault []
|> List.map texts.formatDateTime |> List.map texts.formatDateTime
|> List.map (\s -> li [ class "" ] [ text s ]) |> List.map (\s -> li [ class "" ] [ text s ])

View File

@ -18,7 +18,6 @@ import Html.Events exposing (onClick)
import Http import Http
import Messages.Comp.ChangePasswordForm exposing (Texts) import Messages.Comp.ChangePasswordForm exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
@ -28,12 +27,20 @@ type alias Model =
, newPass1 : Maybe String , newPass1 : Maybe String
, pass2Model : Comp.PasswordInput.Model , pass2Model : Comp.PasswordInput.Model
, newPass2 : Maybe String , newPass2 : Maybe String
, errors : List String , formState : FormState
, loading : Bool , loading : Bool
, successMsg : String
} }
type FormState
= FormStateNone
| FormStateHttpError Http.Error
| FormStateSubmitOk
| FormStateRequiredMissing
| FormStatePasswordMismatch
| FormStateSubmitError String
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
validateModel validateModel
@ -43,9 +50,8 @@ emptyModel =
, pass1Model = Comp.PasswordInput.init , pass1Model = Comp.PasswordInput.init
, newPass2 = Nothing , newPass2 = Nothing
, pass2Model = Comp.PasswordInput.init , pass2Model = Comp.PasswordInput.init
, errors = []
, loading = False , loading = False
, successMsg = "" , formState = FormStateNone
} }
@ -57,37 +63,21 @@ type Msg
| SubmitResp (Result Http.Error BasicResult) | SubmitResp (Result Http.Error BasicResult)
validate : Model -> List String validate : Model -> FormState
validate model = validate model =
List.concat if model.newPass1 /= Nothing && model.newPass2 /= Nothing && model.newPass1 /= model.newPass2 then
[ if model.newPass1 /= Nothing && model.newPass2 /= Nothing && model.newPass1 /= model.newPass2 then FormStatePasswordMismatch
[ "New passwords do not match." ]
else if model.newPass1 == Nothing || model.newPass2 == Nothing || model.current == Nothing then
FormStateRequiredMissing
else else
[] FormStateNone
, if model.newPass1 == Nothing || model.newPass2 == Nothing || model.current == Nothing then
[ "Please fill in required fields." ]
else
[]
]
validateModel : Model -> Model validateModel : Model -> Model
validateModel model = validateModel model =
let { model | formState = validate model }
err =
validate model
in
{ model
| errors = err
, successMsg =
if err == [] then
model.successMsg
else
""
}
@ -126,7 +116,7 @@ update flags msg model =
Submit -> Submit ->
let let
valid = state =
validate model validate model
cp = cp =
@ -134,43 +124,34 @@ update flags msg model =
(Maybe.withDefault "" model.current) (Maybe.withDefault "" model.current)
(Maybe.withDefault "" model.newPass1) (Maybe.withDefault "" model.newPass1)
in in
if List.isEmpty valid then if state == FormStateNone then
( { model | loading = True, errors = [], successMsg = "" } ( { model | loading = True, formState = state }
, Api.changePassword flags cp SubmitResp , Api.changePassword flags cp SubmitResp
) )
else else
( model, Cmd.none ) ( { model | formState = state }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
let let
em = em =
{ emptyModel { emptyModel | formState = FormStateSubmitOk }
| errors = []
, successMsg = "Password has been changed."
}
in in
if res.success then if res.success then
( em, Cmd.none ) ( em, Cmd.none )
else else
( { model ( { model
| errors = [ res.message ] | formState = FormStateSubmitError res.message
, loading = False , loading = False
, successMsg = ""
} }
, Cmd.none , Cmd.none
) )
SubmitResp (Err err) -> SubmitResp (Err err) ->
let
str =
Util.Http.errorToString err
in
( { model ( { model
| errors = [ str ] | formState = FormStateHttpError err
, loading = False , loading = False
, successMsg = ""
} }
, Cmd.none , Cmd.none
) )
@ -235,29 +216,7 @@ view2 texts model =
model.pass2Model model.pass2Model
) )
] ]
, div , renderResultMessage texts model
[ 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)
]
, div [ class "flex flex-row" ] , div [ class "flex flex-row" ]
[ button [ button
[ class S.primaryButton [ class S.primaryButton
@ -272,3 +231,33 @@ view2 texts model =
, label = texts.basics.loading , 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
]

View File

@ -19,7 +19,6 @@ import Data.DropdownStyle as DS
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.ListType exposing (ListType) import Data.ListType exposing (ListType)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Data.Validated exposing (Validated(..))
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Http import Http
@ -31,7 +30,7 @@ import Util.Tag
type alias Model = type alias Model =
{ scheduleModel : Comp.CalEventInput.Model { scheduleModel : Comp.CalEventInput.Model
, schedule : Validated CalEvent , schedule : Maybe CalEvent
, itemCountModel : Comp.IntField.Model , itemCountModel : Comp.IntField.Model
, itemCount : Maybe Int , itemCount : Maybe Int
, categoryListModel : Comp.Dropdown.Model String , categoryListModel : Comp.Dropdown.Model String
@ -59,7 +58,7 @@ init flags sett =
Comp.CalEventInput.init flags newSchedule Comp.CalEventInput.init flags newSchedule
in in
( { scheduleModel = cem ( { scheduleModel = cem
, schedule = Data.Validated.Unknown newSchedule , schedule = Just newSchedule
, itemCountModel = Comp.IntField.init (Just 0) Nothing True , itemCountModel = Comp.IntField.init (Just 0) Nothing True
, itemCount = Just sett.itemCount , itemCount = Just sett.itemCount
, categoryListModel = , categoryListModel =
@ -90,12 +89,12 @@ init flags sett =
) )
getSettings : Model -> Validated ClassifierSetting getSettings : Model -> Maybe ClassifierSetting
getSettings model = getSettings model =
Data.Validated.map Maybe.map
(\sch -> (\s ->
{ schedule = { schedule =
Data.CalEvent.makeEvent sch Data.CalEvent.makeEvent s
, itemCount = Maybe.withDefault 0 model.itemCount , itemCount = Maybe.withDefault 0 model.itemCount
, listType = Data.ListType.toString model.categoryListType , listType = Data.ListType.toString model.categoryListType
, categoryList = Comp.Dropdown.getSelected model.categoryListModel , categoryList = Comp.Dropdown.getSelected model.categoryListModel
@ -126,7 +125,7 @@ update flags msg model =
( cm, cc, ce ) = ( cm, cc, ce ) =
Comp.CalEventInput.update Comp.CalEventInput.update
flags flags
(Data.Validated.value model.schedule) model.schedule
lmsg lmsg
model.scheduleModel model.scheduleModel
in in
@ -240,7 +239,7 @@ view2 texts settings model =
(Comp.CalEventInput.view2 (Comp.CalEventInput.view2
texts.calEventInput texts.calEventInput
"" ""
(Data.Validated.value model.schedule) model.schedule
model.scheduleModel model.scheduleModel
) )
] ]

View File

@ -18,14 +18,12 @@ import Data.DropdownStyle as DS
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.Language exposing (Language) import Data.Language exposing (Language)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Data.Validated exposing (Validated)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput) import Html.Events exposing (onCheck, onClick, onInput)
import Http import Http
import Messages.Comp.CollectiveSettingsForm exposing (Texts) import Messages.Comp.CollectiveSettingsForm exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
@ -33,12 +31,27 @@ type alias Model =
, intEnabled : Bool , intEnabled : Bool
, initSettings : CollectiveSettings , initSettings : CollectiveSettings
, fullTextConfirmText : String , fullTextConfirmText : String
, fullTextReIndexResult : Maybe BasicResult , fullTextReIndexResult : FulltextReindexResult
, classifierModel : Comp.ClassifierSettingsForm.Model , 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 -> CollectiveSettings -> ( Model, Cmd Msg )
init flags settings = init flags settings =
let let
@ -57,17 +70,17 @@ init flags settings =
, intEnabled = settings.integrationEnabled , intEnabled = settings.integrationEnabled
, initSettings = settings , initSettings = settings
, fullTextConfirmText = "" , fullTextConfirmText = ""
, fullTextReIndexResult = Nothing , fullTextReIndexResult = FulltextReindexInitial
, classifierModel = cm , classifierModel = cm
, startClassifierResult = Nothing , startClassifierResult = ClassifierResultInitial
} }
, Cmd.map ClassifierSettingMsg cc , Cmd.map ClassifierSettingMsg cc
) )
getSettings : Model -> Validated CollectiveSettings getSettings : Model -> Maybe CollectiveSettings
getSettings model = getSettings model =
Data.Validated.map Maybe.map
(\cls -> (\cls ->
{ language = { language =
Comp.Dropdown.getSelected model.langModel Comp.Dropdown.getSelected model.langModel
@ -121,31 +134,36 @@ update flags msg model =
TriggerReIndex -> TriggerReIndex ->
case String.toLower model.fullTextConfirmText of case String.toLower model.fullTextConfirmText of
"ok" -> "ok" ->
( { model | fullTextReIndexResult = Nothing } ( { model | fullTextReIndexResult = FulltextReindexInitial }
, Api.startReIndex flags TriggerReIndexResult , Api.startReIndex flags TriggerReIndexResult
, Nothing , Nothing
) )
_ -> _ ->
( { model ( { model
| fullTextReIndexResult = | fullTextReIndexResult = FulltextReindexOKMissing
Just
(BasicResult False <|
"Please type OK in the field if you really "
++ "want to start re-indexing your data."
)
} }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
TriggerReIndexResult (Ok br) -> 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) -> TriggerReIndexResult (Err err) ->
( { model ( { model
| fullTextReIndexResult = | fullTextReIndexResult =
Just (BasicResult False (Util.Http.errorToString err)) FulltextReindexHttpError err
} }
, Cmd.none , Cmd.none
, Nothing , Nothing
@ -165,26 +183,30 @@ update flags msg model =
SaveSettings -> SaveSettings ->
case getSettings model of case getSettings model of
Data.Validated.Valid s -> Just s ->
( model, Cmd.none, Just s ) ( model, Cmd.none, Just s )
_ -> Nothing ->
( model, Cmd.none, Nothing ) ( model, Cmd.none, Nothing )
StartClassifierTask -> StartClassifierTask ->
( model, Api.startClassifier flags StartClassifierResp, Nothing ) ( model, Api.startClassifier flags StartClassifierResp, Nothing )
StartClassifierResp (Ok br) -> StartClassifierResp (Ok br) ->
( { model | startClassifierResult = Just br } ( { model
| startClassifierResult =
if br.success then
ClassifierResultOk
else
ClassifierResultSubmitError br.message
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
StartClassifierResp (Err err) -> StartClassifierResp (Err err) ->
( { model ( { model | startClassifierResult = ClassifierResultHttpError err }
| startClassifierResult =
Just (BasicResult False (Util.Http.errorToString err))
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -209,12 +231,7 @@ view2 flags texts settings model =
} }
in in
div div
[ classList [ class "flex flex-col relative"
[ ( "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"
] ]
[ MB.view [ MB.view
{ start = { start =
@ -227,7 +244,7 @@ view2 flags texts settings model =
[ title texts.saveSettings [ title texts.saveSettings
, href "#" , href "#"
] ]
, disabled = getSettings model |> Data.Validated.isInvalid , disabled = getSettings model == Nothing
} }
] ]
, end = [] , end = []
@ -263,13 +280,13 @@ view2 flags texts settings model =
, div [ class "mb-4" ] , div [ class "mb-4" ]
[ label [ label
[ class "inline-flex items-center" [ class "inline-flex items-center"
, for "intendpoint-enabled" , for "int-endpoint-enabled"
] ]
[ input [ input
[ type_ "checkbox" [ type_ "checkbox"
, onCheck (\_ -> ToggleIntegrationEndpoint) , onCheck (\_ -> ToggleIntegrationEndpoint)
, checked model.intEnabled , checked model.intEnabled
, id "intendpoint-enabled" , id "int-endpoint-enabled"
, class S.checkboxInput , class S.checkboxInput
] ]
[] []
@ -316,7 +333,7 @@ view2 flags texts settings model =
, div [ class "opacity-50 text-sm" ] , div [ class "opacity-50 text-sm" ]
[ text texts.reindexAllDataHelp [ text texts.reindexAllDataHelp
] ]
, renderResultMessage2 model.fullTextReIndexResult , renderFulltextReindexResultMessage texts model.fullTextReIndexResult
] ]
] ]
, div , div
@ -340,26 +357,66 @@ view2 flags texts settings model =
{ handler = onClick StartClassifierTask { handler = onClick StartClassifierTask
, icon = "fa fa-play" , icon = "fa fa-play"
, label = texts.startNow , label = texts.startNow
, disabled = Data.Validated.isInvalid model.classifierModel.schedule , disabled = model.classifierModel.schedule == Nothing
, attrs = [ href "#" ] , attrs = [ href "#" ]
} }
, renderResultMessage2 model.startClassifierResult , renderClassifierResultMessage texts model.startClassifierResult
] ]
] ]
] ]
] ]
renderResultMessage2 : Maybe BasicResult -> Html msg renderClassifierResultMessage : Texts -> ClassifierResult -> Html msg
renderResultMessage2 result = renderClassifierResultMessage texts result =
let
isSuccess =
case result of
ClassifierResultOk ->
True
_ ->
False
isError =
not isSuccess
in
div div
[ classList [ classList
[ ( S.errorMessage, Maybe.map .success result == Just False ) [ ( S.errorMessage, isError )
, ( S.successMessage, Maybe.map .success result == Just True ) , ( S.successMessage, isSuccess )
, ( "hidden", result == Nothing ) , ( "hidden", result == ClassifierResultInitial )
] ]
] ]
[ Maybe.map .message result [ case result of
|> Maybe.withDefault "" ClassifierResultInitial ->
|> text 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

View File

@ -20,19 +20,17 @@ import Comp.YesNoDimmer
import Data.CustomFieldType exposing (CustomFieldType) import Data.CustomFieldType exposing (CustomFieldType)
import Data.DropdownStyle as DS import Data.DropdownStyle as DS
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.Validated exposing (Validated)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onInput) import Html.Events exposing (onInput)
import Http import Http
import Messages.Comp.CustomFieldForm exposing (Texts) import Messages.Comp.CustomFieldForm exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
type alias Model = type alias Model =
{ result : Maybe BasicResult { formState : FormState
, field : CustomField , field : CustomField
, name : Maybe String , name : Maybe String
, label : 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 type Msg
= SetName String = SetName String
| SetLabel String | SetLabel String
| FTypeMsg (Comp.FixedDropdown.Msg CustomFieldType) | FTypeMsg (Comp.FixedDropdown.Msg CustomFieldType)
| RequestDelete | RequestDelete
| DeleteMsg Comp.YesNoDimmer.Msg | DeleteMsg Comp.YesNoDimmer.Msg
| UpdateResp (Result Http.Error BasicResult) | UpdateResp UpdateType (Result Http.Error BasicResult)
| GoBack | GoBack
| SubmitForm | SubmitForm
init : CustomField -> Model init : CustomField -> Model
init field = init field =
{ result = Nothing { formState = FormStateInitial
, field = field , field = field
, name = Util.Maybe.fromString field.name , name = Util.Maybe.fromString field.name
, label = field.label , label = field.label
@ -77,22 +122,22 @@ initEmpty =
--- Update --- Update
makeField : Model -> Validated NewCustomField makeField : Model -> Result FormState NewCustomField
makeField model = makeField model =
let let
name = name =
Maybe.map Data.Validated.Valid model.name Maybe.map Ok model.name
|> Maybe.withDefault (Data.Validated.Invalid [ "A name is required." ] "") |> Maybe.withDefault (Err FormStateNameRequired)
ftype = ftype =
Maybe.map Data.CustomFieldType.asString model.ftype Maybe.map Data.CustomFieldType.asString model.ftype
|> Maybe.map Data.Validated.Valid |> Maybe.map Ok
|> Maybe.withDefault (Data.Validated.Invalid [ "A field type is required." ] "") |> Maybe.withDefault (Err FormStateTypeRequired)
make n ft = make n ft =
NewCustomField n model.label ft NewCustomField n model.label ft
in in
Data.Validated.map2 make name ftype Result.map2 make name ftype
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Bool ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Bool )
@ -129,29 +174,22 @@ update flags msg model =
makeField model makeField model
in in
case newField of case newField of
Data.Validated.Valid f -> Ok f ->
( model ( model
, if model.field.id == "" then , if model.field.id == "" then
Api.postCustomField flags f UpdateResp Api.postCustomField flags f (UpdateResp UpdateCreate)
else else
Api.putCustomField flags model.field.id f UpdateResp Api.putCustomField flags model.field.id f (UpdateResp UpdateChange)
, False , False
) )
Data.Validated.Invalid msgs _ -> Err fe ->
let ( { model | formState = fe }
combined =
String.join "; " msgs
in
( { model | result = Just (BasicResult False combined) }
, Cmd.none , Cmd.none
, False , False
) )
Data.Validated.Unknown _ ->
( model, Cmd.none, False )
RequestDelete -> RequestDelete ->
let let
( dm, _ ) = ( dm, _ ) =
@ -166,18 +204,28 @@ update flags msg model =
cmd = cmd =
if flag then if flag then
Api.deleteCustomField flags model.field.id UpdateResp Api.deleteCustomField flags model.field.id (UpdateResp UpdateDelete)
else else
Cmd.none Cmd.none
in in
( { model | deleteDimmer = dm }, cmd, False ) ( { model | deleteDimmer = dm }, cmd, False )
UpdateResp (Ok r) -> UpdateResp updateType (Ok r) ->
( { model | result = Just r }, Cmd.none, r.success ) ( { model
| formState =
if r.success then
FormStateUpdateOk updateType
UpdateResp (Err err) -> else
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } FormStateUpdateFailed updateType r.message
}
, Cmd.none
, r.success
)
UpdateResp _ (Err err) ->
( { model | formState = FormStateHttp err }
, Cmd.none , Cmd.none
, False , False
) )
@ -230,15 +278,30 @@ view2 texts viewSettings model =
) )
, div , div
[ classList [ classList
[ ( "hidden", model.result == Nothing ) [ ( "hidden", model.formState == FormStateInitial )
, ( S.errorMessage, Maybe.map .success model.result == Just False ) , ( S.errorMessage, isFormError model.formState )
, ( S.successMessage, Maybe.map .success model.result == Just True ) , ( S.successMessage, isFormSuccess model.formState )
] ]
, class "my-2" , class "my-2"
] ]
[ Maybe.map .message model.result [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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 , if model.field.id == "" then
div [ class "py-2 text-lg opacity-75" ] div [ class "py-2 text-lg opacity-75" ]

View File

@ -42,14 +42,12 @@ import Comp.TagForm
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.Icons as Icons import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Data.Validated
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Http import Http
import Messages.Comp.DetailEdit exposing (Texts) import Messages.Comp.DetailEdit exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
@ -57,10 +55,47 @@ type alias Model =
, itemId : String , itemId : String
, submitting : Bool , submitting : Bool
, loading : 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 type FormModel
= TM Comp.TagForm.Model = TM Comp.TagForm.Model
| PMR Comp.PersonForm.Model | PMR Comp.PersonForm.Model
@ -105,7 +140,7 @@ init itemId fm =
, itemId = itemId , itemId = itemId
, submitting = False , submitting = False
, loading = False , loading = False
, result = Nothing , formState = FormStateInitial
} }
@ -125,7 +160,7 @@ editOrg flags orgId om =
, itemId = "" , itemId = ""
, submitting = False , submitting = False
, loading = True , loading = True
, result = Nothing , formState = FormStateInitial
} }
, Api.getOrgFull orgId flags GetOrgResp , Api.getOrgFull orgId flags GetOrgResp
) )
@ -137,7 +172,7 @@ editPerson flags persId pm =
, itemId = "" , itemId = ""
, submitting = False , submitting = False
, loading = True , loading = True
, result = Nothing , formState = FormStateInitial
} }
, Cmd.batch , Cmd.batch
[ Api.getPersonFull persId flags GetPersonResp [ Api.getPersonFull persId flags GetPersonResp
@ -152,7 +187,7 @@ editEquip flags equipId em =
, itemId = "" , itemId = ""
, submitting = False , submitting = False
, loading = True , loading = True
, result = Nothing , formState = FormStateInitial
} }
, Api.getEquipment flags equipId GetEquipResp , Api.getEquipment flags equipId GetEquipResp
) )
@ -246,10 +281,10 @@ makeValue fm =
Comp.CustomFieldForm.makeField fieldModel Comp.CustomFieldForm.makeField fieldModel
in in
case cfield of case cfield of
Data.Validated.Valid field -> Ok field ->
SubmitCustomField field SubmitCustomField field
_ -> Err _ ->
CancelForm CancelForm
@ -285,7 +320,10 @@ update flags msg model =
) )
GetOrgResp (Err err) -> GetOrgResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model
| loading = False
, formState = FormStateHttpError err
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -312,7 +350,10 @@ update flags msg model =
) )
GetPersonResp (Err err) -> GetPersonResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model
| loading = False
, formState = FormStateHttpError err
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -349,7 +390,10 @@ update flags msg model =
( { model | loading = False }, Cmd.none, Nothing ) ( { model | loading = False }, Cmd.none, Nothing )
GetOrgsResp (Err err) -> GetOrgsResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model
| loading = False
, formState = FormStateHttpError err
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -376,7 +420,10 @@ update flags msg model =
) )
GetEquipResp (Err err) -> GetEquipResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model
| loading = False
, formState = FormStateHttpError err
}
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -391,7 +438,12 @@ update flags msg model =
Nothing Nothing
in in
( { model ( { model
| result = Just res | formState =
if res.success then
FormStateSubmitSuccessful
else
FormStateSubmitError res.message
, submitting = False , submitting = False
} }
, Cmd.none , Cmd.none
@ -400,7 +452,7 @@ update flags msg model =
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model ( { model
| result = Just (BasicResult False (Util.Http.errorToString err)) | formState = FormStateHttpError err
, submitting = False , submitting = False
} }
, Cmd.none , Cmd.none
@ -408,10 +460,6 @@ update flags msg model =
) )
Submit -> Submit ->
let
failMsg =
Just (BasicResult False "Please fill required fields.")
in
case model.form of case model.form of
TM tm -> TM tm ->
let let
@ -425,7 +473,7 @@ update flags msg model =
) )
else else
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -446,7 +494,7 @@ update flags msg model =
) )
else else
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -467,7 +515,7 @@ update flags msg model =
) )
else else
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -488,7 +536,7 @@ update flags msg model =
) )
else else
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -509,7 +557,7 @@ update flags msg model =
) )
else else
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -520,14 +568,14 @@ update flags msg model =
Comp.CustomFieldForm.makeField fm Comp.CustomFieldForm.makeField fm
in in
case cfield of case cfield of
Data.Validated.Valid newField -> Ok newField ->
( { model | submitting = True } ( { model | submitting = True }
, Api.postCustomField flags newField SubmitResp , Api.postCustomField flags newField SubmitResp
, Nothing , Nothing
) )
_ -> Err _ ->
( { model | result = failMsg } ( { model | formState = FormStateMissingRequiredFields }
, Cmd.none , Cmd.none
, Nothing , Nothing
) )
@ -541,7 +589,7 @@ update flags msg model =
in in
( { model ( { model
| form = TM tm_ | form = TM tm_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map TagMsg tc_ , Cmd.map TagMsg tc_
, Nothing , Nothing
@ -559,7 +607,7 @@ update flags msg model =
in in
( { model ( { model
| form = PMR pm_ | form = PMR pm_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map PersonMsg pc_ , Cmd.map PersonMsg pc_
, Nothing , Nothing
@ -572,7 +620,7 @@ update flags msg model =
in in
( { model ( { model
| form = PMC pm_ | form = PMC pm_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map PersonMsg pc_ , Cmd.map PersonMsg pc_
, Nothing , Nothing
@ -590,7 +638,7 @@ update flags msg model =
in in
( { model ( { model
| form = OM om_ | form = OM om_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map OrgMsg oc_ , Cmd.map OrgMsg oc_
, Nothing , Nothing
@ -608,7 +656,7 @@ update flags msg model =
in in
( { model ( { model
| form = EM em_ | form = EM em_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map EquipMsg ec_ , Cmd.map EquipMsg ec_
, Nothing , Nothing
@ -626,7 +674,7 @@ update flags msg model =
in in
( { model ( { model
| form = CFM fm_ | form = CFM fm_
, result = Nothing , formState = FormStateInitial
} }
, Cmd.map CustomFieldMsg fc_ , Cmd.map CustomFieldMsg fc_
, Nothing , Nothing
@ -756,14 +804,26 @@ viewIntern2 : Texts -> UiSettings -> Bool -> Model -> List (Html Msg)
viewIntern2 texts settings withButtons model = viewIntern2 texts settings withButtons model =
[ div [ div
[ classList [ classList
[ ( S.errorMessage, Maybe.map .success model.result == Just False ) [ ( S.errorMessage, isError model.formState )
, ( S.successMessage, Maybe.map .success model.result == Just True ) , ( S.successMessage, isSuccess model.formState )
, ( "hidden", model.result == Nothing ) , ( "hidden", model.formState == FormStateInitial )
] ]
] ]
[ Maybe.map .message model.result [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text text ""
FormStateHttpError err ->
text (texts.httpError err)
FormStateSubmitSuccessful ->
text texts.submitSuccessful
FormStateSubmitError m ->
text m
FormStateMissingRequiredFields ->
text texts.missingRequiredFields
] ]
, case model.form of , case model.form of
TM tm -> TM tm ->

View File

@ -23,26 +23,32 @@ import Html.Attributes exposing (..)
import Http import Http
import Messages.Comp.EmailSettingsManage exposing (Texts) import Messages.Comp.EmailSettingsManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
{ tableModel : Comp.EmailSettingsTable.Model { tableModel : Comp.EmailSettingsTable.Model
, formModel : Comp.EmailSettingsForm.Model , formModel : Comp.EmailSettingsForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, query : String , query : String
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorSubmit String
| FormErrorFillRequired
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ tableModel = Comp.EmailSettingsTable.emptyModel { tableModel = Comp.EmailSettingsTable.emptyModel
, formModel = Comp.EmailSettingsForm.emptyModel , formModel = Comp.EmailSettingsForm.emptyModel
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, query = "" , query = ""
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
@ -84,7 +90,7 @@ update flags msg model =
nm = nm =
{ model { model
| viewMode = Form | viewMode = Form
, formError = Nothing , formError = FormErrorNone
, formModel = Comp.EmailSettingsForm.init ems , formModel = Comp.EmailSettingsForm.init ems
} }
in in
@ -101,7 +107,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if tm.selected /= Nothing then if tm.selected /= Nothing then
Nothing FormErrorNone
else else
model.formError model.formError
@ -166,7 +172,7 @@ update flags msg model =
( { model | loading = True }, Api.createMailSettings flags mid ems SubmitResp ) ( { model | loading = True }, Api.createMailSettings flags mid ems SubmitResp )
else else
( { model | formError = Just "Please fill required fields." }, Cmd.none ) ( { model | formError = FormErrorFillRequired }, Cmd.none )
LoadSettings -> LoadSettings ->
( { model | loading = True }, Api.getMailSettings flags model.query MailSettingsResp ) ( { model | loading = True }, Api.getMailSettings flags model.query MailSettingsResp )
@ -183,10 +189,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> 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) -> MailSettingsResp (Ok ems) ->
let let
@ -286,12 +292,23 @@ viewForm2 texts settings model =
} }
, div , div
[ classList [ classList
[ ( "hidden", model.formError == Nothing ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class "my-2" , class "my-2"
, class S.errorMessage , 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 , Html.map FormMsg
(Comp.EmailSettingsForm.view2 texts.settingsForm (Comp.EmailSettingsForm.view2 texts.settingsForm

View File

@ -22,7 +22,6 @@ import Html.Events exposing (onSubmit)
import Http import Http
import Messages.Comp.EquipmentManage exposing (Texts) import Messages.Comp.EquipmentManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
@ -30,13 +29,20 @@ type alias Model =
{ tableModel : Comp.EquipmentTable.Model { tableModel : Comp.EquipmentTable.Model
, formModel : Comp.EquipmentForm.Model , formModel : Comp.EquipmentForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
, query : String , query : String
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorSubmit String
| FormErrorInvalid
type ViewMode type ViewMode
= Table = Table
| Form | Form
@ -47,7 +53,7 @@ emptyModel =
{ tableModel = Comp.EquipmentTable.emptyModel { tableModel = Comp.EquipmentTable.emptyModel
, formModel = Comp.EquipmentForm.emptyModel , formModel = Comp.EquipmentForm.emptyModel
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
, query = "" , query = ""
@ -82,7 +88,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if Util.Maybe.nonEmpty tm.selected then if Util.Maybe.nonEmpty tm.selected then
Nothing FormErrorNone
else else
model.formError model.formError
@ -135,7 +141,7 @@ update flags msg model =
InitNewEquipment -> InitNewEquipment ->
let let
nm = nm =
{ model | viewMode = Form, formError = Nothing } { model | viewMode = Form, formError = FormErrorNone }
equipment = equipment =
Api.Model.Equipment.empty Api.Model.Equipment.empty
@ -154,7 +160,7 @@ update flags msg model =
( { model | loading = True }, Api.postEquipment flags equipment SubmitResp ) ( { model | loading = True }, Api.postEquipment flags equipment SubmitResp )
else else
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none ) ( { model | formError = FormErrorInvalid }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
if res.success then if res.success then
@ -168,10 +174,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none ) ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
RequestDelete -> RequestDelete ->
update flags (YesNoMsg Comp.YesNoDimmer.activate) model update flags (YesNoMsg Comp.YesNoDimmer.activate) model
@ -316,12 +322,23 @@ viewForm2 texts model =
} }
, div , div
[ classList [ classList
[ ( "hidden", Util.Maybe.isEmpty model.formError ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class S.errorMessage , class S.errorMessage
, class "my-2" , 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) , Html.map FormMsg (Comp.EquipmentForm.view2 texts.equipmentForm model.formModel)
, B.loadingDimmer , B.loadingDimmer

View 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
]
]
]

View File

@ -26,12 +26,11 @@ import Html.Events exposing (onClick, onInput)
import Http import Http
import Messages.Comp.FolderDetail exposing (Texts) import Messages.Comp.FolderDetail exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
type alias Model = type alias Model =
{ result : Maybe BasicResult { formState : FormState
, folder : FolderDetail , folder : FolderDetail
, name : Maybe String , name : Maybe String
, members : List IdName , 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 type Msg
= SetName String = SetName String
| MemberDropdownMsg (Comp.FixedDropdown.Msg IdName) | MemberDropdownMsg (Comp.FixedDropdown.Msg IdName)
@ -61,7 +113,7 @@ type Msg
init : List User -> FolderDetail -> Model init : List User -> FolderDetail -> Model
init users folder = init users folder =
{ result = Nothing { formState = FormStateInitial
, folder = folder , folder = folder
, name = Util.Maybe.fromString folder.name , name = Util.Maybe.fromString folder.name
, members = folder.members , members = folder.members
@ -143,7 +195,7 @@ update flags msg model =
in in
( { model ( { model
| loading = True | loading = True
, result = Nothing , formState = FormStateInitial
} }
, cmd , cmd
, False , False
@ -159,7 +211,12 @@ update flags msg model =
else else
( { model ( { model
| loading = False | loading = False
, result = Just (BasicResult ir.success ir.message) , formState =
if ir.success then
FormStateFolderCreated
else
FormStateGenericError ir.message
} }
, Cmd.none , Cmd.none
, False , False
@ -168,7 +225,7 @@ update flags msg model =
NewFolderResp (Err err) -> NewFolderResp (Err err) ->
( { model ( { model
| loading = False | loading = False
, result = Just (BasicResult False (Util.Http.errorToString err)) , formState = FormStateHttpError err
} }
, Cmd.none , Cmd.none
, False , False
@ -182,7 +239,7 @@ update flags msg model =
) )
else else
( { model | loading = False, result = Just r } ( { model | loading = False, formState = FormStateGenericError r.message }
, Cmd.none , Cmd.none
, False , False
) )
@ -190,7 +247,7 @@ update flags msg model =
ChangeFolderResp (Err err) -> ChangeFolderResp (Err err) ->
( { model ( { model
| loading = False | loading = False
, result = Just (BasicResult False (Util.Http.errorToString err)) , formState = FormStateHttpError err
} }
, Cmd.none , Cmd.none
, False , False
@ -199,13 +256,21 @@ update flags msg model =
ChangeNameResp (Ok r) -> ChangeNameResp (Ok r) ->
let let
model_ = model_ =
{ model | result = Just r, loading = False } { model
| formState =
if r.success then
FormStateNameChangeSuccessful
else
FormStateGenericError r.message
, loading = False
}
in in
( model_, Cmd.none, False ) ( model_, Cmd.none, False )
ChangeNameResp (Err err) -> ChangeNameResp (Err err) ->
( { model ( { model
| result = Just (BasicResult False (Util.Http.errorToString err)) | formState = FormStateHttpError err
, loading = False , loading = False
} }
, Cmd.none , Cmd.none
@ -218,7 +283,7 @@ update flags msg model =
FolderDetailResp (Err err) -> FolderDetailResp (Err err) ->
( { model ( { model
| loading = False | loading = False
, result = Just (BasicResult False (Util.Http.errorToString err)) , formState = FormStateHttpError err
} }
, Cmd.none , Cmd.none
, False , False
@ -263,10 +328,20 @@ update flags msg model =
( { model | deleteDimmer = dm }, cmd, False ) ( { model | deleteDimmer = dm }, cmd, False )
DeleteResp (Ok r) -> 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) -> DeleteResp (Err err) ->
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model | formState = FormStateHttpError err }
, Cmd.none , Cmd.none
, False , False
) )
@ -350,15 +425,30 @@ view2 texts flags model =
] ]
, div , div
[ classList [ classList
[ ( "hidden", model.result == Nothing ) [ ( "hidden", model.formState == FormStateInitial )
, ( S.errorMessage, Maybe.map .success model.result == Just False ) , ( S.errorMessage, isError model.formState )
, ( S.successMessage, Maybe.map .success model.result == Just True ) , ( S.successMessage, isSuccess model.formState )
] ]
, class "my-4" , class "my-4"
] ]
[ Maybe.map .message model.result [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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 ++ viewMembers2 texts model

View File

@ -11,11 +11,12 @@ module Comp.FolderSelect exposing
) )
import Api.Model.FolderStats exposing (FolderStats) import Api.Model.FolderStats exposing (FolderStats)
import Comp.ExpandCollapse
import Dict import Dict
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Util.ExpandCollapse import Messages.Comp.FolderSelect exposing (Texts)
import Util.ItemDragDrop as DD import Util.ItemDragDrop as DD
import Util.List import Util.List
@ -134,24 +135,28 @@ selectedFolder model =
--- View2 --- View2
expandToggle : Int -> Model -> List (Html Msg) expandToggle : Texts -> Int -> Model -> List (Html Msg)
expandToggle max model = expandToggle texts max model =
Util.ExpandCollapse.expandToggle Comp.ExpandCollapse.expandToggle
max texts.expandCollapse
(List.length model.all) { max = max
, all = List.length model.all
}
ToggleExpand ToggleExpand
collapseToggle : Int -> Model -> List (Html Msg) collapseToggle : Texts -> Int -> Model -> List (Html Msg)
collapseToggle max model = collapseToggle texts max model =
Util.ExpandCollapse.collapseToggle Comp.ExpandCollapse.collapseToggle
max texts.expandCollapse
(List.length model.all) { max = max
, all = List.length model.all
}
ToggleExpand ToggleExpand
viewDrop2 : DD.Model -> Int -> Model -> Html Msg viewDrop2 : Texts -> DD.Model -> Int -> Model -> Html Msg
viewDrop2 dropModel constr model = viewDrop2 texts dropModel constr model =
let let
highlightDrop = highlightDrop =
DD.getDropId dropModel == Just DD.FolderRemove DD.getDropId dropModel == Just DD.FolderRemove
@ -169,20 +174,20 @@ viewDrop2 dropModel constr model =
[ text "Folders" [ text "Folders"
] ]
, div [ class "flex flex-col space-y-2 md:space-y-1" ] , 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 : Texts -> DD.Model -> Int -> Model -> List (Html Msg)
renderItems2 dropModel constr model = renderItems2 texts dropModel constr model =
if constr <= 0 then if constr <= 0 then
List.map (viewItem2 dropModel model) model.all List.map (viewItem2 dropModel model) model.all
else if model.expanded then 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 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 viewItem2 : DD.Model -> Model -> FolderStats -> Html Msg

View File

@ -23,26 +23,32 @@ import Html.Attributes exposing (..)
import Http import Http
import Messages.Comp.ImapSettingsManage exposing (Texts) import Messages.Comp.ImapSettingsManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
{ tableModel : Comp.ImapSettingsTable.Model { tableModel : Comp.ImapSettingsTable.Model
, formModel : Comp.ImapSettingsForm.Model , formModel : Comp.ImapSettingsForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, query : String , query : String
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorSubmit String
| FormErrorFillRequired
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ tableModel = Comp.ImapSettingsTable.emptyModel { tableModel = Comp.ImapSettingsTable.emptyModel
, formModel = Comp.ImapSettingsForm.emptyModel , formModel = Comp.ImapSettingsForm.emptyModel
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, query = "" , query = ""
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
@ -84,7 +90,7 @@ update flags msg model =
nm = nm =
{ model { model
| viewMode = Form | viewMode = Form
, formError = Nothing , formError = FormErrorNone
, formModel = Comp.ImapSettingsForm.init ems , formModel = Comp.ImapSettingsForm.init ems
} }
in in
@ -101,7 +107,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if tm.selected /= Nothing then if tm.selected /= Nothing then
Nothing FormErrorNone
else else
model.formError model.formError
@ -166,7 +172,7 @@ update flags msg model =
( { model | loading = True }, Api.createImapSettings flags mid ems SubmitResp ) ( { model | loading = True }, Api.createImapSettings flags mid ems SubmitResp )
else else
( { model | formError = Just "Please fill required fields." }, Cmd.none ) ( { model | formError = FormErrorFillRequired }, Cmd.none )
LoadSettings -> LoadSettings ->
( { model | loading = True }, Api.getImapSettings flags model.query MailSettingsResp ) ( { model | loading = True }, Api.getImapSettings flags model.query MailSettingsResp )
@ -183,10 +189,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> 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) -> MailSettingsResp (Ok ems) ->
let let
@ -287,12 +293,23 @@ viewForm2 texts settings model =
} }
, div , div
[ classList [ classList
[ ( "hidden", model.formError == Nothing ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class "my-2" , class "my-2"
, class S.errorMessage , 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 , Html.map FormMsg
(Comp.ImapSettingsForm.view2 (Comp.ImapSettingsForm.view2

View File

@ -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

View File

@ -1,5 +1,7 @@
module Comp.ItemDetail.Model exposing module Comp.ItemDetail.Model exposing
( AttachmentRename ( AttachmentRename
, ConfirmModalValue(..)
, MailSendResult(..)
, Model , Model
, Msg(..) , Msg(..)
, NotesField(..) , NotesField(..)
@ -75,7 +77,7 @@ type alias Model =
, nameSaveThrottle : Throttle Msg , nameSaveThrottle : Throttle Msg
, notesModel : Maybe String , notesModel : Maybe String
, notesField : NotesField , notesField : NotesField
, itemModal : Maybe (Comp.ConfirmModal.Settings Msg) , itemModal : Maybe ConfirmModalValue
, itemDatePicker : DatePicker , itemDatePicker : DatePicker
, itemDate : Maybe Int , itemDate : Maybe Int
, itemProposals : ItemProposals , itemProposals : ItemProposals
@ -84,13 +86,13 @@ type alias Model =
, itemMail : Comp.ItemMail.Model , itemMail : Comp.ItemMail.Model
, mailOpen : Bool , mailOpen : Bool
, mailSending : Bool , mailSending : Bool
, mailSendResult : Maybe BasicResult , mailSendResult : MailSendResult
, sentMails : Comp.SentMails.Model , sentMails : Comp.SentMails.Model
, sentMailsOpen : Bool , sentMailsOpen : Bool
, attachMeta : Dict String Comp.AttachmentMeta.Model , attachMeta : Dict String Comp.AttachmentMeta.Model
, attachMetaOpen : Bool , attachMetaOpen : Bool
, pdfNativeView : Maybe Bool , pdfNativeView : Maybe Bool
, attachModal : Maybe (Comp.ConfirmModal.Settings Msg) , attachModal : Maybe ConfirmModalValue
, addFilesOpen : Bool , addFilesOpen : Bool
, addFilesModel : Comp.Dropzone.Model , addFilesModel : Comp.Dropzone.Model
, selectedFiles : List File , selectedFiles : List File
@ -112,6 +114,14 @@ type alias Model =
} }
type ConfirmModalValue
= ConfirmModalReprocessItem Msg
| ConfirmModalReprocessFile Msg
| ConfirmModalDeleteItem Msg
| ConfirmModalDeleteFile Msg
| ConfirmModalDeleteAllFiles Msg
type ViewMode type ViewMode
= SimpleView = SimpleView
| SelectView SelectViewModel | SelectView SelectViewModel
@ -128,6 +138,13 @@ type SelectActionMode
| DeleteSelected | DeleteSelected
type MailSendResult
= MailSendSuccessful
| MailSendHttpError Http.Error
| MailSendFailed String
| MailSendResultInitial
type NotesField type NotesField
= ViewNotes = ViewNotes
| EditNotes Comp.MarkdownInput.Model | EditNotes Comp.MarkdownInput.Model
@ -181,7 +198,7 @@ emptyModel =
, itemMail = Comp.ItemMail.emptyModel , itemMail = Comp.ItemMail.emptyModel
, mailOpen = False , mailOpen = False
, mailSending = False , mailSending = False
, mailSendResult = Nothing , mailSendResult = MailSendResultInitial
, sentMails = Comp.SentMails.init , sentMails = Comp.SentMails.init
, sentMailsOpen = False , sentMailsOpen = False
, attachMeta = Dict.empty , attachMeta = Dict.empty

View File

@ -3,7 +3,7 @@ module Comp.ItemDetail.SingleAttachment exposing (view)
import Api import Api
import Api.Model.Attachment exposing (Attachment) import Api.Model.Attachment exposing (Attachment)
import Comp.AttachmentMeta import Comp.AttachmentMeta
import Comp.ConfirmModal import Comp.ItemDetail.ConfirmModalView
import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..), ViewMode(..)) import Comp.ItemDetail.Model exposing (Model, Msg(..), NotesField(..), SaveNameState(..), ViewMode(..))
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
@ -32,7 +32,7 @@ view texts settings model pos attach =
[ ( "hidden", not (attachmentVisible model pos) ) [ ( "hidden", not (attachmentVisible model pos) )
] ]
] ]
[ renderModal model [ renderModal texts model
, div , div
[ class "flex flex-row px-2 py-2 text-sm" [ class "flex flex-row px-2 py-2 text-sm"
, class S.border , class S.border
@ -420,11 +420,11 @@ menuItem texts model pos attach =
] ]
renderModal : Model -> Html Msg renderModal : Texts -> Model -> Html Msg
renderModal model = renderModal texts model =
case model.attachModal of case model.attachModal of
Just confirmModal -> Just mm ->
Comp.ConfirmModal.view confirmModal Comp.ItemDetail.ConfirmModalView.view texts.confirmModal mm model
Nothing -> Nothing ->
span [ class "hidden" ] [] span [ class "hidden" ] []

View File

@ -24,7 +24,24 @@ import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.Dropzone import Comp.Dropzone
import Comp.EquipmentForm import Comp.EquipmentForm
import Comp.ItemDetail.FieldTabState as FTabState 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.ItemMail
import Comp.KeyInput import Comp.KeyInput
import Comp.LinkTarget import Comp.LinkTarget
@ -48,7 +65,6 @@ import Set exposing (Set)
import Throttle import Throttle
import Time import Time
import Util.File exposing (makeFileId) import Util.File exposing (makeFileId)
import Util.Http
import Util.List import Util.List
import Util.Maybe import Util.Maybe
import Util.String import Util.String
@ -545,19 +561,7 @@ update key flags inav settings msg model =
resultModel { model | itemModal = Nothing } resultModel { model | itemModal = Nothing }
RequestDelete -> RequestDelete ->
let resultModel { model | itemModal = Just (ConfirmModalDeleteItem DeleteItemConfirmed) }
confirmMsg =
"Really delete this item? This cannot be undone."
confirm =
Comp.ConfirmModal.defaultSettings
DeleteItemConfirmed
ItemModalCancelled
"Ok"
"Cancel"
confirmMsg
in
resultModel { model | itemModal = Just confirm }
SetCorrOrgSuggestion idname -> SetCorrOrgSuggestion idname ->
resultModelCmd ( model, setCorrOrg flags model (Just idname) ) resultModelCmd ( model, setCorrOrg flags model (Just idname) )
@ -750,7 +754,7 @@ update key flags inav settings msg model =
( { model ( { model
| itemMail = Comp.ItemMail.clear im | itemMail = Comp.ItemMail.clear im
, mailOpen = False , mailOpen = False
, mailSendResult = Nothing , mailSendResult = MailSendResultInitial
} }
, Cmd.map ItemMailMsg ic , Cmd.map ItemMailMsg ic
) )
@ -788,7 +792,7 @@ update key flags inav settings msg model =
model.mailSendResult model.mailSendResult
else else
Nothing MailSendResultInitial
in in
resultModel resultModel
{ model { model
@ -810,7 +814,12 @@ update key flags inav settings msg model =
( { model ( { model
| itemMail = mm | itemMail = mm
, mailSending = False , mailSending = False
, mailSendResult = Just br , mailSendResult =
if br.success then
MailSendSuccessful
else
MailSendFailed br.message
} }
, if br.success then , if br.success then
Api.itemDetail flags model.item.id GetItemResp Api.itemDetail flags model.item.id GetItemResp
@ -820,13 +829,9 @@ update key flags inav settings msg model =
) )
SendMailResp (Err err) -> SendMailResp (Err err) ->
let
errmsg =
Util.Http.errorToString err
in
resultModel resultModel
{ model { model
| mailSendResult = Just (BasicResult False errmsg) | mailSendResult = MailSendHttpError err
, mailSending = False , mailSending = False
} }
@ -924,18 +929,10 @@ update key flags inav settings msg model =
RequestDeleteAttachment id -> RequestDeleteAttachment id ->
let let
confirmModal =
Comp.ConfirmModal.defaultSettings
(DeleteAttachConfirmed id)
AttachModalCancelled
"Ok"
"Cancel"
"Really delete this file?"
model_ = model_ =
{ model { model
| attachmentDropdownOpen = False | attachmentDropdownOpen = False
, attachModal = Just confirmModal , attachModal = Just (ConfirmModalDeleteFile (DeleteAttachConfirmed id))
} }
in in
resultModel model_ resultModel model_
@ -948,14 +945,6 @@ update key flags inav settings msg model =
else else
let let
confirmModal =
Comp.ConfirmModal.defaultSettings
DeleteSelectedConfirmed
AttachModalCancelled
"Ok"
"Cancel"
"Really delete these files?"
model_ = model_ =
{ model { model
| viewMode = | viewMode =
@ -963,7 +952,7 @@ update key flags inav settings msg model =
{ svm { svm
| action = DeleteSelected | action = DeleteSelected
} }
, attachModal = Just confirmModal , attachModal = Just (ConfirmModalDeleteAllFiles DeleteSelectedConfirmed)
} }
in in
resultModel model_ resultModel model_
@ -1551,27 +1540,10 @@ update key flags inav settings msg model =
RequestReprocessFile id -> RequestReprocessFile id ->
let 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_ =
{ model { model
| attachmentDropdownOpen = False | attachmentDropdownOpen = False
, attachModal = Just confirmModal , attachModal = Just (ConfirmModalReprocessFile (ReprocessFileConfirmed id))
} }
in in
resultModel model_ resultModel model_
@ -1588,27 +1560,10 @@ update key flags inav settings msg model =
RequestReprocessItem -> RequestReprocessItem ->
let 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_ =
{ model { model
| attachmentDropdownOpen = False | attachmentDropdownOpen = False
, itemModal = Just confirmModal , itemModal = Just (ConfirmModalReprocessItem ReprocessItemConfirmed)
} }
in in
resultModel model_ resultModel model_

View File

@ -1,13 +1,14 @@
module Comp.ItemDetail.View2 exposing (view) module Comp.ItemDetail.View2 exposing (view)
import Comp.Basic as B import Comp.Basic as B
import Comp.ConfirmModal
import Comp.DetailEdit import Comp.DetailEdit
import Comp.ItemDetail.AddFilesForm import Comp.ItemDetail.AddFilesForm
import Comp.ItemDetail.ConfirmModalView
import Comp.ItemDetail.ItemInfoHeader import Comp.ItemDetail.ItemInfoHeader
import Comp.ItemDetail.Model import Comp.ItemDetail.Model
exposing exposing
( Model ( MailSendResult(..)
, Model
, Msg(..) , Msg(..)
, NotesField(..) , NotesField(..)
, SaveNameState(..) , SaveNameState(..)
@ -26,7 +27,6 @@ import Html.Events exposing (onClick)
import Messages.Comp.ItemDetail exposing (Texts) import Messages.Comp.ItemDetail exposing (Texts)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Styles as S import Styles as S
import Util.Time
view : Texts -> ItemNav -> UiSettings -> Model -> Html Msg view : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
@ -35,15 +35,15 @@ view texts inav settings model =
[ header texts settings model [ header texts settings model
, menuBar texts inav settings model , menuBar texts inav settings model
, body texts inav settings model , body texts inav settings model
, itemModal model , itemModal texts model
] ]
itemModal : Model -> Html Msg itemModal : Texts -> Model -> Html Msg
itemModal model = itemModal texts model =
case model.itemModal of case model.itemModal of
Just confirm -> Just confirm ->
Comp.ConfirmModal.view confirm Comp.ItemDetail.ConfirmModalView.view texts.confirmModal confirm model
Nothing -> Nothing ->
span [ class "hidden" ] [] span [ class "hidden" ] []
@ -257,22 +257,24 @@ sendMailForm texts settings model =
, Html.map ItemMailMsg (Comp.ItemMail.view2 texts.itemMail settings model.itemMail) , Html.map ItemMailMsg (Comp.ItemMail.view2 texts.itemMail settings model.itemMail)
, div , div
[ classList [ classList
[ ( S.errorMessage [ ( S.errorMessage, model.mailSendResult /= MailSendSuccessful )
, Maybe.map .success model.mailSendResult , ( S.successMessage, model.mailSendResult == MailSendSuccessful )
|> Maybe.map not , ( "hidden", model.mailSendResult == MailSendResultInitial )
|> Maybe.withDefault False
)
, ( S.successMessage
, Maybe.map .success model.mailSendResult
|> Maybe.withDefault False
)
, ( "hidden", model.mailSendResult == Nothing )
] ]
, class "mt-2" , class "mt-2"
] ]
[ Maybe.map .message model.mailSendResult [ case model.mailSendResult of
|> Maybe.withDefault "" MailSendSuccessful ->
|> text text texts.mailSendSuccessful
MailSendHttpError err ->
text (texts.httpError err)
MailSendFailed m ->
text m
MailSendResultInitial ->
text ""
] ]
] ]

View File

@ -25,7 +25,6 @@ import Html.Events exposing (onClick, onInput)
import Http import Http
import Messages.Comp.ItemMail exposing (Texts) import Messages.Comp.ItemMail exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
@ -39,10 +38,16 @@ type alias Model =
, bccRecipientsModel : Comp.EmailInput.Model , bccRecipientsModel : Comp.EmailInput.Model
, body : String , body : String
, attachAll : Bool , attachAll : Bool
, formError : Maybe String , formError : FormError
} }
type FormError
= FormErrorNone
| FormErrorNoConnection
| FormErrorHttp Http.Error
type Msg type Msg
= SetSubject String = SetSubject String
| RecipientMsg Comp.EmailInput.Msg | RecipientMsg Comp.EmailInput.Msg
@ -80,7 +85,7 @@ emptyModel =
, bccRecipientsModel = Comp.EmailInput.init , bccRecipientsModel = Comp.EmailInput.init
, body = "" , body = ""
, attachAll = True , attachAll = True
, formError = Nothing , formError = FormErrorNone
} }
@ -111,7 +116,10 @@ update flags msg model =
( em, ec, rec ) = ( em, ec, rec ) =
Comp.EmailInput.update flags model.recipients m model.recipientsModel Comp.EmailInput.update flags model.recipients m model.recipientsModel
in in
( { model | recipients = rec, recipientsModel = em } ( { model
| recipients = rec
, recipientsModel = em
}
, Cmd.map RecipientMsg ec , Cmd.map RecipientMsg ec
, FormNone , FormNone
) )
@ -121,7 +129,10 @@ update flags msg model =
( em, ec, rec ) = ( em, ec, rec ) =
Comp.EmailInput.update flags model.ccRecipients m model.ccRecipientsModel Comp.EmailInput.update flags model.ccRecipients m model.ccRecipientsModel
in in
( { model | ccRecipients = rec, ccRecipientsModel = em } ( { model
| ccRecipients = rec
, ccRecipientsModel = em
}
, Cmd.map CCRecipientMsg ec , Cmd.map CCRecipientMsg ec
, FormNone , FormNone
) )
@ -165,24 +176,24 @@ update flags msg model =
| connectionModel = cm | connectionModel = cm
, formError = , formError =
if names == [] then if names == [] then
Just "No E-Mail connections configured. Goto user settings to add one." FormErrorNoConnection
else else
Nothing FormErrorNone
} }
, Cmd.none , Cmd.none
, FormNone , FormNone
) )
ConnResp (Err err) -> ConnResp (Err err) ->
( { model | formError = Just (Util.Http.errorToString err) }, Cmd.none, FormNone ) ( { model | formError = FormErrorHttp err }, Cmd.none, FormNone )
Cancel -> Cancel ->
( model, Cmd.none, FormCancel ) ( model, Cmd.none, FormCancel )
Send -> Send ->
case ( model.formError, Comp.Dropdown.getSelected model.connectionModel ) of case ( model.formError, Comp.Dropdown.getSelected model.connectionModel ) of
( Nothing, conn :: [] ) -> ( FormErrorNone, conn :: [] ) ->
let let
emptyMail = emptyMail =
Api.Model.SimpleMail.empty Api.Model.SimpleMail.empty
@ -212,7 +223,9 @@ isValid model =
&& model.body && model.body
/= "" /= ""
&& model.formError && model.formError
== Nothing == FormErrorNone
&& Comp.Dropdown.getSelected model.connectionModel
/= []
@ -249,9 +262,17 @@ view2 texts settings model =
] ]
, div , div
[ class S.errorMessage [ 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" ] , div [ class "mb-4" ]
[ label [ label
@ -320,7 +341,7 @@ view2 texts settings model =
} }
, div [ class "flex flex-row space-x-2" ] , div [ class "flex flex-row space-x-2" ]
[ B.primaryButton [ B.primaryButton
{ label = "Send" { label = texts.sendLabel
, icon = "fa fa-paper-plane font-thin" , icon = "fa fa-paper-plane font-thin"
, handler = onClick Send , handler = onClick Send
, attrs = [ href "#" ] , attrs = [ href "#" ]

View File

@ -102,7 +102,7 @@ makeCustomFieldLink :
-> (LinkTarget -> msg) -> (LinkTarget -> msg)
-> Html msg -> Html msg
makeCustomFieldLink cv classes tagger = makeCustomFieldLink cv classes tagger =
Util.CustomField.renderValue1 Util.CustomField.renderValue2
classes classes
(tagger (LinkCustomField cv) |> Just) (tagger (LinkCustomField cv) |> Just)
cv cv

View File

@ -9,7 +9,6 @@ module Comp.NotificationForm exposing
) )
import Api import Api
import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.EmailSettingsList exposing (EmailSettingsList) import Api.Model.EmailSettingsList exposing (EmailSettingsList)
import Api.Model.NotificationSettings exposing (NotificationSettings) import Api.Model.NotificationSettings exposing (NotificationSettings)
import Api.Model.Tag exposing (Tag) import Api.Model.Tag exposing (Tag)
@ -33,7 +32,6 @@ import Http
import Markdown import Markdown
import Messages.Comp.NotificationForm exposing (Texts) import Messages.Comp.NotificationForm exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
import Util.Tag import Util.Tag
import Util.Update import Util.Update
@ -50,15 +48,28 @@ type alias Model =
, remindDaysModel : Comp.IntField.Model , remindDaysModel : Comp.IntField.Model
, capOverdue : Bool , capOverdue : Bool
, enabled : Bool , enabled : Bool
, schedule : Validated CalEvent , schedule : Maybe CalEvent
, scheduleModel : Comp.CalEventInput.Model , scheduleModel : Comp.CalEventInput.Model
, formMsg : Maybe BasicResult , formState : FormState
, loading : Int , loading : Int
, yesNoDelete : Comp.YesNoDimmer.Model , yesNoDelete : Comp.YesNoDimmer.Model
, summary : Maybe String , summary : Maybe String
} }
type FormState
= FormStateInitial
| FormStateHttpError Http.Error
| FormStateInvalid ValidateError
type ValidateError
= ValidateConnectionMissing
| ValidateRemindDaysRequired
| ValidateRecipientsRequired
| ValidateCalEventInvalid
type Action type Action
= SubmitAction NotificationSettings = SubmitAction NotificationSettings
| StartOnceAction NotificationSettings | StartOnceAction NotificationSettings
@ -121,9 +132,9 @@ initWith flags s =
, remindDays = Just s.remindDays , remindDays = Just s.remindDays
, enabled = s.enabled , enabled = s.enabled
, capOverdue = s.capOverdue , capOverdue = s.capOverdue
, schedule = Data.Validated.Unknown newSchedule , schedule = Just newSchedule
, scheduleModel = sm , scheduleModel = sm
, formMsg = Nothing , formState = FormStateInitial
, loading = im.loading , loading = im.loading
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, summary = s.summary , summary = s.summary
@ -140,10 +151,10 @@ init : Flags -> ( Model, Cmd Msg )
init flags = init flags =
let let
initialSchedule = initialSchedule =
Data.Validated.Valid Data.CalEvent.everyMonth Data.CalEvent.everyMonth
sm = ( sm, scmd ) =
Comp.CalEventInput.initDefault Comp.CalEventInput.init flags initialSchedule
in in
( { settings = Api.Model.NotificationSettings.empty ( { settings = Api.Model.NotificationSettings.empty
, connectionModel = Comp.Dropdown.makeSingle , connectionModel = Comp.Dropdown.makeSingle
@ -155,9 +166,9 @@ init flags =
, remindDaysModel = Comp.IntField.init (Just 1) Nothing True , remindDaysModel = Comp.IntField.init (Just 1) Nothing True
, enabled = False , enabled = False
, capOverdue = False , capOverdue = False
, schedule = initialSchedule , schedule = Just initialSchedule
, scheduleModel = sm , scheduleModel = sm
, formMsg = Nothing , formState = FormStateInitial
, loading = 2 , loading = 2
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, summary = Nothing , summary = Nothing
@ -165,6 +176,7 @@ init flags =
, Cmd.batch , Cmd.batch
[ Api.getMailSettings flags "" ConnResp [ Api.getMailSettings flags "" ConnResp
, Api.getTags flags "" GetTagsResp , Api.getTags flags "" GetTagsResp
, Cmd.map CalEventMsg scmd
] ]
) )
@ -173,7 +185,7 @@ init flags =
--- Update --- Update
makeSettings : Model -> Validated NotificationSettings makeSettings : Model -> Result ValidateError NotificationSettings
makeSettings model = makeSettings model =
let let
prev = prev =
@ -182,19 +194,27 @@ makeSettings model =
conn = conn =
Comp.Dropdown.getSelected model.connectionModel Comp.Dropdown.getSelected model.connectionModel
|> List.head |> List.head
|> Maybe.map Valid |> Maybe.map Ok
|> Maybe.withDefault (Invalid [ "Connection missing" ] "") |> Maybe.withDefault (Err ValidateConnectionMissing)
recp = recp =
if List.isEmpty model.recipients then if List.isEmpty model.recipients then
Invalid [ "No recipients" ] [] Err ValidateRecipientsRequired
else else
Valid model.recipients Ok model.recipients
rmdays = rmdays =
Maybe.map Valid model.remindDays Maybe.map Ok model.remindDays
|> Maybe.withDefault (Invalid [ "Remind Days is required" ] 0) |> Maybe.withDefault (Err ValidateRemindDaysRequired)
schedule_ =
case model.schedule of
Just s ->
Ok s
Nothing ->
Err ValidateCalEventInvalid
make smtp rec days timer = make smtp rec days timer =
{ prev { prev
@ -209,34 +229,24 @@ makeSettings model =
, summary = model.summary , summary = model.summary
} }
in in
Data.Validated.map4 make Result.map4 make
conn conn
recp recp
rmdays rmdays
model.schedule schedule_
withValidSettings : (NotificationSettings -> Action) -> Model -> ( Model, Action, Cmd Msg ) withValidSettings : (NotificationSettings -> Action) -> Model -> ( Model, Action, Cmd Msg )
withValidSettings mkcmd model = withValidSettings mkcmd model =
case makeSettings model of case makeSettings model of
Valid set -> Ok set ->
( { model | formMsg = Nothing } ( { model | formState = FormStateInitial }
, mkcmd set , mkcmd set
, Cmd.none , Cmd.none
) )
Invalid errs _ -> Err errs ->
let ( { model | formState = FormStateInvalid errs }
errMsg =
String.join ", " errs
in
( { model | formMsg = Just (BasicResult False errMsg) }
, NoAction
, Cmd.none
)
Unknown _ ->
( { model | formMsg = Just (BasicResult False "An unknown error occured") }
, NoAction , NoAction
, Cmd.none , Cmd.none
) )
@ -249,14 +259,14 @@ update flags msg model =
let let
( cm, cc, cs ) = ( cm, cc, cs ) =
Comp.CalEventInput.update flags Comp.CalEventInput.update flags
(Data.Validated.value model.schedule) model.schedule
lmsg lmsg
model.scheduleModel model.scheduleModel
in in
( { model ( { model
| schedule = cs | schedule = cs
, scheduleModel = cm , scheduleModel = cm
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map CalEventMsg cc , Cmd.map CalEventMsg cc
@ -270,7 +280,7 @@ update flags msg model =
( { model ( { model
| recipients = rec | recipients = rec
, recipientsModel = em , recipientsModel = em
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map RecipientMsg ec , Cmd.map RecipientMsg ec
@ -283,7 +293,7 @@ update flags msg model =
in in
( { model ( { model
| connectionModel = cm | connectionModel = cm
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map ConnMsg cc , Cmd.map ConnMsg cc
@ -303,15 +313,12 @@ update flags msg model =
( { model ( { model
| connectionModel = cm | connectionModel = cm
, loading = model.loading - 1 , loading = model.loading - 1
, formMsg = , formState =
if names == [] then if names == [] then
Just FormStateInvalid ValidateConnectionMissing
(BasicResult False
"No E-Mail connections configured. Goto E-Mail Settings to add one."
)
else else
Nothing FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -319,7 +326,7 @@ update flags msg model =
ConnResp (Err err) -> ConnResp (Err err) ->
( { model ( { model
| formMsg = Just (BasicResult False (Util.Http.errorToString err)) | formState = FormStateHttpError err
, loading = model.loading - 1 , loading = model.loading - 1
} }
, NoAction , NoAction
@ -333,7 +340,7 @@ update flags msg model =
in in
( { model ( { model
| tagInclModel = m2 | tagInclModel = m2
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map TagIncMsg c2 , Cmd.map TagIncMsg c2
@ -346,7 +353,7 @@ update flags msg model =
in in
( { model ( { model
| tagExclModel = m2 | tagExclModel = m2
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map TagExcMsg c2 , Cmd.map TagExcMsg c2
@ -372,7 +379,7 @@ update flags msg model =
GetTagsResp (Err err) -> GetTagsResp (Err err) ->
( { model ( { model
| loading = model.loading - 1 | loading = model.loading - 1
, formMsg = Just (BasicResult False (Util.Http.errorToString err)) , formState = FormStateHttpError err
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -386,7 +393,7 @@ update flags msg model =
( { model ( { model
| remindDaysModel = pm | remindDaysModel = pm
, remindDays = val , remindDays = val
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -395,7 +402,7 @@ update flags msg model =
ToggleEnabled -> ToggleEnabled ->
( { model ( { model
| enabled = not model.enabled | enabled = not model.enabled
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -404,7 +411,7 @@ update flags msg model =
ToggleCapOverdue -> ToggleCapOverdue ->
( { model ( { model
| capOverdue = not model.capOverdue | capOverdue = not model.capOverdue
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -465,15 +472,17 @@ update flags msg model =
isFormError : Model -> Bool isFormError : Model -> Bool
isFormError model = isFormError model =
Maybe.map .success model.formMsg case model.formState of
|> Maybe.map not FormStateInitial ->
|> Maybe.withDefault False False
_ ->
True
isFormSuccess : Model -> Bool isFormSuccess : Model -> Bool
isFormSuccess model = isFormSuccess model =
Maybe.map .success model.formMsg not (isFormError model)
|> Maybe.withDefault False
view2 : Texts -> String -> UiSettings -> Model -> Html Msg view2 : Texts -> String -> UiSettings -> Model -> Html Msg
@ -547,13 +556,28 @@ view2 texts extraClasses settings model =
[ classList [ classList
[ ( S.successMessage, isFormSuccess model ) [ ( S.successMessage, isFormSuccess model )
, ( S.errorMessage, isFormError model ) , ( S.errorMessage, isFormError model )
, ( "hidden", model.formMsg == Nothing ) , ( "hidden", model.formState == FormStateInitial )
] ]
, class "mb-4" , class "mb-4"
] ]
[ Maybe.map .message model.formMsg [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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" ] , div [ class "mb-4" ]
[ MB.viewItem <| [ MB.viewItem <|
@ -678,7 +702,7 @@ view2 texts extraClasses settings model =
(Comp.CalEventInput.view2 (Comp.CalEventInput.view2
texts.calEventInput texts.calEventInput
"" ""
(Data.Validated.value model.schedule) model.schedule
model.scheduleModel model.scheduleModel
) )
, span [ class "opacity-50 text-sm" ] , span [ class "opacity-50 text-sm" ]

View File

@ -20,24 +20,36 @@ import Html.Attributes exposing (..)
import Http import Http
import Messages.Comp.NotificationManage exposing (Texts) import Messages.Comp.NotificationManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
{ listModel : Comp.NotificationList.Model { listModel : Comp.NotificationList.Model
, detailModel : Maybe Comp.NotificationForm.Model , detailModel : Maybe Comp.NotificationForm.Model
, items : List NotificationSettings , 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 type Msg
= ListMsg Comp.NotificationList.Msg = ListMsg Comp.NotificationList.Msg
| DetailMsg Comp.NotificationForm.Msg | DetailMsg Comp.NotificationForm.Msg
| GetDataResp (Result Http.Error NotificationSettingsList) | GetDataResp (Result Http.Error NotificationSettingsList)
| NewTask | NewTask
| SubmitResp Bool (Result Http.Error BasicResult) | SubmitResp SubmitType (Result Http.Error BasicResult)
| DeleteResp (Result Http.Error BasicResult)
initModel : Model initModel : Model
@ -45,7 +57,7 @@ initModel =
{ listModel = Comp.NotificationList.init { listModel = Comp.NotificationList.init
, detailModel = Nothing , detailModel = Nothing
, items = [] , items = []
, result = Nothing , formState = FormStateInitial
} }
@ -69,13 +81,13 @@ update flags msg model =
GetDataResp (Ok res) -> GetDataResp (Ok res) ->
( { model ( { model
| items = res.items | items = res.items
, result = Nothing , formState = FormStateInitial
} }
, Cmd.none , Cmd.none
) )
GetDataResp (Err err) -> GetDataResp (Err err) ->
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model | formState = FormHttpError err }
, Cmd.none , Cmd.none
) )
@ -113,26 +125,29 @@ update flags msg model =
( model_, cmd_ ) = ( model_, cmd_ ) =
case action of case action of
Comp.NotificationForm.NoAction -> Comp.NotificationForm.NoAction ->
( { model | detailModel = Just mm } ( { model
| detailModel = Just mm
, formState = FormStateInitial
}
, Cmd.none , Cmd.none
) )
Comp.NotificationForm.SubmitAction settings -> Comp.NotificationForm.SubmitAction settings ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, if settings.id == "" then , if settings.id == "" then
Api.createNotifyDueItems flags settings (SubmitResp True) Api.createNotifyDueItems flags settings (SubmitResp SubmitCreate)
else else
Api.updateNotifyDueItems flags settings (SubmitResp True) Api.updateNotifyDueItems flags settings (SubmitResp SubmitUpdate)
) )
Comp.NotificationForm.CancelAction -> Comp.NotificationForm.CancelAction ->
( { model ( { model
| detailModel = Nothing | detailModel = Nothing
, result = Nothing , formState = FormStateInitial
} }
, initCmd flags , initCmd flags
) )
@ -140,17 +155,17 @@ update flags msg model =
Comp.NotificationForm.StartOnceAction settings -> Comp.NotificationForm.StartOnceAction settings ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, Api.startOnceNotifyDueItems flags settings (SubmitResp False) , Api.startOnceNotifyDueItems flags settings (SubmitResp SubmitStartOnce)
) )
Comp.NotificationForm.DeleteAction id -> Comp.NotificationForm.DeleteAction id ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, Api.deleteNotifyDueItems flags id DeleteResp , Api.deleteNotifyDueItems flags id (SubmitResp SubmitDelete)
) )
in in
( model_ ( model_
@ -170,17 +185,22 @@ update flags msg model =
in in
( { model | detailModel = Just mm }, Cmd.map DetailMsg mc ) ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc )
SubmitResp close (Ok res) -> SubmitResp submitType (Ok res) ->
( { model ( { model
| result = Just res | formState =
if res.success then
FormSubmitSuccessful submitType
else
FormSubmitFailed res.message
, detailModel = , detailModel =
if close then if submitType == SubmitDelete then
Nothing Nothing
else else
model.detailModel model.detailModel
} }
, if close then , if submitType == SubmitDelete then
initCmd flags initCmd flags
else else
@ -188,23 +208,7 @@ update flags msg model =
) )
SubmitResp _ (Err err) -> SubmitResp _ (Err err) ->
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model | formState = FormHttpError 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)) }
, Cmd.none , Cmd.none
) )
@ -218,15 +222,33 @@ view2 texts settings model =
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
(div (div
[ classList [ classList
[ ( S.errorMessage, Maybe.map .success model.result == Just False ) [ ( S.errorMessage, model.formState /= FormStateInitial )
, ( S.successMessage, Maybe.map .success model.result == Just True ) , ( S.successMessage, isSuccess model.formState )
, ( "hidden", model.result == Nothing ) , ( "hidden", model.formState == FormStateInitial )
] ]
, class "mb-2" , class "mb-2"
] ]
[ Maybe.map .message model.result [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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 :: (case model.detailModel of
Just msett -> 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 -> UiSettings -> Comp.NotificationForm.Model -> List (Html Msg)
viewForm2 texts settings model = viewForm2 texts settings model =
[ Html.map DetailMsg [ Html.map DetailMsg

View File

@ -23,7 +23,6 @@ import Html.Events exposing (onSubmit)
import Http import Http
import Messages.Comp.OrgManage exposing (Texts) import Messages.Comp.OrgManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
@ -31,13 +30,20 @@ type alias Model =
{ tableModel : Comp.OrgTable.Model { tableModel : Comp.OrgTable.Model
, formModel : Comp.OrgForm.Model , formModel : Comp.OrgForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
, query : String , query : String
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorSubmit String
| FormErrorInvalid
type ViewMode type ViewMode
= Table = Table
| Form | Form
@ -48,7 +54,7 @@ emptyModel =
{ tableModel = Comp.OrgTable.emptyModel { tableModel = Comp.OrgTable.emptyModel
, formModel = Comp.OrgForm.emptyModel , formModel = Comp.OrgForm.emptyModel
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
, query = "" , query = ""
@ -83,7 +89,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if Util.Maybe.nonEmpty tm.selected then if Util.Maybe.nonEmpty tm.selected then
Nothing FormErrorNone
else else
model.formError model.formError
@ -136,7 +142,7 @@ update flags msg model =
InitNewOrg -> InitNewOrg ->
let let
nm = nm =
{ model | viewMode = Form, formError = Nothing } { model | viewMode = Form, formError = FormErrorNone }
org = org =
Api.Model.Organization.empty Api.Model.Organization.empty
@ -155,7 +161,7 @@ update flags msg model =
( { model | loading = True }, Api.postOrg flags org SubmitResp ) ( { model | loading = True }, Api.postOrg flags org SubmitResp )
else else
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none ) ( { model | formError = FormErrorInvalid }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
if res.success then if res.success then
@ -169,10 +175,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none ) ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
RequestDelete -> RequestDelete ->
update flags (YesNoMsg Comp.YesNoDimmer.activate) model update flags (YesNoMsg Comp.YesNoDimmer.activate) model
@ -310,12 +316,23 @@ viewForm2 texts settings model =
} }
, div , div
[ classList [ classList
[ ( "hidden", Util.Maybe.isEmpty model.formError ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class S.errorMessage , class S.errorMessage
, class "my-2" , 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 , Html.map FormMsg
(Comp.OrgForm.view2 (Comp.OrgForm.view2

View File

@ -24,7 +24,6 @@ import Html.Events exposing (onSubmit)
import Http import Http
import Messages.Comp.PersonManage exposing (Texts) import Messages.Comp.PersonManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
@ -32,13 +31,20 @@ type alias Model =
{ tableModel : Comp.PersonTable.Model { tableModel : Comp.PersonTable.Model
, formModel : Comp.PersonForm.Model , formModel : Comp.PersonForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Int , loading : Int
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
, query : String , query : String
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorSubmit String
| FormErrorInvalid
type ViewMode type ViewMode
= Table = Table
| Form | Form
@ -49,7 +55,7 @@ emptyModel =
{ tableModel = Comp.PersonTable.emptyModel { tableModel = Comp.PersonTable.emptyModel
, formModel = Comp.PersonForm.emptyModel , formModel = Comp.PersonForm.emptyModel
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = 0 , loading = 0
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
, query = "" , query = ""
@ -85,7 +91,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if Util.Maybe.nonEmpty tm.selected then if Util.Maybe.nonEmpty tm.selected then
Nothing FormErrorNone
else else
model.formError model.formError
@ -156,7 +162,7 @@ update flags msg model =
InitNewPerson -> InitNewPerson ->
let let
nm = nm =
{ model | viewMode = Form, formError = Nothing } { model | viewMode = Form, formError = FormErrorNone }
org = org =
Api.Model.Person.empty Api.Model.Person.empty
@ -177,7 +183,7 @@ update flags msg model =
) )
else else
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none ) ( { model | formError = FormErrorInvalid }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
if res.success then if res.success then
@ -192,7 +198,7 @@ update flags msg model =
else else
( { model ( { model
| formError = Just res.message | formError = FormErrorSubmit res.message
, loading = Basics.max 0 (model.loading - 1) , loading = Basics.max 0 (model.loading - 1)
} }
, Cmd.none , Cmd.none
@ -200,7 +206,7 @@ update flags msg model =
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model ( { model
| formError = Just (Util.Http.errorToString err) | formError = FormErrorHttp err
, loading = Basics.max 0 (model.loading - 1) , loading = Basics.max 0 (model.loading - 1)
} }
, Cmd.none , Cmd.none
@ -347,12 +353,23 @@ viewForm2 texts settings model =
} }
, div , div
[ classList [ classList
[ ( "hidden", Util.Maybe.isEmpty model.formError ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class S.errorMessage , class S.errorMessage
, class "my-2" , 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 , Html.map FormMsg
(Comp.PersonForm.view2 texts.personForm (Comp.PersonForm.view2 texts.personForm

View File

@ -9,7 +9,6 @@ module Comp.ScanMailboxForm exposing
) )
import Api import Api
import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.FolderItem exposing (FolderItem) import Api.Model.FolderItem exposing (FolderItem)
import Api.Model.FolderList exposing (FolderList) import Api.Model.FolderList exposing (FolderList)
import Api.Model.IdName exposing (IdName) import Api.Model.IdName exposing (IdName)
@ -44,7 +43,6 @@ import Messages.Data.Language
import Set exposing (Set) import Set exposing (Set)
import Styles as S import Styles as S
import Util.Folder exposing (mkFolderOption) import Util.Folder exposing (mkFolderOption)
import Util.Http
import Util.List import Util.List
import Util.Maybe import Util.Maybe
import Util.Tag import Util.Tag
@ -62,9 +60,9 @@ type alias Model =
, foldersModel : Comp.StringListInput.Model , foldersModel : Comp.StringListInput.Model
, folders : List String , folders : List String
, direction : Maybe Direction , direction : Maybe Direction
, schedule : Validated CalEvent , schedule : Maybe CalEvent
, scheduleModel : Comp.CalEventInput.Model , scheduleModel : Comp.CalEventInput.Model
, formMsg : Maybe BasicResult , formState : FormState
, loading : Int , loading : Int
, yesNoDelete : Comp.YesNoDimmer.Model , yesNoDelete : Comp.YesNoDimmer.Model
, folderModel : Comp.Dropdown.Model IdName , 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 type Action
= SubmitAction ScanMailboxSettings = SubmitAction ScanMailboxSettings
| StartOnceAction ScanMailboxSettings | StartOnceAction ScanMailboxSettings
@ -179,10 +189,10 @@ initWith flags s =
, receivedHours = s.receivedSinceHours , receivedHours = s.receivedSinceHours
, targetFolder = s.targetFolder , targetFolder = s.targetFolder
, folders = s.folders , folders = s.folders
, schedule = Data.Validated.Unknown newSchedule , schedule = Just newSchedule
, direction = Maybe.andThen Data.Direction.fromString s.direction , direction = Maybe.andThen Data.Direction.fromString s.direction
, scheduleModel = sm , scheduleModel = sm
, formMsg = Nothing , formState = FormStateInitial
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, itemFolderId = s.itemFolder , itemFolderId = s.itemFolder
, tagModel = Util.Tag.makeDropdownModel , tagModel = Util.Tag.makeDropdownModel
@ -211,10 +221,10 @@ init : Flags -> ( Model, Cmd Msg )
init flags = init flags =
let let
initialSchedule = initialSchedule =
Data.Validated.Valid Data.CalEvent.everyMonth Data.CalEvent.everyMonth
sm = ( sm, scmd ) =
Comp.CalEventInput.initDefault Comp.CalEventInput.init flags initialSchedule
in in
( { settings = Api.Model.ScanMailboxSettings.empty ( { settings = Api.Model.ScanMailboxSettings.empty
, connectionModel = Comp.Dropdown.makeSingle , connectionModel = Comp.Dropdown.makeSingle
@ -226,9 +236,9 @@ init flags =
, folders = [] , folders = []
, targetFolder = Nothing , targetFolder = Nothing
, direction = Nothing , direction = Nothing
, schedule = initialSchedule , schedule = Just initialSchedule
, scheduleModel = sm , scheduleModel = sm
, formMsg = Nothing , formState = FormStateInitial
, loading = 3 , loading = 3
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, folderModel = Comp.Dropdown.makeSingle , folderModel = Comp.Dropdown.makeSingle
@ -249,6 +259,7 @@ init flags =
[ Api.getImapSettings flags "" ConnResp [ Api.getImapSettings flags "" ConnResp
, Api.getFolders flags "" False GetFolderResp , Api.getFolders flags "" False GetFolderResp
, Api.getTags flags "" GetTagResp , Api.getTags flags "" GetTagResp
, Cmd.map CalEventMsg scmd
] ]
) )
@ -257,7 +268,7 @@ init flags =
--- Update --- Update
makeSettings : Model -> Validated ScanMailboxSettings makeSettings : Model -> Result ValidateError ScanMailboxSettings
makeSettings model = makeSettings model =
let let
prev = prev =
@ -266,15 +277,23 @@ makeSettings model =
conn = conn =
Comp.Dropdown.getSelected model.connectionModel Comp.Dropdown.getSelected model.connectionModel
|> List.head |> List.head
|> Maybe.map Valid |> Maybe.map Ok
|> Maybe.withDefault (Invalid [ "Connection missing" ] "") |> Maybe.withDefault (Err ValidateConnectionMissing)
infolders = infolders =
if model.folders == [] then if model.folders == [] then
Invalid [ "No processing folders given" ] [] Err ValidateNoProcessingFolders
else else
Valid model.folders Ok model.folders
schedule_ =
case model.schedule of
Just s ->
Ok s
Nothing ->
Err ValidateCalEventInvalid
make imap timer folders = make imap timer folders =
{ prev { prev
@ -303,33 +322,20 @@ makeSettings model =
, summary = model.summary , summary = model.summary
} }
in in
Data.Validated.map3 make Result.map3 make conn schedule_ infolders
conn
model.schedule
infolders
withValidSettings : (ScanMailboxSettings -> Action) -> Model -> ( Model, Action, Cmd Msg ) withValidSettings : (ScanMailboxSettings -> Action) -> Model -> ( Model, Action, Cmd Msg )
withValidSettings mkAction model = withValidSettings mkAction model =
case makeSettings model of case makeSettings model of
Valid set -> Ok set ->
( { model | formMsg = Nothing } ( { model | formState = FormStateInitial }
, mkAction set , mkAction set
, Cmd.none , Cmd.none
) )
Invalid errs _ -> Err errs ->
let ( { model | formState = FormStateInvalid errs }
errMsg =
String.join ", " errs
in
( { model | formMsg = Just (BasicResult False errMsg) }
, NoAction
, Cmd.none
)
Unknown _ ->
( { model | formMsg = Just (BasicResult False "An unknown error occured") }
, NoAction , NoAction
, Cmd.none , Cmd.none
) )
@ -342,14 +348,14 @@ update flags msg model =
let let
( cm, cc, cs ) = ( cm, cc, cs ) =
Comp.CalEventInput.update flags Comp.CalEventInput.update flags
(Data.Validated.value model.schedule) model.schedule
lmsg lmsg
model.scheduleModel model.scheduleModel
in in
( { model ( { model
| schedule = cs | schedule = cs
, scheduleModel = cm , scheduleModel = cm
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map CalEventMsg cc , Cmd.map CalEventMsg cc
@ -362,7 +368,7 @@ update flags msg model =
in in
( { model ( { model
| connectionModel = cm | connectionModel = cm
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.map ConnMsg cc , Cmd.map ConnMsg cc
@ -394,15 +400,12 @@ update flags msg model =
( { model ( { model
| connectionModel = cm | connectionModel = cm
, loading = model.loading - 1 , loading = model.loading - 1
, formMsg = , formState =
if names == [] then if names == [] then
Just FormStateInvalid ValidateConnectionMissing
(BasicResult False
"No E-Mail connections configured. Goto E-Mail Settings to add one."
)
else else
Nothing FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -410,7 +413,7 @@ update flags msg model =
ConnResp (Err err) -> ConnResp (Err err) ->
( { model ( { model
| formMsg = Just (BasicResult False (Util.Http.errorToString err)) | formState = FormStateHttpError err
, loading = model.loading - 1 , loading = model.loading - 1
} }
, NoAction , NoAction
@ -420,7 +423,7 @@ update flags msg model =
ToggleEnabled -> ToggleEnabled ->
( { model ( { model
| enabled = not model.enabled | enabled = not model.enabled
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -429,7 +432,7 @@ update flags msg model =
ToggleDeleteMail -> ToggleDeleteMail ->
( { model ( { model
| deleteMail = not model.deleteMail | deleteMail = not model.deleteMail
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -443,7 +446,7 @@ update flags msg model =
( { model ( { model
| receivedHoursModel = pm | receivedHoursModel = pm
, receivedHours = val , receivedHours = val
, formMsg = Nothing , formState = FormStateInitial
} }
, NoAction , NoAction
, Cmd.none , Cmd.none
@ -714,15 +717,17 @@ update flags msg model =
isFormError : Model -> Bool isFormError : Model -> Bool
isFormError model = isFormError model =
Maybe.map .success model.formMsg case model.formState of
|> Maybe.map not FormStateInitial ->
|> Maybe.withDefault False False
_ ->
True
isFormSuccess : Model -> Bool isFormSuccess : Model -> Bool
isFormSuccess model = isFormSuccess model =
Maybe.map .success model.formMsg not (isFormError model)
|> Maybe.withDefault False
isFolderMember : Model -> Bool isFolderMember : Model -> Bool
@ -796,12 +801,24 @@ view2 texts flags extraClasses settings model =
[ classList [ classList
[ ( S.successMessage, isFormSuccess model ) [ ( S.successMessage, isFormSuccess model )
, ( S.errorMessage, isFormError model ) , ( S.errorMessage, isFormError model )
, ( "hidden", model.formMsg == Nothing ) , ( "hidden", model.formState == FormStateInitial )
] ]
] ]
[ Maybe.map .message model.formMsg [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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.akkordion
Comp.Tabs.defaultStyle Comp.Tabs.defaultStyle
@ -1172,7 +1189,7 @@ viewSchedule2 texts model =
(Comp.CalEventInput.view2 (Comp.CalEventInput.view2
texts.calEventInput texts.calEventInput
"" ""
(Data.Validated.value model.schedule) model.schedule
model.scheduleModel model.scheduleModel
) )
, span [ class "opacity-50 text-sm" ] , span [ class "opacity-50 text-sm" ]

View File

@ -20,24 +20,36 @@ import Html.Attributes exposing (..)
import Http import Http
import Messages.Comp.ScanMailboxManage exposing (Texts) import Messages.Comp.ScanMailboxManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
type alias Model = type alias Model =
{ listModel : Comp.ScanMailboxList.Model { listModel : Comp.ScanMailboxList.Model
, detailModel : Maybe Comp.ScanMailboxForm.Model , detailModel : Maybe Comp.ScanMailboxForm.Model
, items : List ScanMailboxSettings , 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 type Msg
= ListMsg Comp.ScanMailboxList.Msg = ListMsg Comp.ScanMailboxList.Msg
| DetailMsg Comp.ScanMailboxForm.Msg | DetailMsg Comp.ScanMailboxForm.Msg
| GetDataResp (Result Http.Error ScanMailboxSettingsList) | GetDataResp (Result Http.Error ScanMailboxSettingsList)
| NewTask | NewTask
| SubmitResp Bool (Result Http.Error BasicResult) | SubmitResp SubmitType (Result Http.Error BasicResult)
| DeleteResp (Result Http.Error BasicResult)
initModel : Model initModel : Model
@ -45,7 +57,7 @@ initModel =
{ listModel = Comp.ScanMailboxList.init { listModel = Comp.ScanMailboxList.init
, detailModel = Nothing , detailModel = Nothing
, items = [] , items = []
, result = Nothing , formState = FormStateInitial
} }
@ -69,13 +81,13 @@ update flags msg model =
GetDataResp (Ok res) -> GetDataResp (Ok res) ->
( { model ( { model
| items = res.items | items = res.items
, result = Nothing , formState = FormStateInitial
} }
, Cmd.none , Cmd.none
) )
GetDataResp (Err err) -> GetDataResp (Err err) ->
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model | formState = FormHttpError err }
, Cmd.none , Cmd.none
) )
@ -113,26 +125,29 @@ update flags msg model =
( model_, cmd_ ) = ( model_, cmd_ ) =
case action of case action of
Comp.ScanMailboxForm.NoAction -> Comp.ScanMailboxForm.NoAction ->
( { model | detailModel = Just mm } ( { model
| detailModel = Just mm
, formState = FormStateInitial
}
, Cmd.none , Cmd.none
) )
Comp.ScanMailboxForm.SubmitAction settings -> Comp.ScanMailboxForm.SubmitAction settings ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, if settings.id == "" then , if settings.id == "" then
Api.createScanMailbox flags settings (SubmitResp True) Api.createScanMailbox flags settings (SubmitResp SubmitCreate)
else else
Api.updateScanMailbox flags settings (SubmitResp True) Api.updateScanMailbox flags settings (SubmitResp SubmitUpdate)
) )
Comp.ScanMailboxForm.CancelAction -> Comp.ScanMailboxForm.CancelAction ->
( { model ( { model
| detailModel = Nothing | detailModel = Nothing
, result = Nothing , formState = FormStateInitial
} }
, initCmd flags , initCmd flags
) )
@ -140,17 +155,17 @@ update flags msg model =
Comp.ScanMailboxForm.StartOnceAction settings -> Comp.ScanMailboxForm.StartOnceAction settings ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, Api.startOnceScanMailbox flags settings (SubmitResp False) , Api.startOnceScanMailbox flags settings (SubmitResp SubmitStartOnce)
) )
Comp.ScanMailboxForm.DeleteAction id -> Comp.ScanMailboxForm.DeleteAction id ->
( { model ( { model
| detailModel = Just mm | detailModel = Just mm
, result = Nothing , formState = FormStateInitial
} }
, Api.deleteScanMailbox flags id DeleteResp , Api.deleteScanMailbox flags id (SubmitResp SubmitDelete)
) )
in in
( model_ ( model_
@ -170,17 +185,22 @@ update flags msg model =
in in
( { model | detailModel = Just mm }, Cmd.map DetailMsg mc ) ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc )
SubmitResp close (Ok res) -> SubmitResp submitType (Ok res) ->
( { model ( { model
| result = Just res | formState =
if res.success then
FormSubmitSuccessful submitType
else
FormSubmitFailed res.message
, detailModel = , detailModel =
if close then if submitType == SubmitDelete then
Nothing Nothing
else else
model.detailModel model.detailModel
} }
, if close then , if submitType == SubmitDelete then
initCmd flags initCmd flags
else else
@ -188,23 +208,7 @@ update flags msg model =
) )
SubmitResp _ (Err err) -> SubmitResp _ (Err err) ->
( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } ( { model | formState = FormHttpError 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)) }
, Cmd.none , Cmd.none
) )
@ -218,14 +222,33 @@ view2 texts flags settings model =
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
(div (div
[ classList [ classList
[ ( S.errorMessage, Maybe.map .success model.result == Just False ) [ ( S.errorMessage, model.formState /= FormStateInitial )
, ( S.successMessage, Maybe.map .success model.result == Just True ) , ( S.successMessage, isSuccess model.formState )
, ( "hidden", model.result == Nothing ) , ( "hidden", model.formState == FormStateInitial )
] ]
, class "mb-2"
] ]
[ Maybe.map .message model.result [ case model.formState of
|> Maybe.withDefault "" FormStateInitial ->
|> text 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 :: (case model.detailModel of
Just msett -> 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 -> UiSettings -> Comp.ScanMailboxForm.Model -> List (Html Msg)
viewForm2 texts flags settings model = viewForm2 texts flags settings model =
[ Html.map DetailMsg [ Html.map DetailMsg

View File

@ -1223,6 +1223,7 @@ searchTabs texts ddd flags settings model =
, body = , body =
[ Html.map TagSelectMsg [ Html.map TagSelectMsg
(Comp.TagSelect.viewCats2 (Comp.TagSelect.viewCats2
texts.tagSelect
settings settings
tagSelectWM tagSelectWM
model.tagSelectModel model.tagSelectModel
@ -1235,7 +1236,8 @@ searchTabs texts ddd flags settings model =
, info = Nothing , info = Nothing
, body = , body =
[ Html.map FolderSelectMsg [ Html.map FolderSelectMsg
(Comp.FolderSelect.viewDrop2 ddd.model (Comp.FolderSelect.viewDrop2 texts.folderSelect
ddd.model
settings.searchMenuFolderCount settings.searchMenuFolderCount
model.folderList model.folderList
) )

View File

@ -25,20 +25,25 @@ import Messages.Comp.SourceManage exposing (Texts)
import Ports import Ports
import QRCode import QRCode
import Styles as S import Styles as S
import Util.Http
import Util.Maybe
type alias Model = type alias Model =
{ formModel : Comp.SourceForm.Model { formModel : Comp.SourceForm.Model
, viewMode : SelectMode , viewMode : SelectMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
, sources : List SourceAndTags , sources : List SourceAndTags
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorInvalid
| FormErrorSubmit String
init : Flags -> ( Model, Cmd Msg ) init : Flags -> ( Model, Cmd Msg )
init flags = init flags =
let let
@ -47,7 +52,7 @@ init flags =
in in
( { formModel = fm ( { formModel = fm
, viewMode = None , viewMode = None
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
, sources = [] , sources = []
@ -103,7 +108,7 @@ update flags msg model =
model.formError model.formError
else else
Nothing FormErrorNone
} }
, Cmd.map TableMsg tc , Cmd.map TableMsg tc
) )
@ -152,7 +157,7 @@ update flags msg model =
Api.Model.SourceAndTags.empty Api.Model.SourceAndTags.empty
nm = nm =
{ model | viewMode = Edit source, formError = Nothing } { model | viewMode = Edit source, formError = FormErrorNone }
in in
update flags (FormMsg (Comp.SourceForm.SetSource source)) nm update flags (FormMsg (Comp.SourceForm.SetSource source)) nm
@ -168,7 +173,7 @@ update flags msg model =
( { model | loading = True }, Api.postSource flags source SubmitResp ) ( { model | loading = True }, Api.postSource flags source SubmitResp )
else else
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none ) ( { model | formError = FormErrorInvalid }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
if res.success then if res.success then
@ -182,10 +187,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none ) ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
RequestDelete -> RequestDelete ->
update flags (YesNoMsg Comp.YesNoDimmer.activate) model update flags (YesNoMsg Comp.YesNoDimmer.activate) model
@ -444,10 +449,21 @@ viewForm2 texts flags settings model =
, div , div
[ classList [ classList
[ ( S.errorMessage, True ) [ ( 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 , Html.map YesNoMsg
(Comp.YesNoDimmer.viewN True (Comp.YesNoDimmer.viewN True

View File

@ -22,7 +22,6 @@ import Html.Events exposing (onSubmit)
import Http import Http
import Messages.Comp.TagManage exposing (Texts) import Messages.Comp.TagManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
import Util.Tag import Util.Tag
import Util.Update import Util.Update
@ -32,13 +31,20 @@ type alias Model =
{ tagTableModel : Comp.TagTable.Model { tagTableModel : Comp.TagTable.Model
, tagFormModel : Comp.TagForm.Model , tagFormModel : Comp.TagForm.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : Maybe String , formError : FormError
, loading : Bool , loading : Bool
, deleteConfirm : Comp.YesNoDimmer.Model , deleteConfirm : Comp.YesNoDimmer.Model
, query : String , query : String
} }
type FormError
= FormErrorNone
| FormErrorHttp Http.Error
| FormErrorInvalid
| FormErrorSubmit String
type ViewMode type ViewMode
= Table = Table
| Form | Form
@ -49,7 +55,7 @@ emptyModel =
{ tagTableModel = Comp.TagTable.emptyModel { tagTableModel = Comp.TagTable.emptyModel
, tagFormModel = Comp.TagForm.emptyModel [] , tagFormModel = Comp.TagForm.emptyModel []
, viewMode = Table , viewMode = Table
, formError = Nothing , formError = FormErrorNone
, loading = False , loading = False
, deleteConfirm = Comp.YesNoDimmer.emptyModel , deleteConfirm = Comp.YesNoDimmer.emptyModel
, query = "" , query = ""
@ -84,7 +90,7 @@ update flags msg model =
, viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table , viewMode = Maybe.map (\_ -> Form) tm.selected |> Maybe.withDefault Table
, formError = , formError =
if Util.Maybe.nonEmpty tm.selected then if Util.Maybe.nonEmpty tm.selected then
Nothing FormErrorNone
else else
model.formError model.formError
@ -144,7 +150,7 @@ update flags msg model =
InitNewTag -> InitNewTag ->
let let
nm = nm =
{ model | viewMode = Form, formError = Nothing } { model | viewMode = Form, formError = FormErrorNone }
tag = tag =
Api.Model.Tag.empty Api.Model.Tag.empty
@ -163,7 +169,7 @@ update flags msg model =
( { model | loading = True }, Api.postTag flags tag SubmitResp ) ( { model | loading = True }, Api.postTag flags tag SubmitResp )
else else
( { model | formError = Just "Please correct the errors in the form." }, Cmd.none ) ( { model | formError = FormErrorInvalid }, Cmd.none )
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
if res.success then if res.success then
@ -177,10 +183,10 @@ update flags msg model =
( { m3 | loading = False }, Cmd.batch [ c2, c3 ] ) ( { m3 | loading = False }, Cmd.batch [ c2, c3 ] )
else else
( { model | formError = Just res.message, loading = False }, Cmd.none ) ( { model | formError = FormErrorSubmit res.message, loading = False }, Cmd.none )
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model | formError = Just (Util.Http.errorToString err), loading = False }, Cmd.none ) ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none )
RequestDelete -> RequestDelete ->
update flags (YesNoMsg Comp.YesNoDimmer.activate) model update flags (YesNoMsg Comp.YesNoDimmer.activate) model
@ -322,12 +328,23 @@ viewForm2 texts model =
} }
, div , div
[ classList [ classList
[ ( "hidden", Util.Maybe.isEmpty model.formError ) [ ( "hidden", model.formError == FormErrorNone )
] ]
, class "my-2" , class "my-2"
, class S.errorMessage , 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) , Html.map FormMsg (Comp.TagForm.view2 texts.tagForm model.tagFormModel)
, B.loadingDimmer , B.loadingDimmer

View File

@ -21,6 +21,7 @@ module Comp.TagSelect exposing
import Api.Model.NameCount exposing (NameCount) import Api.Model.NameCount exposing (NameCount)
import Api.Model.Tag exposing (Tag) import Api.Model.Tag exposing (Tag)
import Api.Model.TagCount exposing (TagCount) import Api.Model.TagCount exposing (TagCount)
import Comp.ExpandCollapse
import Data.Icons as I import Data.Icons as I
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Dict exposing (Dict) import Dict exposing (Dict)
@ -32,7 +33,6 @@ import Set
import Simple.Fuzzy import Simple.Fuzzy
import String as S import String as S
import Styles as S import Styles as S
import Util.ExpandCollapse
import Util.ItemDragDrop as DD import Util.ItemDragDrop as DD
import Util.Maybe import Util.Maybe
@ -405,7 +405,7 @@ viewAll2 texts ddm settings sel model =
wm = wm =
makeWorkModel sel model makeWorkModel sel model
in 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) 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" ] , 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 : Texts -> UiSettings -> WorkModel -> Model -> Html Msg
viewCats2 settings wm model = viewCats2 texts settings wm model =
div [ class "flex flex-col" ] div [ class "flex flex-col" ]
[ div [ class "flex flex-col space-y-2 md:space-y-1" ] [ 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 : Texts -> DD.Model -> UiSettings -> Model -> WorkModel -> List (Html Msg)
renderTagItems2 ddm settings model wm = renderTagItems2 texts ddm settings model wm =
let let
tags = tags =
wm.filteredTags wm.filteredTags
@ -462,15 +462,19 @@ renderTagItems2 ddm settings model wm =
settings.searchMenuTagCount settings.searchMenuTagCount
expLink = expLink =
Util.ExpandCollapse.expandToggle2 Comp.ExpandCollapse.expandToggle
max texts.expandCollapse
(List.length tags) { max = max
, all = List.length tags
}
ToggleExpandTags ToggleExpandTags
cpsLink = cpsLink =
Util.ExpandCollapse.collapseToggle2 Comp.ExpandCollapse.collapseToggle
max texts.expandCollapse
(List.length tags) { max = max
, all = List.length tags
}
ToggleExpandTags ToggleExpandTags
in in
if max <= 0 then if max <= 0 then
@ -557,8 +561,8 @@ viewCategoryItem2 settings model cat =
] ]
renderCatItems2 : UiSettings -> Model -> WorkModel -> List (Html Msg) renderCatItems2 : Texts -> UiSettings -> Model -> WorkModel -> List (Html Msg)
renderCatItems2 settings model wm = renderCatItems2 texts settings model wm =
let let
cats = cats =
wm.filteredCats wm.filteredCats
@ -567,15 +571,19 @@ renderCatItems2 settings model wm =
settings.searchMenuTagCatCount settings.searchMenuTagCatCount
expLink = expLink =
Util.ExpandCollapse.expandToggle2 Comp.ExpandCollapse.expandToggle
max texts.expandCollapse
(List.length cats) { max = max
, all = List.length cats
}
ToggleExpandCats ToggleExpandCats
cpsLink = cpsLink =
Util.ExpandCollapse.collapseToggle2 Comp.ExpandCollapse.collapseToggle
max texts.expandCollapse
(List.length cats) { max = max
, all = List.length cats
}
ToggleExpandCats ToggleExpandCats
in in
if max <= 0 then if max <= 0 then

View File

@ -23,7 +23,6 @@ import Html.Events exposing (onSubmit)
import Http import Http
import Messages.Comp.UserManage exposing (Texts) import Messages.Comp.UserManage exposing (Texts)
import Styles as S import Styles as S
import Util.Http
import Util.Maybe import Util.Maybe
@ -45,6 +44,7 @@ type ViewMode
type FormError type FormError
= FormErrorNone = FormErrorNone
| FormErrorSubmit String | FormErrorSubmit String
| FormErrorHttp Http.Error
| FormErrorInvalid | FormErrorInvalid
@ -183,7 +183,7 @@ update flags msg model =
SubmitResp (Err err) -> SubmitResp (Err err) ->
( { model ( { model
| formError = FormErrorSubmit (Util.Http.errorToString err) | formError = FormErrorHttp err
, loading = False , loading = False
} }
, Cmd.none , Cmd.none
@ -319,6 +319,9 @@ viewForm2 texts settings model =
FormErrorSubmit err -> FormErrorSubmit err ->
text err text err
FormErrorHttp err ->
text (texts.httpError err)
FormErrorInvalid -> FormErrorInvalid ->
text texts.pleaseCorrectErrors text texts.pleaseCorrectErrors
] ]

View File

@ -5,9 +5,12 @@ module Data.Validated exposing
, map2 , map2
, map3 , map3
, map4 , map4
, toResult
, value , value
) )
-- TODO Remove this, use Result
type Validated a type Validated a
= Valid a = Valid a
@ -15,6 +18,19 @@ type Validated a
| Unknown 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 : Validated a -> Bool
isInvalid v = isInvalid v =
case v of case v of

View File

@ -1,12 +1,15 @@
module Messages.Comp.AttachmentMeta exposing (Texts, gb) module Messages.Comp.AttachmentMeta exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.DateFormat as DF import Messages.DateFormat as DF
import Messages.UiLanguage import Messages.UiLanguage
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, extractedMetadata : String , extractedMetadata : String
, content : String , content : String
, labels : String , labels : String
@ -24,6 +27,7 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, extractedMetadata = "Extracted Meta Data" , extractedMetadata = "Extracted Meta Data"
, content = "Content" , content = "Content"
, labels = "Labels" , labels = "Labels"

View File

@ -1,5 +1,7 @@
module Messages.Comp.CalEventInput exposing (Texts, gb) module Messages.Comp.CalEventInput exposing (Texts, gb)
import Http
import Messages.Comp.HttpError
import Messages.DateFormat as DF import Messages.DateFormat as DF
import Messages.UiLanguage import Messages.UiLanguage
@ -15,6 +17,7 @@ type alias Texts =
, schedule : String , schedule : String
, next : String , next : String
, formatDateTime : Int -> String , formatDateTime : Int -> String
, httpError : Http.Error -> String
} }
@ -30,4 +33,5 @@ gb =
, schedule = "Schedule" , schedule = "Schedule"
, next = "Next" , next = "Next"
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English , formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
, httpError = Messages.Comp.HttpError.gb
} }

View File

@ -1,26 +1,36 @@
module Messages.Comp.ChangePasswordForm exposing (Texts, gb) module Messages.Comp.ChangePasswordForm exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, currentPassword : String , currentPassword : String
, newPassword : String , newPassword : String
, repeatPassword : String , repeatPassword : String
, currentPasswordPlaceholder : String , currentPasswordPlaceholder : String
, newPasswordPlaceholder : String , newPasswordPlaceholder : String
, repeatPasswordPlaceholder : String , repeatPasswordPlaceholder : String
, passwordMismatch : String
, fillRequiredFields : String
, passwordChangeSuccessful : String
} }
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, currentPassword = "Current Password" , currentPassword = "Current Password"
, newPassword = "New Password" , newPassword = "New Password"
, repeatPassword = "New Password (repeat)" , repeatPassword = "New Password (repeat)"
, currentPasswordPlaceholder = "Password" , currentPasswordPlaceholder = "Password"
, newPasswordPlaceholder = "Password" , newPasswordPlaceholder = "Password"
, repeatPasswordPlaceholder = "Password" , repeatPasswordPlaceholder = "Password"
, passwordMismatch = "The passwords do not match."
, fillRequiredFields = "Please fill required fields."
, passwordChangeSuccessful = "Password has been changed."
} }

View File

@ -1,14 +1,17 @@
module Messages.Comp.CollectiveSettingsForm exposing (Texts, gb) module Messages.Comp.CollectiveSettingsForm exposing (Texts, gb)
import Data.Language exposing (Language) import Data.Language exposing (Language)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.ClassifierSettingsForm import Messages.Comp.ClassifierSettingsForm
import Messages.Comp.HttpError
import Messages.Data.Language import Messages.Data.Language
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, classifierSettingsForm : Messages.Comp.ClassifierSettingsForm.Texts , classifierSettingsForm : Messages.Comp.ClassifierSettingsForm.Texts
, httpError : Http.Error -> String
, save : String , save : String
, saveSettings : String , saveSettings : String
, documentLanguage : String , documentLanguage : String
@ -22,6 +25,9 @@ type alias Texts =
, autoTagging : String , autoTagging : String
, startNow : String , startNow : String
, languageLabel : Language -> String , languageLabel : Language -> String
, classifierTaskStarted : String
, fulltextReindexSubmitted : String
, fulltextReindexOkMissing : String
} }
@ -29,6 +35,7 @@ gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, classifierSettingsForm = Messages.Comp.ClassifierSettingsForm.gb , classifierSettingsForm = Messages.Comp.ClassifierSettingsForm.gb
, httpError = Messages.Comp.HttpError.gb
, save = "Save" , save = "Save"
, saveSettings = "Save Settings" , saveSettings = "Save Settings"
, documentLanguage = "Document Language" , documentLanguage = "Document Language"
@ -46,4 +53,8 @@ gb =
, autoTagging = "Auto-Tagging" , autoTagging = "Auto-Tagging"
, startNow = "Start now" , startNow = "Start now"
, languageLabel = Messages.Data.Language.gb , 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."
} }

View File

@ -1,7 +1,9 @@
module Messages.Comp.CustomFieldForm exposing (Texts, gb) module Messages.Comp.CustomFieldForm exposing (Texts, gb)
import Data.CustomFieldType exposing (CustomFieldType) import Data.CustomFieldType exposing (CustomFieldType)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Data.CustomFieldType import Messages.Data.CustomFieldType
@ -9,6 +11,7 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, reallyDeleteField : String , reallyDeleteField : String
, fieldTypeLabel : CustomFieldType -> String , fieldTypeLabel : CustomFieldType -> String
, httpError : Http.Error -> String
, createCustomField : String , createCustomField : String
, modifyTypeWarning : String , modifyTypeWarning : String
, nameInfo : String , nameInfo : String
@ -17,6 +20,9 @@ type alias Texts =
, label : String , label : String
, labelInfo : String , labelInfo : String
, deleteThisField : String , deleteThisField : String
, fieldNameRequired : String
, fieldTypeRequired : String
, updateSuccessful : String
} }
@ -25,6 +31,7 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, reallyDeleteField = "Really delete this custom field?" , reallyDeleteField = "Really delete this custom field?"
, fieldTypeLabel = Messages.Data.CustomFieldType.gb , fieldTypeLabel = Messages.Data.CustomFieldType.gb
, httpError = Messages.Comp.HttpError.gb
, createCustomField = "Create a new custom field." , createCustomField = "Create a new custom field."
, modifyTypeWarning = , modifyTypeWarning =
"Note that changing the format may " "Note that changing the format may "
@ -41,4 +48,7 @@ gb =
"The user defined label for this field. This is used to represent " "The user defined label for this field. This is used to represent "
++ "this field in the ui. If not present, the name is used." ++ "this field in the ui. If not present, the name is used."
, deleteThisField = "Delete this field" , deleteThisField = "Delete this field"
, fieldNameRequired = "A name is required."
, fieldTypeRequired = "A type is required."
, updateSuccessful = "Field has been saved."
} }

View File

@ -1,8 +1,10 @@
module Messages.Comp.DetailEdit exposing (Texts, gb) module Messages.Comp.DetailEdit exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.CustomFieldForm import Messages.Comp.CustomFieldForm
import Messages.Comp.EquipmentForm import Messages.Comp.EquipmentForm
import Messages.Comp.HttpError
import Messages.Comp.OrgForm import Messages.Comp.OrgForm
import Messages.Comp.PersonForm import Messages.Comp.PersonForm
import Messages.Comp.TagForm import Messages.Comp.TagForm
@ -15,6 +17,9 @@ type alias Texts =
, orgForm : Messages.Comp.OrgForm.Texts , orgForm : Messages.Comp.OrgForm.Texts
, equipmentForm : Messages.Comp.EquipmentForm.Texts , equipmentForm : Messages.Comp.EquipmentForm.Texts
, customFieldForm : Messages.Comp.CustomFieldForm.Texts , customFieldForm : Messages.Comp.CustomFieldForm.Texts
, httpError : Http.Error -> String
, submitSuccessful : String
, missingRequiredFields : String
} }
@ -26,4 +31,7 @@ gb =
, orgForm = Messages.Comp.OrgForm.gb , orgForm = Messages.Comp.OrgForm.gb
, equipmentForm = Messages.Comp.EquipmentForm.gb , equipmentForm = Messages.Comp.EquipmentForm.gb
, customFieldForm = Messages.Comp.CustomFieldForm.gb , customFieldForm = Messages.Comp.CustomFieldForm.gb
, httpError = Messages.Comp.HttpError.gb
, submitSuccessful = "Successfully saved."
, missingRequiredFields = "Please fill required fields."
} }

View File

@ -1,18 +1,22 @@
module Messages.Comp.EmailSettingsManage exposing (Texts, gb) module Messages.Comp.EmailSettingsManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.EmailSettingsForm import Messages.Comp.EmailSettingsForm
import Messages.Comp.EmailSettingsTable import Messages.Comp.EmailSettingsTable
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, settingsForm : Messages.Comp.EmailSettingsForm.Texts , settingsForm : Messages.Comp.EmailSettingsForm.Texts
, settingsTable : Messages.Comp.EmailSettingsTable.Texts , settingsTable : Messages.Comp.EmailSettingsTable.Texts
, httpError : Http.Error -> String
, newSettings : String , newSettings : String
, addNewSmtpSettings : String , addNewSmtpSettings : String
, reallyDeleteConnection : String , reallyDeleteConnection : String
, deleteThisEntry : String , deleteThisEntry : String
, fillRequiredFields : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, settingsForm = Messages.Comp.EmailSettingsForm.gb , settingsForm = Messages.Comp.EmailSettingsForm.gb
, settingsTable = Messages.Comp.EmailSettingsTable.gb , settingsTable = Messages.Comp.EmailSettingsTable.gb
, httpError = Messages.Comp.HttpError.gb
, newSettings = "New Settings" , newSettings = "New Settings"
, addNewSmtpSettings = "Add new SMTP settings" , addNewSmtpSettings = "Add new SMTP settings"
, reallyDeleteConnection = "Really delete these connection?" , reallyDeleteConnection = "Really delete these connection?"
, deleteThisEntry = "Delete this connection" , deleteThisEntry = "Delete this connection"
, fillRequiredFields = "Please fill required fields."
} }

View File

@ -1,18 +1,22 @@
module Messages.Comp.EquipmentManage exposing (Texts, gb) module Messages.Comp.EquipmentManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.EquipmentForm import Messages.Comp.EquipmentForm
import Messages.Comp.EquipmentTable import Messages.Comp.EquipmentTable
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, equipmentTable : Messages.Comp.EquipmentTable.Texts , equipmentTable : Messages.Comp.EquipmentTable.Texts
, equipmentForm : Messages.Comp.EquipmentForm.Texts , equipmentForm : Messages.Comp.EquipmentForm.Texts
, httpError : Http.Error -> String
, createNewEquipment : String , createNewEquipment : String
, newEquipment : String , newEquipment : String
, reallyDeleteEquipment : String , reallyDeleteEquipment : String
, deleteThisEquipment : String , deleteThisEquipment : String
, correctFormErrors : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, equipmentTable = Messages.Comp.EquipmentTable.gb , equipmentTable = Messages.Comp.EquipmentTable.gb
, equipmentForm = Messages.Comp.EquipmentForm.gb , equipmentForm = Messages.Comp.EquipmentForm.gb
, httpError = Messages.Comp.HttpError.gb
, createNewEquipment = "Create a new equipment" , createNewEquipment = "Create a new equipment"
, newEquipment = "New Equipment" , newEquipment = "New Equipment"
, reallyDeleteEquipment = "Really delete this equipment?" , reallyDeleteEquipment = "Really delete this equipment?"
, deleteThisEquipment = "Delete this equipment" , deleteThisEquipment = "Delete this equipment"
, correctFormErrors = "Please correct the errors in the form."
} }

View 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 "
}

View File

@ -1,10 +1,13 @@
module Messages.Comp.FolderDetail exposing (Texts, gb) module Messages.Comp.FolderDetail exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, reallyDeleteThisFolder : String , reallyDeleteThisFolder : String
, autoOwnerInfo : String , autoOwnerInfo : String
, modifyInfo : String , modifyInfo : String
@ -14,12 +17,16 @@ type alias Texts =
, add : String , add : String
, removeMember : String , removeMember : String
, deleteThisFolder : String , deleteThisFolder : String
, folderCreated : String
, nameChangeSuccessful : String
, deleteSuccessful : String
} }
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, reallyDeleteThisFolder = "Really delete this folder?" , reallyDeleteThisFolder = "Really delete this folder?"
, autoOwnerInfo = "You are automatically set as owner of this new folder." , autoOwnerInfo = "You are automatically set as owner of this new folder."
, modifyInfo = "Modify this folder by changing the name or add/remove members." , modifyInfo = "Modify this folder by changing the name or add/remove members."
@ -29,4 +36,7 @@ gb =
, add = "Add" , add = "Add"
, removeMember = "Remove this member" , removeMember = "Remove this member"
, deleteThisFolder = "Delete this folder" , deleteThisFolder = "Delete this folder"
, folderCreated = "Folder has been created."
, nameChangeSuccessful = "Name has been changed."
, deleteSuccessful = "Folder has been deleted."
} }

View 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
}

View 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

View File

@ -1,6 +1,8 @@
module Messages.Comp.ImapSettingsManage exposing (Texts, gb) module Messages.Comp.ImapSettingsManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.ImapSettingsForm import Messages.Comp.ImapSettingsForm
import Messages.Comp.ImapSettingsTable import Messages.Comp.ImapSettingsTable
@ -9,10 +11,12 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, imapForm : Messages.Comp.ImapSettingsForm.Texts , imapForm : Messages.Comp.ImapSettingsForm.Texts
, imapTable : Messages.Comp.ImapSettingsTable.Texts , imapTable : Messages.Comp.ImapSettingsTable.Texts
, httpError : Http.Error -> String
, addNewImapSettings : String , addNewImapSettings : String
, newSettings : String , newSettings : String
, reallyDeleteSettings : String , reallyDeleteSettings : String
, deleteThisEntry : String , deleteThisEntry : String
, fillRequiredFields : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, imapForm = Messages.Comp.ImapSettingsForm.gb , imapForm = Messages.Comp.ImapSettingsForm.gb
, imapTable = Messages.Comp.ImapSettingsTable.gb , imapTable = Messages.Comp.ImapSettingsTable.gb
, httpError = Messages.Comp.HttpError.gb
, addNewImapSettings = "Add new IMAP settings" , addNewImapSettings = "Add new IMAP settings"
, newSettings = "New Settings" , newSettings = "New Settings"
, reallyDeleteSettings = "Really delete this mail-box connection?" , reallyDeleteSettings = "Really delete this mail-box connection?"
, deleteThisEntry = "Delete this settings entry" , deleteThisEntry = "Delete this settings entry"
, fillRequiredFields = "Please fill required fields."
} }

View File

@ -1,7 +1,10 @@
module Messages.Comp.ItemDetail exposing (Texts, gb) module Messages.Comp.ItemDetail exposing (Texts, gb)
import Http
import Messages.Comp.DetailEdit import Messages.Comp.DetailEdit
import Messages.Comp.HttpError
import Messages.Comp.ItemDetail.AddFilesForm import Messages.Comp.ItemDetail.AddFilesForm
import Messages.Comp.ItemDetail.ConfirmModal
import Messages.Comp.ItemDetail.ItemInfoHeader import Messages.Comp.ItemDetail.ItemInfoHeader
import Messages.Comp.ItemDetail.Notes import Messages.Comp.ItemDetail.Notes
import Messages.Comp.ItemDetail.SingleAttachment import Messages.Comp.ItemDetail.SingleAttachment
@ -19,6 +22,8 @@ type alias Texts =
, notes : Messages.Comp.ItemDetail.Notes.Texts , notes : Messages.Comp.ItemDetail.Notes.Texts
, itemMail : Messages.Comp.ItemMail.Texts , itemMail : Messages.Comp.ItemMail.Texts
, detailEdit : Messages.Comp.DetailEdit.Texts , detailEdit : Messages.Comp.DetailEdit.Texts
, confirmModal : Messages.Comp.ItemDetail.ConfirmModal.Texts
, httpError : Http.Error -> String
, key : String , key : String
, backToSearchResults : String , backToSearchResults : String
, previousItem : String , previousItem : String
@ -37,6 +42,7 @@ type alias Texts =
, lastUpdateOn : String , lastUpdateOn : String
, sendingMailNow : String , sendingMailNow : String
, formatDateTime : Int -> String , formatDateTime : Int -> String
, mailSendSuccessful : String
} }
@ -49,6 +55,8 @@ gb =
, notes = Messages.Comp.ItemDetail.Notes.gb , notes = Messages.Comp.ItemDetail.Notes.gb
, itemMail = Messages.Comp.ItemMail.gb , itemMail = Messages.Comp.ItemMail.gb
, detailEdit = Messages.Comp.DetailEdit.gb , detailEdit = Messages.Comp.DetailEdit.gb
, confirmModal = Messages.Comp.ItemDetail.ConfirmModal.gb
, httpError = Messages.Comp.HttpError.gb
, key = "Key" , key = "Key"
, backToSearchResults = "Back to search results" , backToSearchResults = "Back to search results"
, previousItem = "Previous item." , previousItem = "Previous item."
@ -67,4 +75,5 @@ gb =
, lastUpdateOn = "Last update on" , lastUpdateOn = "Last update on"
, sendingMailNow = "Sending e-mail" , sendingMailNow = "Sending e-mail"
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English , formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
, mailSendSuccessful = "Mail sent."
} }

View File

@ -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?"
}

View File

@ -1,10 +1,12 @@
module Messages.Comp.ItemDetail.SingleAttachment exposing (Texts, gb) module Messages.Comp.ItemDetail.SingleAttachment exposing (Texts, gb)
import Messages.Comp.AttachmentMeta import Messages.Comp.AttachmentMeta
import Messages.Comp.ItemDetail.ConfirmModal
type alias Texts = type alias Texts =
{ attachmentMeta : Messages.Comp.AttachmentMeta.Texts { attachmentMeta : Messages.Comp.AttachmentMeta.Texts
, confirmModal : Messages.Comp.ItemDetail.ConfirmModal.Texts
, noName : String , noName : String
, openFileInNewTab : String , openFileInNewTab : String
, downloadFile : String , downloadFile : String
@ -24,6 +26,7 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ attachmentMeta = Messages.Comp.AttachmentMeta.gb { attachmentMeta = Messages.Comp.AttachmentMeta.gb
, confirmModal = Messages.Comp.ItemDetail.ConfirmModal.gb
, noName = "No name" , noName = "No name"
, openFileInNewTab = "Open file in new tab" , openFileInNewTab = "Open file in new tab"
, downloadFile = "Download file" , downloadFile = "Download file"

View File

@ -1,10 +1,13 @@
module Messages.Comp.ItemMail exposing (Texts, gb) module Messages.Comp.ItemMail exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, selectConnection : String , selectConnection : String
, sendVia : String , sendVia : String
, recipients : String , recipients : String
@ -13,12 +16,15 @@ type alias Texts =
, subject : String , subject : String
, body : String , body : String
, includeAllAttachments : String , includeAllAttachments : String
, connectionMissing : String
, sendLabel : String
} }
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, selectConnection = "Select connection..." , selectConnection = "Select connection..."
, sendVia = "Send via" , sendVia = "Send via"
, recipients = "Recipient(s)" , recipients = "Recipient(s)"
@ -27,4 +33,6 @@ gb =
, subject = "Subject" , subject = "Subject"
, body = "Body" , body = "Body"
, includeAllAttachments = "Include all item attachments" , includeAllAttachments = "Include all item attachments"
, connectionMissing = "No E-Mail connections configured. Goto user settings to add one."
, sendLabel = "Send"
} }

View File

@ -1,12 +1,15 @@
module Messages.Comp.NotificationForm exposing (Texts, gb) module Messages.Comp.NotificationForm exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.CalEventInput import Messages.Comp.CalEventInput
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, calEventInput : Messages.Comp.CalEventInput.Texts , calEventInput : Messages.Comp.CalEventInput.Texts
, httpError : Http.Error -> String
, reallyDeleteTask : String , reallyDeleteTask : String
, startOnce : String , startOnce : String
, startTaskNow : String , startTaskNow : String
@ -30,6 +33,10 @@ type alias Texts =
, schedule : String , schedule : String
, scheduleClickForHelp : String , scheduleClickForHelp : String
, scheduleInfo : String , scheduleInfo : String
, connectionMissing : String
, invalidCalEvent : String
, remindDaysRequired : String
, recipientsRequired : String
} }
@ -37,6 +44,7 @@ gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, calEventInput = Messages.Comp.CalEventInput.gb , calEventInput = Messages.Comp.CalEventInput.gb
, httpError = Messages.Comp.HttpError.gb
, reallyDeleteTask = "Really delete this notification task?" , reallyDeleteTask = "Really delete this notification task?"
, startOnce = "Start Once" , startOnce = "Start Once"
, startTaskNow = "Start this task now" , startTaskNow = "Start this task now"
@ -64,4 +72,8 @@ gb =
++ "Use English 3-letter weekdays. Either a single value, " ++ "Use English 3-letter weekdays. Either a single value, "
++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) " ++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) "
++ "is allowed for each part." ++ "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."
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.NotificationManage exposing (Texts, gb) module Messages.Comp.NotificationManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.NotificationForm import Messages.Comp.NotificationForm
import Messages.Comp.NotificationTable import Messages.Comp.NotificationTable
@ -9,8 +11,13 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, notificationForm : Messages.Comp.NotificationForm.Texts , notificationForm : Messages.Comp.NotificationForm.Texts
, notificationTable : Messages.Comp.NotificationTable.Texts , notificationTable : Messages.Comp.NotificationTable.Texts
, httpError : Http.Error -> String
, newTask : String , newTask : String
, createNewTask : String , createNewTask : String
, taskCreated : String
, taskUpdated : String
, taskStarted : String
, taskDeleted : String
} }
@ -19,6 +26,11 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, notificationForm = Messages.Comp.NotificationForm.gb , notificationForm = Messages.Comp.NotificationForm.gb
, notificationTable = Messages.Comp.NotificationTable.gb , notificationTable = Messages.Comp.NotificationTable.gb
, httpError = Messages.Comp.HttpError.gb
, newTask = "New Task" , newTask = "New Task"
, createNewTask = "Create a new notification task" , createNewTask = "Create a new notification task"
, taskCreated = "Task created."
, taskUpdated = "Task updated."
, taskStarted = "Task started."
, taskDeleted = "Task deleted."
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.OrgManage exposing (Texts, gb) module Messages.Comp.OrgManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.OrgForm import Messages.Comp.OrgForm
import Messages.Comp.OrgTable import Messages.Comp.OrgTable
@ -9,10 +11,12 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, orgForm : Messages.Comp.OrgForm.Texts , orgForm : Messages.Comp.OrgForm.Texts
, orgTable : Messages.Comp.OrgTable.Texts , orgTable : Messages.Comp.OrgTable.Texts
, httpError : Http.Error -> String
, newOrganization : String , newOrganization : String
, createNewOrganization : String , createNewOrganization : String
, reallyDeleteOrg : String , reallyDeleteOrg : String
, deleteThisOrg : String , deleteThisOrg : String
, correctFormErrors : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, orgForm = Messages.Comp.OrgForm.gb , orgForm = Messages.Comp.OrgForm.gb
, orgTable = Messages.Comp.OrgTable.gb , orgTable = Messages.Comp.OrgTable.gb
, httpError = Messages.Comp.HttpError.gb
, newOrganization = "New Organization" , newOrganization = "New Organization"
, createNewOrganization = "Create a new organization" , createNewOrganization = "Create a new organization"
, reallyDeleteOrg = "Really delete this organization?" , reallyDeleteOrg = "Really delete this organization?"
, deleteThisOrg = "Delete this organization" , deleteThisOrg = "Delete this organization"
, correctFormErrors = "Please correct the errors in the form."
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.PersonManage exposing (Texts, gb) module Messages.Comp.PersonManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.PersonForm import Messages.Comp.PersonForm
import Messages.Comp.PersonTable import Messages.Comp.PersonTable
@ -9,10 +11,12 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, personForm : Messages.Comp.PersonForm.Texts , personForm : Messages.Comp.PersonForm.Texts
, personTable : Messages.Comp.PersonTable.Texts , personTable : Messages.Comp.PersonTable.Texts
, httpError : Http.Error -> String
, newPerson : String , newPerson : String
, createNewPerson : String , createNewPerson : String
, reallyDeletePerson : String , reallyDeletePerson : String
, deleteThisPerson : String , deleteThisPerson : String
, correctFormErrors : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, personForm = Messages.Comp.PersonForm.gb , personForm = Messages.Comp.PersonForm.gb
, personTable = Messages.Comp.PersonTable.gb , personTable = Messages.Comp.PersonTable.gb
, httpError = Messages.Comp.HttpError.gb
, newPerson = "New Person" , newPerson = "New Person"
, createNewPerson = "Create a new person" , createNewPerson = "Create a new person"
, reallyDeletePerson = "Really delete this person?" , reallyDeletePerson = "Really delete this person?"
, deleteThisPerson = "Delete this person" , deleteThisPerson = "Delete this person"
, correctFormErrors = "Please correct the errors in the form."
} }

View File

@ -1,12 +1,15 @@
module Messages.Comp.ScanMailboxForm exposing (Texts, gb) module Messages.Comp.ScanMailboxForm exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.CalEventInput import Messages.Comp.CalEventInput
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, calEventInput : Messages.Comp.CalEventInput.Texts , calEventInput : Messages.Comp.CalEventInput.Texts
, httpError : Http.Error -> String
, reallyDeleteTask : String , reallyDeleteTask : String
, startOnce : String , startOnce : String
, startNow : String , startNow : String
@ -54,6 +57,9 @@ type alias Texts =
, schedule : String , schedule : String
, scheduleClickForHelp : String , scheduleClickForHelp : String
, scheduleInfo : String , scheduleInfo : String
, connectionMissing : String
, noProcessingFolders : String
, invalidCalEvent : String
} }
@ -61,6 +67,7 @@ gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, calEventInput = Messages.Comp.CalEventInput.gb , calEventInput = Messages.Comp.CalEventInput.gb
, httpError = Messages.Comp.HttpError.gb
, reallyDeleteTask = "Really delete this scan mailbox task?" , reallyDeleteTask = "Really delete this scan mailbox task?"
, startOnce = "Start Once" , startOnce = "Start Once"
, startNow = "Start this task now" , startNow = "Start this task now"
@ -135,4 +142,7 @@ disappear then.
++ "Use English 3-letter weekdays. Either a single value, " ++ "Use English 3-letter weekdays. Either a single value, "
++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) " ++ "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) "
++ "is allowed for each part." ++ "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."
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.ScanMailboxManage exposing (Texts, gb) module Messages.Comp.ScanMailboxManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.ScanMailboxForm import Messages.Comp.ScanMailboxForm
import Messages.Comp.ScanMailboxTable import Messages.Comp.ScanMailboxTable
@ -9,8 +11,13 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, form : Messages.Comp.ScanMailboxForm.Texts , form : Messages.Comp.ScanMailboxForm.Texts
, table : Messages.Comp.ScanMailboxTable.Texts , table : Messages.Comp.ScanMailboxTable.Texts
, httpError : Http.Error -> String
, newTask : String , newTask : String
, createNewTask : String , createNewTask : String
, taskCreated : String
, taskUpdated : String
, taskStarted : String
, taskDeleted : String
} }
@ -19,6 +26,11 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, form = Messages.Comp.ScanMailboxForm.gb , form = Messages.Comp.ScanMailboxForm.gb
, table = Messages.Comp.ScanMailboxTable.gb , table = Messages.Comp.ScanMailboxTable.gb
, httpError = Messages.Comp.HttpError.gb
, newTask = "New Task" , newTask = "New Task"
, createNewTask = "Create a new scan mailbox task" , createNewTask = "Create a new scan mailbox task"
, taskCreated = "Task created."
, taskUpdated = "Task updated."
, taskStarted = "Task started."
, taskDeleted = "Task deleted."
} }

View File

@ -2,6 +2,7 @@ module Messages.Comp.SearchMenu exposing (Texts, gb)
import Messages.Basics import Messages.Basics
import Messages.Comp.CustomFieldMultiInput import Messages.Comp.CustomFieldMultiInput
import Messages.Comp.FolderSelect
import Messages.Comp.TagSelect import Messages.Comp.TagSelect
@ -9,6 +10,7 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts , customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts
, tagSelect : Messages.Comp.TagSelect.Texts , tagSelect : Messages.Comp.TagSelect.Texts
, folderSelect : Messages.Comp.FolderSelect.Texts
, chooseDirection : String , chooseDirection : String
, choosePerson : String , choosePerson : String
, chooseEquipment : String , chooseEquipment : String
@ -38,6 +40,7 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb , customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb
, tagSelect = Messages.Comp.TagSelect.gb , tagSelect = Messages.Comp.TagSelect.gb
, folderSelect = Messages.Comp.FolderSelect.gb
, chooseDirection = "Choose a direction" , chooseDirection = "Choose a direction"
, choosePerson = "Choose a person" , choosePerson = "Choose a person"
, chooseEquipment = "Choose an equipment" , chooseEquipment = "Choose an equipment"

View File

@ -1,6 +1,8 @@
module Messages.Comp.SourceManage exposing (Texts, gb) module Messages.Comp.SourceManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.SourceForm import Messages.Comp.SourceForm
import Messages.Comp.SourceTable import Messages.Comp.SourceTable
@ -9,6 +11,7 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, sourceTable : Messages.Comp.SourceTable.Texts , sourceTable : Messages.Comp.SourceTable.Texts
, sourceForm : Messages.Comp.SourceForm.Texts , sourceForm : Messages.Comp.SourceForm.Texts
, httpError : Http.Error -> String
, addSourceUrl : String , addSourceUrl : String
, newSource : String , newSource : String
, publicUploads : String , publicUploads : String
@ -22,6 +25,7 @@ type alias Texts =
, createNewSource : String , createNewSource : String
, deleteThisSource : String , deleteThisSource : String
, errorGeneratingQR : String , errorGeneratingQR : String
, correctFormErrors : String
} }
@ -30,6 +34,7 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, sourceTable = Messages.Comp.SourceTable.gb , sourceTable = Messages.Comp.SourceTable.gb
, sourceForm = Messages.Comp.SourceForm.gb , sourceForm = Messages.Comp.SourceForm.gb
, httpError = Messages.Comp.HttpError.gb
, addSourceUrl = "Add a source url" , addSourceUrl = "Add a source url"
, newSource = "New source" , newSource = "New source"
, publicUploads = "Public Uploads" , publicUploads = "Public Uploads"
@ -50,4 +55,5 @@ gb =
, createNewSource = "Create new source" , createNewSource = "Create new source"
, deleteThisSource = "Delete this source" , deleteThisSource = "Delete this source"
, errorGeneratingQR = "Error generating QR Code" , errorGeneratingQR = "Error generating QR Code"
, correctFormErrors = "Please correct the errors in the form."
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.TagManage exposing (Texts, gb) module Messages.Comp.TagManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.TagForm import Messages.Comp.TagForm
import Messages.Comp.TagTable import Messages.Comp.TagTable
@ -9,10 +11,12 @@ type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, tagTable : Messages.Comp.TagTable.Texts , tagTable : Messages.Comp.TagTable.Texts
, tagForm : Messages.Comp.TagForm.Texts , tagForm : Messages.Comp.TagForm.Texts
, httpError : Http.Error -> String
, createNewTag : String , createNewTag : String
, newTag : String , newTag : String
, reallyDeleteTag : String , reallyDeleteTag : String
, deleteThisTag : String , deleteThisTag : String
, correctFormErrors : String
} }
@ -21,8 +25,10 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, tagTable = Messages.Comp.TagTable.gb , tagTable = Messages.Comp.TagTable.gb
, tagForm = Messages.Comp.TagForm.gb , tagForm = Messages.Comp.TagForm.gb
, httpError = Messages.Comp.HttpError.gb
, createNewTag = "Create a new tag" , createNewTag = "Create a new tag"
, newTag = "New Tag" , newTag = "New Tag"
, reallyDeleteTag = "Really delete this tag?" , reallyDeleteTag = "Really delete this tag?"
, deleteThisTag = "Delete this tag" , deleteThisTag = "Delete this tag"
, correctFormErrors = "Please correct the errors in the form."
} }

View File

@ -1,8 +1,11 @@
module Messages.Comp.TagSelect exposing (Texts, gb) module Messages.Comp.TagSelect exposing (Texts, gb)
import Messages.Comp.ExpandCollapse
type alias Texts = type alias Texts =
{ hideEmpty : String { expandCollapse : Messages.Comp.ExpandCollapse.Texts
, hideEmpty : String
, showEmpty : String , showEmpty : String
, filterPlaceholder : String , filterPlaceholder : String
} }
@ -10,7 +13,8 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ hideEmpty = "Hide empty" { expandCollapse = Messages.Comp.ExpandCollapse.gb
, hideEmpty = "Hide empty"
, showEmpty = "Show empty" , showEmpty = "Show empty"
, filterPlaceholder = "Filter " , filterPlaceholder = "Filter "
} }

View File

@ -1,6 +1,8 @@
module Messages.Comp.UserManage exposing (Texts, gb) module Messages.Comp.UserManage exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.UserForm import Messages.Comp.UserForm
import Messages.Comp.UserTable import Messages.Comp.UserTable
@ -8,6 +10,7 @@ import Messages.Comp.UserTable
type alias Texts = type alias Texts =
{ userTable : Messages.Comp.UserTable.Texts { userTable : Messages.Comp.UserTable.Texts
, userForm : Messages.Comp.UserForm.Texts , userForm : Messages.Comp.UserForm.Texts
, httpError : Http.Error -> String
, users : String , users : String
, newUser : String , newUser : String
, addNewUser : String , addNewUser : String
@ -24,6 +27,7 @@ gb =
{ userTable = Messages.Comp.UserTable.gb { userTable = Messages.Comp.UserTable.gb
, userForm = Messages.Comp.UserForm.gb , userForm = Messages.Comp.UserForm.gb
, basics = Messages.Basics.gb , basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, users = "Users" , users = "Users"
, newUser = "New user" , newUser = "New user"
, addNewUser = "Add new user" , addNewUser = "Add new user"
@ -32,8 +36,3 @@ gb =
, deleteThisUser = "Delete this user" , deleteThisUser = "Delete this user"
, pleaseCorrectErrors = "Please correct the errors in the form." , pleaseCorrectErrors = "Please correct the errors in the form."
} }
de : Texts
de =
gb

View File

@ -1,7 +1,9 @@
module Messages.Page.CollectiveSettings exposing (Texts, gb) module Messages.Page.CollectiveSettings exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.CollectiveSettingsForm import Messages.Comp.CollectiveSettingsForm
import Messages.Comp.HttpError
import Messages.Comp.SourceManage import Messages.Comp.SourceManage
import Messages.Comp.UserManage import Messages.Comp.UserManage
@ -11,6 +13,7 @@ type alias Texts =
, userManage : Messages.Comp.UserManage.Texts , userManage : Messages.Comp.UserManage.Texts
, collectiveSettingsForm : Messages.Comp.CollectiveSettingsForm.Texts , collectiveSettingsForm : Messages.Comp.CollectiveSettingsForm.Texts
, sourceManage : Messages.Comp.SourceManage.Texts , sourceManage : Messages.Comp.SourceManage.Texts
, httpError : Http.Error -> String
, collectiveSettings : String , collectiveSettings : String
, insights : String , insights : String
, sources : String , sources : String
@ -19,6 +22,7 @@ type alias Texts =
, user : String , user : String
, collective : String , collective : String
, size : String , size : String
, submitSuccessful : String
} }
@ -28,6 +32,7 @@ gb =
, userManage = Messages.Comp.UserManage.gb , userManage = Messages.Comp.UserManage.gb
, collectiveSettingsForm = Messages.Comp.CollectiveSettingsForm.gb , collectiveSettingsForm = Messages.Comp.CollectiveSettingsForm.gb
, sourceManage = Messages.Comp.SourceManage.gb , sourceManage = Messages.Comp.SourceManage.gb
, httpError = Messages.Comp.HttpError.gb
, collectiveSettings = "Collective Settings" , collectiveSettings = "Collective Settings"
, insights = "Insights" , insights = "Insights"
, sources = "Sources" , sources = "Sources"
@ -36,4 +41,5 @@ gb =
, user = "User" , user = "User"
, collective = "Collective" , collective = "Collective"
, size = "Size" , size = "Size"
, submitSuccessful = "Settings saved."
} }

View File

@ -1,8 +1,12 @@
module Messages.Page.Login exposing (Texts, gb) module Messages.Page.Login exposing (Texts, gb)
import Http
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ loginToDocspell : String { httpError : Http.Error -> String
, loginToDocspell : String
, username : String , username : String
, collectiveSlashLogin : String , collectiveSlashLogin : String
, password : String , password : String
@ -18,7 +22,8 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ loginToDocspell = "Login to Docspell" { httpError = Messages.Comp.HttpError.gb
, loginToDocspell = "Login to Docspell"
, username = "Username" , username = "Username"
, collectiveSlashLogin = "Collective / Login" , collectiveSlashLogin = "Collective / Login"
, password = "Password" , password = "Password"

View File

@ -1,14 +1,18 @@
module Messages.Page.NewInvite exposing (Texts, gb) module Messages.Page.NewInvite exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, createNewInvitations : String , createNewInvitations : String
, invitationKey : String , invitationKey : String
, password : String , password : String
, reset : String , reset : String
, newInvitationCreated : String
, inviteInfo : String , inviteInfo : String
} }
@ -16,18 +20,22 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, createNewInvitations = "Create new invitations" , createNewInvitations = "Create new invitations"
, invitationKey = "Invitation Key" , invitationKey = "Invitation Key"
, password = "Password" , password = "Password"
, reset = "Reset" , reset = "Reset"
, newInvitationCreated = "New invitation created."
, inviteInfo = , inviteInfo =
"""Docspell requires an invite when signing up. You can """
create these invites here and send them to friends so Docspell requires an invite when signing up. You can
they can signup with docspell. 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 Each invite can only be used once. You'll need to
create one key for each person you want to invite. create one key for each person you want to invite.
Creating an invite requires providing the password Creating an invite requires providing the password
from the configuration.""" from the configuration.
"""
} }

View File

@ -1,12 +1,15 @@
module Messages.Page.Queue exposing (Texts, gb) module Messages.Page.Queue exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
import Messages.DateFormat as DF import Messages.DateFormat as DF
import Messages.UiLanguage import Messages.UiLanguage
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, currentlyRunning : String , currentlyRunning : String
, queue : String , queue : String
, waiting : String , waiting : String
@ -32,6 +35,7 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, currentlyRunning = "Currently Running" , currentlyRunning = "Currently Running"
, queue = "Queue" , queue = "Queue"
, waiting = "Waiting" , waiting = "Waiting"

View File

@ -1,10 +1,13 @@
module Messages.Page.Register exposing (Texts, gb) module Messages.Page.Register exposing (Texts, gb)
import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, httpError : Http.Error -> String
, signupToDocspell : String , signupToDocspell : String
, collectiveId : String , collectiveId : String
, collective : String , collective : String
@ -16,12 +19,15 @@ type alias Texts =
, alreadySignedUp : String , alreadySignedUp : String
, signIn : String , signIn : String
, registrationSuccessful : String , registrationSuccessful : String
, passwordsDontMatch : String
, allFieldsRequired : String
} }
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, signupToDocspell = "Signup to Docspell" , signupToDocspell = "Signup to Docspell"
, collectiveId = "Collective ID" , collectiveId = "Collective ID"
, collective = "Collective" , collective = "Collective"
@ -33,4 +39,6 @@ gb =
, alreadySignedUp = "Already signed up?" , alreadySignedUp = "Already signed up?"
, signIn = "Sign in" , signIn = "Sign in"
, registrationSuccessful = "Registration successful." , registrationSuccessful = "Registration successful."
, passwordsDontMatch = "The passwords do not match."
, allFieldsRequired = "All fields are required!"
} }

View File

@ -1,5 +1,6 @@
module Page.CollectiveSettings.Data exposing module Page.CollectiveSettings.Data exposing
( Model ( FormState(..)
, Model
, Msg(..) , Msg(..)
, Tab(..) , Tab(..)
, init , init
@ -21,10 +22,17 @@ type alias Model =
, userModel : Comp.UserManage.Model , userModel : Comp.UserManage.Model
, settingsModel : Comp.CollectiveSettingsForm.Model , settingsModel : Comp.CollectiveSettingsForm.Model
, insights : ItemInsights , insights : ItemInsights
, submitResult : Maybe BasicResult , formState : FormState
} }
type FormState
= InitialState
| SubmitSuccessful
| SubmitFailed String
| SubmitError Http.Error
init : Flags -> ( Model, Cmd Msg ) init : Flags -> ( Model, Cmd Msg )
init flags = init flags =
let let
@ -39,7 +47,7 @@ init flags =
, userModel = Comp.UserManage.emptyModel , userModel = Comp.UserManage.emptyModel
, settingsModel = cm , settingsModel = cm
, insights = Api.Model.ItemInsights.empty , insights = Api.Model.ItemInsights.empty
, submitResult = Nothing , formState = InitialState
} }
, Cmd.batch , Cmd.batch
[ Cmd.map SourceMsg sc [ Cmd.map SourceMsg sc

View File

@ -1,13 +1,11 @@
module Page.CollectiveSettings.Update exposing (update) module Page.CollectiveSettings.Update exposing (update)
import Api import Api
import Api.Model.BasicResult exposing (BasicResult)
import Comp.CollectiveSettingsForm import Comp.CollectiveSettingsForm
import Comp.SourceManage import Comp.SourceManage
import Comp.UserManage import Comp.UserManage
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page.CollectiveSettings.Data exposing (..) import Page.CollectiveSettings.Data exposing (..)
import Util.Http
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -58,12 +56,12 @@ update flags msg model =
Just sett -> Just sett ->
Api.setCollectiveSettings flags sett SubmitResp Api.setCollectiveSettings flags sett SubmitResp
in in
( { model | settingsModel = m2, submitResult = Nothing } ( { model | settingsModel = m2, formState = InitialState }
, Cmd.batch [ cmd, Cmd.map SettingsFormMsg c2 ] , Cmd.batch [ cmd, Cmd.map SettingsFormMsg c2 ]
) )
Init -> Init ->
( { model | submitResult = Nothing } ( { model | formState = InitialState }
, Cmd.batch , Cmd.batch
[ Api.getInsights flags GetInsightsResp [ Api.getInsights flags GetInsightsResp
, Api.getCollectiveSettings flags CollectiveSettingsResp , Api.getCollectiveSettings flags CollectiveSettingsResp
@ -89,11 +87,16 @@ update flags msg model =
( model, Cmd.none ) ( model, Cmd.none )
SubmitResp (Ok res) -> 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) -> SubmitResp (Err err) ->
let ( { model | formState = SubmitError err }, Cmd.none )
res =
BasicResult False (Util.Http.errorToString err)
in
( { model | submitResult = Just res }, Cmd.none )

View File

@ -14,7 +14,6 @@ import Html.Events exposing (onClick)
import Messages.Page.CollectiveSettings exposing (Texts) import Messages.Page.CollectiveSettings exposing (Texts)
import Page.CollectiveSettings.Data exposing (..) import Page.CollectiveSettings.Data exposing (..)
import Styles as S import Styles as S
import Util.Maybe
import Util.Size import Util.Size
@ -249,6 +248,27 @@ viewSettings texts flags settings model =
[ text texts.collectiveSettings [ 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 , Html.map SettingsFormMsg
(Comp.CollectiveSettingsForm.view2 (Comp.CollectiveSettingsForm.view2
flags flags
@ -256,23 +276,4 @@ viewSettings texts flags settings model =
settings settings
model.settingsModel 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
]
] ]

View File

@ -1,5 +1,6 @@
module Page.Login.Data exposing module Page.Login.Data exposing
( Model ( FormState(..)
, Model
, Msg(..) , Msg(..)
, emptyModel , emptyModel
) )
@ -13,16 +14,23 @@ type alias Model =
{ username : String { username : String
, password : String , password : String
, rememberMe : Bool , rememberMe : Bool
, result : Maybe AuthResult , formState : FormState
} }
type FormState
= AuthSuccess AuthResult
| AuthFailed AuthResult
| HttpError Http.Error
| FormInitial
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ username = "" { username = ""
, password = "" , password = ""
, rememberMe = False , rememberMe = False
, result = Nothing , formState = FormInitial
} }

View File

@ -6,7 +6,6 @@ import Data.Flags exposing (Flags)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.Login.Data exposing (..) import Page.Login.Data exposing (..)
import Ports import Ports
import Util.Http
update : Maybe Page -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe AuthResult ) 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 Maybe.withDefault HomePage referrer |> Page.goto
in in
if lr.success then if lr.success then
( { model | result = Just lr, password = "" } ( { model | formState = AuthSuccess lr, password = "" }
, Cmd.batch [ setAccount lr, gotoRef ] , Cmd.batch [ setAccount lr, gotoRef ]
, Just lr , Just lr
) )
else else
( { model | result = Just lr, password = "" } ( { model | formState = AuthFailed lr, password = "" }
, Ports.removeAccount () , Ports.removeAccount ()
, Just lr , Just lr
) )
@ -52,11 +51,11 @@ update referrer flags msg model =
let let
empty = empty =
Api.Model.AuthResult.empty Api.Model.AuthResult.empty
lr =
{ empty | message = Util.Http.errorToString err }
in in
( { model | password = "", result = Just lr }, Ports.removeAccount (), Just empty ) ( { model | password = "", formState = HttpError err }
, Ports.removeAccount ()
, Just empty
)
setAccount : AuthResult -> Cmd msg setAccount : AuthResult -> Cmd msg

View File

@ -158,17 +158,21 @@ viewContent texts flags versionInfo _ model =
resultMessage : Texts -> Model -> Html Msg resultMessage : Texts -> Model -> Html Msg
resultMessage texts model = resultMessage texts model =
case model.result of case model.formState of
Just r -> AuthSuccess _ ->
if r.success then
div [ class ("my-2" ++ S.successMessage) ] div [ class ("my-2" ++ S.successMessage) ]
[ text texts.loginSuccessful [ text texts.loginSuccessful
] ]
else AuthFailed r ->
div [ class ("my-2" ++ S.errorMessage) ] div [ class ("my-2" ++ S.errorMessage) ]
[ text r.message [ text r.message
] ]
Nothing -> HttpError err ->
div [ class ("my-2" ++ S.errorMessage) ]
[ text (texts.httpError err)
]
FormInitial ->
span [ class "hidden" ] [] span [ class "hidden" ] []

View File

@ -19,7 +19,8 @@ type alias Model =
type State type State
= Empty = Empty
| Failed String | Failed Http.Error
| GenericFail String
| Success InviteResult | Success InviteResult
@ -29,6 +30,9 @@ isFailed state =
Failed _ -> Failed _ ->
True True
GenericFail _ ->
True
_ -> _ ->
False False

View File

@ -4,7 +4,6 @@ import Api
import Api.Model.GenInvite exposing (GenInvite) import Api.Model.GenInvite exposing (GenInvite)
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page.NewInvite.Data exposing (..) import Page.NewInvite.Data exposing (..)
import Util.Http
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -24,7 +23,7 @@ update flags msg model =
( { model | result = Success res }, Cmd.none ) ( { model | result = Success res }, Cmd.none )
else else
( { model | result = Failed res.message }, Cmd.none ) ( { model | result = GenericFail res.message }, Cmd.none )
InviteResp (Err err) -> InviteResp (Err err) ->
( { model | result = Failed (Util.Http.errorToString err) }, Cmd.none ) ( { model | result = Failed err }, Cmd.none )

View File

@ -43,7 +43,11 @@ viewContent texts flags _ model =
[ text texts.invitationKey [ text texts.invitationKey
] ]
, div [ class "relative" ] , 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" ] [] [ i [ class "fa fa-key" ] []
] ]
, input , input
@ -93,13 +97,16 @@ resultMessage texts model =
] ]
] ]
[ case model.result of [ case model.result of
Failed m -> Failed err ->
p [] [ text m ] text (texts.httpError err)
GenericFail m ->
text m
Success r -> Success r ->
div [ class "" ] div [ class "" ]
[ p [] [ p []
[ text r.message [ text texts.newInvitationCreated
, text (" " ++ texts.invitationKey ++ ":") , text (" " ++ texts.invitationKey ++ ":")
] ]
, pre [ class "text-center font-mono mt-4" ] , pre [ class "text-center font-mono mt-4" ]

View File

@ -1,5 +1,6 @@
module Page.Queue.Data exposing module Page.Queue.Data exposing
( Model ( FormState(..)
, Model
, Msg(..) , Msg(..)
, QueueView(..) , QueueView(..)
, emptyModel , emptyModel
@ -20,7 +21,7 @@ import Util.Maybe
type alias Model = type alias Model =
{ state : JobQueueState { state : JobQueueState
, error : String , formState : FormState
, pollingInterval : Float , pollingInterval : Float
, init : Bool , init : Bool
, stopRefresh : Bool , stopRefresh : Bool
@ -32,6 +33,11 @@ type alias Model =
} }
type FormState
= InitialForm
| HttpError Http.Error
type QueueView type QueueView
= CurrentJobs = CurrentJobs
| QueueAll | QueueAll
@ -44,7 +50,7 @@ type QueueView
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ state = Api.Model.JobQueueState.empty { state = Api.Model.JobQueueState.empty
, error = "" , formState = InitialForm
, pollingInterval = 1200 , pollingInterval = 1200
, init = False , init = False
, stopRefresh = False , stopRefresh = False

View File

@ -4,10 +4,8 @@ import Api
import Comp.YesNoDimmer import Comp.YesNoDimmer
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page.Queue.Data exposing (..) import Page.Queue.Data exposing (..)
import Ports
import Task import Task
import Time import Time
import Util.Http
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -42,7 +40,7 @@ update flags msg model =
( { model | state = s, stopRefresh = False }, refresh ) ( { model | state = s, stopRefresh = False }, refresh )
StateResp (Err err) -> StateResp (Err err) ->
( { model | error = Util.Http.errorToString err }, Cmd.none ) ( { model | formState = HttpError err }, Cmd.none )
StopRefresh -> StopRefresh ->
( { model | stopRefresh = True, init = False }, Cmd.none ) ( { model | stopRefresh = True, init = False }, Cmd.none )

View File

@ -1,5 +1,6 @@
module Page.Register.Data exposing module Page.Register.Data exposing
( Model ( FormState(..)
, Model
, Msg(..) , Msg(..)
, emptyModel , emptyModel
) )
@ -9,31 +10,36 @@ import Http
type alias Model = type alias Model =
{ result : Maybe BasicResult { collId : String
, collId : String
, login : String , login : String
, pass1 : String , pass1 : String
, pass2 : String , pass2 : String
, showPass1 : Bool , showPass1 : Bool
, showPass2 : Bool , showPass2 : Bool
, errorMsg : List String , formState : FormState
, loading : Bool , loading : Bool
, successMsg : String
, invite : Maybe String , invite : Maybe String
} }
type FormState
= HttpError Http.Error
| GenericError String
| RegistrationSuccessful
| PasswordMismatch
| InputValid
| FormEmpty
emptyModel : Model emptyModel : Model
emptyModel = emptyModel =
{ result = Nothing { collId = ""
, collId = ""
, login = "" , login = ""
, pass1 = "" , pass1 = ""
, pass2 = "" , pass2 = ""
, showPass1 = False , showPass1 = False
, showPass2 = False , showPass2 = False
, errorMsg = [] , formState = FormEmpty
, successMsg = ""
, loading = False , loading = False
, invite = Nothing , invite = Nothing
} }

View File

@ -1,19 +1,17 @@
module Page.Register.Update exposing (update) module Page.Register.Update exposing (update)
import Api import Api
import Api.Model.BasicResult exposing (BasicResult)
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.Register.Data exposing (..) import Page.Register.Data exposing (..)
import Util.Http
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model = update flags msg model =
case msg of case msg of
RegisterSubmit -> RegisterSubmit ->
case model.errorMsg of case model.formState of
[] -> InputValid ->
let let
reg = reg =
{ collectiveName = model.collId { collectiveName = model.collId
@ -35,7 +33,7 @@ update flags msg model =
err = err =
validateForm m validateForm m
in in
( { m | errorMsg = err }, Cmd.none ) ( { m | formState = err }, Cmd.none )
SetLogin str -> SetLogin str ->
let let
@ -45,7 +43,7 @@ update flags msg model =
err = err =
validateForm m validateForm m
in in
( { m | errorMsg = err }, Cmd.none ) ( { m | formState = err }, Cmd.none )
SetPass1 str -> SetPass1 str ->
let let
@ -55,7 +53,7 @@ update flags msg model =
err = err =
validateForm m validateForm m
in in
( { m | errorMsg = err }, Cmd.none ) ( { m | formState = err }, Cmd.none )
SetPass2 str -> SetPass2 str ->
let let
@ -65,7 +63,7 @@ update flags msg model =
err = err =
validateForm m validateForm m
in in
( { m | errorMsg = err }, Cmd.none ) ( { m | formState = err }, Cmd.none )
SetInvite str -> SetInvite str ->
( { model ( { model
@ -98,29 +96,21 @@ update flags msg model =
Cmd.none Cmd.none
in in
( { m ( { m
| result = | formState =
if r.success then if r.success then
Nothing RegistrationSuccessful
else else
Just r GenericError r.message
} }
, cmd , cmd
) )
SubmitResp (Err err) -> SubmitResp (Err err) ->
let ( { model | formState = HttpError err }, Cmd.none )
errMsg =
Util.Http.errorToString err
res =
BasicResult False
(errMsg ++ " Please check the form and try again.")
in
( { model | result = Just res }, Cmd.none )
validateForm : Model -> List String validateForm : Model -> FormState
validateForm model = validateForm model =
if if
model.collId model.collId
@ -132,10 +122,10 @@ validateForm model =
|| model.pass2 || model.pass2
== "" == ""
then then
[ "All fields are required!" ] FormEmpty
else if model.pass1 /= model.pass2 then else if model.pass1 /= model.pass2 then
[ "The passwords do not match." ] PasswordMismatch
else else
[] InputValid

View File

@ -239,22 +239,32 @@ viewContent texts flags _ model =
resultMessage : Texts -> Model -> Html Msg resultMessage : Texts -> Model -> Html Msg
resultMessage texts model = resultMessage texts model =
case model.result of case model.formState of
Just r -> InputValid ->
if r.success then div [ class "hidden" ]
[]
RegistrationSuccessful ->
div [ class S.successMessage ] div [ class S.successMessage ]
[ text texts.registrationSuccessful [ text texts.registrationSuccessful
] ]
else PasswordMismatch ->
div [ class S.errorMessage ] div [ class S.errorMessage ]
[ text r.message [ text texts.passwordsDontMatch
] ]
Nothing -> GenericError m ->
if List.isEmpty model.errorMsg then
span [ class "hidden" ] []
else
div [ class S.errorMessage ] div [ class S.errorMessage ]
(List.map (\s -> div [] [ text s ]) model.errorMsg) [ text m
]
FormEmpty ->
div [ class S.errorMessage ]
[ text texts.allFieldsRequired
]
HttpError err ->
div [ class S.errorMessage ]
[ text (texts.httpError err)
]

View File

@ -1,7 +1,6 @@
module Util.CustomField exposing module Util.CustomField exposing
( nameOrLabel ( nameOrLabel
, renderValue , renderValue
, renderValue1
, renderValue2 , renderValue2
) )
@ -20,43 +19,7 @@ nameOrLabel fv =
renderValue : String -> ItemFieldValue -> Html msg renderValue : String -> ItemFieldValue -> Html msg
renderValue classes cv = renderValue classes cv =
renderValue1 [ ( classes, True ) ] Nothing cv renderValue2 [ ( 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 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg renderValue2 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg

View File

@ -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 "
]
]
]

View File

@ -1,6 +1,5 @@
module Util.Html exposing module Util.Html exposing
( KeyCode(..) ( KeyCode(..)
, checkbox
, checkbox2 , checkbox2
, classActive , classActive
, intToKeyCode , intToKeyCode
@ -22,25 +21,6 @@ import Html.Events exposing (keyCode, on, preventDefaultOn)
import Json.Decode as D 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 : Bool -> Html msg
checkbox2 flag = checkbox2 flag =
if flag then if flag then

View File

@ -5,7 +5,6 @@ module Util.Http exposing
, authPostTrack , authPostTrack
, authPut , authPut
, authTask , authTask
, errorToString
, executeIn , executeIn
, jsonResolver , 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 -- Http.Task Utilities

View 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