mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-10-22 13:20:12 +00:00
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:
@@ -4,12 +4,15 @@ module Comp.OrgManage exposing
|
||||
, emptyModel
|
||||
, update
|
||||
, view
|
||||
, view2
|
||||
)
|
||||
|
||||
import Api
|
||||
import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Api.Model.Organization
|
||||
import Api.Model.OrganizationList exposing (OrganizationList)
|
||||
import Comp.Basic as B
|
||||
import Comp.MenuBar as MB
|
||||
import Comp.OrgForm
|
||||
import Comp.OrgTable
|
||||
import Comp.YesNoDimmer
|
||||
@@ -19,6 +22,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick, onInput, onSubmit)
|
||||
import Http
|
||||
import Styles as S
|
||||
import Util.Http
|
||||
import Util.Maybe
|
||||
|
||||
@@ -301,3 +305,117 @@ 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 relative" ]
|
||||
[ MB.view
|
||||
{ start =
|
||||
[ MB.TextInput
|
||||
{ tagger = SetQuery
|
||||
, value = model.query
|
||||
, placeholder = "Search…"
|
||||
, icon = Just "fa fa-search"
|
||||
}
|
||||
]
|
||||
, end =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = InitNewOrg
|
||||
, title = "Create a new organization"
|
||||
, icon = Just "fa fa-plus"
|
||||
, label = "New Organization"
|
||||
}
|
||||
]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map TableMsg (Comp.OrgTable.view2 model.tableModel)
|
||||
, B.loadingDimmer model.loading
|
||||
]
|
||||
|
||||
|
||||
viewForm2 : UiSettings -> Model -> Html Msg
|
||||
viewForm2 settings model =
|
||||
let
|
||||
newOrg =
|
||||
model.formModel.org.id == ""
|
||||
|
||||
dimmerSettings2 =
|
||||
Comp.YesNoDimmer.defaultSettings2 "Really delete this organization?"
|
||||
in
|
||||
Html.form
|
||||
[ class "md:relative flex flex-col"
|
||||
, onSubmit Submit
|
||||
]
|
||||
[ Html.map YesNoMsg
|
||||
(Comp.YesNoDimmer.viewN
|
||||
True
|
||||
dimmerSettings2
|
||||
model.deleteConfirm
|
||||
)
|
||||
, if newOrg then
|
||||
h3 [ class S.header2 ]
|
||||
[ text "Create new organization"
|
||||
]
|
||||
|
||||
else
|
||||
h3 [ class S.header2 ]
|
||||
[ text model.formModel.org.name
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "Id: "
|
||||
, text model.formModel.org.id
|
||||
]
|
||||
]
|
||||
, 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 newOrg then
|
||||
[ MB.DeleteButton
|
||||
{ tagger = RequestDelete
|
||||
, title = "Delete this organization"
|
||||
, icon = Just "fa fa-trash"
|
||||
, label = "Delete"
|
||||
}
|
||||
]
|
||||
|
||||
else
|
||||
[]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map FormMsg (Comp.OrgForm.view2 False settings model.formModel)
|
||||
, div
|
||||
[ classList
|
||||
[ ( "hidden", Util.Maybe.isEmpty model.formError )
|
||||
]
|
||||
, class S.errorMessage
|
||||
]
|
||||
[ Maybe.withDefault "" model.formError |> text
|
||||
]
|
||||
, B.loadingDimmer model.loading
|
||||
]
|
||||
|
Reference in New Issue
Block a user