mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-09-30 00:28:23 +00:00
Editable dashboard
This commit is contained in:
@@ -11,12 +11,14 @@ module Page.Dashboard.Data exposing
|
||||
, Msg(..)
|
||||
, SideMenuModel
|
||||
, init
|
||||
, reloadDashboard
|
||||
, isHomeContent
|
||||
, reloadDashboardData
|
||||
, reloadUiSettings
|
||||
)
|
||||
|
||||
import Api
|
||||
import Comp.BookmarkChooser
|
||||
import Comp.DashboardEdit
|
||||
import Comp.DashboardView
|
||||
import Comp.EquipmentManage
|
||||
import Comp.FolderManage
|
||||
@@ -72,14 +74,14 @@ initCmd flags =
|
||||
Api.getBookmarks flags ignoreBookmarkError
|
||||
|
||||
|
||||
reloadDashboard : Msg
|
||||
reloadDashboard =
|
||||
reloadDashboardData : Msg
|
||||
reloadDashboardData =
|
||||
ReloadDashboardData
|
||||
|
||||
|
||||
reloadUiSettings : Msg
|
||||
reloadUiSettings =
|
||||
InitDashboard
|
||||
ReloadDashboard
|
||||
|
||||
|
||||
type Msg
|
||||
@@ -96,6 +98,7 @@ type Msg
|
||||
| FolderMsg Comp.FolderManage.Msg
|
||||
| UploadMsg Comp.UploadForm.Msg
|
||||
| DashboardMsg Comp.DashboardView.Msg
|
||||
| DashboardEditMsg Comp.DashboardEdit.Msg
|
||||
| InitNotificationHook
|
||||
| InitDashboard
|
||||
| InitPeriodicQuery
|
||||
@@ -107,7 +110,9 @@ type Msg
|
||||
| InitTags
|
||||
| InitFolder
|
||||
| InitUpload
|
||||
| InitEditDashboard
|
||||
| ReloadDashboardData
|
||||
| ReloadDashboard
|
||||
|
||||
|
||||
type Content
|
||||
@@ -122,3 +127,14 @@ type Content
|
||||
| Tags Comp.TagManage.Model
|
||||
| Folder Comp.FolderManage.Model
|
||||
| Upload Comp.UploadForm.Model
|
||||
| Edit Comp.DashboardEdit.Model
|
||||
|
||||
|
||||
isHomeContent : Content -> Bool
|
||||
isHomeContent cnt =
|
||||
case cnt of
|
||||
Home _ ->
|
||||
True
|
||||
|
||||
_ ->
|
||||
False
|
||||
|
@@ -4,7 +4,7 @@ import Data.Box exposing (Box)
|
||||
import Data.BoxContent exposing (BoxContent(..), SearchQuery(..), SummaryShow(..))
|
||||
import Data.Dashboard exposing (Dashboard)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemTemplate as IT
|
||||
import Data.ItemColumn as IC
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Messages
|
||||
import Messages.Page.DefaultDashboard exposing (Texts)
|
||||
@@ -67,7 +67,7 @@ newDocuments texts =
|
||||
{ query = SearchQueryString "inbox:yes"
|
||||
, limit = 5
|
||||
, details = True
|
||||
, header = []
|
||||
, showHeaders = False
|
||||
, columns = []
|
||||
}
|
||||
}
|
||||
@@ -84,11 +84,11 @@ dueDocuments texts =
|
||||
{ query = SearchQueryString "due>today;-10d due<today;+10d"
|
||||
, limit = 5
|
||||
, details = True
|
||||
, header = texts.dueHeaderColumns
|
||||
, showHeaders = True
|
||||
, columns =
|
||||
[ IT.name
|
||||
, IT.correspondent
|
||||
, IT.dueDateShort
|
||||
[ IC.Name
|
||||
, IC.Correspondent
|
||||
, IC.DueDateShort
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ summary texts =
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content =
|
||||
BoxSummary
|
||||
BoxStats
|
||||
{ query = SearchQueryString ""
|
||||
, show = SummaryShowGeneral
|
||||
}
|
||||
@@ -115,7 +115,7 @@ fieldStats =
|
||||
, decoration = True
|
||||
, colspan = 2
|
||||
, content =
|
||||
BoxSummary
|
||||
BoxStats
|
||||
{ query = SearchQueryString ""
|
||||
, show = SummaryShowFields False
|
||||
}
|
||||
@@ -129,5 +129,7 @@ upload =
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content =
|
||||
BoxUpload Nothing
|
||||
BoxUpload
|
||||
{ sourceId = Nothing
|
||||
}
|
||||
}
|
||||
|
@@ -6,15 +6,15 @@ import Data.Flags exposing (Flags)
|
||||
import Data.Icons as Icons
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (Attribute, Html, a, div, h3, span, text)
|
||||
import Html.Attributes exposing (class, href, target)
|
||||
import Html.Attributes exposing (class, classList, href, target)
|
||||
import Html.Events exposing (onClick)
|
||||
import Messages.Page.Dashboard exposing (Texts)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Dashboard.Data exposing (Msg(..), SideMenuModel)
|
||||
import Page.Dashboard.Data exposing (Model, Msg(..), isHomeContent)
|
||||
import Styles as S
|
||||
|
||||
|
||||
view : Texts -> VersionInfo -> UiSettings -> SideMenuModel -> Html Msg
|
||||
view : Texts -> VersionInfo -> UiSettings -> Model -> Html Msg
|
||||
view texts versionInfo _ model =
|
||||
div [ class "flex flex-col flex-grow" ]
|
||||
[ div [ class "mt-2" ]
|
||||
@@ -32,7 +32,7 @@ view texts versionInfo _ model =
|
||||
(Comp.BookmarkChooser.viewWith
|
||||
{ showUser = True, showCollective = True, showShares = False }
|
||||
texts.bookmarkChooser
|
||||
model.bookmarkChooser
|
||||
model.sideMenu.bookmarkChooser
|
||||
Comp.BookmarkChooser.emptySelection
|
||||
)
|
||||
]
|
||||
@@ -69,6 +69,13 @@ view texts versionInfo _ model =
|
||||
]
|
||||
, div [ class "ml-2" ]
|
||||
[ menuLink [ onClick InitUpload, href "#" ] (Icons.fileUploadIcon "") texts.uploadFiles
|
||||
, menuLink
|
||||
[ onClick InitEditDashboard
|
||||
, classList [ ( "hidden", not (isHomeContent model.content) ) ]
|
||||
, href "#"
|
||||
]
|
||||
(Icons.editIcon "")
|
||||
texts.editDashboard
|
||||
]
|
||||
, div [ class "mt-2 opacity-75" ]
|
||||
[ menuLink [ href Data.UiSettings.documentationSite, target "_blank" ] (Icons.documentationIcon "") texts.documentation
|
||||
|
@@ -9,6 +9,7 @@ module Page.Dashboard.Update exposing (update)
|
||||
|
||||
import Browser.Navigation as Nav
|
||||
import Comp.BookmarkChooser
|
||||
import Comp.DashboardEdit
|
||||
import Comp.DashboardView
|
||||
import Comp.EquipmentManage
|
||||
import Comp.FolderManage
|
||||
@@ -27,7 +28,6 @@ import Page exposing (Page(..))
|
||||
import Page.Dashboard.Data exposing (..)
|
||||
import Page.Dashboard.DefaultDashboard
|
||||
import Set
|
||||
import Styles exposing (content)
|
||||
|
||||
|
||||
update : Texts -> UiSettings -> Nav.Key -> Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
@@ -66,14 +66,17 @@ update texts settings navKey flags msg model =
|
||||
update texts settings navKey flags ReloadDashboardData model
|
||||
|
||||
_ ->
|
||||
let
|
||||
board =
|
||||
Page.Dashboard.DefaultDashboard.getDefaultDashboard flags settings
|
||||
update texts settings navKey flags ReloadDashboard model
|
||||
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.init flags board
|
||||
in
|
||||
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
|
||||
ReloadDashboard ->
|
||||
let
|
||||
board =
|
||||
Page.Dashboard.DefaultDashboard.getDefaultDashboard flags settings
|
||||
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.init flags board
|
||||
in
|
||||
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
|
||||
|
||||
InitNotificationHook ->
|
||||
let
|
||||
@@ -145,6 +148,21 @@ update texts settings navKey flags msg model =
|
||||
in
|
||||
( { model | content = Upload um }, Cmd.none, Sub.none )
|
||||
|
||||
InitEditDashboard ->
|
||||
case model.content of
|
||||
Home m ->
|
||||
let
|
||||
( dm, dc, ds ) =
|
||||
Comp.DashboardEdit.init flags m.dashboard
|
||||
in
|
||||
( { model | content = Edit dm }
|
||||
, Cmd.map DashboardEditMsg dc
|
||||
, Sub.map DashboardEditMsg ds
|
||||
)
|
||||
|
||||
_ ->
|
||||
unit model
|
||||
|
||||
NotificationHookMsg lm ->
|
||||
case model.content of
|
||||
Webhook nhm ->
|
||||
@@ -283,6 +301,39 @@ update texts settings navKey flags msg model =
|
||||
_ ->
|
||||
unit model
|
||||
|
||||
DashboardEditMsg lm ->
|
||||
case model.content of
|
||||
Edit m ->
|
||||
let
|
||||
result =
|
||||
Comp.DashboardEdit.update flags lm m
|
||||
in
|
||||
case result.action of
|
||||
Comp.DashboardEdit.SubmitNone ->
|
||||
( { model | content = Edit result.model }
|
||||
, Cmd.map DashboardEditMsg result.cmd
|
||||
, Sub.map DashboardEditMsg result.sub
|
||||
)
|
||||
|
||||
Comp.DashboardEdit.SubmitSave board ->
|
||||
let
|
||||
( dm, dc ) =
|
||||
Comp.DashboardView.init flags board
|
||||
in
|
||||
( { model | content = Home dm }, Cmd.map DashboardMsg dc, Sub.none )
|
||||
|
||||
Comp.DashboardEdit.SubmitCancel ->
|
||||
update texts settings navKey flags ReloadDashboard model
|
||||
|
||||
Comp.DashboardEdit.SubmitDelete _ ->
|
||||
( { model | content = Edit result.model }
|
||||
, Cmd.map DashboardEditMsg result.cmd
|
||||
, Sub.map DashboardEditMsg result.sub
|
||||
)
|
||||
|
||||
_ ->
|
||||
unit model
|
||||
|
||||
ReloadDashboardData ->
|
||||
let
|
||||
lm =
|
||||
|
@@ -8,6 +8,7 @@
|
||||
module Page.Dashboard.View exposing (viewContent, viewSidebar)
|
||||
|
||||
import Api.Model.VersionInfo exposing (VersionInfo)
|
||||
import Comp.DashboardEdit
|
||||
import Comp.DashboardView
|
||||
import Comp.EquipmentManage
|
||||
import Comp.FolderManage
|
||||
@@ -37,7 +38,7 @@ viewSidebar texts visible flags versionInfo settings model =
|
||||
, class S.sidebarBg
|
||||
, classList [ ( "hidden", not visible ) ]
|
||||
]
|
||||
[ SideMenu.view texts versionInfo settings model.sideMenu
|
||||
[ SideMenu.view texts versionInfo settings model
|
||||
]
|
||||
|
||||
|
||||
@@ -52,6 +53,10 @@ viewContent texts flags settings model =
|
||||
Html.map DashboardMsg
|
||||
(Comp.DashboardView.view texts.dashboard flags settings m)
|
||||
|
||||
Edit m ->
|
||||
Html.map DashboardEditMsg
|
||||
(Comp.DashboardEdit.view texts.dashboardEdit flags settings m)
|
||||
|
||||
Webhook m ->
|
||||
viewHookManage texts settings m
|
||||
|
||||
|
Reference in New Issue
Block a user