Add mail form when creating shares

This commit is contained in:
eikek 2021-10-08 10:15:19 +02:00
parent 337293128d
commit 16ccddab9f
22 changed files with 535 additions and 56 deletions

View File

@ -146,6 +146,7 @@ module Api exposing
, shareAttachmentPreviewURL , shareAttachmentPreviewURL
, shareFileURL , shareFileURL
, shareItemBasePreviewURL , shareItemBasePreviewURL
, shareSendMail
, startClassifier , startClassifier
, startEmptyTrash , startEmptyTrash
, startOnceNotifyDueItems , startOnceNotifyDueItems
@ -233,6 +234,7 @@ import Api.Model.ShareList exposing (ShareList)
import Api.Model.ShareSecret exposing (ShareSecret) import Api.Model.ShareSecret exposing (ShareSecret)
import Api.Model.ShareVerifyResult exposing (ShareVerifyResult) import Api.Model.ShareVerifyResult exposing (ShareVerifyResult)
import Api.Model.SimpleMail exposing (SimpleMail) import Api.Model.SimpleMail exposing (SimpleMail)
import Api.Model.SimpleShareMail exposing (SimpleShareMail)
import Api.Model.SourceAndTags exposing (SourceAndTags) import Api.Model.SourceAndTags exposing (SourceAndTags)
import Api.Model.SourceList exposing (SourceList) import Api.Model.SourceList exposing (SourceList)
import Api.Model.SourceTagIn import Api.Model.SourceTagIn
@ -2312,6 +2314,20 @@ itemDetailShare flags token itemId receive =
} }
shareSendMail :
Flags
-> { conn : String, mail : SimpleShareMail }
-> (Result Http.Error BasicResult -> msg)
-> Cmd msg
shareSendMail flags opts receive =
Http2.authPost
{ url = flags.config.baseUrl ++ "/api/v1/sec/share/email/send/" ++ opts.conn
, account = getAccount flags
, body = Http.jsonBody (Api.Model.SimpleShareMail.encode opts.mail)
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
}
shareAttachmentPreviewURL : String -> String shareAttachmentPreviewURL : String -> String
shareAttachmentPreviewURL id = shareAttachmentPreviewURL id =
"/api/v1/share/attachment/" ++ id ++ "/preview?withFallback=true" "/api/v1/share/attachment/" ++ id ++ "/preview?withFallback=true"

View File

@ -12,7 +12,9 @@ module Comp.ItemMail exposing
, clear , clear
, emptyModel , emptyModel
, init , init
, setMailInfo
, update , update
, view
, view2 , view2
) )
@ -28,7 +30,7 @@ import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput) import Html.Events exposing (onClick, onFocus, 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
@ -61,6 +63,7 @@ type Msg
| CCRecipientMsg Comp.EmailInput.Msg | CCRecipientMsg Comp.EmailInput.Msg
| BCCRecipientMsg Comp.EmailInput.Msg | BCCRecipientMsg Comp.EmailInput.Msg
| SetBody String | SetBody String
| SetSubjectBody String String
| ConnMsg (Comp.Dropdown.Msg String) | ConnMsg (Comp.Dropdown.Msg String)
| ConnResp (Result Http.Error EmailSettingsList) | ConnResp (Result Http.Error EmailSettingsList)
| ToggleAttachAll | ToggleAttachAll
@ -112,12 +115,20 @@ clear model =
} }
setMailInfo : String -> String -> Msg
setMailInfo subject body =
SetSubjectBody subject body
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, FormAction ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg, FormAction )
update flags msg model = update flags msg model =
case msg of case msg of
SetSubject str -> SetSubject str ->
( { model | subject = str }, Cmd.none, FormNone ) ( { model | subject = str }, Cmd.none, FormNone )
SetSubjectBody subj body ->
( { model | subject = subj, body = body }, Cmd.none, FormNone )
RecipientMsg m -> RecipientMsg m ->
let let
( em, ec, rec ) = ( em, ec, rec ) =
@ -239,8 +250,31 @@ isValid model =
--- View2 --- View2
type alias ViewConfig =
{ withAttachments : Bool
, subjectTemplate : Maybe String
, bodyTemplate : Maybe String
, textAreaClass : String
, showCancel : Bool
}
view2 : Texts -> UiSettings -> Model -> Html Msg view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model = view2 texts settings model =
let
cfg =
{ withAttachments = True
, subjectTemplate = Nothing
, bodyTemplate = Nothing
, textAreaClass = ""
, showCancel = True
}
in
view texts settings cfg model
view : Texts -> UiSettings -> ViewConfig -> Model -> Html Msg
view texts settings cfg model =
let let
dds = dds =
Data.DropdownStyle.mainStyle Data.DropdownStyle.mainStyle
@ -323,6 +357,11 @@ view2 texts settings model =
[ type_ "text" [ type_ "text"
, class S.textInput , class S.textInput
, onInput SetSubject , onInput SetSubject
, if model.subject == "" then
onFocus (SetSubject <| Maybe.withDefault "" cfg.subjectTemplate)
else
class ""
, value model.subject , value model.subject
] ]
[] []
@ -334,18 +373,27 @@ view2 texts settings model =
] ]
, textarea , textarea
[ onInput SetBody [ onInput SetBody
, value model.body , if model.body == "" then
value <| Maybe.withDefault "" cfg.bodyTemplate
else
value model.body
, class S.textAreaInput , class S.textAreaInput
, class cfg.textAreaClass
] ]
[] []
] ]
, MB.viewItem <| , if cfg.withAttachments then
MB.Checkbox MB.viewItem <|
{ tagger = \_ -> ToggleAttachAll MB.Checkbox
, label = texts.includeAllAttachments { tagger = \_ -> ToggleAttachAll
, value = model.attachAll , label = texts.includeAllAttachments
, id = "item-send-mail-attach-all" , value = model.attachAll
} , id = "item-send-mail-attach-all"
}
else
span [ class "hidden" ] []
, div [ class "flex flex-row space-x-2" ] , div [ class "flex flex-row space-x-2" ]
[ B.primaryButton [ B.primaryButton
{ label = texts.sendLabel { label = texts.sendLabel
@ -358,7 +406,10 @@ view2 texts settings model =
{ label = texts.basics.cancel { label = texts.basics.cancel
, icon = "fa fa-times" , icon = "fa fa-times"
, handler = onClick Cancel , handler = onClick Cancel
, attrs = [ href "#" ] , attrs =
[ href "#"
, classList [ ( "hidden", not cfg.showCancel ) ]
]
, disabled = False , disabled = False
} }
] ]

View File

@ -21,11 +21,13 @@ import Api.Model.ShareDetail exposing (ShareDetail)
import Comp.Basic as B import Comp.Basic as B
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Comp.ShareForm import Comp.ShareForm
import Comp.ShareMail
import Comp.ShareView import Comp.ShareView
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.Icons as Icons import Data.Icons as Icons
import Data.ItemQuery exposing (ItemQuery) import Data.ItemQuery exposing (ItemQuery)
import Data.SearchMode exposing (SearchMode) import Data.SearchMode exposing (SearchMode)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Http import Http
@ -52,39 +54,54 @@ type FormError
type alias Model = type alias Model =
{ formModel : Comp.ShareForm.Model { formModel : Comp.ShareForm.Model
, mailModel : Comp.ShareMail.Model
, viewMode : ViewMode , viewMode : ViewMode
, formError : FormError , formError : FormError
, loading : Bool , loading : Bool
} }
init : ( Model, Cmd Msg ) init : Flags -> ( Model, Cmd Msg )
init = init flags =
let let
( fm, fc ) = ( fm, fc ) =
Comp.ShareForm.init Comp.ShareForm.init
( mm, mc ) =
Comp.ShareMail.init flags
in in
( { formModel = fm ( { formModel = fm
, mailModel = mm
, viewMode = ViewModeEdit , viewMode = ViewModeEdit
, formError = FormErrorNone , formError = FormErrorNone
, loading = False , loading = False
} }
, Cmd.map FormMsg fc , Cmd.batch
[ Cmd.map FormMsg fc
, Cmd.map MailMsg mc
]
) )
initQuery : ItemQuery -> ( Model, Cmd Msg ) initQuery : Flags -> ItemQuery -> ( Model, Cmd Msg )
initQuery query = initQuery flags query =
let let
( fm, fc ) = ( fm, fc ) =
Comp.ShareForm.initQuery (Data.ItemQuery.render query) Comp.ShareForm.initQuery (Data.ItemQuery.render query)
( mm, mc ) =
Comp.ShareMail.init flags
in in
( { formModel = fm ( { formModel = fm
, mailModel = mm
, viewMode = ViewModeEdit , viewMode = ViewModeEdit
, formError = FormErrorNone , formError = FormErrorNone
, loading = False , loading = False
} }
, Cmd.map FormMsg fc , Cmd.batch
[ Cmd.map FormMsg fc
, Cmd.map MailMsg mc
]
) )
@ -94,6 +111,7 @@ initQuery query =
type Msg type Msg
= FormMsg Comp.ShareForm.Msg = FormMsg Comp.ShareForm.Msg
| MailMsg Comp.ShareMail.Msg
| CancelPublish | CancelPublish
| SubmitPublish | SubmitPublish
| PublishResp (Result Http.Error IdResult) | PublishResp (Result Http.Error IdResult)
@ -134,6 +152,17 @@ update flags msg model =
, outcome = OutcomeInProgress , outcome = OutcomeInProgress
} }
MailMsg lm ->
let
( mm, mc ) =
Comp.ShareMail.update flags lm model.mailModel
in
{ model = { model | mailModel = mm }
, cmd = Cmd.map MailMsg mc
, sub = Sub.none
, outcome = OutcomeInProgress
}
SubmitPublish -> SubmitPublish ->
case Comp.ShareForm.getShare model.formModel of case Comp.ShareForm.getShare model.formModel of
Just ( _, data ) -> Just ( _, data ) ->
@ -173,13 +202,22 @@ update flags msg model =
} }
GetShareResp (Ok share) -> GetShareResp (Ok share) ->
let
( mm, mc ) =
Comp.ShareMail.update flags (Comp.ShareMail.setMailInfo share) model.mailModel
in
{ model = { model =
{ model { model
| formError = FormErrorNone | formError = FormErrorNone
, loading = False , loading = False
, viewMode = ViewModeInfo share , viewMode = ViewModeInfo share
, mailModel = mm
} }
, cmd = Ports.initClipboard (Comp.ShareView.clipboardData share) , cmd =
Cmd.batch
[ Ports.initClipboard (Comp.ShareView.clipboardData share)
, Cmd.map MailMsg mc
]
, sub = Sub.none , sub = Sub.none
, outcome = OutcomeInProgress , outcome = OutcomeInProgress
} }
@ -196,8 +234,8 @@ update flags msg model =
--- View --- View
view : Texts -> Flags -> Model -> Html Msg view : Texts -> UiSettings -> Flags -> Model -> Html Msg
view texts flags model = view texts settings flags model =
div [] div []
[ B.loadingDimmer [ B.loadingDimmer
{ active = model.loading { active = model.loading
@ -208,12 +246,12 @@ view texts flags model =
viewForm texts model viewForm texts model
ViewModeInfo share -> ViewModeInfo share ->
viewInfo texts flags model share viewInfo texts settings flags model share
] ]
viewInfo : Texts -> Flags -> Model -> ShareDetail -> Html Msg viewInfo : Texts -> UiSettings -> Flags -> Model -> ShareDetail -> Html Msg
viewInfo texts flags model share = viewInfo texts settings flags model share =
let let
cfg = cfg =
{ mainClasses = "" { mainClasses = ""
@ -244,6 +282,15 @@ viewInfo texts flags model share =
, div [] , div []
[ Comp.ShareView.view cfg texts.shareView flags share [ Comp.ShareView.view cfg texts.shareView flags share
] ]
, div [ class "flex flex-col mt-6" ]
[ div
[ class S.header2
]
[ text texts.sendViaMail
]
, Html.map MailMsg
(Comp.ShareMail.view texts.shareMail flags settings model.mailModel)
]
] ]

View File

@ -0,0 +1,183 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.ShareMail exposing (Model, Msg, init, setMailInfo, update, view)
import Api
import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.ShareDetail exposing (ShareDetail)
import Comp.Basic as B
import Comp.ItemMail
import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.ShareMail exposing (Texts)
import Page exposing (Page(..))
import Styles as S
type FormState
= FormStateNone
| FormStateSubmit String
| FormStateHttp Http.Error
| FormStateSent
type alias Model =
{ mailModel : Comp.ItemMail.Model
, share : ShareDetail
, sending : Bool
, formState : FormState
}
init : Flags -> ( Model, Cmd Msg )
init flags =
let
( mm, mc ) =
Comp.ItemMail.init flags
in
( { mailModel = mm
, share = Api.Model.ShareDetail.empty
, sending = False
, formState = FormStateNone
}
, Cmd.map MailMsg mc
)
type Msg
= MailMsg Comp.ItemMail.Msg
| SetMailInfo ShareDetail
| SendMailResp (Result Http.Error BasicResult)
--- Update
setMailInfo : ShareDetail -> Msg
setMailInfo share =
SetMailInfo share
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model =
case msg of
MailMsg lm ->
let
( mm, mc, fa ) =
Comp.ItemMail.update flags lm model.mailModel
defaultResult =
( { model | mailModel = mm }, Cmd.map MailMsg mc )
in
case fa of
Comp.ItemMail.FormSend sm ->
let
mail =
{ mail =
{ shareId = model.share.id
, recipients = sm.mail.recipients
, cc = sm.mail.cc
, bcc = sm.mail.bcc
, subject = sm.mail.subject
, body = sm.mail.body
}
, conn = sm.conn
}
in
( { model | sending = True, mailModel = mm }
, Cmd.batch
[ Cmd.map MailMsg mc
, Api.shareSendMail flags mail SendMailResp
]
)
Comp.ItemMail.FormNone ->
defaultResult
Comp.ItemMail.FormCancel ->
defaultResult
SetMailInfo share ->
( { model | share = share }, Cmd.none )
SendMailResp (Ok res) ->
if res.success then
( { model
| formState = FormStateSent
, mailModel = Comp.ItemMail.clear model.mailModel
, sending = False
}
, Cmd.none
)
else
( { model
| formState = FormStateSubmit res.message
, sending = False
}
, Cmd.none
)
SendMailResp (Err err) ->
( { model | formState = FormStateHttp err }, Cmd.none )
--- View
view : Texts -> Flags -> UiSettings -> Model -> Html Msg
view texts flags settings model =
let
url =
flags.config.baseUrl ++ (Page.pageToString <| SharePage model.share.id)
subject =
texts.subjectTemplate model.share.name
body =
texts.bodyTemplate url
cfg =
{ withAttachments = False
, subjectTemplate = Just subject
, bodyTemplate = Just body
, textAreaClass = "h-52"
, showCancel = False
}
in
div [ class "relative" ]
[ case model.formState of
FormStateNone ->
span [ class "hidden" ] []
FormStateSubmit msg ->
div [ class S.errorMessage ]
[ text msg
]
FormStateHttp err ->
div [ class S.errorMessage ]
[ text (texts.httpError err)
]
FormStateSent ->
div [ class S.successMessage ]
[ text "Mail sent."
]
, Html.map MailMsg
(Comp.ItemMail.view texts.itemMail settings cfg model.mailModel)
, B.loadingDimmer
{ active = model.sending
, label = ""
}
]

View File

@ -16,14 +16,17 @@ import Comp.Basic as B
import Comp.ItemDetail.Model exposing (Msg(..)) import Comp.ItemDetail.Model exposing (Msg(..))
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Comp.ShareForm import Comp.ShareForm
import Comp.ShareMail
import Comp.ShareTable import Comp.ShareTable
import Comp.ShareView import Comp.ShareView
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
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.ShareManage exposing (Texts) import Messages.Comp.ShareManage exposing (Texts)
import Page exposing (Page(..))
import Ports import Ports
import Styles as S import Styles as S
@ -49,26 +52,34 @@ type alias Model =
{ viewMode : ViewMode { viewMode : ViewMode
, shares : List ShareDetail , shares : List ShareDetail
, formModel : Comp.ShareForm.Model , formModel : Comp.ShareForm.Model
, mailModel : Comp.ShareMail.Model
, loading : Bool , loading : Bool
, formError : FormError , formError : FormError
, deleteConfirm : DeleteConfirm , deleteConfirm : DeleteConfirm
} }
init : ( Model, Cmd Msg ) init : Flags -> ( Model, Cmd Msg )
init = init flags =
let let
( fm, fc ) = ( fm, fc ) =
Comp.ShareForm.init Comp.ShareForm.init
( mm, mc ) =
Comp.ShareMail.init flags
in in
( { viewMode = Table ( { viewMode = Table
, shares = [] , shares = []
, formModel = fm , formModel = fm
, mailModel = mm
, loading = False , loading = False
, formError = FormErrorNone , formError = FormErrorNone
, deleteConfirm = DeleteConfirmOff , deleteConfirm = DeleteConfirmOff
} }
, Cmd.map FormMsg fc , Cmd.batch
[ Cmd.map FormMsg fc
, Cmd.map MailMsg mc
]
) )
@ -76,6 +87,7 @@ type Msg
= LoadShares = LoadShares
| TableMsg Comp.ShareTable.Msg | TableMsg Comp.ShareTable.Msg
| FormMsg Comp.ShareForm.Msg | FormMsg Comp.ShareForm.Msg
| MailMsg Comp.ShareMail.Msg
| InitNewShare | InitNewShare
| SetViewMode ViewMode | SetViewMode ViewMode
| Submit | Submit
@ -212,10 +224,20 @@ update flags msg model =
DeleteShareResp (Err err) -> DeleteShareResp (Err err) ->
( { model | formError = FormErrorHttp err, loading = False }, Cmd.none, Sub.none ) ( { model | formError = FormErrorHttp err, loading = False }, Cmd.none, Sub.none )
MailMsg lm ->
let
( mm, mc ) =
Comp.ShareMail.update flags lm model.mailModel
in
( { model | mailModel = mm }, Cmd.map MailMsg mc, Sub.none )
setShare : ShareDetail -> Flags -> Model -> ( Model, Cmd Msg, Sub Msg ) setShare : ShareDetail -> Flags -> Model -> ( Model, Cmd Msg, Sub Msg )
setShare share flags model = setShare share flags model =
let let
shareUrl =
flags.config.baseUrl ++ Page.pageToString (SharePage share.id)
nextModel = nextModel =
{ model | formError = FormErrorNone, viewMode = Form, loading = False } { model | formError = FormErrorNone, viewMode = Form, loading = False }
@ -224,21 +246,24 @@ setShare share flags model =
( nm, nc, ns ) = ( nm, nc, ns ) =
update flags (FormMsg <| Comp.ShareForm.setShare share) nextModel update flags (FormMsg <| Comp.ShareForm.setShare share) nextModel
( nm2, nc2, ns2 ) =
update flags (MailMsg <| Comp.ShareMail.setMailInfo share) nm
in in
( nm, Cmd.batch [ initClipboard, nc ], ns ) ( nm2, Cmd.batch [ initClipboard, nc, nc2 ], Sub.batch [ ns, ns2 ] )
--- view --- view
view : Texts -> Flags -> Model -> Html Msg view : Texts -> UiSettings -> Flags -> Model -> Html Msg
view texts flags model = view texts settings flags model =
if model.viewMode == Table then if model.viewMode == Table then
viewTable texts model viewTable texts model
else else
viewForm texts flags model viewForm texts settings flags model
viewTable : Texts -> Model -> Html Msg viewTable : Texts -> Model -> Html Msg
@ -265,13 +290,13 @@ viewTable texts model =
] ]
viewForm : Texts -> Flags -> Model -> Html Msg viewForm : Texts -> UiSettings -> Flags -> Model -> Html Msg
viewForm texts flags model = viewForm texts settings flags model =
let let
newShare = newShare =
model.formModel.share.id == "" model.formModel.share.id == ""
in in
div [ class "relative" ] div []
[ Html.form [] [ Html.form []
[ if newShare then [ if newShare then
h1 [ class S.header2 ] h1 [ class S.header2 ]
@ -367,6 +392,7 @@ viewForm texts flags model =
) )
] ]
, shareInfo texts flags model.formModel.share , shareInfo texts flags model.formModel.share
, shareSendMail texts flags settings model
] ]
@ -376,8 +402,34 @@ shareInfo texts flags share =
[ class "mt-6" [ class "mt-6"
, classList [ ( "hidden", share.id == "" ) ] , classList [ ( "hidden", share.id == "" ) ]
] ]
[ h2 [ class S.header2 ] [ h2
[ class S.header2
, class "border-b-2 dark:border-bluegray-600"
]
[ text texts.shareInformation [ text texts.shareInformation
] ]
, Comp.ShareView.viewDefault texts.shareView flags share , Comp.ShareView.viewDefault texts.shareView flags share
] ]
shareSendMail : Texts -> Flags -> UiSettings -> Model -> Html Msg
shareSendMail texts flags settings model =
let
share =
model.formModel.share
in
div
[ class "mt-8 mb-2"
, classList [ ( "hidden", share.id == "" || not share.enabled || share.expired ) ]
]
[ h2
[ class S.header2
, class "border-b-2 dark:border-bluegray-600"
]
[ text "Send via E-Mail"
]
, div [ class "px-2 py-2 dark:border-bluegray-600" ]
[ Html.map MailMsg
(Comp.ShareMail.view texts.shareMail flags settings model.mailModel)
]
]

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.SharePasswordForm exposing (Model, Msg, init, update, view) module Comp.SharePasswordForm exposing (Model, Msg, init, update, view)
import Api import Api

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.UrlCopy exposing (..) module Comp.UrlCopy exposing (..)
import Comp.Basic as B import Comp.Basic as B

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Data.Pdf exposing (PdfMode(..), allModes, asString, detectUrl, fromString, serverUrl) module Data.Pdf exposing (PdfMode(..), allModes, asString, detectUrl, fromString, serverUrl)
{-| Makes use of the fact, that docspell uses a `/view` suffix on the {-| Makes use of the fact, that docspell uses a `/view` suffix on the

View File

@ -39,8 +39,8 @@ gb =
, selectConnection = "Select connection..." , selectConnection = "Select connection..."
, sendVia = "Send via" , sendVia = "Send via"
, recipients = "Recipient(s)" , recipients = "Recipient(s)"
, ccRecipients = "CC recipient(s)" , ccRecipients = "CC"
, bccRecipients = "BCC recipient(s)..." , bccRecipients = "BCC"
, subject = "Subject" , subject = "Subject"
, body = "Body" , body = "Body"
, includeAllAttachments = "Include all item attachments" , includeAllAttachments = "Include all item attachments"

View File

@ -15,6 +15,7 @@ import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError import Messages.Comp.HttpError
import Messages.Comp.ShareForm import Messages.Comp.ShareForm
import Messages.Comp.ShareMail
import Messages.Comp.ShareView import Messages.Comp.ShareView
import Messages.DateFormat import Messages.DateFormat
import Messages.UiLanguage import Messages.UiLanguage
@ -25,6 +26,7 @@ type alias Texts =
, httpError : Http.Error -> String , httpError : Http.Error -> String
, shareForm : Messages.Comp.ShareForm.Texts , shareForm : Messages.Comp.ShareForm.Texts
, shareView : Messages.Comp.ShareView.Texts , shareView : Messages.Comp.ShareView.Texts
, shareMail : Messages.Comp.ShareMail.Texts
, title : String , title : String
, infoText : String , infoText : String
, formatDateLong : Int -> String , formatDateLong : Int -> String
@ -37,6 +39,7 @@ type alias Texts =
, publishInProcess : String , publishInProcess : String
, correctFormErrors : String , correctFormErrors : String
, doneLabel : String , doneLabel : String
, sendViaMail : String
} }
@ -46,6 +49,7 @@ gb =
, httpError = Messages.Comp.HttpError.gb , httpError = Messages.Comp.HttpError.gb
, shareForm = Messages.Comp.ShareForm.gb , shareForm = Messages.Comp.ShareForm.gb
, shareView = Messages.Comp.ShareView.gb , shareView = Messages.Comp.ShareView.gb
, shareMail = Messages.Comp.ShareMail.gb
, title = "Publish Items" , title = "Publish Items"
, infoText = "Publishing items creates a cryptic link, which can be used by everyone to see the selected documents. This link cannot be guessed, but is public! It exists for a certain amount of time and can be further protected using a password." , infoText = "Publishing items creates a cryptic link, which can be used by everyone to see the selected documents. This link cannot be guessed, but is public! It exists for a certain amount of time and can be further protected using a password."
, formatDateLong = Messages.DateFormat.formatDateLong Messages.UiLanguage.English , formatDateLong = Messages.DateFormat.formatDateLong Messages.UiLanguage.English
@ -58,6 +62,7 @@ gb =
, publishInProcess = "Items are published " , publishInProcess = "Items are published "
, correctFormErrors = "Please correct the errors in the form." , correctFormErrors = "Please correct the errors in the form."
, doneLabel = "Done" , doneLabel = "Done"
, sendViaMail = "Send via E-Mail"
} }
@ -67,6 +72,7 @@ de =
, httpError = Messages.Comp.HttpError.de , httpError = Messages.Comp.HttpError.de
, shareForm = Messages.Comp.ShareForm.de , shareForm = Messages.Comp.ShareForm.de
, shareView = Messages.Comp.ShareView.de , shareView = Messages.Comp.ShareView.de
, shareMail = Messages.Comp.ShareMail.de
, title = "Dokumente publizieren" , title = "Dokumente publizieren"
, infoText = "Beim Publizieren der Dokumente wird ein kryptischer Link erzeugt, mit welchem jeder die dahinter publizierten Dokumente einsehen kann. Dieser Link kann nicht erraten werden, ist aber öffentlich. Er ist zeitlich begrenzt und kann zusätzlich mit einem Passwort geschützt werden." , infoText = "Beim Publizieren der Dokumente wird ein kryptischer Link erzeugt, mit welchem jeder die dahinter publizierten Dokumente einsehen kann. Dieser Link kann nicht erraten werden, ist aber öffentlich. Er ist zeitlich begrenzt und kann zusätzlich mit einem Passwort geschützt werden."
, formatDateLong = Messages.DateFormat.formatDateLong Messages.UiLanguage.German , formatDateLong = Messages.DateFormat.formatDateLong Messages.UiLanguage.German
@ -79,4 +85,5 @@ de =
, publishInProcess = "Dokumente werden publiziert" , publishInProcess = "Dokumente werden publiziert"
, correctFormErrors = "Bitte korrigiere die Fehler im Formular." , correctFormErrors = "Bitte korrigiere die Fehler im Formular."
, doneLabel = "Fertig" , doneLabel = "Fertig"
, sendViaMail = "Per E-Mail versenden"
} }

View File

@ -0,0 +1,60 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Messages.Comp.ShareMail exposing
( Texts
, de
, gb
)
import Http
import Messages.Basics
import Messages.Comp.HttpError
import Messages.Comp.ItemMail
type alias Texts =
{ basics : Messages.Basics.Texts
, itemMail : Messages.Comp.ItemMail.Texts
, httpError : Http.Error -> String
, subjectTemplate : Maybe String -> String
, bodyTemplate : String -> String
}
gb : Texts
gb =
{ basics = Messages.Basics.gb
, httpError = Messages.Comp.HttpError.gb
, itemMail = Messages.Comp.ItemMail.gb
, subjectTemplate = \mt -> "Shared Documents" ++ (Maybe.map (\n -> ": " ++ n) mt |> Maybe.withDefault "")
, bodyTemplate = \url -> """Hi,
you can find the documents here:
""" ++ url ++ """
Kind regards
"""
}
de : Texts
de =
{ basics = Messages.Basics.de
, httpError = Messages.Comp.HttpError.de
, itemMail = Messages.Comp.ItemMail.de
, subjectTemplate = \mt -> "Freigegebene Dokumente" ++ (Maybe.map (\n -> ": " ++ n) mt |> Maybe.withDefault "")
, bodyTemplate = \url -> """Hallo,
die freigegebenen Dokumente befinden sich hier:
""" ++ url ++ """
Freundliche Grüße
"""
}

View File

@ -15,6 +15,7 @@ import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.HttpError import Messages.Comp.HttpError
import Messages.Comp.ShareForm import Messages.Comp.ShareForm
import Messages.Comp.ShareMail
import Messages.Comp.ShareTable import Messages.Comp.ShareTable
import Messages.Comp.ShareView import Messages.Comp.ShareView
@ -24,6 +25,7 @@ type alias Texts =
, shareTable : Messages.Comp.ShareTable.Texts , shareTable : Messages.Comp.ShareTable.Texts
, shareForm : Messages.Comp.ShareForm.Texts , shareForm : Messages.Comp.ShareForm.Texts
, shareView : Messages.Comp.ShareView.Texts , shareView : Messages.Comp.ShareView.Texts
, shareMail : Messages.Comp.ShareMail.Texts
, httpError : Http.Error -> String , httpError : Http.Error -> String
, newShare : String , newShare : String
, copyToClipboard : String , copyToClipboard : String
@ -36,6 +38,7 @@ type alias Texts =
, correctFormErrors : String , correctFormErrors : String
, noName : String , noName : String
, shareInformation : String , shareInformation : String
, sendMail : String
} }
@ -46,6 +49,7 @@ gb =
, shareTable = Messages.Comp.ShareTable.gb , shareTable = Messages.Comp.ShareTable.gb
, shareForm = Messages.Comp.ShareForm.gb , shareForm = Messages.Comp.ShareForm.gb
, shareView = Messages.Comp.ShareView.gb , shareView = Messages.Comp.ShareView.gb
, shareMail = Messages.Comp.ShareMail.gb
, newShare = "New share" , newShare = "New share"
, copyToClipboard = "Copy to clipboard" , copyToClipboard = "Copy to clipboard"
, openInNewTab = "Open in new tab/window" , openInNewTab = "Open in new tab/window"
@ -57,6 +61,7 @@ gb =
, correctFormErrors = "Please correct the errors in the form." , correctFormErrors = "Please correct the errors in the form."
, noName = "No Name" , noName = "No Name"
, shareInformation = "Share Information" , shareInformation = "Share Information"
, sendMail = "Send via E-Mail"
} }
@ -67,6 +72,7 @@ de =
, shareForm = Messages.Comp.ShareForm.de , shareForm = Messages.Comp.ShareForm.de
, shareView = Messages.Comp.ShareView.de , shareView = Messages.Comp.ShareView.de
, httpError = Messages.Comp.HttpError.de , httpError = Messages.Comp.HttpError.de
, shareMail = Messages.Comp.ShareMail.de
, newShare = "Neue Freigabe" , newShare = "Neue Freigabe"
, copyToClipboard = "In die Zwischenablage kopieren" , copyToClipboard = "In die Zwischenablage kopieren"
, openInNewTab = "Im neuen Tab/Fenster öffnen" , openInNewTab = "Im neuen Tab/Fenster öffnen"
@ -78,4 +84,5 @@ de =
, correctFormErrors = "Bitte korrigiere die Fehler im Formular." , correctFormErrors = "Bitte korrigiere die Fehler im Formular."
, noName = "Ohne Name" , noName = "Ohne Name"
, shareInformation = "Informationen zur Freigabe" , shareInformation = "Informationen zur Freigabe"
, sendMail = "Per E-Mail versenden"
} }

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Messages.Comp.SharePasswordForm exposing (Texts, de, gb) module Messages.Comp.SharePasswordForm exposing (Texts, de, gb)
import Http import Http

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Messages.Page.ShareDetail exposing (..) module Messages.Page.ShareDetail exposing (..)
import Data.Fields exposing (Field) import Data.Fields exposing (Field)

View File

@ -52,7 +52,7 @@ init flags =
Comp.CollectiveSettingsForm.init flags Api.Model.CollectiveSettings.empty Comp.CollectiveSettingsForm.init flags Api.Model.CollectiveSettings.empty
( shm, shc ) = ( shm, shc ) =
Comp.ShareManage.init Comp.ShareManage.init flags
in in
( { currentTab = Just InsightsTab ( { currentTab = Just InsightsTab
, sourceModel = sm , sourceModel = sm

View File

@ -118,7 +118,7 @@ viewContent texts flags settings model =
viewSources texts flags settings model viewSources texts flags settings model
Just ShareTab -> Just ShareTab ->
viewShares texts flags model viewShares texts settings flags model
Nothing -> Nothing ->
[] []
@ -245,8 +245,8 @@ viewSources texts flags settings model =
] ]
viewShares : Texts -> Flags -> Model -> List (Html Msg) viewShares : Texts -> UiSettings -> Flags -> Model -> List (Html Msg)
viewShares texts flags model = viewShares texts settings flags model =
[ h1 [ h1
[ class S.header1 [ class S.header1
, class "inline-flex items-center" , class "inline-flex items-center"
@ -256,7 +256,7 @@ viewShares texts flags model =
[ text texts.shares [ text texts.shares
] ]
] ]
, Html.map ShareMsg (Comp.ShareManage.view texts.shareManage flags model.shareModel) , Html.map ShareMsg (Comp.ShareManage.view texts.shareManage settings flags model.shareModel)
] ]

View File

@ -87,14 +87,14 @@ type alias SelectViewModel =
} }
initSelectViewModel : SelectViewModel initSelectViewModel : Flags -> SelectViewModel
initSelectViewModel = initSelectViewModel flags =
{ ids = Set.empty { ids = Set.empty
, action = NoneAction , action = NoneAction
, confirmModal = Nothing , confirmModal = Nothing
, editModel = Comp.ItemDetail.MultiEditMenu.init , editModel = Comp.ItemDetail.MultiEditMenu.init
, mergeModel = Comp.ItemMerge.init [] , mergeModel = Comp.ItemMerge.init []
, publishModel = Tuple.first Comp.PublishItems.init , publishModel = Tuple.first (Comp.PublishItems.init flags)
, saveNameState = SaveSuccess , saveNameState = SaveSuccess
, saveCustomFieldState = Set.empty , saveCustomFieldState = Set.empty
} }

View File

@ -252,10 +252,10 @@ update mId key flags settings msg model =
( nextView, cmd ) = ( nextView, cmd ) =
case model.viewMode of case model.viewMode of
SimpleView -> SimpleView ->
( SelectView initSelectViewModel, loadEditModel flags ) ( SelectView <| initSelectViewModel flags, loadEditModel flags )
SearchView -> SearchView ->
( SelectView initSelectViewModel, loadEditModel flags ) ( SelectView <| initSelectViewModel flags, loadEditModel flags )
SelectView _ -> SelectView _ ->
( SearchView, Cmd.none ) ( SearchView, Cmd.none )
@ -633,7 +633,7 @@ update mId key flags settings msg model =
if svm.action == PublishSelected then if svm.action == PublishSelected then
let let
( mm, mc ) = ( mm, mc ) =
Comp.PublishItems.init Comp.PublishItems.init flags
in in
noSub noSub
( { model ( { model
@ -653,7 +653,7 @@ update mId key flags settings msg model =
else else
let let
( mm, mc ) = ( mm, mc ) =
Comp.PublishItems.initQuery Comp.PublishItems.initQuery flags
(Q.ItemIdIn (Set.toList svm.ids)) (Q.ItemIdIn (Set.toList svm.ids))
in in
noSub noSub
@ -877,7 +877,7 @@ update mId key flags settings msg model =
Just q -> Just q ->
let let
( pm, pc ) = ( pm, pc ) =
Comp.PublishItems.initQuery q Comp.PublishItems.initQuery flags q
in in
noSub ( { model | viewMode = PublishView pm }, Cmd.map PublishViewMsg pc ) noSub ( { model | viewMode = PublishView pm }, Cmd.map PublishViewMsg pc )

View File

@ -80,7 +80,7 @@ mainView texts flags settings model =
PublishSelected -> PublishSelected ->
Just Just
[ div [ class "sm:relative mb-2" ] [ div [ class "sm:relative mb-2" ]
(itemPublishView texts flags svm) (itemPublishView texts settings flags svm)
] ]
_ -> _ ->
@ -89,7 +89,7 @@ mainView texts flags settings model =
PublishView pm -> PublishView pm ->
Just Just
[ div [ class "sm:relative mb-2" ] [ div [ class "sm:relative mb-2" ]
(publishResults texts flags model pm) (publishResults texts settings flags model pm)
] ]
SimpleView -> SimpleView ->
@ -106,10 +106,10 @@ mainView texts flags settings model =
itemCardList texts flags settings model itemCardList texts flags settings model
itemPublishView : Texts -> Flags -> SelectViewModel -> List (Html Msg) itemPublishView : Texts -> UiSettings -> Flags -> SelectViewModel -> List (Html Msg)
itemPublishView texts flags svm = itemPublishView texts settings flags svm =
[ Html.map PublishItemsMsg [ Html.map PublishItemsMsg
(Comp.PublishItems.view texts.publishItems flags svm.publishModel) (Comp.PublishItems.view texts.publishItems settings flags svm.publishModel)
] ]
@ -120,10 +120,10 @@ itemMergeView texts settings svm =
] ]
publishResults : Texts -> Flags -> Model -> Comp.PublishItems.Model -> List (Html Msg) publishResults : Texts -> UiSettings -> Flags -> Model -> Comp.PublishItems.Model -> List (Html Msg)
publishResults texts flags model pm = publishResults texts settings flags model pm =
[ Html.map PublishViewMsg [ Html.map PublishViewMsg
(Comp.PublishItems.view texts.publishItems flags pm) (Comp.PublishItems.view texts.publishItems settings flags pm)
] ]

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.ShareDetail.Data exposing (Model, Msg(..), PageError(..), ViewMode(..), init) module Page.ShareDetail.Data exposing (Model, Msg(..), PageError(..), ViewMode(..), init)
import Api import Api

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.ShareDetail.Update exposing (update) module Page.ShareDetail.Update exposing (update)
import Api import Api

View File

@ -1,3 +1,10 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Page.ShareDetail.View exposing (viewContent, viewSidebar) module Page.ShareDetail.View exposing (viewContent, viewSidebar)
import Api import Api