mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-02 13:32:51 +00:00
Prepare drag-drop for items into folders
This commit is contained in:
parent
f0a5f84c8b
commit
9c50a85363
@ -3,13 +3,16 @@ module Comp.FolderSelect exposing
|
|||||||
, Msg
|
, Msg
|
||||||
, init
|
, init
|
||||||
, update
|
, update
|
||||||
|
, updateDrop
|
||||||
, view
|
, view
|
||||||
|
, viewDrop
|
||||||
)
|
)
|
||||||
|
|
||||||
import Api.Model.FolderItem exposing (FolderItem)
|
import Api.Model.FolderItem exposing (FolderItem)
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
|
import Html5.DragDrop as DD
|
||||||
import Util.ExpandCollapse
|
import Util.ExpandCollapse
|
||||||
import Util.List
|
import Util.List
|
||||||
|
|
||||||
@ -36,10 +39,24 @@ init all =
|
|||||||
type Msg
|
type Msg
|
||||||
= Toggle FolderItem
|
= Toggle FolderItem
|
||||||
| ToggleExpand
|
| ToggleExpand
|
||||||
|
| FolderDDMsg (DD.Msg String String)
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Maybe FolderItem )
|
update : Msg -> Model -> ( Model, Maybe FolderItem )
|
||||||
update msg model =
|
update msg model =
|
||||||
|
let
|
||||||
|
( m, f, _ ) =
|
||||||
|
updateDrop DD.init msg model
|
||||||
|
in
|
||||||
|
( m, f )
|
||||||
|
|
||||||
|
|
||||||
|
updateDrop :
|
||||||
|
DD.Model String String
|
||||||
|
-> Msg
|
||||||
|
-> Model
|
||||||
|
-> ( Model, Maybe FolderItem, DD.Model String String )
|
||||||
|
updateDrop dropModel msg model =
|
||||||
case msg of
|
case msg of
|
||||||
Toggle item ->
|
Toggle item ->
|
||||||
let
|
let
|
||||||
@ -53,13 +70,36 @@ update msg model =
|
|||||||
model_ =
|
model_ =
|
||||||
{ model | selected = selection }
|
{ model | selected = selection }
|
||||||
in
|
in
|
||||||
( model_, selectedFolder model_ )
|
( model_, selectedFolder model_, dropModel )
|
||||||
|
|
||||||
ToggleExpand ->
|
ToggleExpand ->
|
||||||
( { model | expanded = not model.expanded }
|
( { model | expanded = not model.expanded }
|
||||||
, selectedFolder model
|
, selectedFolder model
|
||||||
|
, dropModel
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FolderDDMsg lm ->
|
||||||
|
let
|
||||||
|
( dm_, result ) =
|
||||||
|
DD.update lm dropModel
|
||||||
|
|
||||||
|
_ =
|
||||||
|
case result of
|
||||||
|
Just ( item, folder, _ ) ->
|
||||||
|
let
|
||||||
|
_ =
|
||||||
|
Debug.log "item menu" item
|
||||||
|
|
||||||
|
_ =
|
||||||
|
Debug.log "folder menu" folder
|
||||||
|
in
|
||||||
|
Cmd.none
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
Cmd.none
|
||||||
|
in
|
||||||
|
( model, selectedFolder model, dm_ )
|
||||||
|
|
||||||
|
|
||||||
selectedFolder : Model -> Maybe FolderItem
|
selectedFolder : Model -> Maybe FolderItem
|
||||||
selectedFolder model =
|
selectedFolder model =
|
||||||
@ -75,7 +115,12 @@ selectedFolder model =
|
|||||||
|
|
||||||
|
|
||||||
view : Int -> Model -> Html Msg
|
view : Int -> Model -> Html Msg
|
||||||
view constr model =
|
view =
|
||||||
|
viewDrop DD.init
|
||||||
|
|
||||||
|
|
||||||
|
viewDrop : DD.Model String String -> Int -> Model -> Html Msg
|
||||||
|
viewDrop dropModel constr model =
|
||||||
div [ class "ui list" ]
|
div [ class "ui list" ]
|
||||||
[ div [ class "item" ]
|
[ div [ class "item" ]
|
||||||
[ i [ class "folder open icon" ] []
|
[ i [ class "folder open icon" ] []
|
||||||
@ -84,22 +129,22 @@ view constr model =
|
|||||||
[ text "Folders"
|
[ text "Folders"
|
||||||
]
|
]
|
||||||
, div [ class "ui relaxed list" ]
|
, div [ class "ui relaxed list" ]
|
||||||
(renderItems constr model)
|
(renderItems dropModel constr model)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
renderItems : Int -> Model -> List (Html Msg)
|
renderItems : DD.Model String String -> Int -> Model -> List (Html Msg)
|
||||||
renderItems constr model =
|
renderItems dropModel constr model =
|
||||||
if constr <= 0 then
|
if constr <= 0 then
|
||||||
List.map (viewItem model) model.all
|
List.map (viewItem dropModel model) model.all
|
||||||
|
|
||||||
else if model.expanded then
|
else if model.expanded then
|
||||||
List.map (viewItem model) model.all ++ collapseToggle constr model
|
List.map (viewItem dropModel model) model.all ++ collapseToggle constr model
|
||||||
|
|
||||||
else
|
else
|
||||||
List.map (viewItem model) (List.take constr model.all) ++ expandToggle constr model
|
List.map (viewItem dropModel model) (List.take constr model.all) ++ expandToggle constr model
|
||||||
|
|
||||||
|
|
||||||
expandToggle : Int -> Model -> List (Html Msg)
|
expandToggle : Int -> Model -> List (Html Msg)
|
||||||
@ -118,8 +163,8 @@ collapseToggle max model =
|
|||||||
ToggleExpand
|
ToggleExpand
|
||||||
|
|
||||||
|
|
||||||
viewItem : Model -> FolderItem -> Html Msg
|
viewItem : DD.Model String String -> Model -> FolderItem -> Html Msg
|
||||||
viewItem model item =
|
viewItem dropModel model item =
|
||||||
let
|
let
|
||||||
selected =
|
selected =
|
||||||
Just item.id == model.selected
|
Just item.id == model.selected
|
||||||
@ -130,15 +175,21 @@ viewItem model item =
|
|||||||
|
|
||||||
else
|
else
|
||||||
"folder outline icon"
|
"folder outline icon"
|
||||||
|
|
||||||
|
highlightDrop =
|
||||||
|
DD.getDropId dropModel == Just item.id
|
||||||
in
|
in
|
||||||
a
|
a
|
||||||
[ classList
|
([ classList
|
||||||
[ ( "item", True )
|
[ ( "item", True )
|
||||||
, ( "active", selected )
|
, ( "active", selected )
|
||||||
|
, ( "current-drop-target", highlightDrop )
|
||||||
]
|
]
|
||||||
, href "#"
|
, href "#"
|
||||||
, onClick (Toggle item)
|
, onClick (Toggle item)
|
||||||
]
|
]
|
||||||
|
++ DD.droppable FolderDDMsg item.id
|
||||||
|
)
|
||||||
[ i [ class icon ] []
|
[ i [ class icon ] []
|
||||||
, div [ class "content" ]
|
, div [ class "content" ]
|
||||||
[ div [ class "header" ]
|
[ div [ class "header" ]
|
||||||
|
@ -5,6 +5,7 @@ module Comp.ItemCardList exposing
|
|||||||
, nextItem
|
, nextItem
|
||||||
, prevItem
|
, prevItem
|
||||||
, update
|
, update
|
||||||
|
, updateDrag
|
||||||
, view
|
, view
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ import Data.UiSettings exposing (UiSettings)
|
|||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
|
import Html5.DragDrop as DD
|
||||||
import Markdown
|
import Markdown
|
||||||
import Util.List
|
import Util.List
|
||||||
import Util.String
|
import Util.String
|
||||||
@ -35,6 +37,7 @@ type Msg
|
|||||||
= SetResults ItemLightList
|
= SetResults ItemLightList
|
||||||
| AddResults ItemLightList
|
| AddResults ItemLightList
|
||||||
| SelectItem ItemLight
|
| SelectItem ItemLight
|
||||||
|
| ItemDDMsg (DD.Msg String String)
|
||||||
|
|
||||||
|
|
||||||
init : Model
|
init : Model
|
||||||
@ -60,28 +63,72 @@ prevItem model id =
|
|||||||
|
|
||||||
|
|
||||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe ItemLight )
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe ItemLight )
|
||||||
update _ msg model =
|
update flags msg model =
|
||||||
|
let
|
||||||
|
res =
|
||||||
|
updateDrag DD.init flags msg model
|
||||||
|
in
|
||||||
|
( res.model, res.cmd, res.selected )
|
||||||
|
|
||||||
|
|
||||||
|
type alias UpdateResult =
|
||||||
|
{ model : Model
|
||||||
|
, cmd : Cmd Msg
|
||||||
|
, selected : Maybe ItemLight
|
||||||
|
, dragModel : DD.Model String String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateDrag :
|
||||||
|
DD.Model String String
|
||||||
|
-> Flags
|
||||||
|
-> Msg
|
||||||
|
-> Model
|
||||||
|
-> UpdateResult
|
||||||
|
updateDrag dm _ msg model =
|
||||||
case msg of
|
case msg of
|
||||||
SetResults list ->
|
SetResults list ->
|
||||||
let
|
let
|
||||||
newModel =
|
newModel =
|
||||||
{ model | results = list }
|
{ model | results = list }
|
||||||
in
|
in
|
||||||
( newModel, Cmd.none, Nothing )
|
UpdateResult newModel Cmd.none Nothing dm
|
||||||
|
|
||||||
AddResults list ->
|
AddResults list ->
|
||||||
if list.groups == [] then
|
if list.groups == [] then
|
||||||
( model, Cmd.none, Nothing )
|
UpdateResult model Cmd.none Nothing dm
|
||||||
|
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
newModel =
|
newModel =
|
||||||
{ model | results = Data.Items.concat model.results list }
|
{ model | results = Data.Items.concat model.results list }
|
||||||
in
|
in
|
||||||
( newModel, Cmd.none, Nothing )
|
UpdateResult newModel Cmd.none Nothing dm
|
||||||
|
|
||||||
SelectItem item ->
|
SelectItem item ->
|
||||||
( model, Cmd.none, Just item )
|
UpdateResult model Cmd.none (Just item) dm
|
||||||
|
|
||||||
|
ItemDDMsg lm ->
|
||||||
|
let
|
||||||
|
( dm_, result ) =
|
||||||
|
DD.update lm dm
|
||||||
|
|
||||||
|
_ =
|
||||||
|
case result of
|
||||||
|
Just ( item, folder, _ ) ->
|
||||||
|
let
|
||||||
|
_ =
|
||||||
|
Debug.log "item card" item
|
||||||
|
|
||||||
|
_ =
|
||||||
|
Debug.log "folder card" folder
|
||||||
|
in
|
||||||
|
Cmd.none
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
Cmd.none
|
||||||
|
in
|
||||||
|
UpdateResult model Cmd.none Nothing dm_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -139,14 +186,16 @@ viewItem settings item =
|
|||||||
"blue"
|
"blue"
|
||||||
in
|
in
|
||||||
a
|
a
|
||||||
[ classList
|
([ classList
|
||||||
[ ( "ui fluid card", True )
|
[ ( "ui fluid card", True )
|
||||||
, ( newColor, not isConfirmed )
|
, ( newColor, not isConfirmed )
|
||||||
]
|
]
|
||||||
, id item.id
|
, id item.id
|
||||||
, href "#"
|
, href "#"
|
||||||
, onClick (SelectItem item)
|
, onClick (SelectItem item)
|
||||||
]
|
]
|
||||||
|
++ DD.draggable ItemDDMsg item.id
|
||||||
|
)
|
||||||
[ div [ class "content" ]
|
[ div [ class "content" ]
|
||||||
[ div
|
[ div
|
||||||
[ class "header"
|
[ class "header"
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
module Comp.SearchMenu exposing
|
module Comp.SearchMenu exposing
|
||||||
( Model
|
( DragDropData
|
||||||
|
, Model
|
||||||
, Msg(..)
|
, Msg(..)
|
||||||
, NextState
|
, NextState
|
||||||
, getItemSearch
|
, getItemSearch
|
||||||
, init
|
, init
|
||||||
, update
|
, update
|
||||||
|
, updateDrop
|
||||||
, view
|
, view
|
||||||
|
, viewDrop
|
||||||
)
|
)
|
||||||
|
|
||||||
import Api
|
import Api
|
||||||
@ -29,6 +32,7 @@ import DatePicker exposing (DatePicker)
|
|||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onCheck, onClick, onInput)
|
import Html.Events exposing (onCheck, onClick, onInput)
|
||||||
|
import Html5.DragDrop as DD
|
||||||
import Http
|
import Http
|
||||||
import Util.Html exposing (KeyCode(..))
|
import Util.Html exposing (KeyCode(..))
|
||||||
import Util.Maybe
|
import Util.Maybe
|
||||||
@ -127,33 +131,6 @@ init =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
|
||||||
= Init
|
|
||||||
| TagSelectMsg Comp.TagSelect.Msg
|
|
||||||
| DirectionMsg (Comp.Dropdown.Msg Direction)
|
|
||||||
| OrgMsg (Comp.Dropdown.Msg IdName)
|
|
||||||
| CorrPersonMsg (Comp.Dropdown.Msg IdName)
|
|
||||||
| ConcPersonMsg (Comp.Dropdown.Msg IdName)
|
|
||||||
| ConcEquipmentMsg (Comp.Dropdown.Msg Equipment)
|
|
||||||
| FromDateMsg Comp.DatePicker.Msg
|
|
||||||
| UntilDateMsg Comp.DatePicker.Msg
|
|
||||||
| FromDueDateMsg Comp.DatePicker.Msg
|
|
||||||
| UntilDueDateMsg Comp.DatePicker.Msg
|
|
||||||
| ToggleInbox
|
|
||||||
| GetTagsResp (Result Http.Error TagCloud)
|
|
||||||
| GetOrgResp (Result Http.Error ReferenceList)
|
|
||||||
| GetEquipResp (Result Http.Error EquipmentList)
|
|
||||||
| GetPersonResp (Result Http.Error ReferenceList)
|
|
||||||
| SetName String
|
|
||||||
| SetAllName String
|
|
||||||
| SetFulltext String
|
|
||||||
| ResetForm
|
|
||||||
| KeyUpMsg (Maybe KeyCode)
|
|
||||||
| ToggleNameHelp
|
|
||||||
| FolderSelectMsg Comp.FolderSelect.Msg
|
|
||||||
| GetFolderResp (Result Http.Error FolderList)
|
|
||||||
|
|
||||||
|
|
||||||
getDirection : Model -> Maybe Direction
|
getDirection : Model -> Maybe Direction
|
||||||
getDirection model =
|
getDirection model =
|
||||||
let
|
let
|
||||||
@ -218,19 +195,53 @@ getItemSearch model =
|
|||||||
-- Update
|
-- Update
|
||||||
|
|
||||||
|
|
||||||
type alias NextState =
|
type Msg
|
||||||
{ modelCmd : ( Model, Cmd Msg )
|
= Init
|
||||||
, stateChange : Bool
|
| TagSelectMsg Comp.TagSelect.Msg
|
||||||
|
| DirectionMsg (Comp.Dropdown.Msg Direction)
|
||||||
|
| OrgMsg (Comp.Dropdown.Msg IdName)
|
||||||
|
| CorrPersonMsg (Comp.Dropdown.Msg IdName)
|
||||||
|
| ConcPersonMsg (Comp.Dropdown.Msg IdName)
|
||||||
|
| ConcEquipmentMsg (Comp.Dropdown.Msg Equipment)
|
||||||
|
| FromDateMsg Comp.DatePicker.Msg
|
||||||
|
| UntilDateMsg Comp.DatePicker.Msg
|
||||||
|
| FromDueDateMsg Comp.DatePicker.Msg
|
||||||
|
| UntilDueDateMsg Comp.DatePicker.Msg
|
||||||
|
| ToggleInbox
|
||||||
|
| GetTagsResp (Result Http.Error TagCloud)
|
||||||
|
| GetOrgResp (Result Http.Error ReferenceList)
|
||||||
|
| GetEquipResp (Result Http.Error EquipmentList)
|
||||||
|
| GetPersonResp (Result Http.Error ReferenceList)
|
||||||
|
| SetName String
|
||||||
|
| SetAllName String
|
||||||
|
| SetFulltext String
|
||||||
|
| ResetForm
|
||||||
|
| KeyUpMsg (Maybe KeyCode)
|
||||||
|
| ToggleNameHelp
|
||||||
|
| FolderSelectMsg Comp.FolderSelect.Msg
|
||||||
|
| GetFolderResp (Result Http.Error FolderList)
|
||||||
|
|
||||||
|
|
||||||
|
type alias DragDropData =
|
||||||
|
{ folderDrop : DD.Model String String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
noChange : ( Model, Cmd Msg ) -> NextState
|
type alias NextState =
|
||||||
noChange p =
|
{ model : Model
|
||||||
NextState p False
|
, cmd : Cmd Msg
|
||||||
|
, stateChange : Bool
|
||||||
|
, dragDrop : DragDropData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
update : Flags -> UiSettings -> Msg -> Model -> NextState
|
update : Flags -> UiSettings -> Msg -> Model -> NextState
|
||||||
update flags settings msg model =
|
update =
|
||||||
|
updateDrop (DragDropData DD.init)
|
||||||
|
|
||||||
|
|
||||||
|
updateDrop : DragDropData -> Flags -> UiSettings -> Msg -> Model -> NextState
|
||||||
|
updateDrop dd flags settings msg model =
|
||||||
case msg of
|
case msg of
|
||||||
Init ->
|
Init ->
|
||||||
let
|
let
|
||||||
@ -257,9 +268,9 @@ update flags settings msg model =
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
noChange
|
{ model = mdp
|
||||||
( mdp
|
, cmd =
|
||||||
, Cmd.batch
|
Cmd.batch
|
||||||
[ Api.getTagCloud flags GetTagsResp
|
[ Api.getTagCloud flags GetTagsResp
|
||||||
, Api.getOrgLight flags GetOrgResp
|
, Api.getOrgLight flags GetOrgResp
|
||||||
, Api.getEquipments flags "" GetEquipResp
|
, Api.getEquipments flags "" GetEquipResp
|
||||||
@ -267,7 +278,9 @@ update flags settings msg model =
|
|||||||
, Api.getFolders flags "" False GetFolderResp
|
, Api.getFolders flags "" False GetFolderResp
|
||||||
, cdp
|
, cdp
|
||||||
]
|
]
|
||||||
)
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
ResetForm ->
|
ResetForm ->
|
||||||
let
|
let
|
||||||
@ -286,10 +299,18 @@ update flags settings msg model =
|
|||||||
model_ =
|
model_ =
|
||||||
{ model | tagSelectModel = selectModel }
|
{ model | tagSelectModel = selectModel }
|
||||||
in
|
in
|
||||||
noChange ( model_, Cmd.none )
|
{ model = model_
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetTagsResp (Err _) ->
|
GetTagsResp (Err _) ->
|
||||||
noChange ( model, Cmd.none )
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetEquipResp (Ok equips) ->
|
GetEquipResp (Ok equips) ->
|
||||||
let
|
let
|
||||||
@ -299,7 +320,11 @@ update flags settings msg model =
|
|||||||
update flags settings (ConcEquipmentMsg opts) model
|
update flags settings (ConcEquipmentMsg opts) model
|
||||||
|
|
||||||
GetEquipResp (Err _) ->
|
GetEquipResp (Err _) ->
|
||||||
noChange ( model, Cmd.none )
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetOrgResp (Ok orgs) ->
|
GetOrgResp (Ok orgs) ->
|
||||||
let
|
let
|
||||||
@ -309,98 +334,112 @@ update flags settings msg model =
|
|||||||
update flags settings (OrgMsg opts) model
|
update flags settings (OrgMsg opts) model
|
||||||
|
|
||||||
GetOrgResp (Err _) ->
|
GetOrgResp (Err _) ->
|
||||||
noChange ( model, Cmd.none )
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetPersonResp (Ok ps) ->
|
GetPersonResp (Ok ps) ->
|
||||||
let
|
let
|
||||||
opts =
|
opts =
|
||||||
Comp.Dropdown.SetOptions ps.items
|
Comp.Dropdown.SetOptions ps.items
|
||||||
|
|
||||||
|
next1 =
|
||||||
|
updateDrop dd flags settings (CorrPersonMsg opts) model
|
||||||
|
|
||||||
|
next2 =
|
||||||
|
updateDrop next1.dragDrop flags settings (ConcPersonMsg opts) next1.model
|
||||||
in
|
in
|
||||||
noChange <|
|
next2
|
||||||
Util.Update.andThen1
|
|
||||||
[ update flags settings (CorrPersonMsg opts) >> .modelCmd
|
|
||||||
, update flags settings (ConcPersonMsg opts) >> .modelCmd
|
|
||||||
]
|
|
||||||
model
|
|
||||||
|
|
||||||
GetPersonResp (Err _) ->
|
GetPersonResp (Err _) ->
|
||||||
noChange ( model, Cmd.none )
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
TagSelectMsg m ->
|
TagSelectMsg m ->
|
||||||
let
|
let
|
||||||
( m_, sel ) =
|
( m_, sel ) =
|
||||||
Comp.TagSelect.update m model.tagSelectModel
|
Comp.TagSelect.update m model.tagSelectModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model =
|
||||||
( { model
|
{ model
|
||||||
| tagSelectModel = m_
|
| tagSelectModel = m_
|
||||||
, tagSelection = sel
|
, tagSelection = sel
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, cmd = Cmd.none
|
||||||
)
|
, stateChange = sel /= model.tagSelection
|
||||||
(sel /= model.tagSelection)
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
DirectionMsg m ->
|
DirectionMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
Comp.Dropdown.update m model.directionModel
|
Comp.Dropdown.update m model.directionModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | directionModel = m2 }
|
||||||
( { model | directionModel = m2 }
|
, cmd = Cmd.map DirectionMsg c2
|
||||||
, Cmd.map DirectionMsg c2
|
, stateChange = isDropdownChangeMsg m
|
||||||
)
|
, dragDrop = dd
|
||||||
(isDropdownChangeMsg m)
|
}
|
||||||
|
|
||||||
OrgMsg m ->
|
OrgMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
Comp.Dropdown.update m model.orgModel
|
Comp.Dropdown.update m model.orgModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | orgModel = m2 }
|
||||||
( { model | orgModel = m2 }
|
, cmd = Cmd.map OrgMsg c2
|
||||||
, Cmd.map OrgMsg c2
|
, stateChange = isDropdownChangeMsg m
|
||||||
)
|
, dragDrop = dd
|
||||||
(isDropdownChangeMsg m)
|
}
|
||||||
|
|
||||||
CorrPersonMsg m ->
|
CorrPersonMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
Comp.Dropdown.update m model.corrPersonModel
|
Comp.Dropdown.update m model.corrPersonModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | corrPersonModel = m2 }
|
||||||
( { model | corrPersonModel = m2 }
|
, cmd = Cmd.map CorrPersonMsg c2
|
||||||
, Cmd.map CorrPersonMsg c2
|
, stateChange = isDropdownChangeMsg m
|
||||||
)
|
, dragDrop = dd
|
||||||
(isDropdownChangeMsg m)
|
}
|
||||||
|
|
||||||
ConcPersonMsg m ->
|
ConcPersonMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
Comp.Dropdown.update m model.concPersonModel
|
Comp.Dropdown.update m model.concPersonModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | concPersonModel = m2 }
|
||||||
( { model | concPersonModel = m2 }
|
, cmd = Cmd.map ConcPersonMsg c2
|
||||||
, Cmd.map ConcPersonMsg c2
|
, stateChange = isDropdownChangeMsg m
|
||||||
)
|
, dragDrop = dd
|
||||||
(isDropdownChangeMsg m)
|
}
|
||||||
|
|
||||||
ConcEquipmentMsg m ->
|
ConcEquipmentMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
Comp.Dropdown.update m model.concEquipmentModel
|
Comp.Dropdown.update m model.concEquipmentModel
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | concEquipmentModel = m2 }
|
||||||
( { model | concEquipmentModel = m2 }
|
, cmd = Cmd.map ConcEquipmentMsg c2
|
||||||
, Cmd.map ConcEquipmentMsg c2
|
, stateChange = isDropdownChangeMsg m
|
||||||
)
|
, dragDrop = dd
|
||||||
(isDropdownChangeMsg m)
|
}
|
||||||
|
|
||||||
ToggleInbox ->
|
ToggleInbox ->
|
||||||
let
|
let
|
||||||
current =
|
current =
|
||||||
model.inboxCheckbox
|
model.inboxCheckbox
|
||||||
in
|
in
|
||||||
NextState ( { model | inboxCheckbox = not current }, Cmd.none ) True
|
{ model = { model | inboxCheckbox = not current }
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = True
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
FromDateMsg m ->
|
FromDateMsg m ->
|
||||||
let
|
let
|
||||||
@ -415,11 +454,11 @@ update flags settings msg model =
|
|||||||
_ ->
|
_ ->
|
||||||
Nothing
|
Nothing
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | fromDateModel = dp, fromDate = nextDate }
|
||||||
( { model | fromDateModel = dp, fromDate = nextDate }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = model.fromDate /= nextDate
|
||||||
)
|
, dragDrop = dd
|
||||||
(model.fromDate /= nextDate)
|
}
|
||||||
|
|
||||||
UntilDateMsg m ->
|
UntilDateMsg m ->
|
||||||
let
|
let
|
||||||
@ -434,11 +473,11 @@ update flags settings msg model =
|
|||||||
_ ->
|
_ ->
|
||||||
Nothing
|
Nothing
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | untilDateModel = dp, untilDate = nextDate }
|
||||||
( { model | untilDateModel = dp, untilDate = nextDate }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = model.untilDate /= nextDate
|
||||||
)
|
, dragDrop = dd
|
||||||
(model.untilDate /= nextDate)
|
}
|
||||||
|
|
||||||
FromDueDateMsg m ->
|
FromDueDateMsg m ->
|
||||||
let
|
let
|
||||||
@ -453,11 +492,11 @@ update flags settings msg model =
|
|||||||
_ ->
|
_ ->
|
||||||
Nothing
|
Nothing
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | fromDueDateModel = dp, fromDueDate = nextDate }
|
||||||
( { model | fromDueDateModel = dp, fromDueDate = nextDate }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = model.fromDueDate /= nextDate
|
||||||
)
|
, dragDrop = dd
|
||||||
(model.fromDueDate /= nextDate)
|
}
|
||||||
|
|
||||||
UntilDueDateMsg m ->
|
UntilDueDateMsg m ->
|
||||||
let
|
let
|
||||||
@ -472,79 +511,98 @@ update flags settings msg model =
|
|||||||
_ ->
|
_ ->
|
||||||
Nothing
|
Nothing
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | untilDueDateModel = dp, untilDueDate = nextDate }
|
||||||
( { model | untilDueDateModel = dp, untilDueDate = nextDate }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = model.untilDueDate /= nextDate
|
||||||
)
|
, dragDrop = dd
|
||||||
(model.untilDueDate /= nextDate)
|
}
|
||||||
|
|
||||||
SetName str ->
|
SetName str ->
|
||||||
let
|
let
|
||||||
next =
|
next =
|
||||||
Util.Maybe.fromString str
|
Util.Maybe.fromString str
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | nameModel = next }
|
||||||
( { model | nameModel = next }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = False
|
||||||
)
|
, dragDrop = dd
|
||||||
False
|
}
|
||||||
|
|
||||||
SetAllName str ->
|
SetAllName str ->
|
||||||
let
|
let
|
||||||
next =
|
next =
|
||||||
Util.Maybe.fromString str
|
Util.Maybe.fromString str
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | allNameModel = next }
|
||||||
( { model | allNameModel = next }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = False
|
||||||
)
|
, dragDrop = dd
|
||||||
False
|
}
|
||||||
|
|
||||||
SetFulltext str ->
|
SetFulltext str ->
|
||||||
let
|
let
|
||||||
next =
|
next =
|
||||||
Util.Maybe.fromString str
|
Util.Maybe.fromString str
|
||||||
in
|
in
|
||||||
NextState
|
{ model = { model | fulltextModel = next }
|
||||||
( { model | fulltextModel = next }
|
, cmd = Cmd.none
|
||||||
, Cmd.none
|
, stateChange = False
|
||||||
)
|
, dragDrop = dd
|
||||||
False
|
}
|
||||||
|
|
||||||
KeyUpMsg (Just Enter) ->
|
KeyUpMsg (Just Enter) ->
|
||||||
NextState ( model, Cmd.none ) True
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = True
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
KeyUpMsg _ ->
|
KeyUpMsg _ ->
|
||||||
NextState ( model, Cmd.none ) False
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
ToggleNameHelp ->
|
ToggleNameHelp ->
|
||||||
NextState ( { model | showNameHelp = not model.showNameHelp }, Cmd.none ) False
|
{ model = { model | showNameHelp = not model.showNameHelp }
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetFolderResp (Ok fs) ->
|
GetFolderResp (Ok fs) ->
|
||||||
let
|
let
|
||||||
model_ =
|
model_ =
|
||||||
{ model | folderList = Comp.FolderSelect.init fs.items }
|
{ model | folderList = Comp.FolderSelect.init fs.items }
|
||||||
in
|
in
|
||||||
NextState
|
{ model = model_
|
||||||
( model_, Cmd.none )
|
, cmd = Cmd.none
|
||||||
False
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
GetFolderResp (Err _) ->
|
GetFolderResp (Err _) ->
|
||||||
noChange ( model, Cmd.none )
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = dd
|
||||||
|
}
|
||||||
|
|
||||||
FolderSelectMsg lm ->
|
FolderSelectMsg lm ->
|
||||||
let
|
let
|
||||||
( fsm, sel ) =
|
( fsm, sel, dd_ ) =
|
||||||
Comp.FolderSelect.update lm model.folderList
|
Comp.FolderSelect.updateDrop dd.folderDrop lm model.folderList
|
||||||
in
|
in
|
||||||
NextState
|
{ model =
|
||||||
( { model
|
{ model
|
||||||
| folderList = fsm
|
| folderList = fsm
|
||||||
, selectedFolder = sel
|
, selectedFolder = sel
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, cmd = Cmd.none
|
||||||
)
|
, stateChange = model.selectedFolder /= sel
|
||||||
(model.selectedFolder /= sel)
|
, dragDrop = { dd | folderDrop = dd_ }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -552,7 +610,12 @@ update flags settings msg model =
|
|||||||
|
|
||||||
|
|
||||||
view : Flags -> UiSettings -> Model -> Html Msg
|
view : Flags -> UiSettings -> Model -> Html Msg
|
||||||
view flags settings model =
|
view =
|
||||||
|
viewDrop (DragDropData DD.init)
|
||||||
|
|
||||||
|
|
||||||
|
viewDrop : DragDropData -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
|
viewDrop ddd flags settings model =
|
||||||
let
|
let
|
||||||
formHeader icon headline =
|
formHeader icon headline =
|
||||||
div [ class "ui tiny header" ]
|
div [ class "ui tiny header" ]
|
||||||
@ -585,7 +648,7 @@ view flags settings model =
|
|||||||
[ Html.map TagSelectMsg (Comp.TagSelect.viewTags settings model.tagSelectModel)
|
[ Html.map TagSelectMsg (Comp.TagSelect.viewTags settings model.tagSelectModel)
|
||||||
, Html.map TagSelectMsg (Comp.TagSelect.viewCats settings model.tagSelectModel)
|
, Html.map TagSelectMsg (Comp.TagSelect.viewCats settings model.tagSelectModel)
|
||||||
, Html.map FolderSelectMsg
|
, Html.map FolderSelectMsg
|
||||||
(Comp.FolderSelect.view settings.searchMenuFolderCount model.folderList)
|
(Comp.FolderSelect.viewDrop ddd.folderDrop settings.searchMenuFolderCount model.folderList)
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
, div [ class segmentClass ]
|
||||||
[ formHeader (Icons.correspondentIcon "")
|
[ formHeader (Icons.correspondentIcon "")
|
||||||
|
@ -16,10 +16,11 @@ import Api.Model.ItemLightList exposing (ItemLightList)
|
|||||||
import Api.Model.ItemSearch
|
import Api.Model.ItemSearch
|
||||||
import Comp.FixedDropdown
|
import Comp.FixedDropdown
|
||||||
import Comp.ItemCardList
|
import Comp.ItemCardList
|
||||||
import Comp.SearchMenu
|
import Comp.SearchMenu exposing (DragDropData)
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.Items
|
import Data.Items
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
|
import Html5.DragDrop as DD
|
||||||
import Http
|
import Http
|
||||||
import Throttle exposing (Throttle)
|
import Throttle exposing (Throttle)
|
||||||
import Util.Html exposing (KeyCode(..))
|
import Util.Html exposing (KeyCode(..))
|
||||||
@ -39,6 +40,7 @@ type alias Model =
|
|||||||
, searchType : SearchType
|
, searchType : SearchType
|
||||||
, searchTypeForm : SearchType
|
, searchTypeForm : SearchType
|
||||||
, contentOnlySearch : Maybe String
|
, contentOnlySearch : Maybe String
|
||||||
|
, dragDropData : DragDropData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +69,9 @@ init flags =
|
|||||||
, searchType = BasicSearch
|
, searchType = BasicSearch
|
||||||
, searchTypeForm = defaultSearchType flags
|
, searchTypeForm = defaultSearchType flags
|
||||||
, contentOnlySearch = Nothing
|
, contentOnlySearch = Nothing
|
||||||
|
, dragDropData =
|
||||||
|
{ folderDrop = DD.init
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import Comp.ItemCardList
|
|||||||
import Comp.SearchMenu
|
import Comp.SearchMenu
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
|
import Html5.DragDrop as DD
|
||||||
import Page exposing (Page(..))
|
import Page exposing (Page(..))
|
||||||
import Page.Home.Data exposing (..)
|
import Page.Home.Data exposing (..)
|
||||||
import Throttle
|
import Throttle
|
||||||
@ -39,10 +40,18 @@ update key flags settings msg model =
|
|||||||
SearchMenuMsg m ->
|
SearchMenuMsg m ->
|
||||||
let
|
let
|
||||||
nextState =
|
nextState =
|
||||||
Comp.SearchMenu.update flags settings m model.searchMenuModel
|
Comp.SearchMenu.updateDrop
|
||||||
|
model.dragDropData
|
||||||
|
flags
|
||||||
|
settings
|
||||||
|
m
|
||||||
|
model.searchMenuModel
|
||||||
|
|
||||||
newModel =
|
newModel =
|
||||||
{ model | searchMenuModel = Tuple.first nextState.modelCmd }
|
{ model
|
||||||
|
| searchMenuModel = nextState.model
|
||||||
|
, dragDropData = nextState.dragDrop
|
||||||
|
}
|
||||||
|
|
||||||
( m2, c2, s2 ) =
|
( m2, c2, s2 ) =
|
||||||
if nextState.stateChange && not model.searchInProgress then
|
if nextState.stateChange && not model.searchInProgress then
|
||||||
@ -54,18 +63,21 @@ update key flags settings msg model =
|
|||||||
( m2
|
( m2
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ c2
|
[ c2
|
||||||
, Cmd.map SearchMenuMsg (Tuple.second nextState.modelCmd)
|
, Cmd.map SearchMenuMsg nextState.cmd
|
||||||
]
|
]
|
||||||
, s2
|
, s2
|
||||||
)
|
)
|
||||||
|
|
||||||
ItemCardListMsg m ->
|
ItemCardListMsg m ->
|
||||||
let
|
let
|
||||||
( m2, c2, mitem ) =
|
result =
|
||||||
Comp.ItemCardList.update flags m model.itemListModel
|
Comp.ItemCardList.updateDrag model.dragDropData.folderDrop
|
||||||
|
flags
|
||||||
|
m
|
||||||
|
model.itemListModel
|
||||||
|
|
||||||
cmd =
|
cmd =
|
||||||
case mitem of
|
case result.selected of
|
||||||
Just item ->
|
Just item ->
|
||||||
Page.set key (ItemDetailPage item.id)
|
Page.set key (ItemDetailPage item.id)
|
||||||
|
|
||||||
@ -73,8 +85,11 @@ update key flags settings msg model =
|
|||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
withSub
|
withSub
|
||||||
( { model | itemListModel = m2 }
|
( { model
|
||||||
, Cmd.batch [ Cmd.map ItemCardListMsg c2, cmd ]
|
| itemListModel = result.model
|
||||||
|
, dragDropData = { folderDrop = result.dragModel }
|
||||||
|
}
|
||||||
|
, Cmd.batch [ Cmd.map ItemCardListMsg result.cmd, cmd ]
|
||||||
)
|
)
|
||||||
|
|
||||||
ItemSearchResp (Ok list) ->
|
ItemSearchResp (Ok list) ->
|
||||||
|
@ -63,7 +63,12 @@ view flags settings model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class "ui attached fluid segment" ]
|
, 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
|
, div
|
||||||
|
@ -166,7 +166,7 @@ textarea.markdown-editor {
|
|||||||
background: rgba(240,248,255,0.4);
|
background: rgba(240,248,255,0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.default-layout .ui.menu .item.current-drop-target {
|
.default-layout .ui.menu .item.current-drop-target, a.item.current-drop-target {
|
||||||
background: rgba(0,0,0,0.2);
|
background: rgba(0,0,0,0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user