mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 18:38:26 +00:00
Editable dashboard
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
module Data.Box exposing (Box)
|
||||
module Data.Box exposing (Box, boxIcon, empty, messageBox, queryBox, statsBox, uploadBox)
|
||||
|
||||
import Data.BoxContent exposing (BoxContent)
|
||||
import Data.BoxContent exposing (BoxContent(..))
|
||||
|
||||
|
||||
type alias Box =
|
||||
@ -10,3 +10,38 @@ type alias Box =
|
||||
, colspan : Int
|
||||
, content : BoxContent
|
||||
}
|
||||
|
||||
|
||||
empty : BoxContent -> Box
|
||||
empty cnt =
|
||||
{ name = ""
|
||||
, visible = True
|
||||
, decoration = True
|
||||
, colspan = 1
|
||||
, content = cnt
|
||||
}
|
||||
|
||||
|
||||
boxIcon : Box -> String
|
||||
boxIcon box =
|
||||
Data.BoxContent.boxContentIcon box.content
|
||||
|
||||
|
||||
queryBox : Box
|
||||
queryBox =
|
||||
empty (BoxQuery Data.BoxContent.emptyQueryData)
|
||||
|
||||
|
||||
statsBox : Box
|
||||
statsBox =
|
||||
empty (BoxStats Data.BoxContent.emptyStatsData)
|
||||
|
||||
|
||||
messageBox : Box
|
||||
messageBox =
|
||||
empty (BoxMessage Data.BoxContent.emptyMessageData)
|
||||
|
||||
|
||||
uploadBox : Box
|
||||
uploadBox =
|
||||
empty (BoxUpload Data.BoxContent.emptyUploadData)
|
||||
|
@ -3,18 +3,24 @@ module Data.BoxContent exposing
|
||||
, MessageData
|
||||
, QueryData
|
||||
, SearchQuery(..)
|
||||
, SummaryData
|
||||
, StatsData
|
||||
, SummaryShow(..)
|
||||
, UploadData
|
||||
, boxContentIcon
|
||||
, emptyMessageData
|
||||
, emptyQueryData
|
||||
, emptyStatsData
|
||||
, emptyUploadData
|
||||
)
|
||||
|
||||
import Data.ItemTemplate exposing (ItemTemplate)
|
||||
import Data.ItemColumn exposing (ItemColumn)
|
||||
|
||||
|
||||
type BoxContent
|
||||
= BoxUpload (Maybe String)
|
||||
= BoxUpload UploadData
|
||||
| BoxMessage MessageData
|
||||
| BoxQuery QueryData
|
||||
| BoxSummary SummaryData
|
||||
| BoxStats StatsData
|
||||
|
||||
|
||||
type alias MessageData =
|
||||
@ -23,21 +29,56 @@ type alias MessageData =
|
||||
}
|
||||
|
||||
|
||||
emptyMessageData : MessageData
|
||||
emptyMessageData =
|
||||
{ title = ""
|
||||
, body = ""
|
||||
}
|
||||
|
||||
|
||||
type alias UploadData =
|
||||
{ sourceId : Maybe String
|
||||
}
|
||||
|
||||
|
||||
emptyUploadData : UploadData
|
||||
emptyUploadData =
|
||||
{ sourceId = Nothing
|
||||
}
|
||||
|
||||
|
||||
type alias QueryData =
|
||||
{ query : SearchQuery
|
||||
, limit : Int
|
||||
, details : Bool
|
||||
, header : List String
|
||||
, columns : List ItemTemplate
|
||||
, columns : List ItemColumn
|
||||
, showHeaders : Bool
|
||||
}
|
||||
|
||||
|
||||
type alias SummaryData =
|
||||
emptyQueryData : QueryData
|
||||
emptyQueryData =
|
||||
{ query = SearchQueryString ""
|
||||
, limit = 5
|
||||
, details = True
|
||||
, columns = []
|
||||
, showHeaders = True
|
||||
}
|
||||
|
||||
|
||||
type alias StatsData =
|
||||
{ query : SearchQuery
|
||||
, show : SummaryShow
|
||||
}
|
||||
|
||||
|
||||
emptyStatsData : StatsData
|
||||
emptyStatsData =
|
||||
{ query = SearchQueryString ""
|
||||
, show = SummaryShowGeneral
|
||||
}
|
||||
|
||||
|
||||
type SummaryShow
|
||||
= SummaryShowFields Bool
|
||||
| SummaryShowGeneral
|
||||
@ -46,3 +87,19 @@ type SummaryShow
|
||||
type SearchQuery
|
||||
= SearchQueryString String
|
||||
| SearchQueryBookmark String
|
||||
|
||||
|
||||
boxContentIcon : BoxContent -> String
|
||||
boxContentIcon content =
|
||||
case content of
|
||||
BoxMessage _ ->
|
||||
"fa fa-comment-alt font-thin"
|
||||
|
||||
BoxUpload _ ->
|
||||
"fa fa-file-upload"
|
||||
|
||||
BoxQuery _ ->
|
||||
"fa fa-search"
|
||||
|
||||
BoxStats _ ->
|
||||
"fa fa-chart-bar font-thin"
|
||||
|
@ -39,8 +39,7 @@ module Data.Icons exposing
|
||||
, dueDate2
|
||||
, dueDateIcon
|
||||
, dueDateIcon2
|
||||
, editNotes
|
||||
, editNotesIcon
|
||||
, editIcon
|
||||
, equipment
|
||||
, equipmentIcon
|
||||
, fileUploadIcon
|
||||
@ -378,14 +377,14 @@ dueDateIcon2 classes =
|
||||
i [ class (dueDate2 ++ " " ++ classes) ] []
|
||||
|
||||
|
||||
editNotes : String
|
||||
editNotes =
|
||||
"comment alternate outline icon"
|
||||
edit : String
|
||||
edit =
|
||||
"fa fa-edit font-thin"
|
||||
|
||||
|
||||
editNotesIcon : Html msg
|
||||
editNotesIcon =
|
||||
i [ class editNotes ] []
|
||||
editIcon : String -> Html msg
|
||||
editIcon classes =
|
||||
i [ class edit, class classes ] []
|
||||
|
||||
|
||||
addFiles2 : String
|
||||
|
118
modules/webapp/src/main/elm/Data/ItemColumn.elm
Normal file
118
modules/webapp/src/main/elm/Data/ItemColumn.elm
Normal file
@ -0,0 +1,118 @@
|
||||
module Data.ItemColumn exposing (..)
|
||||
|
||||
import Api.Model.ItemLight exposing (ItemLight)
|
||||
import Data.ItemTemplate as IT exposing (TemplateContext)
|
||||
|
||||
|
||||
type ItemColumn
|
||||
= Name
|
||||
| DateLong
|
||||
| DateShort
|
||||
| DueDateLong
|
||||
| DueDateShort
|
||||
| Folder
|
||||
| Correspondent
|
||||
| Concerning
|
||||
| Tags
|
||||
|
||||
|
||||
all : List ItemColumn
|
||||
all =
|
||||
[ Name, DateLong, DateShort, DueDateLong, DueDateShort, Folder, Correspondent, Concerning, Tags ]
|
||||
|
||||
|
||||
renderString : TemplateContext -> ItemColumn -> ItemLight -> String
|
||||
renderString ctx col item =
|
||||
case col of
|
||||
Name ->
|
||||
IT.render IT.name ctx item
|
||||
|
||||
DateShort ->
|
||||
IT.render IT.dateShort ctx item
|
||||
|
||||
DateLong ->
|
||||
IT.render IT.dateLong ctx item
|
||||
|
||||
DueDateShort ->
|
||||
IT.render IT.dueDateShort ctx item
|
||||
|
||||
DueDateLong ->
|
||||
IT.render IT.dueDateLong ctx item
|
||||
|
||||
Folder ->
|
||||
IT.render IT.folder ctx item
|
||||
|
||||
Correspondent ->
|
||||
IT.render IT.correspondent ctx item
|
||||
|
||||
Concerning ->
|
||||
IT.render IT.concerning ctx item
|
||||
|
||||
Tags ->
|
||||
List.map .name item.tags
|
||||
|> String.join ", "
|
||||
|
||||
|
||||
asString : ItemColumn -> String
|
||||
asString col =
|
||||
case col of
|
||||
Name ->
|
||||
"name"
|
||||
|
||||
DateShort ->
|
||||
"dateshort"
|
||||
|
||||
DateLong ->
|
||||
"datelong"
|
||||
|
||||
DueDateShort ->
|
||||
"duedateshort"
|
||||
|
||||
DueDateLong ->
|
||||
"duedatelong"
|
||||
|
||||
Folder ->
|
||||
"folder"
|
||||
|
||||
Correspondent ->
|
||||
"correspodnent"
|
||||
|
||||
Concerning ->
|
||||
"concerning"
|
||||
|
||||
Tags ->
|
||||
"tags"
|
||||
|
||||
|
||||
fromString : String -> Maybe ItemColumn
|
||||
fromString str =
|
||||
case String.toLower str of
|
||||
"name" ->
|
||||
Just Name
|
||||
|
||||
"dateshort" ->
|
||||
Just DateShort
|
||||
|
||||
"datelong" ->
|
||||
Just DateLong
|
||||
|
||||
"duedateshort" ->
|
||||
Just DueDateShort
|
||||
|
||||
"duedatelong" ->
|
||||
Just DueDateLong
|
||||
|
||||
"folder" ->
|
||||
Just Folder
|
||||
|
||||
"correspodnent" ->
|
||||
Just Correspondent
|
||||
|
||||
"concerning" ->
|
||||
Just Concerning
|
||||
|
||||
"tags" ->
|
||||
Just Tags
|
||||
|
||||
_ ->
|
||||
Nothing
|
Reference in New Issue
Block a user