@@ -16,6 +16,7 @@ import Pages.Loader exposing (loader)
16import Pages.Login as Login
16import Pages.Login as Login
17import Pages.MasterPassword as MasterPassword
17import Pages.MasterPassword as MasterPassword
18import Pages.Navigation as Navigation exposing (TopButton(..))
18import Pages.Navigation as Navigation exposing (TopButton(..))
19+import Pages.SelectCipherType as SelectCipherType
19import Task
20import Task
20import Time
21import Time
21import Types exposing (CipherId)
22import Types exposing (CipherId)
@@ -58,8 +59,12 @@ type Msg
58 | UpdateLastNotificatioTime Time.Posix
59 | UpdateLastNotificatioTime Time.Posix
59 | EditCipher Bridge.FullCipher
60 | EditCipher Bridge.FullCipher
60 | UpdateCipher Bridge.FullCipher
61 | UpdateCipher Bridge.FullCipher
62+ | CreateCipher Bridge.FullCipher
61 | FireGlobalEvent Event
63 | FireGlobalEvent Event
62 | GeneratePassword Bridge.PasswordGeneratorConfig
64 | GeneratePassword Bridge.PasswordGeneratorConfig
66+ | SelectCipherTypeMsg SelectCipherType.Msg
67+ | OpenNewCipherEditPage Bridge.CipherType
65type alias Model =
70type alias Model =
@@ -79,10 +84,11 @@ type PageModel
79 = LoginModel Login.Model
84 = LoginModel Login.Model
80 | LoadingPage
85 | LoadingPage
81 | CiphersModel Ciphers.Model
86 | CiphersModel Ciphers.Model
82− | EditCipherModel EditCipher.Model
87+ | EditCipherModel (EditCipher.Model Msg)
83 | MasterPasswordModel MasterPassword.Model
88 | MasterPasswordModel MasterPassword.Model
84 | CipherModel Cipher.Model
89 | CipherModel Cipher.Model
85 | CaptchaModel Captcha.Model
90 | CaptchaModel Captcha.Model
91+ | SelectCipherTypeModel SelectCipherType.Model
@@ -162,13 +168,23 @@ showPage email page =
162 EditCipherModel model ->
168 EditCipherModel model ->
165− EditCipher.page editCipherCallbacks EditCipherMsg
171+ EditCipher.page EditCipherMsg
167 { title = p.title model
173 { title = p.title model
168 , body = p.view model
174 , body = p.view model
169 , topButton = Just (BackButton { action = PopView, icon = Just "close" })
175 , topButton = Just (BackButton { action = PopView, icon = Just "close" })
178+ SelectCipherTypeModel model ->
181+ SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg
183+ { title = p.title model
184+ , body = p.view model
185+ , topButton = Just simpleBackButton
173main : Program () Model Msg
189main : Program () Model Msg
@@ -263,6 +279,9 @@ doNotStoreInHistory page =
263 LoadingPage ->
279 LoadingPage ->
282+ SelectCipherTypeModel _ ->
@@ -388,8 +407,6 @@ update msg model =
391− -- (Ciphers.page ciphersCallbacks CiphersMsg).init ciphers
392− -- |> Tuple.mapFirst (\pageModel -> appendPageStack <| CiphersModel pageModel)
393 OpenCiphersScreen ->
410 OpenCiphersScreen ->
394 ( appendPageStack <| LoadingPage, Cmd.batch [ sendBridge Bridge.NeedCiphersList, sendBridge Bridge.NeedEmail ] )
411 ( appendPageStack <| LoadingPage, Cmd.batch [ sendBridge Bridge.NeedCiphersList, sendBridge Bridge.NeedEmail ] )
@@ -425,7 +442,7 @@ update msg model =
425 EditCipherMsg imsg ->
442 EditCipherMsg imsg ->
426 case currentPage of
443 case currentPage of
427 EditCipherModel page ->
444 EditCipherModel page ->
428− (EditCipher.page editCipherCallbacks EditCipherMsg).update imsg page |> processPage EditCipherModel
445+ (EditCipher.page EditCipherMsg).update imsg page |> processPage EditCipherModel
431 ( model, Cmd.none )
448 ( model, Cmd.none )
@@ -479,7 +496,7 @@ update msg model =
479 ( model, Cmd.none )
496 ( model, Cmd.none )
481 EditCipher cipher ->
498 EditCipher cipher ->
482− (EditCipher.page editCipherCallbacks EditCipherMsg).init cipher
499+ (EditCipher.page EditCipherMsg).init { fullCipher = cipher, callbacks = editCipherCallbacks }
483 |> Tuple.mapFirst (\pageModel -> keepStackWith <| EditCipherModel pageModel)
500 |> Tuple.mapFirst (\pageModel -> keepStackWith <| EditCipherModel pageModel)
485 UpdateCipher cipher ->
502 UpdateCipher cipher ->
@@ -491,6 +508,14 @@ update msg model =
511+ CreateCipher cipher ->
514+ [ Bridge.CreateCipher cipher |> sendBridge
515+ , PopView |> pureCmd
494 FireGlobalEvent ev ->
519 FireGlobalEvent ev ->
495 ( { model
520 ( { model
496 | pageStack =
521 | pageStack =
@@ -514,10 +539,13 @@ update msg model =
514 (Cipher.page cipherCallbacks CipherMsg).event m ev |> CipherModel
539 (Cipher.page cipherCallbacks CipherMsg).event m ev |> CipherModel
516 EditCipherModel m ->
541 EditCipherModel m ->
517− (EditCipher.page editCipherCallbacks EditCipherMsg).event m ev |> EditCipherModel
542+ (EditCipher.page EditCipherMsg).event m ev |> EditCipherModel
519 CaptchaModel m ->
544 CaptchaModel m ->
520 (Captcha.page captchaCallbacks CaptchaMsg).event m ev |> CaptchaModel
545 (Captcha.page captchaCallbacks CaptchaMsg).event m ev |> CaptchaModel
547+ SelectCipherTypeModel m ->
548+ (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).event m ev |> SelectCipherTypeModel
523 , Cmd.none
551 , Cmd.none
@@ -526,6 +554,73 @@ update msg model =
526 GeneratePassword cfg ->
554 GeneratePassword cfg ->
527 ( model, FFI.sendBridge (Bridge.GeneratePassword cfg) )
555 ( model, FFI.sendBridge (Bridge.GeneratePassword cfg) )
557+ SelectCipherTypeMsg imsg ->
559+ SelectCipherTypeModel page ->
560+ (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).update imsg page |> processPage SelectCipherTypeModel
566+ (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).init ()
567+ |> Tuple.mapFirst (\pageModel -> appendPageStack <| SelectCipherTypeModel pageModel)
569+ OpenNewCipherEditPage t ->
570+ (EditCipher.page EditCipherMsg).init
571+ { callbacks = createCipherCallbacks
582+ , username = Nothing
583+ , password = Nothing
587+ Bridge.NoteCipher ""
591+ { cardholderName = Nothing
594+ , expMonth = Nothing
599+ Bridge.IdentityType ->
600+ Bridge.IdentityCipher
602+ , firstName = Nothing
603+ , middleName = Nothing
604+ , lastName = Nothing
605+ , address1 = Nothing
606+ , address2 = Nothing
607+ , address3 = Nothing
610+ , postalCode = Nothing
616+ , username = Nothing
617+ , passportNumber = Nothing
618+ , licenseNumber = Nothing
622+ |> Tuple.mapFirst (\pageModel -> keepStackWith <| EditCipherModel pageModel)
530loginCallbacks : Login.Callbacks Msg
625loginCallbacks : Login.Callbacks Msg
531loginCallbacks =
626loginCallbacks =
@@ -534,7 +629,10 @@ loginCallbacks =
535ciphersCallbacks : Ciphers.Callbacks Msg
630ciphersCallbacks : Ciphers.Callbacks Msg
536ciphersCallbacks =
631ciphersCallbacks =
537− { selected = RequestCipher, logOut = NeedsReset }
632+ { selected = RequestCipher
633+ , logOut = NeedsReset
634+ , createNewCipher = CreateNewCipher
540cipherCallbacks : Cipher.Callbacks Msg
638cipherCallbacks : Cipher.Callbacks Msg
@@ -547,6 +645,11 @@ editCipherCallbacks =
547 { save = UpdateCipher, generatePassword = GeneratePassword }
645 { save = UpdateCipher, generatePassword = GeneratePassword }
648+createCipherCallbacks : EditCipher.Callbacks Msg
649+createCipherCallbacks =
650+ { save = CreateCipher, generatePassword = GeneratePassword }
550captchaCallbacks : Captcha.Callbacks
653captchaCallbacks : Captcha.Callbacks
551captchaCallbacks =
654captchaCallbacks =
@@ -557,3 +660,8 @@ masterPasswordCallbacks =
557 { submit = SendMasterPassword
660 { submit = SendMasterPassword
558 , reset = NeedsReset
661 , reset = NeedsReset
665+selectCipherTypeCallbacks : SelectCipherType.Callbacks Msg
666+selectCipherTypeCallbacks =
667+ { choose = OpenNewCipherEditPage }