mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Change attachments position via drag-and-drop
This commit is contained in:
parent
3cb738568f
commit
90e039ceb3
1
elm.json
1
elm.json
@ -20,6 +20,7 @@
|
||||
"elm/url": "1.0.0",
|
||||
"elm-explorations/markdown": "1.0.0",
|
||||
"justinmimbs/date": "3.1.2",
|
||||
"norpan/elm-html5-drag-drop": "3.1.4",
|
||||
"ryannhg/date-format": "2.3.0",
|
||||
"truqu/elm-base64": "2.0.4"
|
||||
},
|
||||
|
@ -42,6 +42,7 @@ module Api exposing
|
||||
, login
|
||||
, loginSession
|
||||
, logout
|
||||
, moveAttachmentBefore
|
||||
, newInvite
|
||||
, postEquipment
|
||||
, postNewUser
|
||||
@ -100,6 +101,7 @@ import Api.Model.ItemProposals exposing (ItemProposals)
|
||||
import Api.Model.ItemSearch exposing (ItemSearch)
|
||||
import Api.Model.ItemUploadMeta exposing (ItemUploadMeta)
|
||||
import Api.Model.JobQueueState exposing (JobQueueState)
|
||||
import Api.Model.MoveAttachment exposing (MoveAttachment)
|
||||
import Api.Model.NotificationSettings exposing (NotificationSettings)
|
||||
import Api.Model.OptionalDate exposing (OptionalDate)
|
||||
import Api.Model.OptionalId exposing (OptionalId)
|
||||
@ -1009,6 +1011,21 @@ getJobQueueStateTask flags =
|
||||
-- Item
|
||||
|
||||
|
||||
moveAttachmentBefore :
|
||||
Flags
|
||||
-> String
|
||||
-> MoveAttachment
|
||||
-> (Result Http.Error BasicResult -> msg)
|
||||
-> Cmd msg
|
||||
moveAttachmentBefore flags itemId data receive =
|
||||
Http2.authPost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/item/" ++ itemId ++ "/attachment/movebefore"
|
||||
, account = getAccount flags
|
||||
, body = Http.jsonBody (Api.Model.MoveAttachment.encode data)
|
||||
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||
}
|
||||
|
||||
|
||||
itemSearch : Flags -> ItemSearch -> (Result Http.Error ItemLightList -> msg) -> Cmd msg
|
||||
itemSearch flags search receive =
|
||||
Http2.authPost
|
||||
|
@ -14,6 +14,7 @@ import Api.Model.EquipmentList exposing (EquipmentList)
|
||||
import Api.Model.IdName exposing (IdName)
|
||||
import Api.Model.ItemDetail exposing (ItemDetail)
|
||||
import Api.Model.ItemProposals exposing (ItemProposals)
|
||||
import Api.Model.MoveAttachment exposing (MoveAttachment)
|
||||
import Api.Model.OptionalDate exposing (OptionalDate)
|
||||
import Api.Model.OptionalId exposing (OptionalId)
|
||||
import Api.Model.OptionalText exposing (OptionalText)
|
||||
@ -39,6 +40,7 @@ import File exposing (File)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onClick, onInput)
|
||||
import Html5.DragDrop as DD
|
||||
import Http
|
||||
import Markdown
|
||||
import Page exposing (Page(..))
|
||||
@ -88,6 +90,7 @@ type alias Model =
|
||||
, completed : Set String
|
||||
, errored : Set String
|
||||
, loading : Set String
|
||||
, attachDD : DD.Model String String
|
||||
}
|
||||
|
||||
|
||||
@ -182,6 +185,7 @@ emptyModel =
|
||||
, completed = Set.empty
|
||||
, errored = Set.empty
|
||||
, loading = Set.empty
|
||||
, attachDD = DD.init
|
||||
}
|
||||
|
||||
|
||||
@ -244,6 +248,7 @@ type Msg
|
||||
| AddFilesUploadResp String (Result Http.Error BasicResult)
|
||||
| AddFilesProgress String Http.Progress
|
||||
| AddFilesReset
|
||||
| AttachDDMsg (DD.Msg String String)
|
||||
|
||||
|
||||
|
||||
@ -1174,6 +1179,28 @@ update key flags next msg model =
|
||||
in
|
||||
noSub ( model, updateBars )
|
||||
|
||||
AttachDDMsg lm ->
|
||||
let
|
||||
( model_, result ) =
|
||||
DD.update lm model.attachDD
|
||||
|
||||
cmd =
|
||||
case result of
|
||||
Just ( src, trg, _ ) ->
|
||||
if src /= trg then
|
||||
Api.moveAttachmentBefore flags
|
||||
model.item.id
|
||||
(MoveAttachment src trg)
|
||||
SaveResp
|
||||
|
||||
else
|
||||
Cmd.none
|
||||
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
in
|
||||
noSub ( { model | attachDD = model_ }, cmd )
|
||||
|
||||
|
||||
|
||||
-- view
|
||||
@ -1425,14 +1452,17 @@ renderAttachmentsTabMenu model =
|
||||
(\pos ->
|
||||
\el ->
|
||||
a
|
||||
[ classList
|
||||
([ classList
|
||||
[ ( "item", True )
|
||||
, ( "active", attachmentVisible model pos )
|
||||
]
|
||||
, title (Maybe.withDefault "No Name" el.name)
|
||||
, href ""
|
||||
, onClick (SetActiveAttachment pos)
|
||||
]
|
||||
, title (Maybe.withDefault "No Name" el.name)
|
||||
, href ""
|
||||
, onClick (SetActiveAttachment pos)
|
||||
]
|
||||
++ DD.draggable AttachDDMsg el.id
|
||||
++ DD.droppable AttachDDMsg el.id
|
||||
)
|
||||
[ Maybe.map (Util.String.ellipsis 20) el.name
|
||||
|> Maybe.withDefault "No Name"
|
||||
|> text
|
||||
|
Loading…
x
Reference in New Issue
Block a user