First version of new ui based on tailwind

This drops fomantic-ui as css toolkit and introduces tailwindcss. With
tailwind there are no predefined components, but it's very easy to
create those. So customizing the look&feel is much simpler, most of
the time no additional css is needed.

This requires a complete rewrite of the markup + styles. Luckily all
logic can be kept as is. The now old ui is not removed, it is still
available by using a request header `Docspell-Ui` with a value of `1`
for the old ui and `2` for the new ui.

Another addition is "dev mode", where docspell serves assets with a
no-cache header, to disable browser caching. This makes developing a
lot easier.
This commit is contained in:
Eike Kettner
2021-01-29 20:48:27 +01:00
parent 442b76c5af
commit dd935454c9
140 changed files with 15077 additions and 214 deletions

View File

@ -4,12 +4,15 @@ module Comp.UserManage exposing
, emptyModel
, update
, view
, view2
)
import Api
import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.User
import Api.Model.UserList exposing (UserList)
import Comp.Basic as B
import Comp.MenuBar as MB
import Comp.UserForm
import Comp.UserTable
import Comp.YesNoDimmer
@ -19,6 +22,7 @@ import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onSubmit)
import Http
import Styles as S
import Util.Http
import Util.Maybe
@ -195,6 +199,10 @@ update flags msg model =
( { model | deleteConfirm = cm }, cmd )
--- View
view : UiSettings -> Model -> Html Msg
view settings model =
if model.viewMode == Table then
@ -271,3 +279,106 @@ viewForm settings model =
[ div [ class "ui loader" ] []
]
]
--- View2
view2 : UiSettings -> Model -> Html Msg
view2 settings model =
if model.viewMode == Table then
viewTable2 model
else
viewForm2 settings model
viewTable2 : Model -> Html Msg
viewTable2 model =
div [ class "flex flex-col" ]
[ MB.view
{ start = []
, end =
[ MB.PrimaryButton
{ tagger = InitNewUser
, title = "Add a new user"
, icon = Just "fa fa-plus"
, label = "New user"
}
]
, rootClasses = "mb-4"
}
, Html.map TableMsg (Comp.UserTable.view2 model.tableModel)
, B.loadingDimmer model.loading
]
viewForm2 : UiSettings -> Model -> Html Msg
viewForm2 settings model =
let
newUser =
Comp.UserForm.isNewUser model.formModel
dimmerSettings : Comp.YesNoDimmer.Settings
dimmerSettings =
Comp.YesNoDimmer.defaultSettings2 "Really delete this user?"
in
Html.form
[ class "flex flex-col md:relative"
, onSubmit Submit
]
[ Html.map YesNoMsg
(Comp.YesNoDimmer.viewN True
dimmerSettings
model.deleteConfirm
)
, if newUser then
h3 [ class S.header2 ]
[ text "Create new user"
]
else
h3 [ class S.header2 ]
[ text model.formModel.user.login
]
, MB.view
{ start =
[ MB.PrimaryButton
{ tagger = Submit
, title = "Submit this form"
, icon = Just "fa fa-save"
, label = "Submit"
}
, MB.SecondaryButton
{ tagger = SetViewMode Table
, title = "Back to list"
, icon = Just "fa fa-arrow-left"
, label = "Cancel"
}
]
, end =
if not newUser then
[ MB.DeleteButton
{ tagger = RequestDelete
, title = "Delete this user"
, icon = Just "fa fa-trash"
, label = "Delete"
}
]
else
[]
, rootClasses = "mb-4"
}
, Html.map FormMsg (Comp.UserForm.view2 settings model.formModel)
, div
[ classList
[ ( "hidden", Util.Maybe.isEmpty model.formError )
]
, class S.errorMessage
]
[ Maybe.withDefault "" model.formError |> text
]
, B.loadingDimmer model.loading
]