@@ -21,6 +21,7 @@ type alias Model =
2121 , ciphersListFilter : CiphersFilter
2222 , scroll : InfiniteScroll.Model Msg
2323 , sublist : { end : Int }
24+ , cipherSelectDropdownVisivble : Bool
2425 }
2526
2627
@@ -83,13 +84,14 @@ type Msg
8384 | LogOut
8485 | LoadMore InfiniteScroll.Direction
8586 | InfiniteScrollMsg InfiniteScroll.Msg
86− | CreateNewCipher
87+ | CreateNewCipher Bridge.CipherType
88+ | ToggleSelectCipherTypeVisible
8789
8890
8991type alias Callbacks msg =
9092 { selected : String -> msg
9193 , logOut : msg
92− , createNewCipher : msg
94+ , createNewCipher : Bridge.CipherType -> msg
9395 }
9496
9597
@@ -100,7 +102,7 @@ page callbacks liftMsg =
100102 , update = \msg model -> update callbacks liftMsg msg model
101103 , subscriptions = \model -> subscriptions model |> Sub.map liftMsg
102104 , title =
103− \{ ciphersListFilter } ->
105+ \{ ciphersListFilter, cipherSelectDropdownVisivble } ->
104106 [ text
105107 (case ciphersListFilter of
106108 AllCiphers ->
@@ -120,7 +122,49 @@ page callbacks liftMsg =
120122 Bridge.NoteType ->
121123 "Notes"
122124 )
123− , span [ Attr.class "u-float-right" ] [ iconButton "plus" (liftMsg CreateNewCipher) ]
125+ , span [ Attr.class "u-float-right" ]
126+ [ span [ Attr.class "p-contextual-menu" ]
127+ ([ span [] [ iconButton "plus" (liftMsg ToggleSelectCipherTypeVisible) ]
128+ ]
129+ ++ optionals cipherSelectDropdownVisivble
130+ [ div
131+ [ Attr.class "overlay"
132+ , Ev.onClick (liftMsg ToggleSelectCipherTypeVisible)
133+ ]
134+ []
135+ , span
136+ [ Attr.class "p-contextual-menu__dropdown"
137+ , Attr.attribute "aria-hidden" "false"
138+ ]
139+ (let
140+ create t =
141+ liftMsg (CreateNewCipher t)
142+ in
143+ [ button
144+ [ Attr.class "p-contextual-menu__link"
145+ , Ev.onClick (create Bridge.LoginType)
146+ ]
147+ [ text "Login" ]
148+ , button
149+ [ Attr.class "p-contextual-menu__link"
150+ , Ev.onClick (create Bridge.CardType)
151+ ]
152+ [ text "Card" ]
153+ , button
154+ [ Attr.class "p-contextual-menu__link"
155+ , Ev.onClick (create Bridge.NoteType)
156+ ]
157+ [ text "Note" ]
158+ , button
159+ [ Attr.class "p-contextual-menu__link"
160+ , Ev.onClick (create Bridge.IdentityType)
161+ ]
162+ [ text "Contact" ]
163+ ]
164+ )
165+ ]
166+ )
167+ ]
124168 ]
125169 , event =
126170 \model ev ->
@@ -152,6 +196,7 @@ init ciphers =
152196 , ciphersListFilter = AllCiphers
153197 , scroll = InfiniteScroll.init (LoadMore >> pureCmd)
154198 , sublist = { end = 20 }
199+ , cipherSelectDropdownVisivble = False
155200 }
156201 , Cmd.none
157202 )
@@ -194,8 +239,13 @@ update { logOut, createNewCipher } liftMsg msg model =
194239 in
195240 ( Ok { model | scroll = scroll }, Cmd.map liftMsg cmd )
196241
197− CreateNewCipher ->
198− ( Ok model, pureCmd createNewCipher )
242+ CreateNewCipher t ->
243+ ( Ok { model | cipherSelectDropdownVisivble = False }, pureCmd (createNewCipher t) )
244+
245+ ToggleSelectCipherTypeVisible ->
246+ ( Ok { model | cipherSelectDropdownVisivble = not model.cipherSelectDropdownVisivble }
247+ , Cmd.none
248+ )
199249
200250
201251subscriptions : Model -> Sub Msg