Merge pull request #747 from eikek/ui-l10n

UI l10n
This commit is contained in:
mergify[bot] 2021-04-10 14:44:53 +00:00 committed by GitHub
commit 5974031ac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
247 changed files with 6779 additions and 2969 deletions

View File

@ -92,11 +92,11 @@ def webjarSettings(queryJS: Project) = Seq(
}.taskValue,
Compile / resourceGenerators += Def.task {
val logger = streams.value.log
val out = (queryJS/Compile/fullOptJS).value
val out = (queryJS / Compile / fullOptJS).value
logger.info(s"Produced query js file: ${out.data}")
copyWebjarResources(
Seq(out.data),
(Compile/resourceManaged).value,
(Compile / resourceManaged).value,
name.value,
version.value,
logger
@ -218,7 +218,9 @@ val openapiScalaSettings = Seq(
field.copy(typeDef = TypeDef("OrgUse", Imports("docspell.common.OrgUse")))
case "equipmentuse" =>
field =>
field.copy(typeDef = TypeDef("EquipmentUse", Imports("docspell.common.EquipmentUse")))
field.copy(typeDef =
TypeDef("EquipmentUse", Imports("docspell.common.EquipmentUse"))
)
}))
)

View File

@ -1,14 +1,18 @@
package docspell.analysis.classifier
import munit._
import cats.effect._
import scala.concurrent.ExecutionContext
import java.nio.file.Paths
import cats.data.NonEmptyList
import docspell.common._
import fs2.Stream
import scala.concurrent.ExecutionContext
import cats.data.Kleisli
import TextClassifier.Data
import cats.data.NonEmptyList
import cats.effect._
import fs2.Stream
import docspell.analysis.classifier.TextClassifier.Data
import docspell.common._
import munit._
class StanfordTextClassifierSuite extends FunSuite {
val logger = Logger.log4s[IO](org.log4s.getLogger)

View File

@ -1,6 +1,7 @@
package docspell.analysis.contact
import docspell.common.{NerLabel, NerTag}
import munit._
class ContactAnnotateSpec extends FunSuite {

View File

@ -1,10 +1,12 @@
package docspell.analysis.date
import docspell.files.TestFiles
import munit._
import docspell.common._
import java.time._
import docspell.common._
import docspell.files.TestFiles
import munit._
class DateFindSpec extends FunSuite {
test("find simple dates") {

View File

@ -2,9 +2,10 @@ package docspell.analysis.nlp
import docspell.analysis.Env
import docspell.common.Language.NLPLanguage
import munit._
import docspell.files.TestFiles
import docspell.common._
import docspell.files.TestFiles
import munit._
class BaseCRFAnnotatorSuite extends FunSuite {

View File

@ -3,12 +3,14 @@ package docspell.analysis.nlp
import java.nio.file.Paths
import cats.effect.IO
import docspell.analysis.Env
import munit._
import docspell.files.TestFiles
import docspell.common._
import docspell.common.syntax.FileSyntax._
import docspell.files.TestFiles
import edu.stanford.nlp.pipeline.StanfordCoreNLP
import munit._
class StanfordNerAnnotatorSuite extends FunSuite {
lazy val germanClassifier =

View File

@ -1,7 +1,8 @@
package docspell.common
import docspell.common.Glob._
import munit._
import Glob._
class GlobTest extends FunSuite {

View File

@ -1,6 +1,7 @@
package docspell.common
import cats.implicits._
import munit._
class LenientUriTest extends FunSuite {

View File

@ -1,9 +1,11 @@
package docspell.common
import munit._
import cats.data.NonEmptyList
import docspell.common.MetaProposal.Candidate
import munit._
class MetaProposalListTest extends FunSuite {
test("flatten retains order of candidates") {

View File

@ -3,16 +3,18 @@ package docspell.convert
import java.nio.file.Paths
import cats.data.Kleisli
import cats.implicits._
import cats.effect.IO
import cats.implicits._
import fs2.Stream
import docspell.common._
import docspell.convert.ConversionResult.Handler
import docspell.convert.extern.OcrMyPdfConfig
import docspell.convert.extern.{TesseractConfig, UnoconvConfig, WkHtmlPdfConfig}
import docspell.convert.flexmark.MarkdownConfig
import docspell.files.{ExampleFiles, TestFiles}
import munit._
import docspell.convert.extern.OcrMyPdfConfig
class ConversionTest extends FunSuite with FileChecks {
val blocker = TestFiles.blocker

View File

@ -6,6 +6,7 @@ import java.nio.file.{Files, Path}
import cats.data.Kleisli
import cats.effect.IO
import fs2.{Pipe, Stream}
import docspell.common.MimeType
import docspell.convert.ConversionResult.Handler
import docspell.files.TikaMimetype

View File

@ -1,13 +1,15 @@
package docspell.convert.extern
import java.nio.charset.StandardCharsets
import java.nio.file.{Path, Paths}
import cats.effect._
import docspell.common._
import docspell.convert._
import docspell.files.{ExampleFiles, TestFiles}
import munit._
import java.nio.charset.StandardCharsets
class ExternConvTest extends FunSuite with FileChecks {
val blocker = TestFiles.blocker

View File

@ -1,8 +1,10 @@
package docspell.extract.ocr
import cats.effect.IO
import docspell.common.Logger
import docspell.files.TestFiles
import munit._
class TextExtractionSuite extends FunSuite {

View File

@ -1,7 +1,9 @@
package docspell.extract.odf
import cats.effect._
import docspell.files.{ExampleFiles, TestFiles}
import munit._
class OdfExtractTest extends FunSuite {

View File

@ -1,7 +1,9 @@
package docspell.extract.pdfbox
import cats.effect._
import docspell.files.{ExampleFiles, TestFiles}
import munit._
class PdfboxExtractTest extends FunSuite {

View File

@ -1,11 +1,14 @@
package docspell.extract.pdfbox
import cats.effect._
import docspell.files.{ExampleFiles, TestFiles}
import munit._
import java.nio.file.Path
import cats.effect._
import fs2.Stream
import docspell.files.{ExampleFiles, TestFiles}
import munit._
class PdfboxPreviewTest extends FunSuite {
val blocker = TestFiles.blocker
implicit val CS = TestFiles.CS

View File

@ -1,8 +1,10 @@
package docspell.extract.poi
import cats.effect._
import docspell.common.MimeTypeHint
import docspell.files.{ExampleFiles, TestFiles}
import munit._
class PoiExtractTest extends FunSuite {

View File

@ -1,6 +1,7 @@
package docspell.extract.rtf
import docspell.files.ExampleFiles
import munit._
class RtfExtractTest extends FunSuite {

View File

@ -1,12 +1,13 @@
package docspell.files
import cats.implicits._
import cats.effect.{Blocker, IO}
import munit._
import scala.concurrent.ExecutionContext
import scala.util.Using
import cats.effect.{Blocker, IO}
import cats.implicits._
import munit._
class ImageSizeTest extends FunSuite {
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
implicit val CS = IO.contextShift(ExecutionContext.global)

View File

@ -1,10 +1,11 @@
package docspell.files
import cats.effect.{Blocker, ExitCode, IO, IOApp}
import docspell.common.MimeTypeHint
import scala.concurrent.ExecutionContext
import cats.effect._
import docspell.common.MimeTypeHint
object Playing extends IOApp {
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)

View File

@ -1,10 +1,10 @@
package docspell.files
import scala.concurrent.ExecutionContext
import cats.effect.{Blocker, IO}
import fs2.Stream
import scala.concurrent.ExecutionContext
object TestFiles {
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
implicit val CS = IO.contextShift(ExecutionContext.global)

View File

@ -1,11 +1,14 @@
package docspell.files
import munit._
import scala.concurrent.ExecutionContext
import cats.effect._
import cats.implicits._
import scala.concurrent.ExecutionContext
import docspell.common.Glob
import munit._
class ZipTest extends FunSuite {
val blocker = Blocker.liftExecutionContext(ExecutionContext.global)

View File

@ -1,9 +1,11 @@
package docspell.joex.analysis
import munit._
import NerFile.Pattern
import java.{util => ju}
import docspell.joex.analysis.NerFile.Pattern
import munit._
class NerFileTest extends FunSuite {
test("create valid case insensitive patterns") {

View File

@ -1,6 +1,7 @@
package docspell.joex.scheduler
import docspell.common.Priority
import munit._
class CountingSchemeSpec extends FunSuite {

View File

@ -1,9 +1,11 @@
package docspell.query
import cats.implicits._
import munit._
import docspell.query.FulltextExtract.Result
import munit._
class FulltextExtractTest extends FunSuite {
def findFts(q: String): Result = {

View File

@ -2,6 +2,7 @@ package docspell.query.internal
import docspell.query.ItemQuery.Attr
import docspell.query.internal.AttrParser
import munit._
class AttrParserTest extends FunSuite {

View File

@ -1,9 +1,11 @@
package docspell.query.internal
import munit._
import cats.data.{NonEmptyList => Nel}
import docspell.query.internal.BasicParser
import munit._
class BasicParserTest extends FunSuite {
test("single string values") {
val p = BasicParser.singleString

View File

@ -1,9 +1,11 @@
package docspell.query.internal
import munit._
import docspell.query.Date
import java.time.Period
import docspell.query.Date
import munit._
class DateParserTest extends FunSuite with ValueHelper {
test("local date string") {

View File

@ -1,9 +1,11 @@
package docspell.query.internal
import docspell.query.ItemQuery._
import munit._
import cats.data.{NonEmptyList => Nel}
import docspell.query.ItemQuery._
import munit._
class ExprParserTest extends FunSuite with ValueHelper {
test("simple expr") {

View File

@ -2,9 +2,10 @@ package docspell.query.internal
import cats.implicits._
import munit._
import docspell.query.ItemQueryParser
import docspell.query.ItemQuery
import docspell.query.ItemQueryParser
import munit._
class ItemQueryParserTest extends FunSuite {

View File

@ -1,9 +1,9 @@
package docspell.query.internal
import munit._
//import cats.parse.{Parser => P}
import docspell.query.ItemQuery.Expr
import munit._
class MacroParserTest extends FunSuite {
test("recognize names shortcut") {

View File

@ -1,9 +1,10 @@
package docspell.query.internal
import munit._
import docspell.query.ItemQuery.{Operator, TagOperator}
import docspell.query.internal.OperatorParser
import munit._
class OperatorParserTest extends FunSuite {
test("operator values") {
val p = OperatorParser.op

View File

@ -1,11 +1,14 @@
package docspell.query.internal
import cats.data.{NonEmptyList => Nel}
import docspell.query.ItemQuery._
import munit._
import docspell.query.Date
import java.time.Period
import cats.data.{NonEmptyList => Nel}
import docspell.query.Date
import docspell.query.ItemQuery._
import munit._
class SimpleExprParserTest extends FunSuite with ValueHelper {
test("string expr") {

View File

@ -1,8 +1,9 @@
package docspell.query.internal
import java.time.Period
import docspell.query.Date
import docspell.query.ItemQuery._
import java.time.Period
trait ValueHelper {

View File

@ -1,13 +1,15 @@
package docspell.store
import scala.concurrent.ExecutionContext
import cats.effect._
import docspell.common.LenientUri
import docspell.store.impl.StoreImpl
import doobie._
import org.h2.jdbcx.JdbcConnectionPool
import scala.concurrent.ExecutionContext
trait StoreFixture {
def withStore(db: String)(code: Store[IO] => IO[Unit]): Unit = {
//StoreFixture.store(StoreFixture.memoryDB(db)).use(code).unsafeRunSync()

View File

@ -2,13 +2,14 @@ package docspell.store.generator
import java.time.LocalDate
import docspell.store.records._
import munit._
import docspell.common._
import docspell.query.ItemQueryParser
import docspell.store.queries.AttachCountTable
import docspell.store.qb.DSL._
import docspell.store.qb.generator.{ItemQueryGenerator, Tables}
import docspell.store.queries.AttachCountTable
import docspell.store.records._
import munit._
class ItemQueryGeneratorTest extends FunSuite {
import docspell.store.impl.DoobieMeta._

View File

@ -1,8 +1,9 @@
package docspell.store.qb
import munit._
import docspell.store.qb.model._
import docspell.store.qb.DSL._
import docspell.store.qb.model._
import munit._
class QueryBuilderTest extends FunSuite {

View File

@ -1,10 +1,11 @@
package docspell.store.qb.impl
import munit._
import docspell.store.qb._
import docspell.store.qb.DSL._
import docspell.store.qb._
import docspell.store.qb.model.{CourseRecord, PersonRecord}
import munit._
class ConditionBuilderTest extends FunSuite {
val c = CourseRecord.as("c")

View File

@ -1,10 +1,11 @@
package docspell.store.qb.impl
import munit._
import docspell.store.qb._
import docspell.store.qb.DSL._
import docspell.store.qb._
import docspell.store.qb.model.{CourseRecord, PersonRecord}
import munit._
class DSLTest extends FunSuite {
val course = CourseRecord.as("c")

View File

@ -1,9 +1,10 @@
package docspell.store.qb.impl
import munit._
import docspell.store.qb.DSL._
import docspell.store.qb._
import docspell.store.qb.model._
import docspell.store.qb.DSL._
import munit._
class SelectBuilderTest extends FunSuite {

View File

@ -1,6 +1,7 @@
package docspell.store.qb.model
import cats.data.NonEmptyList
import docspell.store.qb._
case class CourseRecord(

View File

@ -1,8 +1,9 @@
package docspell.store.qb.model
import cats.data.NonEmptyList
import docspell.store.qb._
import docspell.common._
import docspell.store.qb._
case class PersonRecord(id: Long, name: String, created: Timestamp)

View File

@ -2,6 +2,7 @@ module App.Data exposing
( Model
, Msg(..)
, defaultPage
, getUiLanguage
, init
)
@ -13,6 +14,7 @@ import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings)
import Data.UiTheme exposing (UiTheme)
import Http
import Messages.UiLanguage exposing (UiLanguage)
import Page exposing (Page(..))
import Page.CollectiveSettings.Data
import Page.Home.Data
@ -48,6 +50,8 @@ type alias Model =
, uiSettings : UiSettings
, sidebarVisible : Bool
, anonymousTheme : UiTheme
, anonymousUiLang : UiLanguage
, langMenuOpen : Bool
}
@ -97,6 +101,8 @@ init key url flags_ settings =
, uiSettings = settings
, sidebarVisible = settings.sideMenuVisible
, anonymousTheme = Data.UiTheme.Light
, anonymousUiLang = Messages.UiLanguage.English
, langMenuOpen = False
}
, Cmd.batch
[ Cmd.map UserSettingsMsg uc
@ -152,8 +158,20 @@ type Msg
| GetUiSettings UiSettings
| ToggleSidebar
| ToggleDarkMode
| ToggleLangMenu
| SetLanguage UiLanguage
defaultPage : Flags -> Page
defaultPage flags =
defaultPage _ =
HomePage
getUiLanguage : Model -> UiLanguage
getUiLanguage model =
case model.flags.account of
Just _ ->
model.uiSettings.uiLang
Nothing ->
model.anonymousUiLang

View File

@ -84,6 +84,15 @@ updateWithSub msg model =
, Sub.none
)
ToggleLangMenu ->
( { model | langMenuOpen = not model.langMenuOpen }
, Cmd.none
, Sub.none
)
SetLanguage lang ->
( { model | anonymousUiLang = lang, langMenuOpen = False }, Cmd.none, Sub.none )
HomeMsg lm ->
updateHome lm model

View File

@ -7,6 +7,9 @@ import Data.Flags
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages exposing (Messages)
import Messages.App exposing (Texts)
import Messages.UiLanguage
import Page exposing (Page(..))
import Page.CollectiveSettings.View2 as CollectiveSettings
import Page.Home.Data
@ -41,6 +44,10 @@ topNavbar model =
topNavUser : AuthResult -> Model -> Html Msg
topNavUser auth model =
let
texts =
Messages.get <| App.Data.getUiLanguage model
in
nav
[ id "top-nav"
, class styleTopNav
@ -56,8 +63,8 @@ topNavUser auth model =
}
, headerNavItem model
, div [ class "flex flex-grow justify-end" ]
[ userMenu auth model
, dataMenu auth model
[ userMenu texts.app auth model
, dataMenu texts.app auth model
]
]
@ -70,7 +77,8 @@ topNavAnon model =
]
[ headerNavItem model
, div [ class "flex flex-grow justify-end" ]
[ a
[ langMenu model
, a
[ href "#"
, onClick ToggleDarkMode
, class dropdownLink
@ -100,40 +108,44 @@ headerNavItem model =
mainContent : Model -> Html Msg
mainContent model =
let
texts =
Messages.get <| App.Data.getUiLanguage model
in
div
[ id "main"
, class styleMain
]
(case model.page of
HomePage ->
viewHome model
viewHome texts model
CollectiveSettingPage ->
viewCollectiveSettings model
viewCollectiveSettings texts model
LoginPage _ ->
viewLogin model
viewLogin texts model
ManageDataPage ->
viewManageData model
viewManageData texts model
UserSettingPage ->
viewUserSettings model
viewUserSettings texts model
QueuePage ->
viewQueue model
viewQueue texts model
RegisterPage ->
viewRegister model
viewRegister texts model
UploadPage mid ->
viewUpload mid model
viewUpload texts mid model
NewInvitePage ->
viewNewInvite model
viewNewInvite texts model
ItemDetailPage id ->
viewItemDetail id model
viewItemDetail texts id model
)
@ -151,8 +163,47 @@ styleMain =
"mt-12 flex md:flex-row flex-col w-full h-screen-12 overflow-y-hidden bg-white dark:bg-bluegray-800 text-gray-800 dark:text-bluegray-300 antialiased"
dataMenu : AuthResult -> Model -> Html Msg
dataMenu _ model =
langMenu : Model -> Html Msg
langMenu model =
let
texts =
Messages.get <| App.Data.getUiLanguage model
langItem lang =
let
langMsg =
Messages.get lang
in
a
[ classList
[ ( dropdownItem, True )
, ( "bg-gray-200 dark:bg-bluegray-700", lang == texts.lang )
]
, onClick (SetLanguage lang)
, href "#"
]
[ i [ langMsg |> .flagIcon |> class ] []
, span [ class "ml-2" ] [ text langMsg.label ]
]
in
div [ class "relative" ]
[ a
[ class dropdownLink
, onClick ToggleLangMenu
, href "#"
]
[ i [ class texts.flagIcon ] []
]
, div
[ class dropdownMenu
, classList [ ( "hidden", not model.langMenuOpen ) ]
]
(List.map langItem Messages.UiLanguage.all)
]
dataMenu : Texts -> AuthResult -> Model -> Html Msg
dataMenu texts _ model =
div [ class "relative" ]
[ a
[ class dropdownLink
@ -174,7 +225,7 @@ dataMenu _ model =
]
[]
, div [ class "inline-block ml-2" ]
[ text "Items"
[ text texts.items
]
]
, div [ class "py-1" ] [ hr [ class S.border ] [] ]
@ -183,7 +234,7 @@ dataMenu _ model =
[]
[ i [ class "fa fa-cubes w-6" ] []
, span [ class "ml-1" ]
[ text "Manage Data"
[ text texts.manageData
]
]
, div [ class "divider" ] []
@ -192,7 +243,7 @@ dataMenu _ model =
[]
[ i [ class "fa fa-upload w-6" ] []
, span [ class "ml-1" ]
[ text "Upload files"
[ text texts.uploadFiles
]
]
, dataPageLink model
@ -200,7 +251,7 @@ dataMenu _ model =
[]
[ i [ class "fa fa-tachometer-alt w-6" ] []
, span [ class "ml-1" ]
[ text "Processing Queue"
[ text texts.processingQueue
]
]
, div
@ -215,7 +266,7 @@ dataMenu _ model =
[ ( "hidden", model.flags.config.signupMode /= "invite" ) ]
[ i [ class "fa fa-key w-6" ] []
, span [ class "ml-1" ]
[ text "New Invites"
[ text texts.newInvites
]
]
, div [ class "py-1" ]
@ -229,7 +280,7 @@ dataMenu _ model =
, title "Opens https://docspell.org/docs"
]
[ i [ class "fa fa-question-circle w-6" ] []
, span [ class "ml-1" ] [ text "Help" ]
, span [ class "ml-1" ] [ text texts.help ]
, span [ class "float-right" ]
[ i [ class "fa fa-external-link-alt w-6" ] []
]
@ -238,8 +289,8 @@ dataMenu _ model =
]
userMenu : AuthResult -> Model -> Html Msg
userMenu acc model =
userMenu : Texts -> AuthResult -> Model -> Html Msg
userMenu texts acc model =
div [ class "relative" ]
[ a
[ class dropdownLink
@ -263,14 +314,14 @@ userMenu acc model =
CollectiveSettingPage
[ i [ class "fa fa-users w-6" ] []
, span [ class "ml-1" ]
[ text "Collective Profile"
[ text texts.collectiveProfile
]
]
, userPageLink model
UserSettingPage
[ i [ class "fa fa-user-circle w-6" ] []
, span [ class "ml-1" ]
[ text "User Profile"
[ text texts.userProfile
]
]
, a
@ -280,7 +331,7 @@ userMenu acc model =
]
[ i [ class "fa fa-adjust w-6" ] []
, span [ class "ml-1" ]
[ text "Light/Dark"
[ text texts.lightDark
]
]
, div [ class "py-1" ] [ hr [ class S.border ] [] ]
@ -291,7 +342,7 @@ userMenu acc model =
]
[ i [ class "fa fa-sign-out-alt w-6" ] []
, span [ class "ml-1" ]
[ text "Logout"
[ text texts.logout
]
]
]
@ -346,85 +397,121 @@ dropdownMenu =
" absolute right-0 bg-white dark:bg-bluegray-800 border dark:border-bluegray-700 dark:text-bluegray-300 shadow-lg opacity-1 transition duration-200 min-w-max "
viewHome : Model -> List (Html Msg)
viewHome model =
[ Html.map HomeMsg (Home.viewSidebar model.sidebarVisible model.flags model.uiSettings model.homeModel)
, Html.map HomeMsg (Home.viewContent model.flags model.uiSettings model.homeModel)
viewHome : Messages -> Model -> List (Html Msg)
viewHome texts model =
[ Html.map HomeMsg
(Home.viewSidebar texts.home
model.sidebarVisible
model.flags
model.uiSettings
model.homeModel
)
, Html.map HomeMsg
(Home.viewContent texts.home
model.flags
model.uiSettings
model.homeModel
)
]
viewCollectiveSettings : Model -> List (Html Msg)
viewCollectiveSettings model =
viewCollectiveSettings : Messages -> Model -> List (Html Msg)
viewCollectiveSettings texts model =
[ Html.map CollSettingsMsg
(CollectiveSettings.viewSidebar model.sidebarVisible
(CollectiveSettings.viewSidebar texts.collectiveSettings
model.sidebarVisible
model.flags
model.uiSettings
model.collSettingsModel
)
, Html.map CollSettingsMsg
(CollectiveSettings.viewContent model.flags
(CollectiveSettings.viewContent texts.collectiveSettings
model.flags
model.uiSettings
model.collSettingsModel
)
]
viewLogin : Model -> List (Html Msg)
viewLogin model =
viewLogin : Messages -> Model -> List (Html Msg)
viewLogin texts model =
[ Html.map LoginMsg
(Login.viewSidebar model.sidebarVisible model.flags model.uiSettings model.loginModel)
, Html.map LoginMsg
(Login.viewContent model.flags model.version model.uiSettings model.loginModel)
(Login.viewContent texts.login model.flags model.version model.uiSettings model.loginModel)
]
viewManageData : Model -> List (Html Msg)
viewManageData model =
viewManageData : Messages -> Model -> List (Html Msg)
viewManageData texts model =
[ Html.map ManageDataMsg
(ManageData.viewSidebar model.sidebarVisible model.flags model.uiSettings model.manageDataModel)
(ManageData.viewSidebar texts.manageData
model.sidebarVisible
model.flags
model.uiSettings
model.manageDataModel
)
, Html.map ManageDataMsg
(ManageData.viewContent model.flags model.uiSettings model.manageDataModel)
(ManageData.viewContent texts.manageData
model.flags
model.uiSettings
model.manageDataModel
)
]
viewUserSettings : Model -> List (Html Msg)
viewUserSettings model =
viewUserSettings : Messages -> Model -> List (Html Msg)
viewUserSettings texts model =
[ Html.map UserSettingsMsg
(UserSettings.viewSidebar model.sidebarVisible model.flags model.uiSettings model.userSettingsModel)
(UserSettings.viewSidebar texts.userSettings
model.sidebarVisible
model.flags
model.uiSettings
model.userSettingsModel
)
, Html.map UserSettingsMsg
(UserSettings.viewContent model.flags model.uiSettings model.userSettingsModel)
(UserSettings.viewContent texts.userSettings
model.flags
model.uiSettings
model.userSettingsModel
)
]
viewQueue : Model -> List (Html Msg)
viewQueue model =
viewQueue : Messages -> Model -> List (Html Msg)
viewQueue texts model =
[ Html.map QueueMsg
(Queue.viewSidebar model.sidebarVisible model.flags model.uiSettings model.queueModel)
(Queue.viewSidebar texts.queue
model.sidebarVisible
model.flags
model.uiSettings
model.queueModel
)
, Html.map QueueMsg
(Queue.viewContent model.flags model.uiSettings model.queueModel)
(Queue.viewContent texts.queue model.flags model.uiSettings model.queueModel)
]
viewRegister : Model -> List (Html Msg)
viewRegister model =
viewRegister : Messages -> Model -> List (Html Msg)
viewRegister texts model =
[ Html.map RegisterMsg
(Register.viewSidebar model.sidebarVisible model.flags model.uiSettings model.registerModel)
, Html.map RegisterMsg
(Register.viewContent model.flags model.uiSettings model.registerModel)
(Register.viewContent texts.register model.flags model.uiSettings model.registerModel)
]
viewNewInvite : Model -> List (Html Msg)
viewNewInvite model =
viewNewInvite : Messages -> Model -> List (Html Msg)
viewNewInvite texts model =
[ Html.map NewInviteMsg
(NewInvite.viewSidebar model.sidebarVisible model.flags model.uiSettings model.newInviteModel)
, Html.map NewInviteMsg
(NewInvite.viewContent model.flags model.uiSettings model.newInviteModel)
(NewInvite.viewContent texts.newInvite model.flags model.uiSettings model.newInviteModel)
]
viewUpload : Maybe String -> Model -> List (Html Msg)
viewUpload mid model =
viewUpload : Messages -> Maybe String -> Model -> List (Html Msg)
viewUpload texts mid model =
[ Html.map UploadMsg
(Upload.viewSidebar
mid
@ -434,7 +521,8 @@ viewUpload mid model =
model.uploadModel
)
, Html.map UploadMsg
(Upload.viewContent mid
(Upload.viewContent texts.upload
mid
model.flags
model.uiSettings
model.uploadModel
@ -442,21 +530,21 @@ viewUpload mid model =
]
viewItemDetail : String -> Model -> List (Html Msg)
viewItemDetail id model =
viewItemDetail : Messages -> String -> Model -> List (Html Msg)
viewItemDetail texts id model =
let
inav =
Page.Home.Data.itemNav id model.homeModel
in
[ Html.map ItemDetailMsg
(ItemDetail.viewSidebar
(ItemDetail.viewSidebar texts.itemDetail
model.sidebarVisible
model.flags
model.uiSettings
model.itemDetailModel
)
, Html.map ItemDetailMsg
(ItemDetail.viewContent
(ItemDetail.viewContent texts.itemDetail
inav
model.flags
model.uiSettings

View File

@ -14,6 +14,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Messages.Comp.AddressForm exposing (Texts)
import Styles as S
import Util.List
@ -51,9 +52,7 @@ emptyModel =
, city = ""
, country =
Comp.Dropdown.makeSingleList
{ makeOption = \c -> { value = c.code, text = c.label, additional = "" }
, placeholder = "Select Country"
, options = countries
{ options = countries
, selected = Nothing
}
}
@ -112,8 +111,16 @@ update msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
countryCfg =
{ makeOption = \c -> { text = c.label, additional = "" }
, placeholder = texts.selectCountry
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div [ class "flex flex-col" ]
[ div
[ class "mb-2"
@ -122,12 +129,12 @@ view2 settings model =
[ for "street"
, class S.inputLabel
]
[ text "Street"
[ text texts.street
]
, input
[ type_ "text"
, onInput SetStreet
, placeholder "Street"
, placeholder texts.street
, value model.street
, name "street"
, class S.textInput
@ -141,12 +148,12 @@ view2 settings model =
[ for "zip"
, class S.inputLabel
]
[ text "Zip Code"
[ text texts.zipCode
]
, input
[ type_ "text"
, onInput SetZip
, placeholder "Zip"
, placeholder texts.zipCode
, value model.zip
, name "zip"
, class S.textInput
@ -160,12 +167,12 @@ view2 settings model =
[ for "city"
, class S.inputLabel
]
[ text "City"
[ text texts.city
]
, input
[ type_ "text"
, onInput SetCity
, placeholder "City"
, placeholder texts.city
, value model.city
, name "city"
, class S.textInput
@ -174,11 +181,11 @@ view2 settings model =
]
, div [ class "" ]
[ label [ class S.inputLabel ]
[ text "Country"
[ text texts.country
]
, Html.map CountryMsg
(Comp.Dropdown.view2
DS.mainStyle
countryCfg
settings
model.country
)

View File

@ -15,6 +15,7 @@ import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.AttachmentMeta exposing (Texts)
import Styles as S
import Util.Http
import Util.Time
@ -64,15 +65,18 @@ update msg model =
--- View2
view2 : List (Attribute Msg) -> Model -> Html Msg
view2 attrs model =
view2 : Texts -> List (Attribute Msg) -> Model -> Html Msg
view2 texts attrs model =
div attrs
[ h3 [ class S.header3 ]
[ text "Extracted Meta Data"
[ text texts.extractedMetadata
]
, case model.meta of
NotAvailable ->
B.loadingDimmer True
B.loadingDimmer
{ active = True
, label = texts.basics.loading
}
Failure msg ->
div [ class S.errorMessage ]
@ -80,33 +84,33 @@ view2 attrs model =
]
Success data ->
viewData2 data
viewData2 texts data
]
viewData2 : AttachmentMeta -> Html Msg
viewData2 meta =
viewData2 : Texts -> AttachmentMeta -> Html Msg
viewData2 texts meta =
div [ class "flex flex-col" ]
[ div [ class "text-lg font-bold" ]
[ text "Content"
[ text texts.content
]
, div [ class "px-2 py-2 text-sm bg-yellow-50 dark:bg-warmgray-800 break-words whitespace-pre max-h-80 overflow-auto" ]
[ text meta.content
]
, div [ class "text-lg font-bold mt-2" ]
[ text "Labels"
[ text texts.labels
]
, div [ class "flex fex-row flex-wrap" ]
(List.map renderLabelItem2 meta.labels)
, div [ class "text-lg font-bold mt-2" ]
[ text "Proposals"
[ text texts.proposals
]
, viewProposals2 meta.proposals
, viewProposals2 texts meta.proposals
]
viewProposals2 : ItemProposals -> Html Msg
viewProposals2 props =
viewProposals2 : Texts -> ItemProposals -> Html Msg
viewProposals2 texts props =
let
mkItem n lbl =
div
@ -130,32 +134,32 @@ viewProposals2 props =
in
div [ class "flex flex-col" ]
[ div [ class "font-bold mb-2" ]
[ text "Correspondent Organization"
[ text texts.correspondentOrg
]
, div [ class "flex flex-row flex-wrap space-x-2" ]
(List.indexedMap mkItem props.corrOrg)
, div [ class "font-bold mt-3 mb-2" ]
[ text "Correspondent Person"
[ text texts.correspondentPerson
]
, div [ class "flex flex-row flex-wrap space-x-2" ]
(List.indexedMap mkItem props.corrPerson)
, div [ class "font-bold mt-3 mb-2" ]
[ text "Concerning Person"
[ text texts.concerningPerson
]
, div [ class "flex flex-row flex-wrap space-x-2" ]
(List.indexedMap mkItem props.concPerson)
, div [ class "font-bold mt-3 mb-2" ]
[ text "Concerning Equipment"
[ text texts.concerningEquipment
]
, div [ class "flex flex-row flex-wrap space-x-2" ]
(List.indexedMap mkItem props.concEquipment)
, div [ class "font-bold mb-2 mt-3" ]
[ text "Item Date"
[ text texts.itemDate
]
, div [ class "flex flex-row flex-wrap space-x-2" ]
(List.map mkTimeItem props.itemDate)
, div [ class "font-bold mt-3 mb-2" ]
[ text "Item Due Date"
[ text texts.itemDueDate
]
, div [ class "flex flex-row flex-wrap space-x-2 mb-2" ]
(List.map mkTimeItem props.dueDate)

View File

@ -1,6 +1,7 @@
module Comp.Basic exposing
( editLinkLabel
, editLinkTableCell
, editLinkTableCell2
, genericButton
, horizontalDivider
, inputRequired
@ -11,12 +12,12 @@ module Comp.Basic exposing
, secondaryBasicButton
, secondaryButton
, stats
, tooltipRight
)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.Basics
import Styles as S
@ -174,27 +175,32 @@ linkLabel model =
genericLink model.icon model.label attrs
loadingDimmer : Bool -> Html msg
loadingDimmer active =
loadingDimmer : { label : String, active : Bool } -> Html msg
loadingDimmer cfg =
div
[ classList
[ ( "hidden", not active )
[ ( "hidden", not cfg.active )
]
, class S.dimmer
]
[ div [ class "text-gray-200" ]
[ i [ class "fa fa-circle-notch animate-spin" ] []
, span [ class "ml-2" ]
[ text "Loading"
[ text cfg.label
]
]
]
editLinkLabel : msg -> Html msg
editLinkLabel click =
editLinkLabel =
editLinkLabel2 Messages.Basics.gb
editLinkLabel2 : Messages.Basics.Texts -> msg -> Html msg
editLinkLabel2 texts click =
linkLabel
{ label = "Edit"
{ label = texts.edit
, icon = "fa fa-edit"
, handler = click
, disabled = False
@ -204,7 +210,14 @@ editLinkLabel click =
editLinkTableCell : msg -> Html msg
editLinkTableCell m =
td [ class S.editLinkTableCellStyle ]
[ editLinkLabel m
[ editLinkLabel2 Messages.Basics.gb m
]
editLinkTableCell2 : Messages.Basics.Texts -> msg -> Html msg
editLinkTableCell2 texts m =
td [ class S.editLinkTableCellStyle ]
[ editLinkLabel2 texts m
]
@ -265,17 +278,6 @@ inputRequired =
]
tooltipRight : Bool -> String -> Html msg
tooltipRight show msg =
div
[ class "absolute bottom-0 right-5 px-2 py-2 rounded-lg z-50 w-40"
, class "bg-white border"
, class "text-sm font-thin"
]
[ text msg
]
--- Helpers

View File

@ -17,6 +17,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Http
import Messages.Comp.CalEventInput exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -129,8 +130,8 @@ update flags ev msg model =
--- View2
view2 : String -> CalEvent -> Model -> Html Msg
view2 extraClasses ev model =
view2 : Texts -> String -> CalEvent -> Model -> Html Msg
view2 texts extraClasses ev model =
let
yearLen =
Basics.max 4 (String.length ev.year)
@ -155,7 +156,7 @@ view2 extraClasses ev model =
[ label
[ class S.inputLabel
]
[ text "Weekday" ]
[ text texts.weekday ]
, input
[ type_ "text"
, class S.textInput
@ -172,7 +173,7 @@ view2 extraClasses ev model =
]
, div [ class "flex flex-col space-y-2 mr-2" ]
[ label [ class S.inputLabel ]
[ text "Year" ]
[ text texts.year ]
, input
[ type_ "text"
, class S.textInput
@ -188,7 +189,7 @@ view2 extraClasses ev model =
]
, div [ class "flex flex-col space-y-2 mr-2" ]
[ label [ class S.inputLabel ]
[ text "Month" ]
[ text texts.month ]
, input
[ type_ "text"
, class styleInput
@ -204,7 +205,7 @@ view2 extraClasses ev model =
]
, div [ class "flex flex-col space-y-2 mr-4 mr-2" ]
[ label [ class S.inputLabel ]
[ text "Day"
[ text texts.day
]
, input
[ type_ "text"
@ -218,7 +219,8 @@ view2 extraClasses ev model =
]
, div [ class "flex flex-col space-y-2 mr-2" ]
[ label [ class S.inputLabel ]
[ text "Hour" ]
[ text texts.hour
]
, input
[ type_ "text"
, class styleInput
@ -234,7 +236,7 @@ view2 extraClasses ev model =
]
, div [ class "flex flex-col space-y-2" ]
[ label [ class S.inputLabel ]
[ text "Minute"
[ text texts.minute
]
, input
[ type_ "text"
@ -253,7 +255,7 @@ view2 extraClasses ev model =
]
, class S.errorMessage
]
[ text "Error: "
[ text (texts.error ++ ": ")
, Maybe.map .message model.checkResult
|> Maybe.withDefault ""
|> text
@ -269,7 +271,7 @@ view2 extraClasses ev model =
]
[ div []
[ div [ class S.inputLabel ]
[ text "Schedule: "
[ text (texts.schedule ++ ": ")
]
, div [ class "px-12 font-mono " ]
[ Maybe.andThen .event model.checkResult
@ -277,7 +279,7 @@ view2 extraClasses ev model =
|> text
]
, div [ class S.inputLabel ]
[ text "Next: "
[ text (texts.next ++ ": ")
]
, ul [ class "list-decimal list-inside text-sm" ]
(Maybe.map .next model.checkResult

View File

@ -16,6 +16,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Http
import Messages.Comp.ChangePasswordForm exposing (Texts)
import Styles as S
import Util.Http
@ -179,8 +180,8 @@ update flags msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
let
currentEmpty =
model.current == Nothing
@ -195,11 +196,12 @@ view2 model =
[ class "flex flex-col space-y-4 relative" ]
[ div []
[ label [ class S.inputLabel ]
[ text "Current Password"
[ text texts.currentPassword
, B.inputRequired
]
, Html.map SetCurrent
(Comp.PasswordInput.view2
{ placeholder = texts.currentPasswordPlaceholder }
model.current
currentEmpty
model.currentModel
@ -209,11 +211,12 @@ view2 model =
[ label
[ class S.inputLabel
]
[ text "New Password"
[ text texts.newPassword
, B.inputRequired
]
, Html.map SetNew1
(Comp.PasswordInput.view2
{ placeholder = texts.newPasswordPlaceholder }
model.newPass1
pass1Empty
model.pass1Model
@ -221,11 +224,12 @@ view2 model =
]
, div []
[ label [ class S.inputLabel ]
[ text "New Password (repeat)"
[ text texts.repeatPassword
, B.inputRequired
]
, Html.map SetNew2
(Comp.PasswordInput.view2
{ placeholder = texts.repeatPasswordPlaceholder }
model.newPass2
pass2Empty
model.pass2Model
@ -263,5 +267,8 @@ view2 model =
[ text "Submit"
]
]
, B.loadingDimmer model.loading
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

View File

@ -24,6 +24,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Markdown
import Messages.Comp.ClassifierSettingsForm exposing (Texts)
import Styles as S
import Util.Tag
@ -59,20 +60,14 @@ init flags sett =
in
( { scheduleModel = cem
, schedule = Data.Validated.Unknown newSchedule
, itemCountModel = Comp.IntField.init (Just 0) Nothing True "Item Count"
, itemCountModel = Comp.IntField.init (Just 0) Nothing True
, itemCount = Just sett.itemCount
, categoryListModel =
let
mkOption s =
{ value = s, text = s, additional = "" }
minit =
Comp.Dropdown.makeModel
{ multiple = True
, searchable = \n -> n > 0
, makeOption = mkOption
, labelColor = \_ -> \_ -> "grey "
, placeholder = "Choose categories "
}
lm =
@ -86,7 +81,7 @@ init flags sett =
Data.ListType.fromString sett.listType
|> Maybe.withDefault Data.ListType.Whitelist
, categoryListTypeModel =
Comp.FixedDropdown.initMap Data.ListType.label Data.ListType.all
Comp.FixedDropdown.init Data.ListType.all
}
, Cmd.batch
[ Api.getTags flags "" GetTagsResp
@ -183,60 +178,69 @@ update flags msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
catListTypeItem =
Comp.FixedDropdown.Item
model.categoryListType
(Data.ListType.label model.categoryListType)
categoryCfg =
{ makeOption = \s -> { text = s, additional = "" }
, labelColor = \_ -> \_ -> "grey "
, placeholder = "Choose categories "
, style = DS.mainStyle
}
catListCfg =
{ display = Data.ListType.label
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
div []
[ Markdown.toHtml [ class "px-2 py-2 opacity-75" ]
"""
Auto-tagging works by learning from existing documents. The more
documents you have correctly tagged, the better. Learning is done
periodically based on a schedule. You can specify tag-groups that
should either be used (whitelist) or not used (blacklist) for
learning.
Use an empty whitelist to disable auto tagging.
"""
texts.autoTaggingText
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Is the following a blacklist or whitelist?" ]
[ text texts.blacklistOrWhitelist ]
, Html.map CategoryListTypeMsg
(Comp.FixedDropdown.view2 (Just catListTypeItem) model.categoryListTypeModel)
(Comp.FixedDropdown.viewStyled2 catListCfg
False
(Just model.categoryListType)
model.categoryListTypeModel
)
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ case model.categoryListType of
Data.ListType.Whitelist ->
text "Include tag categories for learning"
text texts.whitelistLabel
Data.ListType.Blacklist ->
text "Exclude tag categories from learning"
text texts.blacklistLabel
]
, Html.map CategoryListMsg
(Comp.Dropdown.view2
DS.mainStyle
categoryCfg
settings
model.categoryListModel
)
]
, Html.map ItemCountMsg
(Comp.IntField.viewWithInfo2
"The maximum number of items to learn from, order by date newest first. Use 0 to mean all."
model.itemCount
"mb-4"
(Comp.IntField.view
{ label = texts.itemCount
, info = texts.itemCountHelp
, classes = "mb-4"
, number = model.itemCount
}
model.itemCountModel
)
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Schedule" ]
[ text texts.schedule ]
, Html.map ScheduleMsg
(Comp.CalEventInput.view2 "" (Data.Validated.value model.schedule) model.scheduleModel)
(Comp.CalEventInput.view2
texts.calEventInput
""
(Data.Validated.value model.schedule)
model.scheduleModel
)
]
]

View File

@ -23,6 +23,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Http
import Messages.Comp.CollectiveSettingsForm exposing (Texts)
import Styles as S
import Util.Http
@ -50,14 +51,7 @@ init flags settings =
in
( { langModel =
Comp.Dropdown.makeSingleList
{ makeOption =
\l ->
{ value = Data.Language.toIso3 l
, text = Data.Language.toName l
, additional = ""
}
, placeholder = ""
, options = Data.Language.all
{ options = Data.Language.all
, selected = Just lang
}
, intEnabled = settings.integrationEnabled
@ -200,8 +194,20 @@ update flags msg model =
--- View2
view2 : Flags -> UiSettings -> Model -> Html Msg
view2 flags settings model =
view2 : Flags -> Texts -> UiSettings -> Model -> Html Msg
view2 flags texts settings model =
let
languageCfg =
{ makeOption =
\l ->
{ text = texts.languageLabel l
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div
[ classList
[ ( "ui form error success", True )
@ -215,10 +221,10 @@ view2 flags settings model =
[ MB.CustomElement <|
B.primaryButton
{ handler = onClick SaveSettings
, label = "Save"
, label = texts.save
, icon = "fa fa-save"
, attrs =
[ title "Save settings"
[ title texts.saveSettings
, href "#"
]
, disabled = getSettings model |> Data.Validated.isInvalid
@ -228,20 +234,20 @@ view2 flags settings model =
, rootClasses = "mb-4"
}
, h3 [ class S.header3 ]
[ text "Document Language"
[ text texts.documentLanguage
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Document Language"
[ text texts.documentLanguage
]
, Html.map LangDropdownMsg
(Comp.Dropdown.view2
DS.mainStyle
languageCfg
settings
model.langModel
)
, span [ class "opacity-50 text-sm" ]
[ text "The language of your documents. This helps text recognition (OCR) and text analysis."
[ text texts.documentLanguageHelp
]
]
, div
@ -252,7 +258,7 @@ view2 flags settings model =
[ h3
[ class S.header3
]
[ text "Integration Endpoint"
[ text texts.integrationEndpoint
]
, div [ class "mb-4" ]
[ label
@ -268,12 +274,11 @@ view2 flags settings model =
]
[]
, span [ class "ml-2" ]
[ text "Enable integration endpoint"
[ text texts.integrationEndpointHelp
]
]
, div [ class "opacity-50 text-sm" ]
[ text "The integration endpoint allows (local) applications to submit files. "
, text "You can choose to disable it for your collective."
[ text texts.integrationEndpointHelp
]
]
]
@ -284,7 +289,7 @@ view2 flags settings model =
]
[ h3
[ class S.header3 ]
[ text "Full-Text Search" ]
[ text texts.fulltextSearch ]
, div
[ class "mb-4" ]
[ div [ class "flex flex-row" ]
@ -304,13 +309,12 @@ view2 flags settings model =
]
[ i [ class "fa fa-sync-alt" ] []
, span [ class "ml-2 hidden sm:inline" ]
[ text "Re-Index All Data"
[ text texts.reindexAllData
]
]
]
, div [ class "opacity-50 text-sm" ]
[ text "This starts a task that clears the full-text index and re-indexes all your data again."
, text "You must type OK before clicking the button to avoid accidental re-indexing."
[ text texts.reindexAllDataHelp
]
, renderResultMessage2 model.fullTextReIndexResult
]
@ -322,17 +326,20 @@ view2 flags settings model =
]
[ h3
[ class S.header3 ]
[ text "Auto-Tagging"
[ text texts.autoTagging
]
, div
[ class "mb-4" ]
[ Html.map ClassifierSettingMsg
(Comp.ClassifierSettingsForm.view2 settings model.classifierModel)
(Comp.ClassifierSettingsForm.view2 texts.classifierSettingsForm
settings
model.classifierModel
)
, div [ class "flex flex-row justify-end" ]
[ B.secondaryBasicButton
{ handler = onClick StartClassifierTask
, icon = "fa fa-play"
, label = "Start now"
, label = texts.startNow
, disabled = Data.Validated.isInvalid model.classifierModel.schedule
, attrs = [ href "#" ]
}

View File

@ -9,6 +9,7 @@ module Comp.ColorTagger exposing
import Comp.FixedDropdown
import Data.Color exposing (Color)
import Data.DropdownStyle as DS
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
@ -37,7 +38,7 @@ type Msg
init : List String -> List Color -> Model
init leftSel colors =
{ leftDropdown = Comp.FixedDropdown.initString leftSel
{ leftDropdown = Comp.FixedDropdown.init leftSel
, colors = colors
, leftSelect = Nothing
}
@ -89,6 +90,7 @@ update msg model =
type alias ViewOpts =
{ renderItem : ( String, Color ) -> Html Msg
, colorLabel : Color -> String
, label : String
, description : Maybe String
}
@ -96,16 +98,26 @@ type alias ViewOpts =
view2 : FormData -> ViewOpts -> Model -> Html Msg
view2 data opts model =
let
colorLabelCfg =
{ display = identity
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
div [ class "flex flex-col" ]
[ label [ class S.inputLabel ]
[ text opts.label ]
, Html.map LeftMsg
(Comp.FixedDropdown.view2
(Maybe.map (\s -> Comp.FixedDropdown.Item s s) model.leftSelect)
(Comp.FixedDropdown.viewStyled2
colorLabelCfg
False
model.leftSelect
model.leftDropdown
)
, div [ class "field" ]
[ chooseColor2
opts.colorLabel
(AddPair data)
Data.Color.all
Nothing
@ -159,8 +171,8 @@ renderFormData2 opts data =
(List.map valueItem values)
chooseColor2 : (Color -> msg) -> List Color -> Maybe String -> Html msg
chooseColor2 tagger colors mtext =
chooseColor2 : (Color -> String) -> (Color -> msg) -> List Color -> Maybe String -> Html msg
chooseColor2 colorLabel tagger colors mtext =
let
renderLabel color =
a
@ -170,7 +182,7 @@ chooseColor2 tagger colors mtext =
, onClick (tagger color)
]
[ Maybe.withDefault
(Data.Color.toString color)
(colorLabel color)
mtext
|> text
]

View File

@ -23,14 +23,14 @@ type alias Settings msg =
}
defaultSettings : msg -> msg -> String -> Settings msg
defaultSettings confirm cancel confirmMsg =
defaultSettings : msg -> msg -> String -> String -> String -> Settings msg
defaultSettings confirm cancel okLabel cancelLabel confirmMsg =
{ enabled = True
, extraClass = ""
, headerIcon = "fa fa-exclamation-circle mr-3"
, headerClass = "text-2xl font-bold text-center w-full"
, confirmText = "Ok"
, cancelText = "Cancel"
, confirmText = okLabel
, cancelText = cancelLabel
, message = confirmMsg
, confirm = confirm
, cancel = cancel

View File

@ -1,6 +1,7 @@
module Comp.ContactField exposing
( Model
, Msg(..)
, ViewSettings
, emptyModel
, getContacts
, update
@ -11,6 +12,7 @@ import Api.Model.Contact exposing (Contact)
import Comp.Basic as B
import Comp.FixedDropdown
import Data.ContactType exposing (ContactType)
import Data.DropdownStyle as DS
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
@ -30,7 +32,7 @@ emptyModel : Model
emptyModel =
{ items = []
, kind =
Comp.FixedDropdown.initMap Data.ContactType.toString Data.ContactType.all
Comp.FixedDropdown.init Data.ContactType.all
, selectedKind = List.head Data.ContactType.all
, value = ""
}
@ -41,13 +43,6 @@ getContacts model =
List.filter (\c -> c.value /= "") model.items
makeDropdownItem : ContactType -> Comp.FixedDropdown.Item ContactType
makeDropdownItem ct =
{ id = ct
, display = Data.ContactType.toString ct
}
type Msg
= SetValue String
| TypeMsg (Comp.FixedDropdown.Msg ContactType)
@ -121,19 +116,34 @@ update msg model =
--- View2
view2 : Bool -> UiSettings -> Model -> Html Msg
view2 mobile _ model =
type alias ViewSettings =
{ contactTypeLabel : ContactType -> String
, mobile : Bool
}
view2 : ViewSettings -> UiSettings -> Model -> Html Msg
view2 cfg _ model =
let
kindCfg =
{ display = cfg.contactTypeLabel
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
div [ class "flex flex-col" ]
[ div
[ class "flex flex-col space-y-2"
, classList [ ( " md:flex-row md:space-y-0 md:space-x-2", not mobile ) ]
, classList [ ( " md:flex-row md:space-y-0 md:space-x-2", not cfg.mobile ) ]
]
[ div
[ classList [ ( "flex-none md:w-1/6", not mobile ) ]
[ classList [ ( "flex-none md:w-1/6", not cfg.mobile ) ]
]
[ Html.map TypeMsg
(Comp.FixedDropdown.view2
(Maybe.map makeDropdownItem model.selectedKind)
(Comp.FixedDropdown.viewStyled2
kindCfg
False
model.selectedKind
model.kind
)
]
@ -160,7 +170,7 @@ view2 mobile _ model =
]
, class "flex flex-col space-y-2 mt-2 px-2 border-0 border-l dark:border-bluegray-600 "
]
(List.map (renderItem2 mobile) model.items)
(List.map (renderItem2 cfg.mobile) model.items)
]

View File

@ -23,8 +23,9 @@ import Data.Flags exposing (Flags)
import Data.Validated exposing (Validated)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Html.Events exposing (onInput)
import Http
import Messages.Comp.CustomFieldForm exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -61,8 +62,7 @@ init field =
, label = field.label
, ftype = Data.CustomFieldType.fromString field.ftype
, ftypeModel =
Comp.FixedDropdown.initMap Data.CustomFieldType.label
Data.CustomFieldType.all
Comp.FixedDropdown.init Data.CustomFieldType.all
, loading = False
, deleteDimmer = Comp.YesNoDimmer.emptyModel
}
@ -197,17 +197,22 @@ type alias ViewSettings =
--- View2
view2 : ViewSettings -> Model -> List (Html Msg)
view2 viewSettings model =
view2 : Texts -> ViewSettings -> Model -> List (Html Msg)
view2 texts viewSettings model =
let
mkItem cft =
Comp.FixedDropdown.Item cft (Data.CustomFieldType.label cft)
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this custom field?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteField
texts.basics.yes
texts.basics.no
ftypeCfg =
{ display = texts.fieldTypeLabel
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
(if viewSettings.showControls then
[ viewButtons2 model ]
[ viewButtons2 texts model ]
else
[]
@ -236,20 +241,19 @@ view2 viewSettings model =
]
, if model.field.id == "" then
div [ class "py-2 text-lg opacity-75" ]
[ text "Create a new custom field."
[ text texts.createCustomField
]
else
div [ class "py-2 text-lg opacity-75" ]
[ text "Note that changing the format may "
, text "result in invisible values in the ui, if they don't comply to the new format!"
[ text texts.modifyTypeWarning
]
, div [ class "mb-4" ]
[ label
[ class S.inputLabel
, for "fieldname"
]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, input
@ -266,27 +270,25 @@ view2 viewSettings model =
]
[]
, div [ class "opacity-75 text-sm" ]
[ text "The name uniquely identifies this field. It must be a valid "
, text "identifier, not contain spaces or weird characters."
[ text texts.nameInfo
]
]
, div
[ class "mb-4"
]
[ label [ class S.inputLabel ]
[ text "Field Format"
[ text texts.fieldFormat
, B.inputRequired
]
, Html.map FTypeMsg
(Comp.FixedDropdown.viewStyled2
DS.mainStyle
ftypeCfg
(model.ftype == Nothing)
(Maybe.map mkItem model.ftype)
model.ftype
model.ftypeModel
)
, div [ class "opacity-75 text-sm" ]
[ text "A field must have a format. Values are validated "
, text "according to this format."
[ text texts.fieldFormatInfo
]
]
, div [ class "mb-4" ]
@ -294,7 +296,7 @@ view2 viewSettings model =
[ class S.inputLabel
, for "fieldlabel"
]
[ text "Label" ]
[ text texts.label ]
, input
[ type_ "text"
, onInput SetLabel
@ -306,38 +308,37 @@ view2 viewSettings model =
]
[]
, div [ class "opacity-75 text-sm" ]
[ text "The user defined label for this field. This is used to represent "
, text "this field in the ui. If not present, the name is used."
[ text texts.labelInfo
]
]
]
]
viewButtons2 : Model -> Html Msg
viewButtons2 model =
viewButtons2 : Texts -> Model -> Html Msg
viewButtons2 texts model =
MB.view
{ start =
[ MB.PrimaryButton
{ tagger = SubmitForm
, title = "Submit this form"
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
, label = "Submit"
, label = texts.basics.submit
}
, MB.SecondaryButton
{ tagger = GoBack
, title = "Back to list"
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
, label = texts.basics.cancel
}
]
, end =
if model.field.id /= "" then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this field"
, title = texts.deleteThisField
, icon = Just "fa fa-trash"
, label = "Delete"
, label = texts.basics.delete
}
]

View File

@ -16,12 +16,13 @@ import Comp.DatePicker
import Comp.MenuBar as MB
import Data.CustomFieldType exposing (CustomFieldType)
import Data.Icons as Icons
import Data.Money
import Data.Money exposing (MoneyParseError(..))
import Date exposing (Date)
import DatePicker exposing (DatePicker)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Html.Events exposing (onClick, onInput)
import Messages.Comp.CustomFieldInput exposing (Texts)
import Styles as S
import Util.Maybe
@ -32,9 +33,15 @@ type alias Model =
}
type FieldError
= NoValue
| NotANumber String
| NotMoney MoneyParseError
type alias FloatModel =
{ input : String
, result : Result String Float
, result : Result FieldError Float
}
@ -61,27 +68,47 @@ fieldType field =
|> Maybe.withDefault Data.CustomFieldType.Text
errorMsg : Model -> Maybe String
errorMsg model =
errorMsg : Texts -> Model -> Maybe String
errorMsg texts model =
let
getMsg res =
case res of
Ok _ ->
Nothing
parseMsg isMoneyField perr =
case perr of
NoValue ->
if isMoneyField then
Just <| texts.errorNoAmount
Err m ->
Just m
else
Just <| texts.errorNoNumber
NotANumber str ->
Just <| texts.errorNotANumber str
NotMoney (RequireTwoDigitsAfterDot _) ->
Just "Two digits required after the dot."
NotMoney (NoOrTooManyPoints _) ->
Just "One single dot + digits required for money."
in
case model.fieldModel of
NumberField fm ->
getMsg fm.result
case fm.result of
Ok _ ->
Nothing
Err parseError ->
parseMsg False parseError
MoneyField fm ->
getMsg fm.result
case fm.result of
Ok _ ->
Nothing
Err parseError ->
parseMsg True parseError
TextField mt ->
if mt == Nothing then
Just "Please fill in some value"
Just texts.errorNoValue
else
Nothing
@ -103,10 +130,10 @@ init field =
TextField Nothing
Data.CustomFieldType.Numeric ->
NumberField (FloatModel "" (Err "No number given"))
NumberField (FloatModel "" (Err NoValue))
Data.CustomFieldType.Money ->
MoneyField (FloatModel "" (Err "No amount given"))
MoneyField (FloatModel "" (Err NoValue))
Data.CustomFieldType.Boolean ->
BoolField False
@ -150,7 +177,7 @@ initWith value =
updateFloatModel
False
value.value
Data.Money.fromString
(Data.Money.fromString >> Result.mapError NotMoney)
Data.Money.normalizeInput
in
MoneyField fm
@ -230,7 +257,7 @@ update1 forSearch msg model =
updateFloatModel
forSearch
str
Data.Money.fromString
(Data.Money.fromString >> Result.mapError NotMoney)
Data.Money.normalizeInput
model_ =
@ -294,7 +321,7 @@ update1 forSearch msg model =
updateFloatModel :
Bool
-> String
-> (String -> Result String Float)
-> (String -> Result FieldError Float)
-> (String -> String)
-> ( FloatModel, FieldResult )
updateFloatModel forSearch msg parse normalize =
@ -331,11 +358,11 @@ hasWildCards msg =
--- View2
view2 : String -> Maybe String -> Model -> Html Msg
view2 classes icon model =
view2 : Texts -> String -> Maybe String -> Model -> Html Msg
view2 texts classes icon model =
let
error =
errorMsg model
errorMsg texts model
in
div
[ class classes
@ -473,11 +500,11 @@ mkLabel model =
Maybe.withDefault model.field.name model.field.label
string2Float : String -> Result String Float
string2Float : String -> Result FieldError Float
string2Float str =
case String.toFloat str of
Just n ->
Ok n
Nothing ->
Err ("Not a number: " ++ str)
Err (NotANumber str)

View File

@ -17,8 +17,8 @@ import Comp.MenuBar as MB
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Messages.Comp.CustomFieldManage exposing (Texts)
import Styles as S
import Util.CustomField
@ -135,18 +135,18 @@ update flags msg model =
--- View2
view2 : Flags -> Model -> Html Msg
view2 flags model =
view2 : Texts -> Flags -> Model -> Html Msg
view2 texts flags model =
case model.detailModel of
Just dm ->
viewDetail2 flags dm
viewDetail2 texts flags dm
Nothing ->
viewTable2 model
viewTable2 texts model
viewDetail2 : Flags -> Comp.CustomFieldForm.Model -> Html Msg
viewDetail2 _ detailModel =
viewDetail2 : Texts -> Flags -> Comp.CustomFieldForm.Model -> Html Msg
viewDetail2 texts _ detailModel =
let
viewSettings =
{ showControls = True
@ -156,44 +156,55 @@ viewDetail2 _ detailModel =
div []
((if detailModel.field.id == "" then
h3 [ class S.header2 ]
[ text "Create new custom field"
[ text texts.newCustomField
]
else
h3 [ class S.header2 ]
[ Util.CustomField.nameOrLabel detailModel.field |> text
, div [ class "opacity-50 text-sm" ]
[ text "Id: "
[ text (texts.basics.id ++ ": ")
, text detailModel.field.id
]
]
)
:: List.map (Html.map DetailMsg) (Comp.CustomFieldForm.view2 viewSettings detailModel)
:: List.map (Html.map DetailMsg)
(Comp.CustomFieldForm.view2 texts.fieldForm
viewSettings
detailModel
)
)
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div [ class "flex flex-col md:relative" ]
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
]
, end =
[ MB.PrimaryButton
{ tagger = InitNewCustomField
, title = "Add a new custom field"
, title = texts.addCustomField
, icon = Just "fa fa-plus"
, label = "New custom field"
, label = texts.newCustomField
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.CustomFieldTable.view2 model.tableModel model.fields)
, B.loadingDimmer model.loading
, Html.map TableMsg
(Comp.CustomFieldTable.view2 texts.fieldTable
model.tableModel
model.fields
)
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

View File

@ -29,6 +29,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Http
import Messages.Comp.CustomFieldMultiInput exposing (Texts)
import Styles as S
import Util.CustomField
import Util.Maybe
@ -130,7 +131,7 @@ reset model =
mkFieldSelect : List CustomField -> FieldSelect
mkFieldSelect fields =
{ selected = Nothing
, dropdown = Comp.FixedDropdown.init (List.map mkItem fields)
, dropdown = Comp.FixedDropdown.init fields
}
@ -145,11 +146,6 @@ type alias UpdateResult =
}
mkItem : CustomField -> Comp.FixedDropdown.Item CustomField
mkItem f =
Comp.FixedDropdown.Item f (Maybe.withDefault f.name f.label)
update : Flags -> Msg -> Model -> UpdateResult
update =
update1 False
@ -318,25 +314,33 @@ type alias ViewSettings =
{ showAddButton : Bool
, classes : String
, fieldIcon : CustomField -> Maybe String
, style : DS.DropdownStyle
, createCustomFieldTitle : String
}
view2 : DS.DropdownStyle -> ViewSettings -> Model -> Html Msg
view2 ddstyle viewSettings model =
view2 : Texts -> ViewSettings -> Model -> Html Msg
view2 texts viewSettings model =
div [ class viewSettings.classes ]
(viewMenuBar2 ddstyle viewSettings model
:: List.map (viewCustomField2 viewSettings model) (visibleFields model)
(viewMenuBar2 viewSettings model
:: List.map (viewCustomField2 texts viewSettings model) (visibleFields model)
)
viewMenuBar2 : DS.DropdownStyle -> ViewSettings -> Model -> Html Msg
viewMenuBar2 ddstyle viewSettings model =
viewMenuBar2 : ViewSettings -> Model -> Html Msg
viewMenuBar2 viewSettings model =
let
{ dropdown, selected } =
model.fieldSelect
ddstyle =
viewSettings.style
ddstyleFlex =
{ ddstyle | root = ddstyle.root ++ " flex-grow" }
{ display = \f -> Maybe.withDefault f.name f.label
, icon = \_ -> Nothing
, style = { ddstyle | root = ddstyle.root ++ " flex-grow" }
}
in
div
[ classList
@ -348,11 +352,11 @@ viewMenuBar2 ddstyle viewSettings model =
(Comp.FixedDropdown.viewStyled2
ddstyleFlex
False
(Maybe.map mkItem selected)
selected
dropdown
)
:: (if viewSettings.showAddButton then
[ addFieldLink2 "ml-1" model
[ addFieldLink2 viewSettings.createCustomFieldTitle "ml-1" model
]
else
@ -361,8 +365,8 @@ viewMenuBar2 ddstyle viewSettings model =
)
viewCustomField2 : ViewSettings -> Model -> CustomField -> Html Msg
viewCustomField2 viewSettings model field =
viewCustomField2 : Texts -> ViewSettings -> Model -> CustomField -> Html Msg
viewCustomField2 texts viewSettings model field =
let
visibleField =
Dict.get field.name model.visibleFields
@ -370,7 +374,8 @@ viewCustomField2 viewSettings model field =
case visibleField of
Just vf ->
Html.map (CustomFieldInputMsg field)
(Comp.CustomFieldInput.view2 "mt-2"
(Comp.CustomFieldInput.view2 texts.customFieldInput
"mt-2"
(viewSettings.fieldIcon vf.field)
vf.inputModel
)
@ -379,8 +384,8 @@ viewCustomField2 viewSettings model field =
span [] []
addFieldLink2 : String -> Model -> Html Msg
addFieldLink2 classes _ =
addFieldLink2 : String -> String -> Model -> Html Msg
addFieldLink2 titleStr classes _ =
a
[ class classes
, class S.secondaryButton
@ -388,7 +393,7 @@ addFieldLink2 classes _ =
-- , class "absolute -right-12 top-0"
, href "#"
, onClick CreateNewField
, title "Create a new custom field"
, title titleStr
]
[ i [ class "fa fa-plus" ] []
]

View File

@ -11,7 +11,7 @@ import Api.Model.CustomField exposing (CustomField)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.Comp.CustomFieldTable exposing (Texts)
import Styles as S
import Util.Time
@ -45,17 +45,17 @@ update msg model =
--- View2
view2 : Model -> List CustomField -> Html Msg
view2 _ items =
view2 : Texts -> Model -> List CustomField -> Html Msg
view2 texts _ items =
div []
[ table [ class S.tableMain ]
[ thead []
[ tr []
[ th [] []
, th [ class "text-left" ] [ text "Name/Label" ]
, th [ class "text-left" ] [ text "Format" ]
, th [ class "text-center hidden sm:table-cell" ] [ text "#Usage" ]
, th [ class "text-center hidden sm:table-cell" ] [ text "Created" ]
, th [ class "text-left" ] [ text texts.nameLabel ]
, th [ class "text-left" ] [ text texts.format ]
, th [ class "text-center hidden sm:table-cell" ] [ text texts.usageCount ]
, th [ class "text-center hidden sm:table-cell" ] [ text texts.basics.created ]
]
]
, tbody []

View File

@ -47,6 +47,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Http
import Messages.Comp.DetailEdit exposing (Texts)
import Styles as S
import Util.Http
@ -639,10 +640,10 @@ update flags msg model =
--- View2
view2 : List (Attribute Msg) -> UiSettings -> Model -> Html Msg
view2 attr settings model =
view2 : Texts -> List (Attribute Msg) -> UiSettings -> Model -> Html Msg
view2 texts attr settings model =
div attr
(viewIntern2 settings True model)
(viewIntern2 texts settings True model)
formHeading : String -> Model -> Html msg
@ -668,8 +669,8 @@ formHeading classes model =
]
viewModal2 : UiSettings -> Maybe Model -> Html Msg
viewModal2 settings mm =
viewModal2 : Texts -> UiSettings -> Maybe Model -> Html Msg
viewModal2 texts settings mm =
let
hidden =
mm == Nothing
@ -710,7 +711,7 @@ viewModal2 settings mm =
, div [ class "scrolling content" ]
(case mm of
Just model ->
viewIntern2 settings False model
viewIntern2 texts settings False model
Nothing ->
[]
@ -718,7 +719,7 @@ viewModal2 settings mm =
, div [ class "flex flex-row space-x-2" ]
(case mm of
Just model ->
viewButtons2 model
viewButtons2 texts model
Nothing ->
[]
@ -727,10 +728,10 @@ viewModal2 settings mm =
]
viewButtons2 : Model -> List (Html Msg)
viewButtons2 model =
viewButtons2 : Texts -> Model -> List (Html Msg)
viewButtons2 texts model =
[ B.primaryButton
{ label = "Submit"
{ label = texts.basics.submit
, icon =
if model.submitting || model.loading then
"fa fa-circle-notch animate-spin"
@ -742,7 +743,7 @@ viewButtons2 model =
, attrs = [ href "#" ]
}
, B.secondaryButton
{ label = "Cancel"
{ label = texts.basics.cancel
, handler = onClick Cancel
, disabled = False
, icon = "fa fa-times"
@ -751,8 +752,8 @@ viewButtons2 model =
]
viewIntern2 : UiSettings -> Bool -> Model -> List (Html Msg)
viewIntern2 settings withButtons model =
viewIntern2 : Texts -> UiSettings -> Bool -> Model -> List (Html Msg)
viewIntern2 texts settings withButtons model =
[ div
[ classList
[ ( S.errorMessage, Maybe.map .success model.result == Just False )
@ -766,24 +767,25 @@ viewIntern2 settings withButtons model =
]
, case model.form of
TM tm ->
Html.map TagMsg (Comp.TagForm.view2 tm)
Html.map TagMsg (Comp.TagForm.view2 texts.tagForm tm)
PMR pm ->
Html.map PersonMsg (Comp.PersonForm.view2 True settings pm)
Html.map PersonMsg (Comp.PersonForm.view2 texts.personForm True settings pm)
PMC pm ->
Html.map PersonMsg (Comp.PersonForm.view2 True settings pm)
Html.map PersonMsg (Comp.PersonForm.view2 texts.personForm True settings pm)
OM om ->
Html.map OrgMsg (Comp.OrgForm.view2 True settings om)
Html.map OrgMsg (Comp.OrgForm.view2 texts.orgForm True settings om)
EM em ->
Html.map EquipMsg (Comp.EquipmentForm.view2 em)
Html.map EquipMsg (Comp.EquipmentForm.view2 texts.equipmentForm em)
CFM fm ->
div []
(List.map (Html.map CustomFieldMsg)
(Comp.CustomFieldForm.view2
texts.customFieldForm
{ classes = ""
, showControls = False
}
@ -793,7 +795,7 @@ viewIntern2 settings withButtons model =
]
++ (if withButtons then
[ div [ class "flex flex-row space-x-2" ]
(viewButtons2 model)
(viewButtons2 texts model)
]
else

View File

@ -2,6 +2,7 @@ module Comp.Dropdown exposing
( Model
, Msg(..)
, Option
, ViewSettings
, getSelected
, isDropdownChangeMsg
, makeModel
@ -10,16 +11,13 @@ module Comp.Dropdown exposing
, makeSingleList
, mkOption
, notSelected
, orgDropdown
, orgFormViewSettings
, setMkOption
, update
, view2
, viewSingle2
)
{-| This needs to be rewritten from scratch!
-}
import Api.Model.IdName exposing (IdName)
import Data.DropdownStyle as DS
import Data.UiSettings exposing (UiSettings)
@ -31,32 +29,8 @@ import Util.Html exposing (onKeyUp)
import Util.List
orgDropdown : Model IdName
orgDropdown =
makeModel
{ multiple = False
, searchable = \n -> n > 0
, makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = "Choose an organization"
}
type alias Option =
{ value : String
, text : String
, additional : String
}
mkOption : String -> String -> Option
mkOption value text =
Option value text ""
type alias Item a =
{ value : a
, option : Option
, visible : Bool
, selected : Bool
, active : Bool
@ -66,7 +40,6 @@ type alias Item a =
makeItem : Model a -> a -> Item a
makeItem model val =
{ value = val
, option = model.makeOption val
, visible = True
, selected =
List.any (\i -> i.value == val) model.selected
@ -78,26 +51,15 @@ type alias Model a =
{ multiple : Bool
, selected : List (Item a)
, available : List (Item a)
, makeOption : a -> Option
, menuOpen : Bool
, filterString : String
, labelColor : a -> UiSettings -> String
, searchable : Int -> Bool
, placeholder : String
}
setMkOption : (a -> Option) -> Model a -> Model a
setMkOption mkopt model =
{ model | makeOption = mkopt }
makeModel :
{ multiple : Bool
, searchable : Int -> Bool
, makeOption : a -> Option
, labelColor : a -> UiSettings -> String
, placeholder : String
}
-> Model a
makeModel input =
@ -105,45 +67,28 @@ makeModel input =
, searchable = input.searchable
, selected = []
, available = []
, makeOption = input.makeOption
, menuOpen = False
, filterString = ""
, labelColor = input.labelColor
, placeholder = input.placeholder
}
makeSingle :
{ makeOption : a -> Option
, placeholder : String
}
-> Model a
makeSingle opts =
makeSingle : Model a
makeSingle =
makeModel
{ multiple = False
, searchable = \n -> n > 0
, makeOption = opts.makeOption
, labelColor = \_ -> \_ -> ""
, placeholder =
if opts.placeholder == "" then
"Select"
else
opts.placeholder
}
makeSingleList :
{ makeOption : a -> Option
, placeholder : String
, options : List a
{ options : List a
, selected : Maybe a
}
-> Model a
makeSingleList opts =
let
m =
makeSingle { makeOption = opts.makeOption, placeholder = opts.placeholder }
makeSingle
m2 =
{ m | available = List.map (makeItem m) opts.options }
@ -156,18 +101,11 @@ makeSingleList opts =
m3
makeMultiple :
{ makeOption : a -> Option
, labelColor : a -> UiSettings -> String
}
-> Model a
makeMultiple opts =
makeMultiple : Model a
makeMultiple =
makeModel
{ multiple = True
, searchable = \n -> n > 0
, makeOption = opts.makeOption
, labelColor = opts.labelColor
, placeholder = ""
}
@ -186,9 +124,8 @@ type Msg a
| SetSelection (List a)
| ToggleMenu
| AddItem (Item a)
| RemoveItem (Item a)
| RemoveItem2 (Item a)
| Filter String
| Filter (a -> String) String
| ShowMenu Bool
| KeyPress Int
@ -215,17 +152,17 @@ deselectItem : Model a -> Item a -> Model a
deselectItem model item =
let
value =
item.option.value
item.value
sel =
if model.multiple then
List.filter (\e -> e.option.value /= value) model.selected
List.filter (\e -> e.value /= value) model.selected
else
[]
show e =
if e.option.value == value then
if e.value == value then
{ e | selected = False }
else
@ -241,7 +178,7 @@ selectItem : Model a -> Item a -> Model a
selectItem model item =
let
value =
item.option.value
item.value
sel =
if model.multiple then
@ -251,7 +188,7 @@ selectItem model item =
[ item ]
hide e =
if e.option.value == value then
if e.value == value then
{ e | selected = True }
else if model.multiple then
@ -266,13 +203,13 @@ selectItem model item =
{ model | selected = sel, available = avail }
filterOptions : String -> List (Item a) -> List (Item a)
filterOptions str list =
List.map (\e -> { e | visible = Simple.Fuzzy.match str e.option.text, active = False }) list
filterOptions : String -> (a -> String) -> List (Item a) -> List (Item a)
filterOptions str mkText list =
List.map (\e -> { e | visible = Simple.Fuzzy.match str (mkText e.value), active = False }) list
applyFilter : String -> Model a -> Model a
applyFilter str model =
applyFilter : String -> (a -> String) -> Model a -> Model a
applyFilter str mkText model =
let
selected =
if str /= "" && not model.multiple then
@ -281,7 +218,12 @@ applyFilter str model =
else
model.selected
in
{ model | filterString = str, available = filterOptions str model.available, selected = selected }
{ model | filterString = str, available = filterOptions str mkText model.available, selected = selected }
clearFilter : Model a -> Model a
clearFilter model =
{ model | filterString = "" }
makeNextActive : (Int -> Int) -> Model a -> Model a
@ -299,7 +241,7 @@ makeNextActive nextEl model =
|> Maybe.andThen (Util.List.get opts)
merge item1 item2 =
{ item2 | active = item1.option.value == item2.option.value }
{ item2 | active = item1.value == item2.value }
updateModel item =
{ model | available = List.map (merge item) model.available, menuOpen = True }
@ -325,7 +267,7 @@ selectActive model =
in
case current of
Just item ->
selectItem model item |> applyFilter ""
selectItem model item |> clearFilter
Nothing ->
model
@ -337,9 +279,6 @@ isDropdownChangeMsg cm =
AddItem _ ->
True
RemoveItem _ ->
True
RemoveItem2 _ ->
True
@ -375,34 +314,23 @@ update msg model =
AddItem e ->
let
m =
selectItem model e |> applyFilter ""
selectItem model e |> clearFilter
in
( { m | menuOpen = False }, Cmd.none )
RemoveItem e ->
let
m =
deselectItem model e |> applyFilter ""
in
( -- Setting to True, because parent click sets it to False… ugly
{ m | menuOpen = True }
, Cmd.none
)
RemoveItem2 e ->
let
m =
deselectItem model e |> applyFilter ""
deselectItem model e |> clearFilter
in
( -- Hack above only needed with semanticui
m
( m
, Cmd.none
)
Filter str ->
Filter f str ->
let
m =
applyFilter str model
applyFilter str f model
in
( { m | menuOpen = True }, Cmd.none )
@ -438,7 +366,7 @@ update msg model =
[ e ] ->
let
( m_, c_ ) =
update (RemoveItem e) model
update (RemoveItem2 e) model
in
( { m_ | menuOpen = False }, c_ )
@ -463,32 +391,65 @@ update msg model =
-- View2
view2 : DS.DropdownStyle -> UiSettings -> Model a -> Html (Msg a)
view2 style settings model =
type alias Option =
{ text : String
, additional : String
}
mkOption : String -> Option
mkOption text =
Option text ""
type alias ViewSettings a =
{ makeOption : a -> Option
, placeholder : String
, labelColor : a -> UiSettings -> String
, style : DS.DropdownStyle
}
orgFormViewSettings : String -> DS.DropdownStyle -> ViewSettings IdName
orgFormViewSettings placeholder ds =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = placeholder
, style = ds
}
setMkOption : (a -> Option) -> ViewSettings a -> ViewSettings a
setMkOption mkopt model =
{ model | makeOption = mkopt }
view2 : ViewSettings a -> UiSettings -> Model a -> Html (Msg a)
view2 cfg settings model =
if model.multiple then
viewMultiple2 style settings model
viewMultiple2 cfg settings model
else
viewSingle2 style model
viewSingle2 cfg model
viewSingle2 : DS.DropdownStyle -> Model a -> Html (Msg a)
viewSingle2 style model =
viewSingle2 : ViewSettings a -> Model a -> Html (Msg a)
viewSingle2 cfg model =
let
renderItem item =
a
[ href "#"
, class style.item
, class cfg.style.item
, classList
[ ( style.itemActive, item.active )
[ ( cfg.style.itemActive, item.active )
, ( "font-semibold", item.selected )
]
, onClick (AddItem item)
, onKeyUp KeyPress
]
[ text item.option.text
[ text <| (.value >> cfg.makeOption >> .text) item
, span [ class "text-gray-400 float-right" ]
[ text item.option.additional
[ text <| (.value >> cfg.makeOption >> .additional) item
]
]
@ -500,7 +461,7 @@ viewSingle2 style model =
, onKeyUp KeyPress
]
[ div
[ class style.link
[ class cfg.style.link
]
[ a
[ class "flex-grow"
@ -514,8 +475,8 @@ viewSingle2 style model =
, onClick ToggleMenu
, href "#"
]
[ Maybe.map (.option >> .text) sel
|> Maybe.withDefault model.placeholder
[ Maybe.map (.value >> cfg.makeOption >> .text) sel
|> Maybe.withDefault cfg.placeholder
|> text
]
, a
@ -532,11 +493,11 @@ viewSingle2 style model =
]
, input
[ type_ "text"
, placeholder model.placeholder
, onInput Filter
, placeholder cfg.placeholder
, onInput (Filter (cfg.makeOption >> .text))
, value model.filterString
, class "inline-block border-0 px-0 w-full py-0 focus:ring-0 "
, class style.input
, class cfg.style.input
, classList [ ( "hidden", not (model.menuOpen && isSearchable model) ) ]
]
[]
@ -550,43 +511,43 @@ viewSingle2 style model =
]
]
, div
[ class style.menu
[ class cfg.style.menu
, classList [ ( "hidden", not model.menuOpen ) ]
]
(getOptions model |> List.map renderItem)
]
viewMultiple2 : DS.DropdownStyle -> UiSettings -> Model a -> Html (Msg a)
viewMultiple2 style settings model =
viewMultiple2 : ViewSettings a -> UiSettings -> Model a -> Html (Msg a)
viewMultiple2 cfg settings model =
let
renderItem item =
a
[ href "#"
, class style.item
, class cfg.style.item
, classList
[ ( style.itemActive, item.active )
[ ( cfg.style.itemActive, item.active )
, ( "font-semibold", item.selected )
]
, onClick (AddItem item)
, onKeyUp KeyPress
]
[ text item.option.text
[ text <| (.value >> cfg.makeOption >> .text) item
, span [ class "text-gray-400 float-right" ]
[ text item.option.additional
[ text <| (.value >> cfg.makeOption >> .additional) item
]
]
renderSelectMultiple : Item a -> Html (Msg a)
renderSelectMultiple item =
a
[ class (model.labelColor item.value settings)
[ class (cfg.labelColor item.value settings)
, class "label font-medium inline-flex relative items-center hover:shadow-md mt-1 mr-1"
, onClick (RemoveItem item)
, onClick (RemoveItem2 item)
, href "#"
]
[ span [ class "pl-4" ]
[ text item.option.text
[ text <| (.value >> cfg.makeOption >> .text) item
]
, span [ class "opacity-75 absolute left-2 my-auto" ]
[ i [ class "fa fa-times" ] []
@ -598,7 +559,7 @@ viewMultiple2 style settings model =
, onKeyUp KeyPress
]
[ div
[ class style.link
[ class cfg.style.link
, class "flex inline-flex flex-wrap items-center"
]
[ div
@ -609,10 +570,10 @@ viewMultiple2 style settings model =
, input
[ type_ "text"
, placeholder "Search"
, onInput Filter
, onInput (Filter (cfg.makeOption >> .text))
, value model.filterString
, class "inline-flex w-16 border-0 px-0 focus:ring-0 h-6"
, class style.input
, class cfg.style.input
]
[]
, a
@ -629,7 +590,7 @@ viewMultiple2 style settings model =
]
]
, div
[ class style.menu
[ class cfg.style.menu
, classList [ ( "hidden", not model.menuOpen ) ]
]
(getOptions model |> List.map renderItem)

View File

@ -18,6 +18,7 @@ import File.Select
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Messages.Comp.Dropzone exposing (Texts)
import Styles as S
import Util.Html exposing (onDragEnter, onDragLeave, onDragOver, onDropFiles)
@ -124,8 +125,8 @@ filterMime model files =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
div
[ classList
[ ( "bg-opacity-100 bg-blue-100 dark:bg-lightblue-800", model.state.hover )
@ -144,24 +145,23 @@ view2 model =
]
[ i [ class "fa fa-mouse-pointer" ] []
, div [ class "ml-3" ]
[ text "Drop files here"
[ text texts.dropFilesHere
]
]
, B.horizontalDivider
{ label = "Or"
{ label = texts.or
, topCss = "w-2/3 mb-4 hidden md:inline-flex"
, labelCss = "px-4 bg-gray-200 bg-opacity-50"
, lineColor = "bg-gray-300 dark:bg-bluegray-600"
}
, B.primaryBasicButton
{ label = "Select ..."
{ label = texts.select
, icon = "fa fa-folder-open font-thin"
, handler = onClick PickFiles
, attrs = [ href "#" ]
, disabled = not model.state.active
}
, div [ class "text-center opacity-75 text-sm mt-4" ]
[ text "Choose document files (pdf, docx, txt, html, ). "
, text "Archives (zip and eml) are extracted."
[ text texts.selectInfo
]
]

View File

@ -1,6 +1,7 @@
module Comp.EmailInput exposing
( Model
, Msg
, ViewSettings
, init
, update
, view2
@ -137,10 +138,16 @@ update flags current msg model =
--- View2
view2 : DS.DropdownStyle -> List String -> Model -> Html Msg
view2 style values model =
type alias ViewSettings =
{ placeholder : String
, style : DS.DropdownStyle
}
view2 : ViewSettings -> List String -> Model -> Html Msg
view2 cfg values model =
div [ class "text-sm flex-row space-x-2 relative" ]
[ div [ class style.link ]
[ div [ class cfg.style.link ]
[ div
[ class "flex flex-row space-x-2 mr-2"
, classList [ ( "hidden", List.isEmpty values ) ]
@ -149,7 +156,7 @@ view2 style values model =
, input
[ type_ "text"
, value model.input
, placeholder "Recipients"
, placeholder cfg.placeholder
, onKeyUp KeyPress
, onInput SetInput
, class "inline-flex w-24 border-0 px-0 focus:ring-0 h-6 text-sm"
@ -157,7 +164,7 @@ view2 style values model =
]
[]
]
, renderMenu2 style model
, renderMenu2 cfg.style model
]

View File

@ -21,6 +21,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Messages.Comp.EmailSettingsForm exposing (Texts)
import Styles as S
import Util.Maybe
@ -46,7 +47,7 @@ emptyModel =
{ settings = Api.Model.EmailSettings.empty
, name = ""
, host = ""
, portField = Comp.IntField.init (Just 0) Nothing True "SMTP Port"
, portField = Comp.IntField.init (Just 0) Nothing True
, portNum = Nothing
, user = Nothing
, passField = Comp.PasswordInput.init
@ -55,14 +56,7 @@ emptyModel =
, replyTo = Nothing
, sslType =
Comp.Dropdown.makeSingleList
{ makeOption =
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
{ options = Data.SSLType.all
, selected = Just Data.SSLType.None
}
, ignoreCertificates = False
@ -74,7 +68,7 @@ init ems =
{ settings = ems
, name = ems.name
, host = ems.smtpHost
, portField = Comp.IntField.init (Just 0) Nothing True "SMTP Port"
, portField = Comp.IntField.init (Just 0) Nothing True
, portNum = ems.smtpPort
, user = ems.smtpUser
, passField = Comp.PasswordInput.init
@ -83,14 +77,7 @@ init ems =
, replyTo = ems.replyTo
, sslType =
Comp.Dropdown.makeSingleList
{ makeOption =
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
{ options = Data.SSLType.all
, selected =
Data.SSLType.fromString ems.sslType
|> Maybe.withDefault Data.SSLType.None
@ -184,21 +171,33 @@ update msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
sslCfg =
{ makeOption =
\s ->
{ text = texts.sslTypeLabel s
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div [ class "grid grid-cols-4 gap-y-4 gap-x-2" ]
[ div [ class "col-span-4" ]
[ label
[ class S.inputLabel
]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, input
[ type_ "text"
, value model.name
, onInput SetName
, placeholder "Connection name, e.g. 'gmail.com'"
, placeholder texts.connectionPlaceholder
, class S.textInput
, classList [ ( S.inputErrorBorder, model.name == "" ) ]
]
@ -207,17 +206,17 @@ view2 settings model =
[ class S.message
, class "mt-2"
]
[ text "The connection name must not contain whitespace or special characters."
[ text texts.connectionNameInfo
]
]
, div [ class "col-span-3" ]
[ label [ class S.inputLabel ]
[ text "SMTP Host"
[ text texts.smtpHost
, B.inputRequired
]
, input
[ type_ "text"
, placeholder "SMTP host name, e.g. 'mail.gmail.com'"
, placeholder texts.smtpHostPlaceholder
, value model.host
, onInput SetHost
, class S.textInput
@ -226,20 +225,23 @@ view2 settings model =
[]
]
, Html.map PortMsg
(Comp.IntField.viewWithInfo2 ""
model.portNum
""
(Comp.IntField.view
{ label = texts.smtpPort
, info = ""
, number = model.portNum
, classes = ""
}
model.portField
)
, div [ class "col-span-4 sm:col-span-2" ]
[ label
[ class S.inputLabel
]
[ text "SMTP User"
[ text texts.smtpUser
]
, input
[ type_ "text"
, placeholder "SMTP Username, e.g. 'your.name@gmail.com'"
, placeholder texts.smtpUserPlaceholder
, Maybe.withDefault "" model.user |> value
, onInput SetUser
, class S.textInput
@ -248,10 +250,11 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "SMTP Password"
[ text texts.smtpPassword
]
, Html.map PassMsg
(Comp.PasswordInput.view2
{ placeholder = texts.smtpPasswordPlaceholder }
model.password
False
model.passField
@ -259,12 +262,12 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "From Address"
[ text texts.fromAddress
, B.inputRequired
]
, input
[ type_ "text"
, placeholder "Sender E-Mail address"
, placeholder texts.fromAddressPlaceholder
, value model.from
, onInput SetFrom
, class S.textInput
@ -274,11 +277,11 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "Reply-To"
[ text texts.replyTo
]
, input
[ type_ "text"
, placeholder "Optional reply-to E-Mail address"
, placeholder texts.replyToPlaceholder
, Maybe.withDefault "" model.replyTo |> value
, onInput SetReplyTo
, class S.textInput
@ -287,11 +290,11 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "SSL"
[ text texts.ssl
]
, Html.map SSLTypeMsg
(Comp.Dropdown.view2
DS.mainStyle
sslCfg
settings
model.sslType
)
@ -300,7 +303,7 @@ view2 settings model =
[ MB.viewItem <|
MB.Checkbox
{ tagger = \_ -> ToggleCheckCert
, label = "Ignore certificate check"
, label = texts.ignoreCertCheck
, value = model.ignoreCertificates
, id = "smpt-no-cert-check"
}

View File

@ -21,6 +21,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.EmailSettingsManage exposing (Texts)
import Styles as S
import Util.Http
@ -206,71 +207,76 @@ update flags msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
case model.viewMode of
Table ->
viewTable2 model
viewTable2 texts model
Form ->
viewForm2 settings model
viewForm2 texts settings model
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div []
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
]
, end =
[ MB.PrimaryButton
{ tagger = InitNew
, title = "Add new SMTP settings"
, title = texts.addNewSmtpSettings
, icon = Just "fa fa-plus"
, label = "New Settings"
, label = texts.newSettings
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.EmailSettingsTable.view2 model.tableModel)
, Html.map TableMsg
(Comp.EmailSettingsTable.view2 texts.settingsTable
model.tableModel
)
]
viewForm2 : UiSettings -> Model -> Html Msg
viewForm2 settings model =
viewForm2 : Texts -> UiSettings -> Model -> Html Msg
viewForm2 texts settings model =
let
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete these connection?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteConnection
texts.basics.yes
texts.basics.no
in
div [ class "flex flex-col md:relative" ]
[ MB.view
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, title = "Submit this form"
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
, label = "Submit"
, label = texts.basics.submit
}
, MB.SecondaryButton
{ tagger = SetViewMode Table
, title = "Back to list"
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
, label = texts.basics.cancel
}
]
, end =
if model.formModel.settings.name /= "" then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this settings entry"
, title = texts.deleteThisEntry
, icon = Just "fa fa-trash"
, label = "Delete"
, label = texts.basics.delete
}
]
@ -288,12 +294,18 @@ viewForm2 settings model =
[ Maybe.withDefault "" model.formError |> text
]
, Html.map FormMsg
(Comp.EmailSettingsForm.view2 settings model.formModel)
(Comp.EmailSettingsForm.view2 texts.settingsForm
settings
model.formModel
)
, Html.map YesNoMsg
(Comp.YesNoDimmer.viewN
True
dimmerSettings
model.deleteConfirm
)
, B.loadingDimmer model.loading
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

View File

@ -11,6 +11,7 @@ import Api.Model.EmailSettings exposing (EmailSettings)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.EmailSettingsTable exposing (Texts)
import Styles as S
@ -47,15 +48,15 @@ update msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
table [ class S.tableMain ]
[ thead []
[ tr []
[ th [ class "" ] []
, th [ class "text-left mr-2" ] [ text "Name" ]
, th [ class "text-left mr-2" ] [ text "Host/Port" ]
, th [ class "text-left mr-2 hidden sm:table-cell" ] [ text "From" ]
, th [ class "text-left mr-2" ] [ text texts.basics.name ]
, th [ class "text-left mr-2" ] [ text texts.hostPort ]
, th [ class "text-left mr-2 hidden sm:table-cell" ] [ text texts.from ]
]
]
, tbody []

View File

@ -11,11 +11,13 @@ module Comp.EquipmentForm exposing
import Api.Model.Equipment exposing (Equipment)
import Comp.Basic as B
import Comp.FixedDropdown
import Data.DropdownStyle as DS
import Data.EquipmentUse exposing (EquipmentUse)
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Messages.Comp.EquipmentForm exposing (Texts)
import Styles as S
import Util.Maybe
@ -36,9 +38,7 @@ emptyModel =
, notes = Nothing
, use = Data.EquipmentUse.Concerning
, useModel =
Comp.FixedDropdown.initMap
Data.EquipmentUse.label
Data.EquipmentUse.all
Comp.FixedDropdown.init Data.EquipmentUse.all
}
@ -100,21 +100,28 @@ update _ msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
let
equipUseCfg =
{ display = texts.equipmentUseLabel
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
div [ class "flex flex-col" ]
[ div [ class "mb-4" ]
[ label
[ for "equipname"
, class S.inputLabel
]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, input
[ type_ "text"
, onInput SetName
, placeholder "Name"
, placeholder texts.basics.name
, value model.name
, name "equipname"
, class S.textInput
@ -130,21 +137,21 @@ view2 model =
[ label
[ class S.inputLabel
]
[ text "Use" ]
[ text texts.use ]
, Html.map UseDropdownMsg
(Comp.FixedDropdown.view2 (makeUseItem model) model.useModel)
(Comp.FixedDropdown.viewStyled2 equipUseCfg False (Just model.use) model.useModel)
, span [ class "opacity-50 text-sm" ]
[ case model.use of
Data.EquipmentUse.Concerning ->
text "Use as concerning equipment"
text texts.useAsConcerning
Data.EquipmentUse.Disabled ->
text "Do not use for suggestions."
text texts.useNotSuggestions
]
]
, div [ class "mb-4" ]
[ h3 [ class S.header3 ]
[ text "Notes"
[ text texts.notes
]
, div [ class "" ]
[ textarea
@ -156,9 +163,3 @@ view2 model =
]
]
]
makeUseItem : Model -> Maybe (Comp.FixedDropdown.Item EquipmentUse)
makeUseItem model =
Just <|
Comp.FixedDropdown.Item model.use (Data.EquipmentUse.label model.use)

View File

@ -20,6 +20,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onSubmit)
import Http
import Messages.Comp.EquipmentManage exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -204,38 +205,41 @@ update flags msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
if model.viewMode == Table then
viewTable2 model
viewTable2 texts model
else
viewForm2 model
viewForm2 texts model
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div [ class "flex flex-col" ]
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
]
, end =
[ MB.PrimaryButton
{ tagger = InitNewEquipment
, title = "Create a new equipment"
, title = texts.createNewEquipment
, icon = Just "fa fa-plus"
, label = "New Equipment"
, label = texts.newEquipment
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.EquipmentTable.view2 model.tableModel)
, Html.map TableMsg
(Comp.EquipmentTable.view2 texts.equipmentTable
model.tableModel
)
, div
[ classList
[ ( "ui dimmer", True )
@ -247,14 +251,16 @@ viewTable2 model =
]
viewForm2 : Model -> Html Msg
viewForm2 model =
viewForm2 : Texts -> Model -> Html Msg
viewForm2 texts model =
let
newEquipment =
model.formModel.equipment.id == ""
dimmerSettings2 =
Comp.YesNoDimmer.defaultSettings2 "Really delete this equipment?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteEquipment
texts.basics.yes
texts.basics.no
in
Html.form
[ class "relative flex flex-col"
@ -268,14 +274,14 @@ viewForm2 model =
)
, if newEquipment then
h1 [ class S.header2 ]
[ text "Create new equipment"
[ text texts.createNewEquipment
]
else
h1 [ class S.header2 ]
[ text model.formModel.equipment.name
, div [ class "opacity-50 text-sm" ]
[ text "Id: "
[ text (texts.basics.id ++ ": ")
, text model.formModel.equipment.id
]
]
@ -283,24 +289,24 @@ viewForm2 model =
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, title = "Submit this form"
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
, label = "Submit"
, label = texts.basics.submit
}
, MB.SecondaryButton
{ tagger = SetViewMode Table
, title = "Back to list"
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
, label = texts.basics.cancel
}
]
, end =
if not newEquipment then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this equipment"
, title = texts.deleteThisEquipment
, icon = Just "fa fa-trash"
, label = "Delete"
, label = texts.basics.delete
}
]
@ -317,6 +323,9 @@ viewForm2 model =
]
[ Maybe.withDefault "" model.formError |> text
]
, Html.map FormMsg (Comp.EquipmentForm.view2 model.formModel)
, B.loadingDimmer model.loading
, Html.map FormMsg (Comp.EquipmentForm.view2 texts.equipmentForm model.formModel)
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

View File

@ -12,7 +12,7 @@ import Data.EquipmentUse
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.Comp.EquipmentTable exposing (Texts)
import Styles as S
@ -52,25 +52,25 @@ update _ msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
table [ class S.tableMain ]
[ thead []
[ tr []
[ th [ class "" ] []
, th [ class "text-left pr-1 md:px-2 w-20" ]
[ text "Use"
[ text texts.use
]
, th [ class "text-left" ] [ text "Name" ]
, th [ class "text-left" ] [ text texts.basics.name ]
]
]
, tbody []
(List.map (renderEquipmentLine2 model) model.equips)
(List.map (renderEquipmentLine2 texts model) model.equips)
]
renderEquipmentLine2 : Model -> Equipment -> Html Msg
renderEquipmentLine2 model equip =
renderEquipmentLine2 : Texts -> Model -> Equipment -> Html Msg
renderEquipmentLine2 texts model equip =
tr
[ classList [ ( "active", model.selected == Just equip ) ]
, class S.tableRow
@ -80,7 +80,7 @@ renderEquipmentLine2 model equip =
[ div [ class "label inline-flex text-sm" ]
[ Data.EquipmentUse.fromString equip.use
|> Maybe.withDefault Data.EquipmentUse.Concerning
|> Data.EquipmentUse.label
|> texts.equipmentUseLabel
|> text
]
]

View File

@ -1,6 +1,7 @@
module Comp.FieldListSelect exposing
( Model
, Msg
, ViewSettings
, update
, view2
)
@ -49,17 +50,23 @@ addField selected field =
--- View2
view2 : String -> Model -> Html Msg
view2 classes selected =
type alias ViewSettings =
{ fieldLabel : Field -> String
, classes : String
}
view2 : ViewSettings -> Model -> Html Msg
view2 cfg selected =
div
[ class "flex flex-col space-y-4 md:space-y-2"
, class classes
, class cfg.classes
]
(List.map (fieldCheckbox2 selected) Data.Fields.all)
(List.map (fieldCheckbox2 cfg selected) Data.Fields.all)
fieldCheckbox2 : Model -> Field -> Html Msg
fieldCheckbox2 selected field =
fieldCheckbox2 : ViewSettings -> Model -> Field -> Html Msg
fieldCheckbox2 cfg selected field =
let
isChecked =
List.member field selected
@ -69,5 +76,5 @@ fieldCheckbox2 selected field =
{ id = "field-toggle-" ++ Data.Fields.toString field
, value = isChecked
, tagger = \_ -> Toggle field
, label = Data.Fields.label field
, label = cfg.fieldLabel field
}

View File

@ -2,12 +2,9 @@ module Comp.FixedDropdown exposing
( Item
, Model
, Msg
, ViewSettings
, init
, initMap
, initString
, initTuple
, update
, view2
, viewStyled2
)
@ -22,7 +19,6 @@ import Util.List
type alias Item a =
{ id : a
, display : String
}
@ -39,31 +35,17 @@ type Msg a
| KeyPress (Maybe KeyCode)
init : List (Item a) -> Model a
init options =
initItems : List (Item a) -> Model a
initItems options =
{ options = options
, menuOpen = False
, selected = Nothing
}
initString : List String -> Model String
initString strings =
init <| List.map (\s -> Item s s) strings
initMap : (a -> String) -> List a -> Model a
initMap elToString els =
init <| List.map (\a -> Item a (elToString a)) els
initTuple : List ( String, a ) -> Model a
initTuple tuples =
let
mkItem ( txt, id ) =
Item id txt
in
init <| List.map mkItem tuples
init : List a -> Model a
init els =
List.map Item els |> initItems
isSelected : Model a -> Item a -> Bool
@ -167,28 +149,48 @@ update msg model =
--- View2
viewStyled2 : DS.DropdownStyle -> Bool -> Maybe (Item a) -> Model a -> Html (Msg a)
viewStyled2 style error sel model =
type alias ViewSettings a =
{ display : a -> String
, icon : a -> Maybe String
, style : DS.DropdownStyle
}
viewStyled2 : ViewSettings a -> Bool -> Maybe a -> Model a -> Html (Msg a)
viewStyled2 cfg error sel model =
let
iconItem id =
span
[ classList [ ( "hidden", cfg.icon id == Nothing ) ]
, class (Maybe.withDefault "" (cfg.icon id))
, class "mr-2"
]
[]
renderItem item =
a
[ href "#"
, class style.item
, class cfg.style.item
, classList
[ ( style.itemActive, isSelected model item )
, ( "font-semibold", Just item == sel )
[ ( cfg.style.itemActive, isSelected model item )
, ( "font-semibold", Just item.id == sel )
]
, onClick (SelectItem2 item)
]
[ text item.display
[ iconItem item.id
, text (cfg.display item.id)
]
selIcon =
Maybe.map iconItem sel
|> Maybe.withDefault (span [ class "hidden" ] [])
in
div
[ class ("relative " ++ style.root)
[ class ("relative " ++ cfg.style.root)
, onKeyUpCode KeyPress
]
[ a
[ class style.link
[ class cfg.style.link
, classList [ ( S.inputErrorBorder, error ) ]
, tabindex 0
, onClick ToggleMenu
@ -200,7 +202,8 @@ viewStyled2 style error sel model =
[ ( "opacity-50", sel == Nothing )
]
]
[ Maybe.map .display sel
[ selIcon
, Maybe.map cfg.display sel
|> Maybe.withDefault "Select"
|> text
]
@ -211,13 +214,8 @@ viewStyled2 style error sel model =
]
]
, div
[ class style.menu
[ class cfg.style.menu
, classList [ ( "hidden", not model.menuOpen ) ]
]
(List.map renderItem model.options)
]
view2 : Maybe (Item a) -> Model a -> Html (Msg a)
view2 =
viewStyled2 DS.mainStyle False

View File

@ -18,11 +18,13 @@ import Comp.Basic as B
import Comp.FixedDropdown
import Comp.MenuBar as MB
import Comp.YesNoDimmer
import Data.DropdownStyle as DS
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Messages.Comp.FolderDetail exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -65,8 +67,7 @@ init users folder =
, members = folder.members
, users = users
, memberDropdown =
Comp.FixedDropdown.initMap .name
(makeOptions users folder)
Comp.FixedDropdown.init (makeOptions users folder)
, selectedMember = Nothing
, loading = False
, deleteDimmer = Comp.YesNoDimmer.emptyModel
@ -275,13 +276,8 @@ update flags msg model =
--- View2
makeItem : IdName -> Comp.FixedDropdown.Item IdName
makeItem idn =
Comp.FixedDropdown.Item idn idn.name
view2 : Flags -> Model -> Html Msg
view2 flags model =
view2 : Texts -> Flags -> Model -> Html Msg
view2 texts flags model =
let
isOwner =
Maybe.map .user flags.account
@ -290,10 +286,12 @@ view2 flags model =
dimmerSettings : Comp.YesNoDimmer.Settings
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this folder?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteThisFolder
texts.basics.yes
texts.basics.no
in
div [ class "flex flex-col md:relative" ]
(viewButtons2 model
(viewButtons2 texts model
:: [ Html.map DeleteMsg
(Comp.YesNoDimmer.viewN
True
@ -304,26 +302,26 @@ view2 flags model =
[ class "py-2 text-lg opacity-75"
, classList [ ( "hidden", model.folder.id /= "" ) ]
]
[ text "You are automatically set as owner of this new folder."
[ text texts.autoOwnerInfo
]
, div
[ class "py-2 text-lg opacity-75"
, classList [ ( "hidden", model.folder.id == "" ) ]
]
[ text "Modify this folder by changing the name or add/remove members."
[ text texts.modifyInfo
]
, div
[ class S.message
, classList [ ( "hidden", model.folder.id == "" || isOwner ) ]
]
[ text "You are not the owner of this folder and therefore are not allowed to edit it."
[ text texts.notOwnerInfo
]
, div [ class "mb-4 flex flex-col" ]
[ label
[ class S.inputLabel
, for "folder-name"
]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, div [ class "flex flex-row space-x-2" ]
@ -345,7 +343,7 @@ view2 flags model =
]
[ i [ class "fa fa-save" ] []
, span [ class "ml-2 hidden sm:inline" ]
[ text "Save"
[ text texts.basics.submit
]
]
]
@ -363,12 +361,19 @@ view2 flags model =
|> text
]
]
++ viewMembers2 model
++ viewMembers2 texts model
)
viewMembers2 : Model -> List (Html Msg)
viewMembers2 model =
viewMembers2 : Texts -> Model -> List (Html Msg)
viewMembers2 texts model =
let
folderCfg =
{ display = .name
, icon = \_ -> Nothing
, style = DS.mainStyle
}
in
if model.folder.id == "" then
[]
@ -377,19 +382,21 @@ viewMembers2 model =
[ class S.header3
, class "mt-4"
]
[ text "Members"
[ text texts.members
]
, div [ class "flex flex-col space-y-2" ]
[ div [ class "flex flex-row space-x-2" ]
[ div [ class "flex-grow" ]
[ Html.map MemberDropdownMsg
(Comp.FixedDropdown.view2
(Maybe.map makeItem model.selectedMember)
(Comp.FixedDropdown.viewStyled2
folderCfg
False
model.selectedMember
model.memberDropdown
)
]
, a
[ title "Add a new member"
[ title texts.addMember
, onClick AddMember
, class S.primaryButton
, href "#"
@ -397,7 +404,7 @@ viewMembers2 model =
]
[ i [ class "fa fa-plus" ] []
, span [ class "ml-2 hidden sm:inline" ]
[ text "Add"
[ text texts.add
]
]
]
@ -406,19 +413,19 @@ viewMembers2 model =
[ class "flex flex-col space-y-4 md:space-y-2 mt-2"
, class "px-2 border-0 border-l dark:border-bluegray-600"
]
(List.map viewMember2 model.members)
(List.map (viewMember2 texts) model.members)
]
viewMember2 : IdName -> Html Msg
viewMember2 member =
viewMember2 : Texts -> IdName -> Html Msg
viewMember2 texts member =
div
[ class "flex flex-row space-x-2 items-center"
]
[ a
[ class S.deleteLabel
, href "#"
, title "Remove this member"
, title texts.removeMember
, onClick (RemoveMember member)
]
[ i [ class "fa fa-trash " ] []
@ -429,23 +436,23 @@ viewMember2 member =
]
viewButtons2 : Model -> Html Msg
viewButtons2 model =
viewButtons2 : Texts -> Model -> Html Msg
viewButtons2 texts model =
MB.view
{ start =
[ MB.SecondaryButton
{ tagger = GoBack
, label = "Back"
, label = texts.basics.cancel
, icon = Just "fa fa-arrow-left"
, title = "Back to list"
, title = texts.basics.backToList
}
]
, end =
[ MB.CustomButton
{ tagger = RequestDelete
, label = "Delete"
, label = texts.basics.delete
, icon = Just "fa fa-trash"
, title = "Delete this folder"
, title = texts.deleteThisFolder
, inputClass =
[ ( S.deleteButton, True )
, ( "hidden", model.folder.id == "" )

View File

@ -20,6 +20,7 @@ import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.FolderManage exposing (Texts)
import Styles as S
@ -168,50 +169,54 @@ update flags msg model =
--- View2
view2 : Flags -> Model -> Html Msg
view2 flags model =
view2 : Texts -> Flags -> Model -> Html Msg
view2 texts flags model =
case model.detailModel of
Just dm ->
viewDetail2 flags dm
viewDetail2 texts flags dm
Nothing ->
viewTable2 model
viewTable2 texts model
viewDetail2 : Flags -> Comp.FolderDetail.Model -> Html Msg
viewDetail2 flags model =
viewDetail2 : Texts -> Flags -> Comp.FolderDetail.Model -> Html Msg
viewDetail2 texts flags model =
div []
[ if model.folder.id == "" then
h3 [ class S.header2 ]
[ text "Create new Folder"
[ text texts.createNewFolder
]
else
h3 [ class S.header2 ]
[ text model.folder.name
, div [ class "opacity-50 text-sm" ]
[ text "Id: "
[ text (texts.basics.id ++ ": ")
, text model.folder.id
]
]
, Html.map DetailMsg (Comp.FolderDetail.view2 flags model)
, Html.map DetailMsg
(Comp.FolderDetail.view2 texts.folderDetail
flags
model
)
]
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div [ class "flex flex-col" ]
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
, MB.Checkbox
{ tagger = \_ -> ToggleOwningOnly
, label = "Show owning folders only"
, label = texts.showOwningFoldersOnly
, value = model.owningOnly
, id = "folder-toggle-owner"
}
@ -219,14 +224,19 @@ viewTable2 model =
, end =
[ MB.PrimaryButton
{ tagger = InitNewFolder
, title = "Create a new folder"
, title = texts.createNewFolder
, icon = Just "fa fa-plus"
, label = "New Folder"
, label = texts.newFolder
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.FolderTable.view2 model.tableModel model.folders)
, Html.map TableMsg
(Comp.FolderTable.view2
texts.folderTable
model.tableModel
model.folders
)
, div
[ classList
[ ( "ui dimmer", True )

View File

@ -156,25 +156,20 @@ viewDrop2 dropModel constr model =
highlightDrop =
DD.getDropId dropModel == Just DD.FolderRemove
in
div [ class "ui list" ]
[ div [ class "item" ]
[ i [ class "folder open icon" ] []
, div [ class "content" ]
[ div
(classList
[ ( "hidden", True )
, ( "current-drop-target", highlightDrop )
]
:: DD.droppable FolderDDMsg DD.FolderRemove
-- note: re-enable this when adding a "no-folder selection"
-- this enables a drop target that removes a folder
)
[ text "Folders"
]
, div [ class "flex flex-col space-y-2 md:space-y-1" ]
(renderItems2 dropModel constr model)
div []
[ div
(classList
[ ( "hidden", True )
, ( "current-drop-target", highlightDrop )
]
:: DD.droppable FolderDDMsg DD.FolderRemove
-- note: re-enable this when adding a "no-folder selection"
-- this enables a drop target that removes a folder
)
[ text "Folders"
]
, div [ class "flex flex-col space-y-2 md:space-y-1" ]
(renderItems2 dropModel constr model)
]

View File

@ -11,6 +11,7 @@ import Api.Model.FolderItem exposing (FolderItem)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.FolderTable exposing (Texts)
import Styles as S
import Util.Time
@ -44,23 +45,27 @@ update msg model =
--- View2
view2 : Model -> List FolderItem -> Html Msg
view2 _ items =
view2 : Texts -> Model -> List FolderItem -> Html Msg
view2 texts _ items =
table [ class S.tableMain ]
[ thead []
[ tr []
[ th [ class "w-px whitespace-nowrap pr-1 md:pr-3" ] []
, th [ class "text-left" ] [ text "Name" ]
, th [ class "text-left" ]
[ text texts.basics.name
]
, th [ class "text-left hidden sm:table-cell" ] [ text "Owner" ]
, th [ class "text-center" ]
[ span [ class "hidden sm:inline" ]
[ text "#Member"
[ text texts.memberCount
]
, span [ class "sm:hidden" ]
[ text "#"
]
]
, th [ class "text-center" ] [ text "Created" ]
, th [ class "text-center" ]
[ text texts.basics.created
]
]
]
, tbody []

View File

@ -21,6 +21,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Messages.Comp.ImapSettingsForm exposing (Texts)
import Styles as S
import Util.Maybe
@ -45,21 +46,14 @@ emptyModel =
{ settings = Api.Model.ImapSettings.empty
, name = ""
, host = ""
, portField = Comp.IntField.init (Just 0) Nothing True "IMAP Port"
, portField = Comp.IntField.init (Just 0) Nothing True
, portNum = Nothing
, user = Nothing
, passField = Comp.PasswordInput.init
, password = Nothing
, sslType =
Comp.Dropdown.makeSingleList
{ makeOption =
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
{ options = Data.SSLType.all
, selected = Just Data.SSLType.None
}
, ignoreCertificates = False
@ -72,21 +66,14 @@ init ems =
{ settings = ems
, name = ems.name
, host = ems.imapHost
, portField = Comp.IntField.init (Just 0) Nothing True "IMAP Port"
, portField = Comp.IntField.init (Just 0) Nothing True
, portNum = ems.imapPort
, user = ems.imapUser
, passField = Comp.PasswordInput.init
, password = ems.imapPassword
, sslType =
Comp.Dropdown.makeSingleList
{ makeOption =
\s ->
{ value = Data.SSLType.toString s
, text = Data.SSLType.label s
, additional = ""
}
, placeholder = ""
, options = Data.SSLType.all
{ options = Data.SSLType.all
, selected =
Data.SSLType.fromString ems.sslType
|> Maybe.withDefault Data.SSLType.None
@ -176,20 +163,32 @@ update msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
sslCfg =
{ makeOption =
\s ->
{ text = texts.sslTypeLabel s
, additional = ""
}
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div
[ class "grid grid-cols-4 gap-y-4 gap-x-2" ]
[ div [ class "col-span-4" ]
[ label [ class S.inputLabel ]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, input
[ type_ "text"
, value model.name
, onInput SetName
, placeholder "Connection name, e.g. 'gmail.com'"
, placeholder texts.connectionNamePlaceholder
, class S.textInput
, classList [ ( S.inputErrorBorder, model.name == "" ) ]
]
@ -198,17 +197,17 @@ view2 settings model =
[ class S.message
, class "mt-2"
]
[ text "The connection name must not contain whitespace or special characters."
[ text texts.connectionNameInfo
]
]
, div [ class "col-span-3" ]
[ label [ class S.inputLabel ]
[ text "IMAP Host"
[ text texts.imapHost
, B.inputRequired
]
, input
[ type_ "text"
, placeholder "IMAP host name, e.g. 'mail.gmail.com'"
, placeholder texts.imapHostPlaceholder
, value model.host
, onInput SetHost
, class S.textInput
@ -217,18 +216,21 @@ view2 settings model =
[]
]
, Html.map PortMsg
(Comp.IntField.viewWithInfo2 ""
model.portNum
""
(Comp.IntField.view
{ label = texts.imapPort
, info = ""
, number = model.portNum
, classes = ""
}
model.portField
)
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "IMAP User"
[ text texts.imapUser
]
, input
[ type_ "text"
, placeholder "IMAP Username, e.g. 'your.name@gmail.com'"
, placeholder texts.imapUserPlaceholder
, Maybe.withDefault "" model.user |> value
, onInput SetUser
, class S.textInput
@ -237,9 +239,10 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "IMAP Password" ]
[ text texts.imapPassword ]
, Html.map PassMsg
(Comp.PasswordInput.view2
{ placeholder = texts.imapPasswordPlaceholder }
model.password
False
model.passField
@ -247,11 +250,11 @@ view2 settings model =
]
, div [ class "col-span-4 sm:col-span-2" ]
[ label [ class S.inputLabel ]
[ text "SSL"
[ text texts.ssl
]
, Html.map SSLTypeMsg
(Comp.Dropdown.view2
DS.mainStyle
sslCfg
settings
model.sslType
)
@ -260,7 +263,7 @@ view2 settings model =
[ MB.viewItem <|
MB.Checkbox
{ tagger = \_ -> ToggleCheckCert
, label = "Ignore certificate check"
, label = texts.ignoreCertCheck
, value = model.ignoreCertificates
, id = "imap-no-cert-check"
}
@ -269,12 +272,12 @@ view2 settings model =
[ MB.viewItem <|
MB.Checkbox
{ tagger = \_ -> ToggleUseOAuth
, label = "Enable OAuth2 authentication"
, label = texts.enableOAuth2
, value = model.useOAuthToken
, id = "imap-use-oauth"
}
, div [ class "opacity-50 text-sm" ]
[ text "Enabling this, allows to connect via XOAuth using the password as access token."
[ text texts.oauth2Info
]
]
]

View File

@ -21,6 +21,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.ImapSettingsManage exposing (Texts)
import Styles as S
import Util.Http
@ -206,74 +207,77 @@ update flags msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
case model.viewMode of
Table ->
viewTable2 model
viewTable2 texts model
Form ->
viewForm2 settings model
viewForm2 texts settings model
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div []
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
]
, end =
[ MB.PrimaryButton
{ tagger = InitNew
, title = "Add new SMTP settings"
, title = texts.addNewImapSettings
, icon = Just "fa fa-plus"
, label = "New Settings"
, label = texts.newSettings
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg
(Comp.ImapSettingsTable.view2
texts.imapTable
model.tableModel
)
]
viewForm2 : UiSettings -> Model -> Html Msg
viewForm2 settings model =
viewForm2 : Texts -> UiSettings -> Model -> Html Msg
viewForm2 texts settings model =
let
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this mail-box connection?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteSettings
texts.basics.yes
texts.basics.no
in
div [ class "flex flex-col md:relative" ]
[ MB.view
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, title = "Submit this form"
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
, label = "Submit"
, label = texts.basics.submit
}
, MB.SecondaryButton
{ tagger = SetViewMode Table
, title = "Back to list"
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
, label = texts.basics.cancel
}
]
, end =
if model.formModel.settings.name /= "" then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this settings entry"
, title = texts.deleteThisEntry
, icon = Just "fa fa-trash"
, label = "Delete"
, label = texts.basics.delete
}
]
@ -292,6 +296,7 @@ viewForm2 settings model =
]
, Html.map FormMsg
(Comp.ImapSettingsForm.view2
texts.imapForm
settings
model.formModel
)
@ -301,5 +306,8 @@ viewForm2 settings model =
dimmerSettings
model.deleteConfirm
)
, B.loadingDimmer model.loading
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

View File

@ -11,6 +11,7 @@ import Api.Model.ImapSettings exposing (ImapSettings)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.ImapSettingsTable exposing (Texts)
import Styles as S
@ -47,14 +48,14 @@ update msg model =
--- View2
view2 : Model -> Html Msg
view2 model =
view2 : Texts -> Model -> Html Msg
view2 texts model =
table [ class S.tableMain ]
[ thead []
[ tr []
[ th [] []
, th [ class "text-left mr-2" ] [ text "Name" ]
, th [ class "text-left mr-2" ] [ text "Host/Port" ]
, th [ class "text-left mr-2" ] [ text texts.basics.name ]
, th [ class "text-left mr-2" ] [ text texts.hostPort ]
]
]
, tbody []

View File

@ -1,9 +1,10 @@
module Comp.IntField exposing
( Model
, Msg
, ViewSettings
, init
, update
, viewWithInfo2
, view
)
import Html exposing (..)
@ -16,7 +17,6 @@ import Styles as S
type alias Model =
{ min : Maybe Int
, max : Maybe Int
, label : String
, error : Maybe String
, lastInput : String
, optional : Bool
@ -27,11 +27,10 @@ type Msg
= SetValue String
init : Maybe Int -> Maybe Int -> Bool -> String -> Model
init min max opt label =
init : Maybe Int -> Maybe Int -> Bool -> Model
init min max opt =
{ min = min
, max = max
, label = label
, error = Nothing
, lastInput = ""
, optional = opt
@ -98,20 +97,28 @@ update msg model =
--- View2
viewWithInfo2 : String -> Maybe Int -> String -> Model -> Html Msg
viewWithInfo2 info nval classes model =
type alias ViewSettings =
{ label : String
, info : String
, number : Maybe Int
, classes : String
}
view : ViewSettings -> Model -> Html Msg
view cfg model =
div
[ classList
[ ( classes, True )
[ ( cfg.classes, True )
, ( "error", model.error /= Nothing )
]
]
[ label [ class S.inputLabel ]
[ text model.label
[ text cfg.label
]
, input
[ type_ "text"
, Maybe.map String.fromInt nval
, Maybe.map String.fromInt cfg.number
|> Maybe.withDefault model.lastInput
|> value
, onInput SetValue
@ -120,11 +127,11 @@ viewWithInfo2 info nval classes model =
[]
, span
[ classList
[ ( "hidden", info == "" )
[ ( "hidden", cfg.info == "" )
]
, class "opacity-50 text-sm"
]
[ Markdown.toHtml [] info
[ Markdown.toHtml [] cfg.info
]
, div
[ classList
@ -135,3 +142,16 @@ viewWithInfo2 info nval classes model =
[ Maybe.withDefault "" model.error |> text
]
]
viewWithInfo2 : String -> String -> Maybe Int -> String -> Model -> Html Msg
viewWithInfo2 label info nval classes model =
let
cfg =
{ label = label
, info = info
, number = nval
, classes = classes
}
in
view cfg model

View File

@ -23,6 +23,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Markdown
import Messages.Comp.ItemCard exposing (Texts)
import Page exposing (Page(..))
import Set exposing (Set)
import Styles as S
@ -135,12 +136,11 @@ update ddm msg model =
--- View
--- View2
view2 : ViewConfig -> UiSettings -> Model -> ItemLight -> Html Msg
view2 cfg settings model item =
view2 : Texts -> ViewConfig -> UiSettings -> Model -> ItemLight -> Html Msg
view2 texts cfg settings model item =
let
isConfirmed =
item.state /= "created"
@ -200,11 +200,11 @@ view2 cfg settings model item =
[ previewImage2 settings cardAction model item
]
)
++ [ mainContent2 cardAction cardColor isConfirmed settings cfg item
, metaDataContent2 settings item
++ [ mainContent2 texts cardAction cardColor isConfirmed settings cfg item
, metaDataContent2 texts settings item
, notesContent2 settings item
, fulltextResultsContent2 item
, previewMenu2 settings model item (currentAttachment model item)
, previewMenu2 texts settings model item (currentAttachment model item)
, selectedDimmer
]
)
@ -221,8 +221,8 @@ fulltextResultsContent2 item =
(List.map renderHighlightEntry2 item.highlighting)
metaDataContent2 : UiSettings -> ItemLight -> Html Msg
metaDataContent2 settings item =
metaDataContent2 : Texts -> UiSettings -> ItemLight -> Html Msg
metaDataContent2 texts settings item =
let
fieldHidden f =
Data.UiSettings.fieldHidden settings f
@ -234,7 +234,7 @@ metaDataContent2 settings item =
[ ( "hidden", fieldHidden Data.Fields.Folder )
]
, class "hover:opacity-60"
, title "Folder"
, title texts.basics.folder
]
[ Icons.folderIcon2 "mr-2"
, Comp.LinkTarget.makeFolderLink item
@ -273,8 +273,16 @@ notesContent2 settings item =
]
mainContent2 : List (Attribute Msg) -> String -> Bool -> UiSettings -> ViewConfig -> ItemLight -> Html Msg
mainContent2 cardAction cardColor isConfirmed settings _ item =
mainContent2 :
Texts
-> List (Attribute Msg)
-> String
-> Bool
-> UiSettings
-> ViewConfig
-> ItemLight
-> Html Msg
mainContent2 texts cardAction cardColor isConfirmed settings _ item =
let
dirIcon =
i
@ -303,7 +311,7 @@ mainContent2 cardAction cardColor isConfirmed settings _ item =
&& fieldHidden Data.Fields.CorrPerson
)
]
, title "Correspondent"
, title texts.basics.correspondent
]
(Icons.correspondentIcon2 "mr-2 w-4 text-center"
:: Comp.LinkTarget.makeCorrLink item [ ( "hover:opacity-75", True ) ] SetLinkTarget
@ -315,7 +323,7 @@ mainContent2 cardAction cardColor isConfirmed settings _ item =
&& fieldHidden Data.Fields.ConcEquip
)
]
, title "Concerning"
, title texts.basics.concerning
]
(Icons.concernedIcon2 "mr-2 w-4 text-center"
:: Comp.LinkTarget.makeConcLink item [ ( "hover:opacity-75", True ) ] SetLinkTarget
@ -332,7 +340,7 @@ mainContent2 cardAction cardColor isConfirmed settings _ item =
, ( cardColor, True )
, ( "hidden", isConfirmed )
]
, title "New"
, title texts.new
]
[ i [ class "ml-2 fa fa-exclamation-circle" ] []
]
@ -432,8 +440,8 @@ previewImage2 settings cardAction model item =
]
previewMenu2 : UiSettings -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
previewMenu2 settings model item mainAttach =
previewMenu2 : Texts -> UiSettings -> Model -> ItemLight -> Maybe AttachmentLight -> Html Msg
previewMenu2 texts settings model item mainAttach =
let
pageCount =
Maybe.andThen .pageCount mainAttach
@ -470,7 +478,7 @@ previewMenu2 settings model item mainAttach =
)
]
, class "label font-semibold text-sm border-gray-300 dark:border-bluegray-600"
, title ("Due on " ++ dueDate)
, title (texts.dueOn ++ " " ++ dueDate)
]
[ Icons.dueDateIcon2 "mr-2"
, text (" " ++ dueDate)
@ -482,7 +490,7 @@ previewMenu2 settings model item mainAttach =
, class "px-2 py-1 border rounded "
, href attachUrl
, target "_self"
, title "Open attachment file"
, title texts.openAttachmentFile
]
[ i [ class "fa fa-eye" ] []
]
@ -490,7 +498,7 @@ previewMenu2 settings model item mainAttach =
[ class S.secondaryBasicButtonPlain
, class "px-2 py-1 border rounded ml-2"
, Page.href (ItemDetailPage item.id)
, title "Go to detail view"
, title texts.gotoDetail
]
[ i [ class "fa fa-edit" ] []
]
@ -510,7 +518,7 @@ previewMenu2 settings model item mainAttach =
[ a
[ class S.secondaryBasicButtonPlain
, class "px-2 py-1 border rounded-l block"
, title "Cycle attachments"
, title texts.cycleAttachments
, href "#"
, onClick (CyclePreview item)
]

View File

@ -22,6 +22,7 @@ import Data.UiSettings exposing (UiSettings)
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.ItemCardList exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.ItemDragDrop as DD
@ -148,19 +149,19 @@ type alias ViewConfig =
}
view2 : ViewConfig -> UiSettings -> Model -> Html Msg
view2 cfg settings model =
view2 : Texts -> ViewConfig -> UiSettings -> Model -> Html Msg
view2 texts cfg settings model =
div
[ classList
[ ( "ds-item-list", True )
, ( "ds-multi-select-mode", isMultiSelectMode cfg )
]
]
(List.map (viewGroup2 model cfg settings) model.results.groups)
(List.map (viewGroup2 texts model cfg settings) model.results.groups)
viewGroup2 : Model -> ViewConfig -> UiSettings -> ItemLightGroup -> Html Msg
viewGroup2 model cfg settings group =
viewGroup2 : Texts -> Model -> ViewConfig -> UiSettings -> ItemLightGroup -> Html Msg
viewGroup2 texts model cfg settings group =
div [ class "ds-item-group" ]
[ div
[ class "flex py-0 mt-2 flex flex-row items-center"
@ -185,12 +186,12 @@ viewGroup2 model cfg settings group =
[]
]
, div [ class "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-2" ]
(List.map (viewItem2 model cfg settings) group.items)
(List.map (viewItem2 texts model cfg settings) group.items)
]
viewItem2 : Model -> ViewConfig -> UiSettings -> ItemLight -> Html Msg
viewItem2 model cfg settings item =
viewItem2 : Texts -> Model -> ViewConfig -> UiSettings -> ItemLight -> Html Msg
viewItem2 texts model cfg settings item =
let
currentClass =
if cfg.current == Just item.id then
@ -207,7 +208,7 @@ viewItem2 model cfg settings item =
|> Maybe.withDefault Comp.ItemCard.init
cardHtml =
Comp.ItemCard.view2 vvcfg settings cardModel item
Comp.ItemCard.view2 texts.itemCard vvcfg settings cardModel item
in
Html.map (ItemCardMsg item) cardHtml

View File

@ -13,6 +13,7 @@ import Data.Flags exposing (Flags)
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Messages.Comp.ItemDetail exposing (Texts)
import Page exposing (Page(..))
@ -30,6 +31,6 @@ update =
Comp.ItemDetail.Update.update
view2 : ItemNav -> UiSettings -> Model -> Html Msg
view2 : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
view2 =
Comp.ItemDetail.View2.view

View File

@ -3,20 +3,20 @@ module Comp.ItemDetail.AddFilesForm exposing (view)
import Comp.Dropzone
import Comp.ItemDetail.Model exposing (..)
import Comp.Progress
import Data.DropdownStyle
import Dict
import File exposing (File)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onCheck, onClick, onInput)
import Html.Events exposing (onClick)
import Messages.Comp.ItemDetail.AddFilesForm exposing (Texts)
import Set
import Styles as S
import Util.File exposing (makeFileId)
import Util.Size
view : Model -> Html Msg
view model =
view : Texts -> Model -> Html Msg
view texts model =
div
[ classList
[ ( "hidden", not model.addFilesOpen )
@ -25,24 +25,24 @@ view model =
, class S.box
]
[ div [ class "text-lg font-bold" ]
[ text "Add more files to this item"
[ text texts.addMoreFilesToItem
]
, Html.map AddFilesMsg
(Comp.Dropzone.view2 model.addFilesModel)
(Comp.Dropzone.view2 texts.dropzone model.addFilesModel)
, div [ class "flex flex-row space-x-2 mt-2" ]
[ button
[ class S.primaryButton
, href "#"
, onClick AddFilesSubmitUpload
]
[ text "Submit"
[ text texts.basics.submit
]
, button
[ class S.secondaryButton
, href "#"
, onClick AddFilesReset
]
[ text "Reset"
[ text texts.reset
]
]
, div
@ -52,14 +52,13 @@ view model =
]
, class "mt-2"
]
[ text "All files have been uploaded. They are being processed, some data "
, text "may not be available immediately. "
[ text texts.filesSubmittedInfo
, a
[ class S.successMessageLink
, href "#"
, onClick ReloadItem
]
[ text "Refresh now"
[ text texts.refreshNow
]
]
, div

View File

@ -3,7 +3,7 @@ module Comp.ItemDetail.EditForm exposing (formTabs, view2)
import Comp.CustomFieldMultiInput
import Comp.DatePicker
import Comp.Dropdown
import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..))
import Comp.ItemDetail.Model
exposing
( Model
@ -14,8 +14,10 @@ import Comp.ItemDetail.Model
)
import Comp.KeyInput
import Comp.Tabs as TB
import Data.Direction
import Data.DropdownStyle
import Data.Fields
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Dict
@ -23,15 +25,18 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Markdown
import Messages.Comp.ItemDetail.EditForm exposing (Texts)
import Page exposing (Page(..))
import Set exposing (Set)
import Styles as S
import Util.Folder
import Util.Person
import Util.Tag
import Util.Time
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
view2 texts flags settings model =
let
keyAttr =
if settings.itemDetailShortcuts then
@ -44,10 +49,10 @@ view2 settings model =
TB.searchMenuStyle
tabs =
formTabs settings model
formTabs texts flags settings model
allTabNames =
List.map .title tabs
List.map .name tabs
|> Set.fromList
in
div (class "flex flex-col relative" :: keyAttr)
@ -57,8 +62,8 @@ view2 settings model =
]
formTabs : UiSettings -> Model -> List (TB.Tab Msg)
formTabs settings model =
formTabs : Texts -> Flags -> UiSettings -> Model -> List (TB.Tab Msg)
formTabs texts flags settings model =
let
dds =
Data.DropdownStyle.sidebarStyle
@ -92,10 +97,12 @@ formTabs settings model =
Data.UiSettings.fieldVisible settings field
customFieldSettings =
Comp.CustomFieldMultiInput.ViewSettings
True
"field"
(\f -> Dict.get f.id model.customFieldSavingIcon)
{ showAddButton = True
, classes = ""
, fieldIcon = \f -> Dict.get f.id model.customFieldSavingIcon
, style = dds
, createCustomFieldTitle = texts.createNewCustomField
}
optional fields html =
if
@ -106,8 +113,41 @@ formTabs settings model =
else
span [ class "invisible hidden" ] []
directionCfg =
{ makeOption =
\entry ->
{ text = Data.Direction.toString entry
, additional = ""
}
, placeholder = texts.chooseDirection
, labelColor = \_ -> \_ -> ""
, style = dds
}
folderCfg =
{ makeOption = Util.Folder.mkFolderOption flags model.allFolders
, placeholder = texts.selectPlaceholder
, labelColor = \_ -> \_ -> ""
, style = dds
}
idNameCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = texts.selectPlaceholder
, style = dds
}
personCfg =
{ makeOption = \p -> Util.Person.mkPersonOption p model.allPersons
, labelColor = \_ -> \_ -> ""
, placeholder = texts.selectPlaceholder
, style = dds
}
in
[ { title = "Name"
[ { name = FTabState.tabName TabName
, title = texts.basics.name
, titleRight = []
, info = Nothing
, body =
@ -133,7 +173,8 @@ formTabs settings model =
]
]
}
, { title = "Date"
, { name = FTabState.tabName TabDate
, title = texts.basics.date
, titleRight = []
, info = Nothing
, body =
@ -154,16 +195,21 @@ formTabs settings model =
]
, Icons.dateIcon2 S.dateInputIcon
]
, renderItemDateSuggestions model
, renderItemDateSuggestions texts model
]
]
}
, { title = "Tags"
, { name = FTabState.tabName TabTags
, title = texts.basics.tags
, titleRight = []
, info = Nothing
, body =
[ div [ class "mb-4 flex flex-col" ]
[ Html.map TagDropdownMsg (Comp.Dropdown.view2 dds settings model.tagModel)
[ Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings texts.basics.chooseTag dds)
settings
model.tagModel
)
, div [ class "flex flex-row items-center justify-end" ]
[ a
[ class S.secondaryButton
@ -177,14 +223,15 @@ formTabs settings model =
]
]
}
, { title = "Folder"
, { name = FTabState.tabName TabFolder
, title = texts.basics.folder
, titleRight = []
, info = Nothing
, body =
[ div [ class "mb-4" ]
[ Html.map FolderDropdownMsg
(Comp.Dropdown.view2
dds
folderCfg
settings
model.folderModel
)
@ -194,30 +241,28 @@ formTabs settings model =
, ( "hidden", isFolderMember model )
]
]
[ Markdown.toHtml [] """
You are **not a member** of this folder. This item will be **hidden**
from any search now. Use a folder where you are a member of to make this
item visible. This message will disappear then.
"""
[ Markdown.toHtml [] texts.folderNotOwnerWarning
]
]
]
}
, { title = "Custom Fields"
, { name = FTabState.tabName TabCustomFields
, title = texts.basics.customFields
, titleRight = []
, info = Nothing
, body =
[ div [ class "mb-4" ]
[ Html.map CustomFieldMsg
(Comp.CustomFieldMultiInput.view2
dds
texts.customFieldInput
customFieldSettings
model.customFieldsModel
)
]
]
}
, { title = "Due Date"
, { name = FTabState.tabName TabDueDate
, title = texts.dueDateTab
, titleRight = []
, info = Nothing
, body =
@ -238,11 +283,12 @@ item visible. This message will disappear then.
]
, Icons.dueDateIcon2 S.dateInputIcon
]
, renderDueDateSuggestions model
, renderDueDateSuggestions texts model
]
]
}
, { title = "Correspondent"
, { name = FTabState.tabName TabCorrespondent
, title = texts.basics.correspondent
, titleRight = []
, info = Nothing
, body =
@ -250,25 +296,34 @@ item visible. This message will disappear then.
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.organizationIcon2 "mr-2"
, text "Organization"
, addIconLink "Add new organization" StartCorrOrgModal
, editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal
, text texts.basics.organization
, addIconLink texts.addNewOrg StartCorrOrgModal
, editIconLink texts.editOrg model.corrOrgModel StartEditCorrOrgModal
]
, Html.map OrgDropdownMsg (Comp.Dropdown.view2 dds settings model.corrOrgModel)
, renderOrgSuggestions model
, Html.map OrgDropdownMsg
(Comp.Dropdown.view2
(Comp.Dropdown.orgFormViewSettings texts.chooseOrg dds)
settings
model.corrOrgModel
)
, renderOrgSuggestions texts model
]
, optional [ Data.Fields.CorrPerson ] <|
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.personIcon2 "mr-2"
, text "Person"
, addIconLink "Add new correspondent person" StartCorrPersonModal
, editIconLink "Edit person"
, text texts.basics.person
, addIconLink texts.addNewCorrespondentPerson StartCorrPersonModal
, editIconLink texts.editPerson
model.corrPersonModel
(StartEditPersonModal model.corrPersonModel)
]
, Html.map CorrPersonMsg (Comp.Dropdown.view2 dds settings model.corrPersonModel)
, renderCorrPersonSuggestions model
, Html.map CorrPersonMsg
(Comp.Dropdown.view2 personCfg
settings
model.corrPersonModel
)
, renderCorrPersonSuggestions texts model
, div
[ classList
[ ( "hidden", personMatchesOrg model )
@ -277,12 +332,13 @@ item visible. This message will disappear then.
, class "my-2"
]
[ i [ class "fa fa-info mr-2 " ] []
, text "The selected person doesn't belong to the selected organization."
, text texts.personOrgInfo
]
]
]
}
, { title = "Concerning"
, { name = FTabState.tabName TabConcerning
, title = texts.basics.concerning
, titleRight = []
, info = Nothing
, body =
@ -290,48 +346,49 @@ item visible. This message will disappear then.
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.personIcon2 "mr-2"
, text "Person"
, addIconLink "Add new concerning person" StartConcPersonModal
, editIconLink "Edit person"
, text texts.basics.person
, addIconLink texts.addNewConcerningPerson StartConcPersonModal
, editIconLink texts.editPerson
model.concPersonModel
(StartEditPersonModal model.concPersonModel)
]
, Html.map ConcPersonMsg
(Comp.Dropdown.view2
dds
personCfg
settings
model.concPersonModel
)
, renderConcPersonSuggestions model
, renderConcPersonSuggestions texts model
]
, optional [ Data.Fields.ConcEquip ] <|
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.equipmentIcon2 "mr-2"
, text "Equipment"
, addIconLink "Add new equipment" StartEquipModal
, editIconLink "Edit equipment"
, text texts.basics.equipment
, addIconLink texts.addNewEquipment StartEquipModal
, editIconLink texts.editEquipment
model.concEquipModel
StartEditEquipModal
]
, Html.map ConcEquipMsg
(Comp.Dropdown.view2
dds
idNameCfg
settings
model.concEquipModel
)
, renderConcEquipSuggestions model
, renderConcEquipSuggestions texts model
]
]
}
, { title = "Direction"
, { name = FTabState.tabName TabDirection
, title = texts.basics.direction
, titleRight = []
, info = Nothing
, body =
[ div [ class "mb-4" ]
[ Html.map DirDropdownMsg
(Comp.Dropdown.view2
dds
directionCfg
settings
model.directionModel
)
@ -341,8 +398,8 @@ item visible. This message will disappear then.
]
renderSuggestions : Model -> (a -> String) -> List a -> (a -> Msg) -> Html Msg
renderSuggestions model mkName idnames tagger =
renderSuggestions : Texts -> Model -> (a -> String) -> List a -> (a -> Msg) -> Html Msg
renderSuggestions texts model mkName idnames tagger =
div
[ classList
[ ( "hidden", model.item.state /= "created" )
@ -350,7 +407,7 @@ renderSuggestions model mkName idnames tagger =
, class "flex flex-col text-sm"
]
[ div [ class "font-bold my-1" ]
[ text "Suggestions"
[ text texts.suggestions
]
, ul [ class "list-disc ml-6" ] <|
(idnames
@ -369,49 +426,55 @@ renderSuggestions model mkName idnames tagger =
]
renderOrgSuggestions : Model -> Html Msg
renderOrgSuggestions model =
renderSuggestions model
renderOrgSuggestions : Texts -> Model -> Html Msg
renderOrgSuggestions texts model =
renderSuggestions texts
model
.name
(List.take 6 model.itemProposals.corrOrg)
SetCorrOrgSuggestion
renderCorrPersonSuggestions : Model -> Html Msg
renderCorrPersonSuggestions model =
renderSuggestions model
renderCorrPersonSuggestions : Texts -> Model -> Html Msg
renderCorrPersonSuggestions texts model =
renderSuggestions texts
model
.name
(List.take 6 model.itemProposals.corrPerson)
SetCorrPersonSuggestion
renderConcPersonSuggestions : Model -> Html Msg
renderConcPersonSuggestions model =
renderSuggestions model
renderConcPersonSuggestions : Texts -> Model -> Html Msg
renderConcPersonSuggestions texts model =
renderSuggestions texts
model
.name
(List.take 6 model.itemProposals.concPerson)
SetConcPersonSuggestion
renderConcEquipSuggestions : Model -> Html Msg
renderConcEquipSuggestions model =
renderSuggestions model
renderConcEquipSuggestions : Texts -> Model -> Html Msg
renderConcEquipSuggestions texts model =
renderSuggestions texts
model
.name
(List.take 6 model.itemProposals.concEquipment)
SetConcEquipSuggestion
renderItemDateSuggestions : Model -> Html Msg
renderItemDateSuggestions model =
renderSuggestions model
renderItemDateSuggestions : Texts -> Model -> Html Msg
renderItemDateSuggestions texts model =
renderSuggestions texts
model
Util.Time.formatDate
(List.take 6 model.itemProposals.itemDate)
SetItemDateSuggestion
renderDueDateSuggestions : Model -> Html Msg
renderDueDateSuggestions model =
renderSuggestions model
renderDueDateSuggestions : Texts -> Model -> Html Msg
renderDueDateSuggestions texts model =
renderSuggestions texts
model
Util.Time.formatDate
(List.take 6 model.itemProposals.dueDate)
SetDueDateSuggestion
@ -445,4 +508,4 @@ tabState settings allNames model =
FTabState.tabState settings
openTabs
Nothing
(.title >> ToggleAkkordionTab)
(.name >> ToggleAkkordionTab)

View File

@ -1,4 +1,4 @@
module Comp.ItemDetail.FieldTabState exposing (tabState)
module Comp.ItemDetail.FieldTabState exposing (EditTab(..), allTabs, findTab, tabName, tabState)
import Comp.CustomFieldMultiInput
import Comp.Tabs as TB
@ -7,6 +7,102 @@ import Data.UiSettings exposing (UiSettings)
import Set exposing (Set)
type EditTab
= TabName
| TabDate
| TabTags
| TabFolder
| TabCustomFields
| TabDueDate
| TabCorrespondent
| TabConcerning
| TabDirection
| TabConfirmUnconfirm
allTabs : List EditTab
allTabs =
[ TabName
, TabDate
, TabTags
, TabFolder
, TabCustomFields
, TabDueDate
, TabCorrespondent
, TabConcerning
, TabDirection
, TabConfirmUnconfirm
]
tabName : EditTab -> String
tabName tab =
case tab of
TabName ->
"name"
TabTags ->
"tags"
TabDate ->
"date"
TabFolder ->
"folder"
TabCustomFields ->
"custom-fields"
TabDueDate ->
"due-date"
TabCorrespondent ->
"correspondent"
TabConcerning ->
"concerning"
TabDirection ->
"direction"
TabConfirmUnconfirm ->
"confirm-unconfirm"
findTab : TB.Tab msg -> Maybe EditTab
findTab tab =
case tab.name of
"name" ->
Just TabName
"tags" ->
Just TabTags
"date" ->
Just TabDate
"folder" ->
Just TabFolder
"custom-fields" ->
Just TabCustomFields
"due-date" ->
Just TabDueDate
"correspondent" ->
Just TabCorrespondent
"concerning" ->
Just TabConcerning
"direction" ->
Just TabDirection
_ ->
Nothing
tabState :
UiSettings
-> Set String
@ -20,32 +116,32 @@ tabState settings openTabs cfmodel toggle tab =
Data.UiSettings.fieldHidden settings f
hidden =
case tab.title of
"Tags" ->
case findTab tab of
Just TabTags ->
isHidden Data.Fields.Tag
"Folder" ->
Just TabFolder ->
isHidden Data.Fields.Folder
"Correspondent" ->
Just TabCorrespondent ->
isHidden Data.Fields.CorrOrg && isHidden Data.Fields.CorrPerson
"Concerning" ->
Just TabConcerning ->
isHidden Data.Fields.ConcEquip && isHidden Data.Fields.ConcPerson
"Custom Fields" ->
Just TabCustomFields ->
isHidden Data.Fields.CustomFields
|| (Maybe.map Comp.CustomFieldMultiInput.isEmpty cfmodel
|> Maybe.withDefault False
)
"Date" ->
Just TabDate ->
isHidden Data.Fields.Date
"Due Date" ->
Just TabDueDate ->
isHidden Data.Fields.DueDate
"Direction" ->
Just TabDirection ->
isHidden Data.Fields.Direction
_ ->
@ -55,7 +151,7 @@ tabState settings openTabs cfmodel toggle tab =
if hidden then
TB.Hidden
else if Set.member tab.title openTabs then
else if Set.member tab.name openTabs then
TB.Open
else

View File

@ -15,19 +15,20 @@ import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.ItemDetail.ItemInfoHeader exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.Maybe
import Util.Time
view : UiSettings -> Model -> Html Msg
view settings model =
view : Texts -> UiSettings -> Model -> Html Msg
view texts settings model =
let
date =
( div
[ class "ml-2 sm:ml-0 whitespace-nowrap py-1 whitespace-nowrap opacity-75"
, title "Item Date"
, title texts.itemDate
]
[ Icons.dateIcon2 "mr-2"
, Maybe.withDefault model.item.created model.item.itemDate
@ -47,7 +48,7 @@ view settings model =
( div
[ class "ml-2 sm:ml-4 py-1 max-w-min whitespace-nowrap opacity-100"
, class S.basicLabel
, title "Due Date"
, title texts.dueDate
]
[ Icons.dueDateIcon2 "mr-2"
, Maybe.map Util.Time.formatDate model.item.dueDate
@ -61,7 +62,7 @@ view settings model =
corr =
( div
[ class itemStyle
, title "Correspondent"
, title texts.basics.correspondent
]
(Icons.correspondentIcon2 "mr-2"
:: Comp.LinkTarget.makeCorrLink model.item
@ -75,7 +76,7 @@ view settings model =
conc =
( div
[ class itemStyle
, title "Concerning"
, title texts.basics.concerning
]
(Icons.concernedIcon2 "mr-2"
:: Comp.LinkTarget.makeConcLink model.item
@ -89,7 +90,7 @@ view settings model =
itemfolder =
( div
[ class itemStyle
, title "Folder"
, title texts.basics.folder
]
[ Icons.folderIcon2 "mr-2"
, Comp.LinkTarget.makeFolderLink model.item
@ -102,7 +103,7 @@ view settings model =
src =
( div
[ class itemStyle
, title "Source"
, title texts.source
]
[ Icons.sourceIcon2 "mr-2"
, Comp.LinkTarget.makeSourceLink [ ( linkStyle, True ) ]
@ -132,7 +133,7 @@ view settings model =
]
, class "ml-3 text-base label bg-blue-500 dark:bg-lightblue-500 text-white rounded-lg"
]
[ text "New"
[ text texts.new
, i [ class "fa fa-exclamation ml-2" ] []
]
]

View File

@ -39,7 +39,6 @@ import Comp.KeyInput
import Comp.LinkTarget exposing (LinkTarget)
import Comp.MarkdownInput
import Comp.SentMails
import Comp.YesNoDimmer
import Data.Direction exposing (Direction)
import Data.Fields exposing (Field)
import DatePicker exposing (DatePicker)
@ -136,45 +135,17 @@ emptyModel =
, visibleAttach = 0
, attachMenuOpen = False
, menuOpen = False
, tagModel =
Util.Tag.makeDropdownModel2
, tagModel = Util.Tag.makeDropdownModel
, directionModel =
Comp.Dropdown.makeSingleList
{ makeOption =
\entry ->
{ value = Data.Direction.toString entry
, text = Data.Direction.toString entry
, additional = ""
}
, options = Data.Direction.all
, placeholder = "Choose a direction"
{ options = Data.Direction.all
, selected = Nothing
}
, corrOrgModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, corrPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concEquipModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, folderModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, corrOrgModel = Comp.Dropdown.makeSingle
, corrPersonModel = Comp.Dropdown.makeSingle
, concPersonModel = Comp.Dropdown.makeSingle
, concEquipModel = Comp.Dropdown.makeSingle
, folderModel = Comp.Dropdown.makeSingle
, allFolders = []
, nameModel = ""
, nameState = SaveSuccess

View File

@ -22,7 +22,7 @@ import Comp.CustomFieldMultiInput
import Comp.DatePicker
import Comp.DetailEdit
import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..), tabName)
import Comp.ItemDetail.FormChange exposing (FormChange(..))
import Comp.Tabs as TB
import Data.CustomFieldChange exposing (CustomFieldChange(..))
@ -39,6 +39,7 @@ import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Markdown
import Messages.Comp.ItemDetail.MultiEditMenu exposing (Texts)
import Page exposing (Page(..))
import Set exposing (Set)
import Styles as S
@ -117,45 +118,17 @@ type Msg
init : Model
init =
{ tagModel =
Util.Tag.makeDropdownModel2
{ tagModel = Util.Tag.makeDropdownModel
, directionModel =
Comp.Dropdown.makeSingleList
{ makeOption =
\entry ->
{ value = Data.Direction.toString entry
, text = Data.Direction.toString entry
, additional = ""
}
, options = Data.Direction.all
, placeholder = "Choose a direction"
{ options = Data.Direction.all
, selected = Nothing
}
, corrOrgModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, corrPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concPersonModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, concEquipModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, folderModel =
Comp.Dropdown.makeSingle
{ makeOption = \e -> { value = e.id, text = e.name, additional = "" }
, placeholder = ""
}
, corrOrgModel = Comp.Dropdown.makeSingle
, corrPersonModel = Comp.Dropdown.makeSingle
, concPersonModel = Comp.Dropdown.makeSingle
, concEquipModel = Comp.Dropdown.makeSingle
, folderModel = Comp.Dropdown.makeSingle
, allFolders = []
, nameModel = ""
, nameSaveThrottle = Throttle.create 1
@ -310,13 +283,7 @@ update flags msg model =
GetFolderResp (Ok fs) ->
let
model_ =
{ model
| allFolders = fs.items
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
}
{ model | allFolders = fs.items }
mkIdName fitem =
IdName fitem.id fitem.name
@ -593,14 +560,14 @@ update flags msg model =
in
UpdateResult model_ cmd_ Sub.none change
ToggleAkkordionTab title ->
ToggleAkkordionTab name ->
let
tabs =
if Set.member title model.openTabs then
Set.remove title model.openTabs
if Set.member name model.openTabs then
Set.remove name model.openTabs
else
Set.insert title model.openTabs
Set.insert name model.openTabs
in
UpdateResult { model | openTabs = tabs } Cmd.none Sub.none NoFormChange
@ -635,13 +602,13 @@ defaultViewConfig =
--- View2
view2 : ViewConfig -> UiSettings -> Model -> Html Msg
view2 : Texts -> Flags -> ViewConfig -> UiSettings -> Model -> Html Msg
view2 =
renderEditForm2
renderEditForm2 : ViewConfig -> UiSettings -> Model -> Html Msg
renderEditForm2 cfg settings model =
renderEditForm2 : Texts -> Flags -> ViewConfig -> UiSettings -> Model -> Html Msg
renderEditForm2 texts flags cfg settings model =
let
fieldVisible field =
Data.UiSettings.fieldVisible settings field
@ -670,13 +637,13 @@ renderEditForm2 cfg settings model =
tagModeMsg =
case model.tagEditMode of
AddTags ->
"Tags chosen here are *added* to all selected items."
texts.tagModeAddInfo
RemoveTags ->
"Tags chosen here are *removed* from all selected items."
texts.tagModeRemoveInfo
ReplaceTags ->
"Tags chosen here *replace* those on selected items."
texts.tagModeReplaceInfo
customFieldIcon field =
case cfg.customFieldState field.id of
@ -690,22 +657,50 @@ renderEditForm2 cfg settings model =
Just "fa fa-sync-alt animate-spin"
customFieldSettings =
Comp.CustomFieldMultiInput.ViewSettings
False
"mb-4"
customFieldIcon
{ showAddButton = False
, classes = "mb-4"
, fieldIcon = customFieldIcon
, style = dds
, createCustomFieldTitle = ""
}
dds =
Data.DropdownStyle.sidebarStyle
tabStyle =
TB.searchMenuStyle
folderCfg =
{ makeOption = Util.Folder.mkFolderOption flags model.allFolders
, placeholder = ""
, labelColor = \_ -> \_ -> ""
, style = dds
}
idNameCfg =
{ makeOption = \e -> { text = e.name, additional = "" }
, labelColor = \_ -> \_ -> ""
, placeholder = texts.selectPlaceholder
, style = dds
}
directionCfg =
{ makeOption =
\entry ->
{ text = Data.Direction.toString entry
, additional = ""
}
, placeholder = texts.chooseDirection
, labelColor = \_ -> \_ -> ""
, style = dds
}
in
div [ class cfg.menuClass, class "mt-2" ]
[ TB.akkordion
tabStyle
(tabState settings model)
[ { title = "Confirm/Unconfirm item metadata"
[ { name = tabName TabConfirmUnconfirm
, title = texts.confirmUnconfirm
, titleRight = []
, info = Nothing
, body =
@ -717,69 +712,77 @@ renderEditForm2 cfg settings model =
, class "flex-grow"
, onClick (ConfirmMsg True)
]
[ text "Confirm"
[ text texts.confirm
]
, button
[ class S.secondaryButton
, class "flex-grow"
, onClick (ConfirmMsg False)
]
[ text "Unconfirm"
[ text texts.unconfirm
]
]
]
}
, { title = "Tags"
, { name = tabName TabTags
, title = texts.basics.tags
, titleRight = []
, info = Nothing
, body =
[ div [ class "field" ]
[ label [ class S.inputLabel ]
[ Icons.tagsIcon2 ""
, text "Tags"
, text texts.basics.tags
, a
[ class "float-right"
, class S.link
, href "#"
, title "Change tag edit mode"
, title texts.changeTagMode
, onClick ToggleTagEditMode
]
[ tagModeIcon
]
]
, Html.map TagDropdownMsg (Comp.Dropdown.view2 dds settings model.tagModel)
, Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings texts.basics.chooseTag dds)
settings
model.tagModel
)
, Markdown.toHtml [ class "opacity-50 text-sm" ] tagModeMsg
]
]
}
, { title = "Folder"
, { name = tabName TabFolder
, title = texts.basics.folder
, titleRight = []
, info = Nothing
, body =
[ Html.map FolderDropdownMsg (Comp.Dropdown.view2 dds settings model.folderModel)
[ Html.map FolderDropdownMsg (Comp.Dropdown.view2 folderCfg settings model.folderModel)
, div
[ classList
[ ( S.message, True )
, ( "hidden", isFolderMember model )
]
]
[ Markdown.toHtml [] """
You are **not a member** of this folder. This item will be **hidden**
from any search now. Use a folder where you are a member of to make this
item visible. This message will disappear then.
"""
[ Markdown.toHtml [] texts.folderNotOwnerWarning
]
]
}
, { title = "Custom Fields"
, { name = tabName TabCustomFields
, title = texts.basics.customFields
, titleRight = []
, info = Nothing
, body =
[ Html.map CustomFieldMsg
(Comp.CustomFieldMultiInput.view2 dds customFieldSettings model.customFieldModel)
(Comp.CustomFieldMultiInput.view2
texts.customFieldMultiInput
customFieldSettings
model.customFieldModel
)
]
}
, { title = "Date"
, { name = tabName TabDate
, title = texts.basics.date
, titleRight = []
, info = Nothing
, body =
@ -801,7 +804,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Due Date"
, { name = tabName TabDueDate
, title = texts.dueDateTab
, titleRight = []
, info = Nothing
, body =
@ -823,7 +827,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Correspondent"
, { name = tabName TabCorrespondent
, title = texts.basics.correspondent
, titleRight = []
, info = Nothing
, body =
@ -832,24 +837,35 @@ item visible. This message will disappear then.
[ label [ class S.inputLabel ]
[ Icons.organizationIcon2 ""
, span [ class "ml-2" ]
[ text "Organization"
[ text texts.basics.organization
]
]
, Html.map OrgDropdownMsg (Comp.Dropdown.view2 dds settings model.corrOrgModel)
, Html.map OrgDropdownMsg
(Comp.Dropdown.view2
idNameCfg
settings
model.corrOrgModel
)
]
, optional [ Data.Fields.CorrPerson ] <|
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.personIcon2 ""
, span [ class "ml-2" ]
[ text "Person"
[ text texts.basics.person
]
]
, Html.map CorrPersonMsg (Comp.Dropdown.view2 dds settings model.corrPersonModel)
, Html.map CorrPersonMsg
(Comp.Dropdown.view2
idNameCfg
settings
model.corrPersonModel
)
]
]
}
, { title = "Concerning"
, { name = tabName TabConcerning
, title = texts.basics.concerning
, titleRight = []
, info = Nothing
, body =
@ -858,29 +874,35 @@ item visible. This message will disappear then.
[ label [ class S.inputLabel ]
[ Icons.personIcon2 ""
, span [ class "ml-2" ]
[ text "Person" ]
[ text texts.basics.person ]
]
, Html.map ConcPersonMsg (Comp.Dropdown.view2 dds settings model.concPersonModel)
, Html.map ConcPersonMsg (Comp.Dropdown.view2 idNameCfg settings model.concPersonModel)
]
, optional [ Data.Fields.ConcEquip ] <|
div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ Icons.equipmentIcon2 ""
, span [ class "ml-2" ]
[ text "Equipment" ]
[ text texts.basics.equipment ]
]
, Html.map ConcEquipMsg (Comp.Dropdown.view2 dds settings model.concEquipModel)
, Html.map ConcEquipMsg
(Comp.Dropdown.view2 idNameCfg
settings
model.concEquipModel
)
]
]
}
, { title = "Direction"
, { name = tabName TabDirection
, title = texts.basics.direction
, titleRight = []
, info = Nothing
, body =
[ Html.map DirDropdownMsg (Comp.Dropdown.view2 dds settings model.directionModel)
[ Html.map DirDropdownMsg (Comp.Dropdown.view2 directionCfg settings model.directionModel)
]
}
, { title = "Name"
, { name = tabName TabName
, title = texts.basics.name
, titleRight = []
, info = Nothing
, body =
@ -895,9 +917,15 @@ item visible. This message will disappear then.
, span [ class S.inputLeftIconOnly ]
[ i
[ classList
[ ( "text-green-500 fa fa-check", cfg.nameState == SaveSuccess )
, ( "text-red-500 fa fa-exclamation-triangle", cfg.nameState == SaveFailed )
, ( "sync fa fa-circle-notch animate-spin", cfg.nameState == Saving )
[ ( "text-green-500 fa fa-check"
, cfg.nameState == SaveSuccess
)
, ( "text-red-500 fa fa-exclamation-triangle"
, cfg.nameState == SaveFailed
)
, ( "sync fa fa-circle-notch animate-spin"
, cfg.nameState == Saving
)
]
]
[]
@ -914,7 +942,7 @@ tabState settings model tab =
FTabState.tabState settings
model.openTabs
(Just model.customFieldModel)
(.title >> ToggleAkkordionTab)
(.name >> ToggleAkkordionTab)
tab

View File

@ -12,19 +12,20 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Markdown
import Messages.Comp.ItemDetail.Notes exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.String
view : Model -> Html Msg
view model =
view : Texts -> Model -> Html Msg
view texts model =
case model.notesField of
ViewNotes ->
div [ class "flex flex-col ds-item-detail-notes" ]
[ div [ class "flex flex-row items-center border-b dark:border-bluegray-600" ]
[ div [ class "flex-grow font-bold text-lg" ]
[ text "Notes"
[ text texts.notes
]
, div [ class "" ]
[ a
@ -33,7 +34,7 @@ view model =
, href "#"
]
[ i [ class "fa fa-edit mr-2" ] []
, text "Edit"
, text texts.basics.edit
]
]
]
@ -55,14 +56,14 @@ view model =
[ div [ class "flex flex-col" ]
[ div [ class "flex flex-row items-center" ]
[ div [ class "font-bold text-lg" ]
[ text "Notes"
[ text texts.notes
]
, div [ class "flex flex-grow justify-end text-sm" ]
[ Html.map NotesEditMsg
(Comp.MarkdownInput.viewEditLink2 classes mm)
(Comp.MarkdownInput.viewEditLink2 texts.basics.edit classes mm)
, span [ class "px-3" ] [ text "" ]
, Html.map NotesEditMsg
(Comp.MarkdownInput.viewPreviewLink2 classes mm)
(Comp.MarkdownInput.viewPreviewLink2 texts.preview classes mm)
]
]
]
@ -73,7 +74,9 @@ view model =
mm
)
, div [ class "text-sm flex justify-end" ]
[ Comp.MarkdownInput.viewCheatLink2 S.link mm
[ Comp.MarkdownInput.viewCheatLink2 texts.supportsMarkdown
S.link
mm
]
, div [ class "flex flex-row mt-1" ]
[ a
@ -82,7 +85,7 @@ view model =
, onClick SaveNotes
]
[ i [ class "fa fa-save font-thin mr-2" ] []
, text "Save"
, text texts.basics.submit
]
, a
[ classList
@ -94,7 +97,7 @@ view model =
, onClick ToggleEditNotes
]
[ i [ class "fa fa-times mr-2" ] []
, text "Cancel"
, text texts.basics.cancel
]
]
]

View File

@ -18,6 +18,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Html5.DragDrop as DD
import Messages.Comp.ItemDetail.SingleAttachment exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.Maybe
@ -25,8 +26,8 @@ import Util.Size
import Util.String
view : UiSettings -> Model -> Int -> Attachment -> Html Msg
view settings model pos attach =
view : Texts -> UiSettings -> Model -> Int -> Attachment -> Html Msg
view texts settings model pos attach =
let
fileUrl =
Api.fileURL attach.id
@ -42,15 +43,16 @@ view settings model pos attach =
[ class "flex flex-row px-2 py-2 text-sm"
, class S.border
]
[ attachHeader settings model pos attach
[ attachHeader texts settings model pos attach
]
, editAttachmentName model attach
, attachmentSelect model pos attach
, attachmentSelect texts model pos attach
, if isAttachMetaOpen model attach.id then
case Dict.get attach.id model.attachMeta of
Just am ->
Html.map (AttachMetaMsg attach.id)
(Comp.AttachmentMeta.view2
texts.attachmentMeta
[ class "border-r border-l border-b dark:border-bluegray-600 px-2" ]
am
)
@ -94,11 +96,11 @@ view settings model pos attach =
- native view
-}
attachHeader : UiSettings -> Model -> Int -> Attachment -> Html Msg
attachHeader settings model _ attach =
attachHeader : Texts -> UiSettings -> Model -> Int -> Attachment -> Html Msg
attachHeader texts settings model _ attach =
let
attachName =
Maybe.withDefault "No name" attach.name
Maybe.withDefault texts.noName attach.name
fileUrl =
Api.fileURL attach.id
@ -138,7 +140,7 @@ attachHeader settings model _ attach =
, a
[ href fileUrl
, target "_new"
, title "Open file in new tab"
, title texts.openFileInNewTab
, class S.secondaryBasicButton
, class "ml-2"
]
@ -155,21 +157,21 @@ attachHeader settings model _ attach =
, menuOpen = model.attachmentDropdownOpen
, items =
[ { icon = "fa fa-download"
, label = "Download file"
, label = texts.downloadFile
, attrs =
[ download attachName
, href fileUrl
]
}
, { icon = "fa fa-file"
, label = "Rename file"
, label = texts.renameFile
, attrs =
[ href "#"
, onClick (EditAttachNameStart attach.id)
]
}
, { icon = "fa fa-file-archive"
, label = "Download original archive"
, label = texts.downloadOriginalArchiveFile
, attrs =
[ href (fileUrl ++ "/archive")
, target "_new"
@ -177,7 +179,7 @@ attachHeader settings model _ attach =
]
}
, { icon = "fa fa-external-link-alt"
, label = "Original file"
, label = texts.originalFile
, attrs =
[ href (fileUrl ++ "/original")
, target "_new"
@ -190,7 +192,7 @@ attachHeader settings model _ attach =
else
"fa fa-toggle-off"
, label = "Render pdf by browser"
, label = texts.renderPdfByBrowser
, attrs =
[ onClick (TogglePdfNativeView settings.nativePdfPreview)
, href "#"
@ -202,21 +204,21 @@ attachHeader settings model _ attach =
else
"fa fa-toggle-off"
, label = "View extracted data"
, label = texts.viewExtractedData
, attrs =
[ onClick (AttachMetaClick attach.id)
, href "#"
]
}
, { icon = "fa fa-redo-alt"
, label = "Re-process this file"
, label = texts.reprocessFile
, attrs =
[ onClick (RequestReprocessFile attach.id)
, href "#"
]
}
, { icon = "fa fa-trash"
, label = "Delete this file"
, label = texts.deleteThisFile
, attrs =
[ onClick (RequestDeleteAttachment attach.id)
, href "#"
@ -279,8 +281,8 @@ editAttachmentName model attach =
span [ class "hidden" ] []
attachmentSelect : Model -> Int -> Attachment -> Html Msg
attachmentSelect model _ _ =
attachmentSelect : Texts -> Model -> Int -> Attachment -> Html Msg
attachmentSelect texts model _ _ =
div
[ class "flex flex-row border-l border-r px-2 py-2 dark:border-bluegray-600 "
, class "overflow-x-auto overflow-y-none"
@ -288,11 +290,11 @@ attachmentSelect model _ _ =
[ ( "hidden", not model.attachMenuOpen )
]
]
(List.indexedMap (menuItem model) model.item.attachments)
(List.indexedMap (menuItem texts model) model.item.attachments)
menuItem : Model -> Int -> Attachment -> Html Msg
menuItem model pos attach =
menuItem : Texts -> Model -> Int -> Attachment -> Html Msg
menuItem texts model pos attach =
let
highlight =
let
@ -342,7 +344,7 @@ menuItem model pos attach =
]
, div [ class "mt-1 text-sm break-all w-28 text-center" ]
[ Maybe.map (Util.String.ellipsis 36) attach.name
|> Maybe.withDefault "No Name"
|> Maybe.withDefault texts.noName
|> text
]
]

View File

@ -24,6 +24,7 @@ import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.Dropzone
import Comp.EquipmentForm
import Comp.ItemDetail.EditForm
import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.Model
exposing
( AttachmentRename
@ -62,7 +63,6 @@ import Set exposing (Set)
import Throttle
import Time
import Util.File exposing (makeFileId)
import Util.Folder exposing (mkFolderOption)
import Util.Http
import Util.List
import Util.Maybe
@ -551,6 +551,8 @@ update key flags inav settings msg model =
Comp.ConfirmModal.defaultSettings
DeleteItemConfirmed
ItemModalCancelled
"Ok"
"Cancel"
confirmMsg
in
resultModel { model | itemModal = Just confirm }
@ -576,13 +578,7 @@ update key flags inav settings msg model =
GetFolderResp (Ok fs) ->
let
model_ =
{ model
| allFolders = fs.items
, folderModel =
Comp.Dropdown.setMkOption
(mkFolderOption flags fs.items)
model.folderModel
}
{ model | allFolders = fs.items }
mkIdName fitem =
IdName fitem.id fitem.name
@ -645,23 +641,8 @@ update key flags inav settings msg model =
List.filter personFilter correspondent
|> List.map (\e -> IdName e.id e.name)
mkPersonOption idref =
let
org =
Dict.get idref.id personDict
|> Maybe.andThen .organization
|> Maybe.map .name
|> Maybe.map (Util.String.ellipsis 15)
|> Maybe.withDefault ""
in
Comp.Dropdown.Option idref.id idref.name org
model_ =
{ model
| corrPersonModel = Comp.Dropdown.setMkOption mkPersonOption model.corrPersonModel
, concPersonModel = Comp.Dropdown.setMkOption mkPersonOption model.concPersonModel
, allPersons = personDict
}
{ model | allPersons = personDict }
res1 =
update key
@ -945,6 +926,8 @@ update key flags inav settings msg model =
Comp.ConfirmModal.defaultSettings
(DeleteAttachConfirmed id)
AttachModalCancelled
"Ok"
"Cancel"
"Really delete this file?"
model_ =
@ -1491,22 +1474,21 @@ update key flags inav settings msg model =
ToggleAttachmentDropdown ->
resultModel { model | attachmentDropdownOpen = not model.attachmentDropdownOpen }
ToggleAkkordionTab title ->
ToggleAkkordionTab name ->
let
tabs =
if Set.member title model.editMenuTabsOpen then
Set.remove title model.editMenuTabsOpen
if Set.member name model.editMenuTabsOpen then
Set.remove name model.editMenuTabsOpen
else
Set.insert title model.editMenuTabsOpen
Set.insert name model.editMenuTabsOpen
in
resultModel { model | editMenuTabsOpen = tabs }
ToggleOpenAllAkkordionTabs ->
let
allNames =
Comp.ItemDetail.EditForm.formTabs settings model
|> List.map .title
List.map FTabState.tabName FTabState.allTabs
|> Set.fromList
next =
@ -1533,6 +1515,8 @@ update key flags inav settings msg model =
Comp.ConfirmModal.defaultSettings
(ReprocessFileConfirmed id)
AttachModalCancelled
"Ok"
"Cancel"
confirmMsg
model_ =
@ -1568,6 +1552,8 @@ update key flags inav settings msg model =
Comp.ConfirmModal.defaultSettings
ReprocessItemConfirmed
ItemModalCancelled
"Ok"
"Cancel"
confirmMsg
model_ =

View File

@ -23,17 +23,18 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Messages.Comp.ItemDetail exposing (Texts)
import Page exposing (Page(..))
import Styles as S
import Util.Time
view : ItemNav -> UiSettings -> Model -> Html Msg
view inav settings model =
view : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
view texts inav settings model =
div [ class "flex flex-col h-full" ]
[ header settings model
, menuBar inav settings model
, body inav settings model
[ header texts settings model
, menuBar texts inav settings model
, body texts inav settings model
, itemModal model
]
@ -48,18 +49,18 @@ itemModal model =
span [ class "hidden" ] []
header : UiSettings -> Model -> Html Msg
header settings model =
header : Texts -> UiSettings -> Model -> Html Msg
header texts settings model =
div [ class "my-3" ]
[ Comp.ItemDetail.ItemInfoHeader.view settings model ]
[ Comp.ItemDetail.ItemInfoHeader.view texts.itemInfoHeader settings model ]
menuBar : ItemNav -> UiSettings -> Model -> Html Msg
menuBar inav settings model =
menuBar : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
menuBar texts inav settings model =
let
keyDescr name =
if settings.itemDetailShortcuts && model.menuOpen then
" Key '" ++ name ++ "'."
" " ++ texts.key ++ "'" ++ name ++ "'."
else
""
@ -70,7 +71,7 @@ menuBar inav settings model =
a
[ class S.secondaryBasicButton
, Page.href HomePage
, title "Back to search results"
, title texts.backToSearchResults
]
[ i [ class "fa fa-arrow-left" ] []
]
@ -87,7 +88,7 @@ menuBar inav settings model =
|> Maybe.withDefault (href "#")
, disabled = inav.prev == Nothing
, attrs =
[ title ("Previous item." ++ keyDescr "Ctrl-,")
[ title (texts.previousItem ++ keyDescr "Ctrl-,")
]
}
, div
@ -116,7 +117,7 @@ menuBar inav settings model =
|> Maybe.withDefault (href "#")
, disabled = inav.next == Nothing
, attrs =
[ title ("Next item." ++ keyDescr "Ctrl-.")
[ title (texts.nextItem ++ keyDescr "Ctrl-.")
]
}
]
@ -125,7 +126,7 @@ menuBar inav settings model =
[ classList
[ ( "bg-gray-200 dark:bg-bluegray-600", model.mailOpen )
]
, title "Send Mail"
, title texts.sendMail
, onClick ToggleMail
, class S.secondaryBasicButton
, href "#"
@ -141,7 +142,7 @@ menuBar inav settings model =
title "Close"
else
title "Add more files to this item"
title texts.addMoreFiles
, onClick AddFilesToggle
, class S.secondaryBasicButton
, href "#"
@ -153,11 +154,11 @@ menuBar inav settings model =
[ class S.primaryButton
, href "#"
, onClick ConfirmItem
, title "Confirm item metadata"
, title texts.confirmItemMetadata
, classList [ ( "hidden", model.item.state /= "created" ) ]
]
[ i [ class "fa fa-check mr-2" ] []
, text "Confirm"
, text texts.confirm
]
]
, end =
@ -166,7 +167,7 @@ menuBar inav settings model =
[ class S.secondaryBasicButton
, href "#"
, onClick UnconfirmItem
, title "Un-confirm item metadata"
, title texts.unconfirmItemMetadata
, classList [ ( "hidden", model.item.state == "created" ) ]
]
[ i [ class "fa fa-eye-slash font-thin" ] []
@ -176,7 +177,7 @@ menuBar inav settings model =
[ class S.secondaryBasicButton
, href "#"
, onClick RequestReprocessItem
, title "Reprocess this item"
, title texts.reprocessItem
]
[ i [ class "fa fa-redo" ] []
]
@ -185,7 +186,7 @@ menuBar inav settings model =
[ class S.deleteButton
, href "#"
, onClick RequestDelete
, title "Delete this item"
, title texts.deleteThisItem
]
[ i [ class "fa fa-trash" ] []
]
@ -194,21 +195,21 @@ menuBar inav settings model =
}
body : ItemNav -> UiSettings -> Model -> Html Msg
body inav settings model =
body : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
body texts _ settings model =
div [ class "grid gap-2 grid-cols-1 md:grid-cols-3 h-full" ]
[ leftArea settings model
, rightArea settings model
[ leftArea texts settings model
, rightArea texts settings model
]
leftArea : UiSettings -> Model -> Html Msg
leftArea settings model =
leftArea : Texts -> UiSettings -> Model -> Html Msg
leftArea texts settings model =
div [ class "w-full md:order-first md:mr-2 flex flex-col" ]
[ addDetailForm settings model
, sendMailForm settings model
, Comp.ItemDetail.AddFilesForm.view model
, Comp.ItemDetail.Notes.view model
[ addDetailForm texts settings model
, sendMailForm texts settings model
, Comp.ItemDetail.AddFilesForm.view texts.addFilesForm model
, Comp.ItemDetail.Notes.view texts.notes model
, div
[ classList
[ ( "hidden", Comp.SentMails.isEmpty model.sentMails )
@ -216,29 +217,29 @@ leftArea settings model =
, class "mt-4 "
]
[ h3 [ class "flex flex-row items-center border-b dark:border-bluegray-600 font-bold text-lg" ]
[ text "Sent E-Mails"
[ text texts.sentEmails
]
, Html.map SentMailsMsg (Comp.SentMails.view2 model.sentMails)
, Html.map SentMailsMsg (Comp.SentMails.view2 texts.sentMails model.sentMails)
]
, div [ class "flex-grow" ] []
, itemIdInfo model
, itemIdInfo texts model
]
rightArea : UiSettings -> Model -> Html Msg
rightArea settings model =
rightArea : Texts -> UiSettings -> Model -> Html Msg
rightArea texts settings model =
div [ class "md:col-span-2 h-full" ]
(attachmentsBody settings model)
(attachmentsBody texts settings model)
attachmentsBody : UiSettings -> Model -> List (Html Msg)
attachmentsBody settings model =
List.indexedMap (Comp.ItemDetail.SingleAttachment.view settings model)
attachmentsBody : Texts -> UiSettings -> Model -> List (Html Msg)
attachmentsBody texts settings model =
List.indexedMap (Comp.ItemDetail.SingleAttachment.view texts.singleAttachment settings model)
model.item.attachments
sendMailForm : UiSettings -> Model -> Html Msg
sendMailForm settings model =
sendMailForm : Texts -> UiSettings -> Model -> Html Msg
sendMailForm texts settings model =
div
[ classList
[ ( "hidden", not model.mailOpen )
@ -247,10 +248,13 @@ sendMailForm settings model =
, class "mb-4 px-2 py-2"
]
[ div [ class "text-lg font-bold" ]
[ text "Send this item via E-Mail"
[ text texts.sendThisItemViaEmail
]
, B.loadingDimmer model.mailSending
, Html.map ItemMailMsg (Comp.ItemMail.view2 settings model.itemMail)
, B.loadingDimmer
{ active = model.mailSending
, label = texts.sendingMailNow
}
, Html.map ItemMailMsg (Comp.ItemMail.view2 texts.itemMail settings model.itemMail)
, div
[ classList
[ ( S.errorMessage
@ -273,26 +277,26 @@ sendMailForm settings model =
]
itemIdInfo : Model -> Html msg
itemIdInfo model =
itemIdInfo : Texts -> Model -> Html msg
itemIdInfo texts model =
div [ class "flex flex-col opacity-50 text-xs pb-1 mt-3 border-t dark:border-bluegray-600" ]
[ div
[ class "inline-flex items-center"
, title "Item ID"
, title texts.itemId
]
[ i [ class "fa fa-bullseye mr-2" ] []
, text model.item.id
]
, div
[ class "inline-flex items-center"
, title "Created on"
, title texts.createdOn
]
[ i [ class "fa fa-sun font-thin mr-2" ] []
, Util.Time.formatDateTime model.item.created |> text
]
, div
[ class "inline-flex items-center"
, title "Last update on"
, title texts.lastUpdateOn
]
[ i [ class "fa fa-pencil-alt mr-2" ] []
, Util.Time.formatDateTime model.item.updated |> text
@ -300,8 +304,8 @@ itemIdInfo model =
]
addDetailForm : UiSettings -> Model -> Html Msg
addDetailForm settings model =
addDetailForm : Texts -> UiSettings -> Model -> Html Msg
addDetailForm texts settings model =
case model.modalEdit of
Just mm ->
div
@ -309,7 +313,7 @@ addDetailForm settings model =
, class S.box
]
[ Comp.DetailEdit.formHeading S.header3 mm
, Html.map ModalEditMsg (Comp.DetailEdit.view2 [] settings mm)
, Html.map ModalEditMsg (Comp.DetailEdit.view2 texts.detailEdit [] settings mm)
]
Nothing ->

View File

@ -23,6 +23,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Messages.Comp.ItemMail exposing (Texts)
import Styles as S
import Util.Http
@ -69,11 +70,7 @@ type FormAction
emptyModel : Model
emptyModel =
{ connectionModel =
Comp.Dropdown.makeSingle
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select connection..."
}
{ connectionModel = Comp.Dropdown.makeSingle
, subject = ""
, recipients = []
, recipientsModel = Comp.EmailInput.init
@ -160,9 +157,7 @@ update flags msg model =
cm =
Comp.Dropdown.makeSingleList
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select Connection..."
, options = names
{ options = names
, selected = List.head names
}
in
@ -224,21 +219,33 @@ isValid model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
let
dds =
Data.DropdownStyle.mainStyle
connectionCfg =
{ makeOption = \a -> { text = a, additional = "" }
, placeholder = texts.selectConnection
, labelColor = \_ -> \_ -> ""
, style = dds
}
in
div
[ class "flex flex-col"
]
[ div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Send via"
[ text texts.sendVia
, B.inputRequired
]
, Html.map ConnMsg (Comp.Dropdown.view2 dds settings model.connectionModel)
, Html.map ConnMsg
(Comp.Dropdown.view2
connectionCfg
settings
model.connectionModel
)
]
, div
[ class S.errorMessage
@ -250,29 +257,38 @@ view2 settings model =
[ label
[ class S.inputLabel
]
[ text "Recipient(s)"
[ text texts.recipients
, B.inputRequired
]
, Html.map RecipientMsg
(Comp.EmailInput.view2 dds model.recipients model.recipientsModel)
(Comp.EmailInput.view2 { style = dds, placeholder = appendDots texts.recipients }
model.recipients
model.recipientsModel
)
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "CC(s)"
[ text texts.ccRecipients
]
, Html.map CCRecipientMsg
(Comp.EmailInput.view2 dds model.ccRecipients model.ccRecipientsModel)
(Comp.EmailInput.view2 { style = dds, placeholder = appendDots texts.ccRecipients }
model.ccRecipients
model.ccRecipientsModel
)
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "BCC(s)"
[ text texts.bccRecipients
]
, Html.map BCCRecipientMsg
(Comp.EmailInput.view2 dds model.bccRecipients model.bccRecipientsModel)
(Comp.EmailInput.view2 { style = dds, placeholder = appendDots texts.bccRecipients }
model.bccRecipients
model.bccRecipientsModel
)
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Subject"
[ text texts.subject
, B.inputRequired
]
, input
@ -285,7 +301,7 @@ view2 settings model =
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Body"
[ text texts.body
, B.inputRequired
]
, textarea
@ -298,7 +314,7 @@ view2 settings model =
, MB.viewItem <|
MB.Checkbox
{ tagger = \_ -> ToggleAttachAll
, label = "Include all item attachments"
, label = texts.includeAllAttachments
, value = model.attachAll
, id = "item-send-mail-attach-all"
}
@ -311,7 +327,7 @@ view2 settings model =
, disabled = not (isValid model)
}
, B.secondaryButton
{ label = "Cancel"
{ label = texts.basics.cancel
, icon = "fa fa-times"
, handler = onClick Cancel
, attrs = [ href "#" ]
@ -319,3 +335,8 @@ view2 settings model =
}
]
]
appendDots : String -> String
appendDots name =
name ++ ""

View File

@ -68,48 +68,48 @@ viewContent2 txt model =
splitDisplay2 txt
viewEditLink2 : (Bool -> Attribute Msg) -> Model -> Html Msg
viewEditLink2 classes model =
viewEditLink2 : String -> (Bool -> Attribute Msg) -> Model -> Html Msg
viewEditLink2 label classes model =
a
[ onClick (SetDisplay Edit)
, classes (model.display == Edit)
, href "#"
]
[ text "Edit"
[ text label
]
viewPreviewLink2 : (Bool -> Attribute Msg) -> Model -> Html Msg
viewPreviewLink2 classes model =
viewPreviewLink2 : String -> (Bool -> Attribute Msg) -> Model -> Html Msg
viewPreviewLink2 label classes model =
a
[ onClick (SetDisplay Preview)
, classes (model.display == Preview)
, href "#"
]
[ text "Preview"
[ text label
]
viewSplitLink2 : (Bool -> Attribute Msg) -> Model -> Html Msg
viewSplitLink2 classes model =
viewSplitLink2 : String -> (Bool -> Attribute Msg) -> Model -> Html Msg
viewSplitLink2 label classes model =
a
[ onClick (SetDisplay Split)
, classes (model.display == Split)
, href "#"
]
[ text "Split"
[ text label
]
viewCheatLink2 : String -> Model -> Html msg
viewCheatLink2 classes model =
viewCheatLink2 : String -> String -> Model -> Html msg
viewCheatLink2 label classes model =
a
[ class classes
, target "_new"
, href model.cheatSheetUrl
]
[ i [ class "fa fa-question mr-2" ] []
, text "Supports Markdown"
, text label
]

View File

@ -30,6 +30,8 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Http
import Markdown
import Messages.Comp.NotificationForm exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -144,17 +146,13 @@ init flags =
Comp.CalEventInput.initDefault
in
( { settings = Api.Model.NotificationSettings.empty
, connectionModel =
Comp.Dropdown.makeSingle
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select connection..."
}
, tagInclModel = Util.Tag.makeDropdownModel2
, tagExclModel = Util.Tag.makeDropdownModel2
, connectionModel = Comp.Dropdown.makeSingle
, tagInclModel = Util.Tag.makeDropdownModel
, tagExclModel = Util.Tag.makeDropdownModel
, recipients = []
, recipientsModel = Comp.EmailInput.init
, remindDays = Just 1
, remindDaysModel = Comp.IntField.init (Just 1) Nothing True "Remind Days"
, remindDaysModel = Comp.IntField.init (Just 1) Nothing True
, enabled = False
, capOverdue = False
, schedule = initialSchedule
@ -298,9 +296,7 @@ update flags msg model =
cm =
Comp.Dropdown.makeSingleList
{ makeOption = \a -> { value = a, text = a, additional = "" }
, placeholder = "Select Connection..."
, options = names
{ options = names
, selected = List.head names
}
in
@ -480,19 +476,28 @@ isFormSuccess model =
|> Maybe.withDefault False
view2 : String -> UiSettings -> Model -> Html Msg
view2 extraClasses settings model =
view2 : Texts -> String -> UiSettings -> Model -> Html Msg
view2 texts extraClasses settings model =
let
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this notification task?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteTask
texts.basics.yes
texts.basics.no
startOnceBtn =
MB.SecondaryButton
{ tagger = StartOnce
, label = "Start Once"
, title = "Start this task now"
, label = texts.startOnce
, title = texts.startTaskNow
, icon = Just "fa fa-play"
}
connectionCfg =
{ makeOption = \a -> { text = a, additional = "" }
, placeholder = texts.selectConnection
, labelColor = \_ -> \_ -> ""
, style = DS.mainStyle
}
in
div
[ class "flex flex-col md:relative"
@ -503,19 +508,22 @@ view2 extraClasses settings model =
dimmerSettings
model.yesNoDelete
)
, B.loadingDimmer (model.loading > 0)
, B.loadingDimmer
{ active = model.loading > 0
, label = texts.basics.loading
}
, MB.view
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, label = "Submit"
, title = "Save"
, label = texts.basics.submit
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
}
, MB.SecondaryButton
{ tagger = Cancel
, label = "Cancel"
, title = "Back to list"
, label = texts.basics.cancel
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
}
]
@ -524,8 +532,8 @@ view2 extraClasses settings model =
[ startOnceBtn
, MB.DeleteButton
{ tagger = RequestDelete
, label = "Delete"
, title = "Delete this task"
, label = texts.basics.delete
, title = texts.deleteThisTask
, icon = Just "fa fa-trash"
}
]
@ -551,14 +559,14 @@ view2 extraClasses settings model =
[ MB.viewItem <|
MB.Checkbox
{ tagger = \_ -> ToggleEnabled
, label = "Enable or disable this task."
, label = texts.enableDisable
, value = model.enabled
, id = "notify-enabled"
}
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Summary"
[ text texts.summary
]
, input
[ type_ "text"
@ -569,72 +577,74 @@ view2 extraClasses settings model =
]
[]
, span [ class "opacity-50 text-sm" ]
[ text "Some human readable name, only for displaying"
[ text texts.summaryInfo
]
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Send via"
[ text texts.sendVia
, B.inputRequired
]
, Html.map ConnMsg
(Comp.Dropdown.view2
DS.mainStyle
connectionCfg
settings
model.connectionModel
)
, span [ class "opacity-50 text-sm" ]
[ text "The SMTP connection to use when sending notification mails."
[ text texts.sendViaInfo
]
]
, div [ class "mb-4" ]
[ label
[ class S.inputLabel
]
[ text "Recipient(s)"
[ text texts.recipients
, B.inputRequired
]
, Html.map RecipientMsg
(Comp.EmailInput.view2
DS.mainStyle
{ style = DS.mainStyle, placeholder = texts.recipients }
model.recipients
model.recipientsModel
)
, span [ class "opacity-50 text-sm" ]
[ text "One or more mail addresses, confirm each by pressing 'Return'."
[ text texts.recipientsInfo
]
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Tags Include (and)" ]
[ text texts.tagsInclude ]
, Html.map TagIncMsg
(Comp.Dropdown.view2
DS.mainStyle
(Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle)
settings
model.tagInclModel
)
, span [ class "opacity-50 text-sm" ]
[ text "Items must have all the tags specified here."
[ text texts.tagsIncludeInfo
]
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Tags Exclude (or)" ]
[ text texts.tagsExclude ]
, Html.map TagExcMsg
(Comp.Dropdown.view2
DS.mainStyle
(Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle)
settings
model.tagExclModel
)
, span [ class "small-info" ]
[ text "Items must not have any tag specified here."
[ text texts.tagsExcludeInfo
]
]
, Html.map RemindDaysMsg
(Comp.IntField.viewWithInfo2
"Select items with a due date *lower than* `today+remindDays`"
model.remindDays
"mb-4"
(Comp.IntField.view
{ label = texts.remindDaysLabel
, info = texts.remindDaysInfo
, number = model.remindDays
, classes = "mb-4"
}
model.remindDaysModel
)
, div [ class "mb-4" ]
@ -643,20 +653,15 @@ view2 extraClasses settings model =
{ tagger = \_ -> ToggleCapOverdue
, id = "notify-toggle-cap-overdue"
, value = model.capOverdue
, label = "Cap overdue items"
, label = texts.capOverdue
}
, div [ class "opacity-50 text-sm" ]
[ text "If checked, only items with a due date"
, em [ class "font-italic" ]
[ text " greater than " ]
, code [ class "font-mono" ]
[ text "today-remindDays" ]
, text " are considered."
[ Markdown.toHtml [] texts.capOverdueInfo
]
]
, div [ class "mb-4" ]
[ label [ class S.inputLabel ]
[ text "Schedule"
[ text texts.schedule
, a
[ class "float-right"
, class S.link
@ -665,20 +670,19 @@ view2 extraClasses settings model =
]
[ i [ class "fa fa-question" ] []
, span [ class "pl-2" ]
[ text "Click here for help"
[ text texts.scheduleClickForHelp
]
]
]
, Html.map CalEventMsg
(Comp.CalEventInput.view2 ""
(Comp.CalEventInput.view2
texts.calEventInput
""
(Data.Validated.value model.schedule)
model.scheduleModel
)
, span [ class "opacity-50 text-sm" ]
[ text "Specify how often and when this task should run. "
, text "Use English 3-letter weekdays. Either a single value, "
, text "a list (ex. 1,2,3), a range (ex. 1..3) or a '*' (meaning all) "
, text "is allowed for each part."
[ text texts.scheduleInfo
]
]
]

View File

@ -11,6 +11,7 @@ import Api.Model.NotificationSettings exposing (NotificationSettings)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.NotificationTable exposing (Texts)
import Styles as S
import Util.Html
@ -44,8 +45,8 @@ update msg model =
--- View2
view2 : Model -> List NotificationSettings -> Html Msg
view2 _ items =
view2 : Texts -> Model -> List NotificationSettings -> Html Msg
view2 texts _ items =
div []
[ table [ class S.tableMain ]
[ thead []
@ -54,13 +55,13 @@ view2 _ items =
, th [ class "text-center mr-2" ]
[ i [ class "fa fa-check" ] []
]
, th [ class "text-left " ] [ text "Summary" ]
, th [ class "text-left " ] [ text texts.summary ]
, th [ class "text-left hidden sm:table-cell mr-2" ]
[ text "Schedule" ]
[ text texts.schedule ]
, th [ class "text-left mr-2" ]
[ text "Connection" ]
[ text texts.connection ]
, th [ class "text-left hidden sm:table-cell mr-2" ]
[ text "Recipients" ]
[ text texts.recipients ]
]
]
, tbody []

View File

@ -18,6 +18,7 @@ import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import Messages.Comp.NotificationManage exposing (Texts)
import Styles as S
import Util.Http
@ -212,8 +213,8 @@ update flags msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
div [ class "flex flex-col" ]
(div
[ classList
@ -229,34 +230,38 @@ view2 settings model =
]
:: (case model.detailModel of
Just msett ->
viewForm2 settings msett
viewForm2 texts settings msett
Nothing ->
viewList2 model
viewList2 texts model
)
)
viewForm2 : UiSettings -> Comp.NotificationForm.Model -> List (Html Msg)
viewForm2 settings model =
viewForm2 : Texts -> UiSettings -> Comp.NotificationForm.Model -> List (Html Msg)
viewForm2 texts settings model =
[ Html.map DetailMsg
(Comp.NotificationForm.view2 "flex flex-col" settings model)
(Comp.NotificationForm.view2 texts.notificationForm "flex flex-col" settings model)
]
viewList2 : Model -> List (Html Msg)
viewList2 model =
viewList2 : Texts -> Model -> List (Html Msg)
viewList2 texts model =
[ MB.view
{ start =
[ MB.PrimaryButton
{ tagger = NewTask
, label = "New Task"
, label = texts.newTask
, icon = Just "fa fa-plus"
, title = "Create a new notification task"
, title = texts.createNewTask
}
]
, end = []
, rootClasses = "mb-4"
}
, Html.map ListMsg (Comp.NotificationList.view2 model.listModel model.items)
, Html.map ListMsg
(Comp.NotificationList.view2 texts.notificationTable
model.listModel
model.items
)
]

View File

@ -13,12 +13,14 @@ import Comp.AddressForm
import Comp.Basic as B
import Comp.ContactField
import Comp.FixedDropdown
import Data.DropdownStyle as DS
import Data.Flags exposing (Flags)
import Data.OrgUse exposing (OrgUse)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import Messages.Comp.OrgForm exposing (Texts)
import Styles as S
import Util.Maybe
@ -45,9 +47,7 @@ emptyModel =
, shortName = Nothing
, use = Data.OrgUse.Correspondent
, useModel =
Comp.FixedDropdown.initMap
Data.OrgUse.label
Data.OrgUse.all
Comp.FixedDropdown.init Data.OrgUse.all
}
@ -147,14 +147,20 @@ update flags msg model =
--- View2
makeUseItem : Model -> Maybe (Comp.FixedDropdown.Item OrgUse)
makeUseItem model =
Just <|
Comp.FixedDropdown.Item model.use (Data.OrgUse.label model.use)
view2 : Texts -> Bool -> UiSettings -> Model -> Html Msg
view2 texts mobile settings model =
let
orgUseCfg =
{ display = texts.orgUseLabel
, icon = \_ -> Nothing
, style = DS.mainStyle
}
view2 : Bool -> UiSettings -> Model -> Html Msg
view2 mobile settings model =
contactTypeCfg =
{ mobile = mobile
, contactTypeLabel = texts.contactTypeLabel
}
in
div [ class "flex flex-col" ]
[ div
[ class "mb-4" ]
@ -162,13 +168,13 @@ view2 mobile settings model =
[ for "orgname"
, class S.inputLabel
]
[ text "Name"
[ text texts.basics.name
, B.inputRequired
]
, input
[ type_ "text"
, onInput SetName
, placeholder "Name"
, placeholder texts.basics.name
, value model.name
, name "orgname"
, class S.textInput
@ -184,12 +190,12 @@ view2 mobile settings model =
[ for "org-short-name"
, class S.inputLabel
]
[ text "Short Name"
[ text texts.shortName
]
, input
[ type_ "text"
, onInput SetShortName
, placeholder "Abbreviation"
, placeholder texts.shortName
, Maybe.withDefault "" model.shortName
|> value
, name "org-short-name"
@ -201,35 +207,40 @@ view2 mobile settings model =
[ label
[ class S.inputLabel
]
[ text "Use" ]
[ text texts.use
]
, Html.map UseDropdownMsg
(Comp.FixedDropdown.view2 (makeUseItem model) model.useModel)
(Comp.FixedDropdown.viewStyled2 orgUseCfg
False
(Just model.use)
model.useModel
)
, span [ class "opacity-50 text-sm" ]
[ case model.use of
Data.OrgUse.Correspondent ->
text "Use as correspondent"
text texts.useAsCorrespondent
Data.OrgUse.Disabled ->
text "Do not use for suggestions."
text texts.dontUseForSuggestions
]
]
, div [ class "mb-4" ]
[ h3 [ class S.header3 ]
[ text "Address"
[ text texts.address
]
, Html.map AddressMsg
(Comp.AddressForm.view2 settings model.addressModel)
(Comp.AddressForm.view2 texts.addressForm settings model.addressModel)
]
, div [ class "mb-4" ]
[ h3 [ class S.header3 ]
[ text "Contacts"
[ text texts.contacts
]
, Html.map ContactMsg
(Comp.ContactField.view2 mobile settings model.contactModel)
(Comp.ContactField.view2 contactTypeCfg settings model.contactModel)
]
, div [ class "mb-4" ]
[ h3 [ class S.header3 ]
[ text "Notes"
[ text texts.notes
]
, div [ class "" ]
[ textarea

View File

@ -21,6 +21,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onSubmit)
import Http
import Messages.Comp.OrgManage exposing (Texts)
import Styles as S
import Util.Http
import Util.Maybe
@ -205,50 +206,55 @@ update flags msg model =
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
view2 : Texts -> UiSettings -> Model -> Html Msg
view2 texts settings model =
if model.viewMode == Table then
viewTable2 model
viewTable2 texts model
else
viewForm2 settings model
viewForm2 texts settings model
viewTable2 : Model -> Html Msg
viewTable2 model =
viewTable2 : Texts -> Model -> Html Msg
viewTable2 texts model =
div [ class "flex flex-col relative" ]
[ MB.view
{ start =
[ MB.TextInput
{ tagger = SetQuery
, value = model.query
, placeholder = "Search"
, placeholder = texts.basics.searchPlaceholder
, icon = Just "fa fa-search"
}
]
, end =
[ MB.PrimaryButton
{ tagger = InitNewOrg
, title = "Create a new organization"
, title = texts.createNewOrganization
, icon = Just "fa fa-plus"
, label = "New Organization"
, label = texts.newOrganization
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.OrgTable.view2 model.tableModel)
, B.loadingDimmer model.loading
, Html.map TableMsg (Comp.OrgTable.view2 texts.orgTable model.tableModel)
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]
viewForm2 : UiSettings -> Model -> Html Msg
viewForm2 settings model =
viewForm2 : Texts -> UiSettings -> Model -> Html Msg
viewForm2 texts settings model =
let
newOrg =
model.formModel.org.id == ""
dimmerSettings2 =
Comp.YesNoDimmer.defaultSettings2 "Really delete this organization?"
Comp.YesNoDimmer.defaultSettings texts.reallyDeleteOrg
texts.basics.yes
texts.basics.no
in
Html.form
[ class "md:relative flex flex-col"
@ -262,14 +268,14 @@ viewForm2 settings model =
)
, if newOrg then
h3 [ class S.header2 ]
[ text "Create new organization"
[ text texts.createNewOrganization
]
else
h3 [ class S.header2 ]
[ text model.formModel.org.name
, div [ class "opacity-50 text-sm" ]
[ text "Id: "
[ text (texts.basics.id ++ ": ")
, text model.formModel.org.id
]
]
@ -277,24 +283,24 @@ viewForm2 settings model =
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, title = "Submit this form"
, title = texts.basics.submitThisForm
, icon = Just "fa fa-save"
, label = "Submit"
, label = texts.basics.submit
}
, MB.SecondaryButton
{ tagger = SetViewMode Table
, title = "Back to list"
, title = texts.basics.backToList
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
, label = texts.basics.cancel
}
]
, end =
if not newOrg then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this organization"
, title = texts.deleteThisOrg
, icon = Just "fa fa-trash"
, label = "Delete"
, label = texts.basics.delete
}
]
@ -311,6 +317,15 @@ viewForm2 settings model =
]
[ Maybe.withDefault "" model.formError |> text
]
, Html.map FormMsg (Comp.OrgForm.view2 False settings model.formModel)
, B.loadingDimmer model.loading
, Html.map FormMsg
(Comp.OrgForm.view2
texts.orgForm
False
settings
model.formModel
)
, B.loadingDimmer
{ active = model.loading
, label = texts.basics.loading
}
]

Some files were not shown because too many files have changed in this diff Show More