mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Remove old ui code in frontend
This commit is contained in:
@ -1,181 +0,0 @@
|
||||
module Comp.ItemDetail.AttachmentTabMenu exposing (view)
|
||||
|
||||
import Api
|
||||
import Api.Model.Attachment exposing (Attachment)
|
||||
import Comp.ItemDetail.Model exposing (Model, Msg(..))
|
||||
import Comp.SentMails
|
||||
import Html exposing (Html, a, div, i, img, text)
|
||||
import Html.Attributes exposing (class, classList, href, src, title)
|
||||
import Html.Events exposing (onClick)
|
||||
import Html5.DragDrop as DD
|
||||
import Util.List
|
||||
import Util.Maybe
|
||||
import Util.String
|
||||
|
||||
|
||||
view : Model -> List (Html Msg)
|
||||
view model =
|
||||
[ div [ class "ui top attached tabular menu" ]
|
||||
(activeAttach model
|
||||
:: selectMenu model
|
||||
++ sentMailsTab model
|
||||
)
|
||||
, div
|
||||
[ classList
|
||||
[ ( "ui attached segment", model.attachMenuOpen )
|
||||
, ( "invisible hidden", not model.attachMenuOpen )
|
||||
]
|
||||
]
|
||||
[ div [ class "ui doubling small cards" ]
|
||||
(List.indexedMap (menuItem model) model.item.attachments)
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
activeAttach : Model -> Html Msg
|
||||
activeAttach model =
|
||||
let
|
||||
attachM =
|
||||
Util.Maybe.or
|
||||
[ Util.List.get model.item.attachments model.visibleAttach
|
||||
|> Maybe.map (Tuple.pair model.visibleAttach)
|
||||
, List.head model.item.attachments
|
||||
|> Maybe.map (Tuple.pair 0)
|
||||
]
|
||||
|
||||
visible =
|
||||
not model.sentMailsOpen
|
||||
in
|
||||
case attachM of
|
||||
Just ( pos, attach ) ->
|
||||
a
|
||||
([ classList
|
||||
[ ( "active", visible )
|
||||
, ( "item", True )
|
||||
]
|
||||
, title (Maybe.withDefault "No Name" attach.name)
|
||||
, href "#"
|
||||
]
|
||||
++ (if visible then
|
||||
[]
|
||||
|
||||
else
|
||||
[ onClick (SetActiveAttachment pos) ]
|
||||
)
|
||||
)
|
||||
[ Maybe.map (Util.String.ellipsis 30) attach.name
|
||||
|> Maybe.withDefault "No Name"
|
||||
|> text
|
||||
, a
|
||||
[ classList
|
||||
[ ( "right-tab-icon-link", True )
|
||||
, ( "invisible hidden", not visible )
|
||||
]
|
||||
, href "#"
|
||||
, onClick (EditAttachNameStart attach.id)
|
||||
]
|
||||
[ i [ class "grey edit link icon" ] []
|
||||
]
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
div [] []
|
||||
|
||||
|
||||
selectMenu : Model -> List (Html Msg)
|
||||
selectMenu model =
|
||||
case model.item.attachments of
|
||||
[] ->
|
||||
[]
|
||||
|
||||
[ _ ] ->
|
||||
[]
|
||||
|
||||
_ ->
|
||||
[ a
|
||||
[ class "ui dropdown item"
|
||||
, href "#"
|
||||
, onClick ToggleAttachMenu
|
||||
]
|
||||
[ i
|
||||
[ classList
|
||||
[ ( "large ellipsis icon", True )
|
||||
, ( "horizontal", not model.attachMenuOpen )
|
||||
, ( "vertical", model.attachMenuOpen )
|
||||
]
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
menuItem : Model -> Int -> Attachment -> Html Msg
|
||||
menuItem model pos attach =
|
||||
let
|
||||
highlight =
|
||||
let
|
||||
dropId =
|
||||
DD.getDropId model.attachDD
|
||||
|
||||
dragId =
|
||||
DD.getDragId model.attachDD
|
||||
|
||||
enable =
|
||||
Just attach.id == dropId && dropId /= dragId
|
||||
in
|
||||
[ ( "current-drop-target", enable )
|
||||
]
|
||||
|
||||
active =
|
||||
model.visibleAttach == pos
|
||||
in
|
||||
a
|
||||
([ classList <|
|
||||
[ ( "ui card", True )
|
||||
, ( "blue", pos == 0 )
|
||||
]
|
||||
++ highlight
|
||||
, href "#"
|
||||
, onClick (SetActiveAttachment pos)
|
||||
]
|
||||
++ DD.draggable AttachDDMsg attach.id
|
||||
++ DD.droppable AttachDDMsg attach.id
|
||||
)
|
||||
[ div
|
||||
[ classList [ ( "invisible hidden", not active ) ]
|
||||
, class "ui corner icon label"
|
||||
]
|
||||
[ i [ class "check icon" ] []
|
||||
]
|
||||
, div [ class "image" ]
|
||||
[ img
|
||||
[ src (Api.attachmentPreviewURL attach.id)
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div [ class "content" ]
|
||||
[ div [ class "description" ]
|
||||
[ Maybe.map (Util.String.ellipsis 60) attach.name
|
||||
|> Maybe.withDefault "No Name"
|
||||
|> text
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
sentMailsTab : Model -> List (Html Msg)
|
||||
sentMailsTab model =
|
||||
if Comp.SentMails.isEmpty model.sentMails then
|
||||
[]
|
||||
|
||||
else
|
||||
[ div
|
||||
[ classList
|
||||
[ ( "right item", True )
|
||||
, ( "active", model.sentMailsOpen )
|
||||
]
|
||||
, onClick ToggleSentMails
|
||||
]
|
||||
[ text "E-Mails"
|
||||
]
|
||||
]
|
@ -6,7 +6,6 @@ module Comp.ItemDetail.MultiEditMenu exposing
|
||||
, init
|
||||
, loadModel
|
||||
, update
|
||||
, view
|
||||
, view2
|
||||
)
|
||||
|
||||
@ -626,257 +625,12 @@ type alias ViewConfig =
|
||||
|
||||
defaultViewConfig : ViewConfig
|
||||
defaultViewConfig =
|
||||
{ menuClass = "ui vertical segment"
|
||||
{ menuClass = ""
|
||||
, nameState = SaveSuccess
|
||||
, customFieldState = \_ -> SaveSuccess
|
||||
}
|
||||
|
||||
|
||||
view : ViewConfig -> UiSettings -> Model -> Html Msg
|
||||
view =
|
||||
renderEditForm
|
||||
|
||||
|
||||
renderEditForm : ViewConfig -> UiSettings -> Model -> Html Msg
|
||||
renderEditForm cfg settings model =
|
||||
let
|
||||
fieldVisible field =
|
||||
Data.UiSettings.fieldVisible settings field
|
||||
|
||||
optional fields html =
|
||||
if
|
||||
List.map fieldVisible fields
|
||||
|> List.foldl (||) False
|
||||
then
|
||||
html
|
||||
|
||||
else
|
||||
span [ class "invisible hidden" ] []
|
||||
|
||||
tagModeIcon =
|
||||
case model.tagEditMode of
|
||||
AddTags ->
|
||||
i [ class "grey plus link icon" ] []
|
||||
|
||||
RemoveTags ->
|
||||
i [ class "grey eraser link icon" ] []
|
||||
|
||||
ReplaceTags ->
|
||||
i [ class "grey redo alternate link icon" ] []
|
||||
|
||||
tagModeMsg =
|
||||
case model.tagEditMode of
|
||||
AddTags ->
|
||||
"Tags chosen here are *added* to all selected items."
|
||||
|
||||
RemoveTags ->
|
||||
"Tags chosen here are *removed* from all selected items."
|
||||
|
||||
ReplaceTags ->
|
||||
"Tags chosen here *replace* those on selected items."
|
||||
|
||||
customFieldIcon field =
|
||||
case cfg.customFieldState field.id of
|
||||
SaveSuccess ->
|
||||
Nothing
|
||||
|
||||
SaveFailed ->
|
||||
Just "red exclamation triangle icon"
|
||||
|
||||
Saving ->
|
||||
Just "refresh loading icon"
|
||||
|
||||
customFieldSettings =
|
||||
Comp.CustomFieldMultiInput.ViewSettings
|
||||
False
|
||||
"field"
|
||||
customFieldIcon
|
||||
in
|
||||
div [ class cfg.menuClass ]
|
||||
[ div [ class "ui form warning" ]
|
||||
[ div [ class "field" ]
|
||||
[ div
|
||||
[ class "ui fluid buttons"
|
||||
]
|
||||
[ button
|
||||
[ class "ui primary button"
|
||||
, onClick (ConfirmMsg True)
|
||||
]
|
||||
[ text "Confirm"
|
||||
]
|
||||
, div [ class "or" ] []
|
||||
, button
|
||||
[ class "ui secondary button"
|
||||
, onClick (ConfirmMsg False)
|
||||
]
|
||||
[ text "Unconfirm"
|
||||
]
|
||||
]
|
||||
]
|
||||
, optional [ Data.Fields.Tag ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.tagsIcon "grey"
|
||||
, text "Tags"
|
||||
, a
|
||||
[ class "right-float"
|
||||
, href "#"
|
||||
, title "Change tag edit mode"
|
||||
, onClick ToggleTagEditMode
|
||||
]
|
||||
[ tagModeIcon
|
||||
]
|
||||
]
|
||||
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
|
||||
, Markdown.toHtml [ class "small-info" ] tagModeMsg
|
||||
]
|
||||
, div [ class " field" ]
|
||||
[ label [] [ text "Name" ]
|
||||
, div [ class "ui icon input" ]
|
||||
[ input [ type_ "text", value model.nameModel, onInput SetName ] []
|
||||
, i
|
||||
[ classList
|
||||
[ ( "green check icon", cfg.nameState == SaveSuccess )
|
||||
, ( "red exclamation triangle icon", cfg.nameState == SaveFailed )
|
||||
, ( "sync loading icon", cfg.nameState == Saving )
|
||||
]
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
, optional [ Data.Fields.Folder ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.folderIcon "grey"
|
||||
, text "Folder"
|
||||
]
|
||||
, Html.map FolderDropdownMsg (Comp.Dropdown.view settings model.folderModel)
|
||||
, div
|
||||
[ classList
|
||||
[ ( "ui warning 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.
|
||||
"""
|
||||
]
|
||||
]
|
||||
, optional [ Data.Fields.CustomFields ] <|
|
||||
h4 [ class "ui dividing header" ]
|
||||
[ Icons.customFieldIcon ""
|
||||
, text "Custom Fields"
|
||||
]
|
||||
, optional [ Data.Fields.CustomFields ] <|
|
||||
Html.map CustomFieldMsg
|
||||
(Comp.CustomFieldMultiInput.view customFieldSettings model.customFieldModel)
|
||||
, optional [ Data.Fields.Date, Data.Fields.DueDate ] <|
|
||||
h4 [ class "ui dividing header" ]
|
||||
[ Icons.itemDatesIcon ""
|
||||
, text "Item Dates"
|
||||
]
|
||||
, optional [ Data.Fields.Date ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.dateIcon "grey"
|
||||
, text "Date"
|
||||
]
|
||||
, div [ class "ui left icon action input" ]
|
||||
[ Html.map ItemDatePickerMsg
|
||||
(Comp.DatePicker.viewTime
|
||||
model.itemDate
|
||||
actionInputDatePicker
|
||||
model.itemDatePicker
|
||||
)
|
||||
, a [ class "ui icon button", href "#", onClick RemoveDate ]
|
||||
[ i [ class "trash alternate outline icon" ] []
|
||||
]
|
||||
, Icons.dateIcon ""
|
||||
]
|
||||
]
|
||||
, optional [ Data.Fields.DueDate ] <|
|
||||
div [ class " field" ]
|
||||
[ label []
|
||||
[ Icons.dueDateIcon "grey"
|
||||
, text "Due Date"
|
||||
]
|
||||
, div [ class "ui left icon action input" ]
|
||||
[ Html.map DueDatePickerMsg
|
||||
(Comp.DatePicker.viewTime
|
||||
model.dueDate
|
||||
actionInputDatePicker
|
||||
model.dueDatePicker
|
||||
)
|
||||
, a [ class "ui icon button", href "#", onClick RemoveDueDate ]
|
||||
[ i [ class "trash alternate outline icon" ] [] ]
|
||||
, Icons.dueDateIcon ""
|
||||
]
|
||||
]
|
||||
, optional [ Data.Fields.CorrOrg, Data.Fields.CorrPerson ] <|
|
||||
h4 [ class "ui dividing header" ]
|
||||
[ Icons.correspondentIcon ""
|
||||
, text "Correspondent"
|
||||
]
|
||||
, optional [ Data.Fields.CorrOrg ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.organizationIcon "grey"
|
||||
, text "Organization"
|
||||
]
|
||||
, Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel)
|
||||
]
|
||||
, optional [ Data.Fields.CorrPerson ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.personIcon "grey"
|
||||
, text "Person"
|
||||
]
|
||||
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
||||
]
|
||||
, optional [ Data.Fields.ConcPerson, Data.Fields.ConcEquip ] <|
|
||||
h4 [ class "ui dividing header" ]
|
||||
[ Icons.concernedIcon
|
||||
, text "Concerning"
|
||||
]
|
||||
, optional [ Data.Fields.ConcPerson ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.personIcon "grey"
|
||||
, text "Person"
|
||||
]
|
||||
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
||||
]
|
||||
, optional [ Data.Fields.ConcEquip ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.equipmentIcon "grey"
|
||||
, text "Equipment"
|
||||
]
|
||||
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
||||
]
|
||||
, optional [ Data.Fields.Direction ] <|
|
||||
div [ class "field" ]
|
||||
[ label []
|
||||
[ Icons.directionIcon "grey"
|
||||
, text "Direction"
|
||||
]
|
||||
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
actionInputDatePicker : DatePicker.Settings
|
||||
actionInputDatePicker =
|
||||
let
|
||||
ds =
|
||||
Comp.DatePicker.defaultSettings
|
||||
in
|
||||
{ ds | containerClassList = [ ( "ui action input", True ) ] }
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user