Skip to content

Commit

Permalink
Update FilePicker with reordering functionality (Issue #13).
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Dec 21, 2020
1 parent 889b86c commit f3a11f0
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 40 deletions.
5 changes: 3 additions & 2 deletions src/Client/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ type PersistentStorageMsg =
| UpdateAppVersion of string

type FilePickerMsg =
| NewFilesLoaded of string list
| RemoveFileFromFileList of string
| LoadNewFiles of string list
| UpdateFileNames of newFileNames:(int*string) list
| UpdateDNDDropped of isDropped:bool

type AddBuildingBlockMsg =
| NewBuildingBlockSelected of AnnotationBuildingBlock
Expand Down
7 changes: 6 additions & 1 deletion src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,15 @@ type PageState = {
}

type FilePickerState = {
FileNames : string list
FileNames : (int*string) list
/// Used for drag and drop, to determine if something is currently dragged or not.
/// Necessary to deactivate pointer events on children during drag.
DNDDropped : bool
} with
static member init () = {
FileNames = []
/// This is used to deactivate pointerevents of drag and drop childs during drag and drop
DNDDropped = true
}


Expand Down
1 change: 1 addition & 0 deletions src/Client/OfficeInterop/OfficeInterop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ let insertFileNamesFromFilePicker (annotationTable, fileNameList:string list) =
])

range.values <- newVals
range.format.autofitColumns()
r.enableEvents <- true
//sprintf "%s filled with %s; ExtraCols: %s" range.address v nextColsRange.address

Expand Down
20 changes: 11 additions & 9 deletions src/Client/Update.fs
Original file line number Diff line number Diff line change
Expand Up @@ -923,22 +923,24 @@ let handleStyleChangeMsg (styleChangeMsg:StyleChangeMsg) (currentState:SiteStyle

let handleFilePickerMsg (filePickerMsg:FilePickerMsg) (currentState: FilePickerState) : FilePickerState * Cmd<Msg> =
match filePickerMsg with
| NewFilesLoaded fileNames ->
| LoadNewFiles fileNames ->
let nextState = {
FilePickerState.init() with
FileNames = fileNames |> List.mapi (fun i x -> i+1,x)
}
let nextCmd = UpdatePageState (Some Routing.Route.FilePicker) |> Cmd.ofMsg
nextState, nextCmd
| UpdateFileNames newFileNames ->
let nextState = {
currentState with
FileNames = fileNames
FileNames = newFileNames
}

nextState, Cmd.none

| RemoveFileFromFileList fileName ->
| UpdateDNDDropped isDropped ->
let nextState = {
currentState with
FileNames =
currentState.FileNames
|> List.filter (fun fn -> not (fn = fileName))
DNDDropped = isDropped
}

nextState, Cmd.none

let handleAddBuildingBlockMsg (addBuildingBlockMsg:AddBuildingBlockMsg) (currentState: AddBuildingBlockState) : AddBuildingBlockState * Cmd<Msg> =
Expand Down
Loading

0 comments on commit f3a11f0

Please sign in to comment.