mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Prepare drag-drop for items into folders
This commit is contained in:
@ -16,10 +16,11 @@ import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.ItemSearch
|
||||
import Comp.FixedDropdown
|
||||
import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
import Comp.SearchMenu exposing (DragDropData)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Items
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html5.DragDrop as DD
|
||||
import Http
|
||||
import Throttle exposing (Throttle)
|
||||
import Util.Html exposing (KeyCode(..))
|
||||
@ -39,6 +40,7 @@ type alias Model =
|
||||
, searchType : SearchType
|
||||
, searchTypeForm : SearchType
|
||||
, contentOnlySearch : Maybe String
|
||||
, dragDropData : DragDropData
|
||||
}
|
||||
|
||||
|
||||
@ -67,6 +69,9 @@ init flags =
|
||||
, searchType = BasicSearch
|
||||
, searchTypeForm = defaultSearchType flags
|
||||
, contentOnlySearch = Nothing
|
||||
, dragDropData =
|
||||
{ folderDrop = DD.init
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html5.DragDrop as DD
|
||||
import Page exposing (Page(..))
|
||||
import Page.Home.Data exposing (..)
|
||||
import Throttle
|
||||
@ -39,10 +40,18 @@ update key flags settings msg model =
|
||||
SearchMenuMsg m ->
|
||||
let
|
||||
nextState =
|
||||
Comp.SearchMenu.update flags settings m model.searchMenuModel
|
||||
Comp.SearchMenu.updateDrop
|
||||
model.dragDropData
|
||||
flags
|
||||
settings
|
||||
m
|
||||
model.searchMenuModel
|
||||
|
||||
newModel =
|
||||
{ model | searchMenuModel = Tuple.first nextState.modelCmd }
|
||||
{ model
|
||||
| searchMenuModel = nextState.model
|
||||
, dragDropData = nextState.dragDrop
|
||||
}
|
||||
|
||||
( m2, c2, s2 ) =
|
||||
if nextState.stateChange && not model.searchInProgress then
|
||||
@ -54,18 +63,21 @@ update key flags settings msg model =
|
||||
( m2
|
||||
, Cmd.batch
|
||||
[ c2
|
||||
, Cmd.map SearchMenuMsg (Tuple.second nextState.modelCmd)
|
||||
, Cmd.map SearchMenuMsg nextState.cmd
|
||||
]
|
||||
, s2
|
||||
)
|
||||
|
||||
ItemCardListMsg m ->
|
||||
let
|
||||
( m2, c2, mitem ) =
|
||||
Comp.ItemCardList.update flags m model.itemListModel
|
||||
result =
|
||||
Comp.ItemCardList.updateDrag model.dragDropData.folderDrop
|
||||
flags
|
||||
m
|
||||
model.itemListModel
|
||||
|
||||
cmd =
|
||||
case mitem of
|
||||
case result.selected of
|
||||
Just item ->
|
||||
Page.set key (ItemDetailPage item.id)
|
||||
|
||||
@ -73,8 +85,11 @@ update key flags settings msg model =
|
||||
Cmd.none
|
||||
in
|
||||
withSub
|
||||
( { model | itemListModel = m2 }
|
||||
, Cmd.batch [ Cmd.map ItemCardListMsg c2, cmd ]
|
||||
( { model
|
||||
| itemListModel = result.model
|
||||
, dragDropData = { folderDrop = result.dragModel }
|
||||
}
|
||||
, Cmd.batch [ Cmd.map ItemCardListMsg result.cmd, cmd ]
|
||||
)
|
||||
|
||||
ItemSearchResp (Ok list) ->
|
||||
|
@ -63,7 +63,12 @@ view flags settings model =
|
||||
]
|
||||
]
|
||||
, div [ class "ui attached fluid segment" ]
|
||||
[ Html.map SearchMenuMsg (Comp.SearchMenu.view flags settings model.searchMenuModel)
|
||||
[ Html.map SearchMenuMsg
|
||||
(Comp.SearchMenu.viewDrop model.dragDropData
|
||||
flags
|
||||
settings
|
||||
model.searchMenuModel
|
||||
)
|
||||
]
|
||||
]
|
||||
, div
|
||||
|
Reference in New Issue
Block a user