From c254248886ff1f99f96c0dde7d09541bc6979248 Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Thu, 4 Oct 2018 15:00:33 -0400 Subject: [PATCH] SPARK-1538: Clones incoming --- src/web/ui/src/Users/State.fs | 4 ++-- src/web/ui/src/Users/Types.fs | 2 +- src/web/ui/src/Users/View.fs | 31 +++++++++---------------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/web/ui/src/Users/State.fs b/src/web/ui/src/Users/State.fs index 18f708009..dc61a1346 100644 --- a/src/web/ui/src/Users/State.fs +++ b/src/web/ui/src/Users/State.fs @@ -226,8 +226,8 @@ let update msg (model:Users.Types.Model) : Model * Cmd = model, Cmd.Empty | UpdateField field -> { model with scratchUser = applyUpdate field model.scratchUser; ConfirmModal = ("", Msg.SwitchTab model.currentTab) } , Cmd.Empty - | Clone usr -> - { model with scratchUser = { usr with id = 0u; name = usr.name + "_copy" }}, Cmd.Empty + | CloneUser -> + { model with PreviousScratchUser = model.scratchUser; scratchUser = { model.scratchUser with id = 0u; name = sprintf "%s_clone" model.scratchUser.name }; OptionsMenuOpen = ""}, Cmd.ofMsg (SwitchTab General) | CopyFrom (usrSrc, usrDest) -> let nusr = { usrSrc with id = usrDest.id diff --git a/src/web/ui/src/Users/Types.fs b/src/web/ui/src/Users/Types.fs index 985232714..a4f71feca 100644 --- a/src/web/ui/src/Users/Types.fs +++ b/src/web/ui/src/Users/Types.fs @@ -36,7 +36,7 @@ type Msg = | RpcResponse of string | UpdateAdminData of AdminData | UpdateField of UserField - | Clone of BTSUser + | CloneUser | CopyFrom of BTSUser * BTSUser | Delete of BTSUser | AddUser diff --git a/src/web/ui/src/Users/View.fs b/src/web/ui/src/Users/View.fs index 4f3e8a72e..0ecb7f512 100644 --- a/src/web/ui/src/Users/View.fs +++ b/src/web/ui/src/Users/View.fs @@ -178,27 +178,6 @@ let userControls (model:Model) (dispatch:Msg->Unit) = [ saveButton model dispatch Button.button "Revert" "" "" (if dirty then Button.Enabled else Button.Disabled) (fun _ -> SwitchUser (currentUser) |> dispatch) - (*p [ ClassName "control" ] - [ a [ ClassName "button is-light" - Title "Clone" - OnClick (fun _ -> dispatch <| Clone currentUser) - Disabled disabled - ] - [ span [ ClassName "icon is-small" ] - [ i [ ClassName "fa fa-clone" ] - [ ] ] - ] - ]*) - (*p [ ClassName "control" ] - [ a [ ClassName "button is-light" ] - [ span [ ClassName "icon is-small" - Title "Copy from user 1 ..." - OnClick (fun _ -> dispatch <| CopyFrom (usersList.Head, currentUser)) - ] - [ i [ ClassName "fa fa-copy" ] - [ ] ] - ] - ]*) ] @@ -276,7 +255,11 @@ let userSelectionGrid (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:M let menuItem (user:BTSUser) (selectedUser:BTSUser) model dispatch = a [ ClassName (isActiveUser user.id selectedUser) - OnClick (fun _ -> SwitchUser user |> dispatch) + OnClick (fun _ -> + match user.name = model.OptionsMenuOpen with + | false -> SwitchUser user |> dispatch + | _ -> () + ) ] [ span [] [ str user.name ] span [ Class "is-pulled-right menu-icon" ] @@ -305,6 +288,10 @@ let menuItem (user:BTSUser) (selectedUser:BTSUser) model dispatch = OnClick (fun _ -> dispatch <| Delete user) ] [ str "Remove" ] + a [ Class "dropdown-item" + OnClick (fun _ -> dispatch <| CloneUser) + ] + [ str "Clone" ] ] ] ]