on master help sign in
Updated name
commit83e9a4eb12fb9cd6937cc8b1bffdc76dca52f5e9 authoriko <ilyakooo0@gmail.com> dateThu 11 Aug 2022, 15:06 (4 years ago) parent517e90f
1 file changed+272−261
frontend/Pages/EditCipher.elm+272−261
frontend/Pages/EditCipher.elm+272−261
@@ -6,7 +6,6 @@ import Html exposing (..)
66import Html.Attributes as Attr
77import Html.Events as Ev
88import Page exposing (..)
9−import Types exposing (CipherId)
109import Utils exposing (..)
1110
1211
@@ -85,275 +84,287 @@ row { name, nameIcon, attrs } =
8584
8685view : Model -> List (Html Msg)
8786view { fullCipher } =
88− case fullCipher.cipher of
89− Bridge.LoginCipher cipher ->
90− let
91− { username, password, uris } =
92− cipher
93−
94− edit c =
95− { fullCipher | cipher = Bridge.LoginCipher c } |> EditCipher
96− in
97− [ row
98− { name = "Username"
99− , nameIcon = "user"
100− , attrs =
101− [ Attr.type_ "text"
102− , Attr.value (Maybe.withDefault "" username)
103− , Ev.onInput (\x -> edit { cipher | username = Just x })
104− , Attr.attribute "autocomplete" "username"
105− ]
106− }
107− , row
108− { name = "Password"
109− , nameIcon = "security"
110− , attrs =
111− [ Attr.type_ "text"
112− , Attr.value (Maybe.withDefault "" password)
113− , Ev.onInput (\x -> edit { cipher | password = Just x })
114− , Attr.attribute "autocomplete" "new-password"
115− ]
116− }
87+ [ row
88+ { name = "Entry name"
89+ , nameIcon = ""
90+ , attrs =
91+ [ Attr.type_ "text"
92+ , Attr.value fullCipher.name
93+ , Ev.onInput (\x -> { fullCipher | name = x } |> EditCipher)
94+ , Attr.attribute "autocomplete" "off"
11795 ]
118− ++ (uris
119− |> List.indexedMap
120− (\i uri ->
121− row
122− { name = "URL"
123− , nameIcon = "get-link"
124− , attrs =
125− [ Attr.type_ "url"
126− , Attr.value uri
127− , Ev.onInput (\x -> edit { cipher | uris = replace i x uris })
128− ]
129− }
130− )
131− )
132− ++ [ row
133− { name = "URL"
134− , nameIcon = "get-link"
96+ }
97+ ]
98+ ++ (case fullCipher.cipher of
99+ Bridge.LoginCipher cipher ->
100+ let
101+ { username, password, uris } =
102+ cipher
103+
104+ edit c =
105+ { fullCipher | cipher = Bridge.LoginCipher c } |> EditCipher
106+ in
107+ [ row
108+ { name = "Username"
109+ , nameIcon = "user"
135110 , attrs =
136− [ Attr.type_ "url"
137− , Ev.onInput (\x -> edit { cipher | uris = uris ++ [ x ] })
111+ [ Attr.type_ "text"
112+ , Attr.value (Maybe.withDefault "" username)
113+ , Ev.onInput (\x -> edit { cipher | username = Just x })
114+ , Attr.attribute "autocomplete" "username"
115+ ]
116+ }
117+ , row
118+ { name = "Password"
119+ , nameIcon = "security"
120+ , attrs =
121+ [ Attr.type_ "text"
122+ , Attr.value (Maybe.withDefault "" password)
123+ , Ev.onInput (\x -> edit { cipher | password = Just x })
124+ , Attr.attribute "autocomplete" "new-password"
138125 ]
139126 }
140− ]
141−
142− Bridge.NoteCipher contents ->
143− [ p []
144− [ heading "switcher-environments" "Note"
145− , br [] []
146− , textarea
147− [ Attr.spellcheck True
148− , Attr.style "height" "70vh"
149− , Attr.value contents
150− , Ev.onInput (\x -> EditCipher { fullCipher | cipher = Bridge.NoteCipher x })
151− ]
152− []
153− ]
154− ]
155−
156− Bridge.CardCipher cipher ->
157− let
158− { number, code, cardholderName, expMonth, expYear } =
159− cipher
160−
161− edit c =
162− { fullCipher | cipher = Bridge.CardCipher c } |> EditCipher
163− in
164− [ row
165− { name = "Card number"
166− , nameIcon = "containers"
167− , attrs =
168− [ Attr.attribute "autocomplete" "cc-number"
169− , Attr.type_ "text"
170− , Attr.value (Maybe.withDefault "" number)
171− , Ev.onInput (\x -> edit { cipher | number = Just x })
172− ]
173− }
174− , p []
175− [ heading "timed-out" "Expiration date"
176− , br [] []
177− , input
178− [ Attr.attribute "autocomplete" "cc-exp-month"
179− , Attr.type_ "text"
180− , Attr.value (Maybe.withDefault "" expMonth)
181− , Ev.onInput (\x -> edit { cipher | expMonth = Just x })
182− , Attr.style "width" "20%"
183− , Attr.class "u-align--right"
184− ]
185− []
186− , text " / "
187− , input
188− [ Attr.attribute "autocomplete" "cc-exp-year"
189− , Attr.type_ "text"
190− , Attr.value (Maybe.withDefault "" expYear)
191− , Ev.onInput (\x -> edit { cipher | expYear = Just x })
192− , Attr.style "width" "20%"
193− ]
194− []
195− ]
196− , row
197− { name = "CVV"
198− , nameIcon = "security"
199− , attrs =
200− [ Attr.attribute "autocomplete" "cc-csc"
201− , Attr.type_ "text"
202− , Attr.value (Maybe.withDefault "" code)
203− , Ev.onInput (\x -> edit { cipher | code = Just x })
204127 ]
205− }
206− , row
207− { name = "Cardholder name"
208− , nameIcon = "user"
209− , attrs =
210− [ Attr.attribute "autocomplete" "cc-name"
211− , Attr.type_ "text"
212− , Attr.value (Maybe.withDefault "" cardholderName)
213− , Ev.onInput (\x -> edit { cipher | cardholderName = Just x })
128+ ++ (uris
129+ |> List.indexedMap
130+ (\i uri ->
131+ row
132+ { name = "URL"
133+ , nameIcon = "get-link"
134+ , attrs =
135+ [ Attr.type_ "url"
136+ , Attr.value uri
137+ , Ev.onInput (\x -> edit { cipher | uris = replace i x uris })
138+ ]
139+ }
140+ )
141+ )
142+ ++ [ row
143+ { name = "URL"
144+ , nameIcon = "get-link"
145+ , attrs =
146+ [ Attr.type_ "url"
147+ , Ev.onInput (\x -> edit { cipher | uris = uris ++ [ x ] })
148+ ]
149+ }
150+ ]
151+
152+ Bridge.NoteCipher contents ->
153+ [ p []
154+ [ heading "switcher-environments" "Note"
155+ , br [] []
156+ , textarea
157+ [ Attr.spellcheck True
158+ , Attr.style "height" "70vh"
159+ , Attr.value contents
160+ , Ev.onInput (\x -> EditCipher { fullCipher | cipher = Bridge.NoteCipher x })
161+ ]
162+ []
163+ ]
214164 ]
215− }
216− ]
217165
218− Bridge.IdentityCipher cipher ->
219− let
220− { address1, address2, address3, company, email, firstName, lastName, licenseNumber, middleName, passportNumber, phone, ssn, username } =
221− cipher
222−
223− edit c =
224− { fullCipher | cipher = Bridge.IdentityCipher c } |> EditCipher
225− in
226− [ row
227− { name = "First name"
228− , nameIcon = ""
229− , attrs =
230− [ Attr.attribute "autocomplete" "given-name"
231− , Attr.type_ "text"
232− , Attr.value (Maybe.withDefault "" firstName)
233− , Ev.onInput (\x -> edit { cipher | firstName = Just x })
234− ]
235− }
236− , row
237− { name = "Middle name"
238− , nameIcon = ""
239− , attrs =
240− [ Attr.attribute "autocomplete" "additional-name"
241− , Attr.type_ "text"
242− , Attr.value (Maybe.withDefault "" middleName)
243− , Ev.onInput (\x -> edit { cipher | middleName = Just x })
244− ]
245− }
246− , row
247− { name = "Last name"
248− , nameIcon = ""
249− , attrs =
250− [ Attr.attribute "autocomplete" "family-name"
251− , Attr.type_ "text"
252− , Attr.value (Maybe.withDefault "" lastName)
253− , Ev.onInput (\x -> edit { cipher | lastName = Just x })
254− ]
255− }
256− , row
257− { name = "Username"
258− , nameIcon = ""
259− , attrs =
260− [ Attr.attribute "autocomplete" "username"
261− , Attr.type_ "text"
262− , Attr.value (Maybe.withDefault "" username)
263− , Ev.onInput (\x -> edit { cipher | username = Just x })
264− ]
265− }
266− , row
267− { name = "Company"
268− , nameIcon = ""
269− , attrs =
270− [ Attr.attribute "autocomplete" "organization"
271− , Attr.type_ "text"
272− , Attr.value (Maybe.withDefault "" company)
273− , Ev.onInput (\x -> edit { cipher | company = Just x })
274− ]
275− }
276− , row
277− { name = "Social security number"
278− , nameIcon = ""
279− , attrs =
280− [ Attr.attribute "autocomplete" "off"
281− , Attr.type_ "number"
282− , Attr.value (Maybe.withDefault "" ssn)
283− , Ev.onInput (\x -> edit { cipher | ssn = Just x })
284− ]
285− }
286− , row
287− { name = "Passport number"
288− , nameIcon = ""
289− , attrs =
290− [ Attr.attribute "autocomplete" "off"
291− , Attr.type_ "number"
292− , Attr.value (Maybe.withDefault "" passportNumber)
293− , Ev.onInput (\x -> edit { cipher | passportNumber = Just x })
294− ]
295− }
296− , row
297− { name = "License Number"
298− , nameIcon = ""
299− , attrs =
300− [ Attr.attribute "autocomplete" "off"
301− , Attr.type_ "number"
302− , Attr.value (Maybe.withDefault "" licenseNumber)
303− , Ev.onInput (\x -> edit { cipher | licenseNumber = Just x })
304− ]
305− }
306− , row
307− { name = "Email"
308− , nameIcon = ""
309− , attrs =
310− [ Attr.attribute "autocomplete" "email"
311− , Attr.type_ "email"
312− , Attr.value (Maybe.withDefault "" email)
313− , Ev.onInput (\x -> edit { cipher | email = Just x })
314− ]
315− }
316− , row
317− { name = "Phone number"
318− , nameIcon = ""
319− , attrs =
320− [ Attr.attribute "autocomplete" "tel"
321− , Attr.type_ "tel"
322− , Attr.value (Maybe.withDefault "" phone)
323− , Ev.onInput (\x -> edit { cipher | phone = Just x })
324− ]
325− }
326− , row
327− { name = "Address line 1"
328− , nameIcon = ""
329− , attrs =
330− [ Attr.attribute "autocomplete" "address-line1"
331− , Attr.type_ "text"
332− , Attr.value (Maybe.withDefault "" address1)
333− , Ev.onInput (\x -> edit { cipher | address1 = Just x })
334− ]
335− }
336− , row
337− { name = "Address line 2"
338− , nameIcon = ""
339− , attrs =
340− [ Attr.attribute "autocomplete" "address-line2"
341− , Attr.type_ "text"
342− , Attr.value (Maybe.withDefault "" address2)
343− , Ev.onInput (\x -> edit { cipher | address2 = Just x })
166+ Bridge.CardCipher cipher ->
167+ let
168+ { number, code, cardholderName, expMonth, expYear } =
169+ cipher
170+
171+ edit c =
172+ { fullCipher | cipher = Bridge.CardCipher c } |> EditCipher
173+ in
174+ [ row
175+ { name = "Card number"
176+ , nameIcon = "containers"
177+ , attrs =
178+ [ Attr.attribute "autocomplete" "cc-number"
179+ , Attr.type_ "text"
180+ , Attr.value (Maybe.withDefault "" number)
181+ , Ev.onInput (\x -> edit { cipher | number = Just x })
182+ ]
183+ }
184+ , p []
185+ [ heading "timed-out" "Expiration date"
186+ , br [] []
187+ , input
188+ [ Attr.attribute "autocomplete" "cc-exp-month"
189+ , Attr.type_ "text"
190+ , Attr.value (Maybe.withDefault "" expMonth)
191+ , Ev.onInput (\x -> edit { cipher | expMonth = Just x })
192+ , Attr.style "width" "20%"
193+ , Attr.class "u-align--right"
194+ ]
195+ []
196+ , text " / "
197+ , input
198+ [ Attr.attribute "autocomplete" "cc-exp-year"
199+ , Attr.type_ "text"
200+ , Attr.value (Maybe.withDefault "" expYear)
201+ , Ev.onInput (\x -> edit { cipher | expYear = Just x })
202+ , Attr.style "width" "20%"
203+ ]
204+ []
205+ ]
206+ , row
207+ { name = "CVV"
208+ , nameIcon = "security"
209+ , attrs =
210+ [ Attr.attribute "autocomplete" "cc-csc"
211+ , Attr.type_ "text"
212+ , Attr.value (Maybe.withDefault "" code)
213+ , Ev.onInput (\x -> edit { cipher | code = Just x })
214+ ]
215+ }
216+ , row
217+ { name = "Cardholder name"
218+ , nameIcon = "user"
219+ , attrs =
220+ [ Attr.attribute "autocomplete" "cc-name"
221+ , Attr.type_ "text"
222+ , Attr.value (Maybe.withDefault "" cardholderName)
223+ , Ev.onInput (\x -> edit { cipher | cardholderName = Just x })
224+ ]
225+ }
344226 ]
345− }
346− , row
347− { name = "Address line 3"
348− , nameIcon = ""
349− , attrs =
350− [ Attr.attribute "autocomplete" "address-line3"
351− , Attr.type_ "text"
352− , Attr.value (Maybe.withDefault "" address3)
353− , Ev.onInput (\x -> edit { cipher | address3 = Just x })
227+
228+ Bridge.IdentityCipher cipher ->
229+ let
230+ { address1, address2, address3, company, email, firstName, lastName, licenseNumber, middleName, passportNumber, phone, ssn, username } =
231+ cipher
232+
233+ edit c =
234+ { fullCipher | cipher = Bridge.IdentityCipher c } |> EditCipher
235+ in
236+ [ row
237+ { name = "First name"
238+ , nameIcon = ""
239+ , attrs =
240+ [ Attr.attribute "autocomplete" "given-name"
241+ , Attr.type_ "text"
242+ , Attr.value (Maybe.withDefault "" firstName)
243+ , Ev.onInput (\x -> edit { cipher | firstName = Just x })
244+ ]
245+ }
246+ , row
247+ { name = "Middle name"
248+ , nameIcon = ""
249+ , attrs =
250+ [ Attr.attribute "autocomplete" "additional-name"
251+ , Attr.type_ "text"
252+ , Attr.value (Maybe.withDefault "" middleName)
253+ , Ev.onInput (\x -> edit { cipher | middleName = Just x })
254+ ]
255+ }
256+ , row
257+ { name = "Last name"
258+ , nameIcon = ""
259+ , attrs =
260+ [ Attr.attribute "autocomplete" "family-name"
261+ , Attr.type_ "text"
262+ , Attr.value (Maybe.withDefault "" lastName)
263+ , Ev.onInput (\x -> edit { cipher | lastName = Just x })
264+ ]
265+ }
266+ , row
267+ { name = "Username"
268+ , nameIcon = ""
269+ , attrs =
270+ [ Attr.attribute "autocomplete" "username"
271+ , Attr.type_ "text"
272+ , Attr.value (Maybe.withDefault "" username)
273+ , Ev.onInput (\x -> edit { cipher | username = Just x })
274+ ]
275+ }
276+ , row
277+ { name = "Company"
278+ , nameIcon = ""
279+ , attrs =
280+ [ Attr.attribute "autocomplete" "organization"
281+ , Attr.type_ "text"
282+ , Attr.value (Maybe.withDefault "" company)
283+ , Ev.onInput (\x -> edit { cipher | company = Just x })
284+ ]
285+ }
286+ , row
287+ { name = "Social security number"
288+ , nameIcon = ""
289+ , attrs =
290+ [ Attr.attribute "autocomplete" "off"
291+ , Attr.type_ "number"
292+ , Attr.value (Maybe.withDefault "" ssn)
293+ , Ev.onInput (\x -> edit { cipher | ssn = Just x })
294+ ]
295+ }
296+ , row
297+ { name = "Passport number"
298+ , nameIcon = ""
299+ , attrs =
300+ [ Attr.attribute "autocomplete" "off"
301+ , Attr.type_ "number"
302+ , Attr.value (Maybe.withDefault "" passportNumber)
303+ , Ev.onInput (\x -> edit { cipher | passportNumber = Just x })
304+ ]
305+ }
306+ , row
307+ { name = "License Number"
308+ , nameIcon = ""
309+ , attrs =
310+ [ Attr.attribute "autocomplete" "off"
311+ , Attr.type_ "number"
312+ , Attr.value (Maybe.withDefault "" licenseNumber)
313+ , Ev.onInput (\x -> edit { cipher | licenseNumber = Just x })
314+ ]
315+ }
316+ , row
317+ { name = "Email"
318+ , nameIcon = ""
319+ , attrs =
320+ [ Attr.attribute "autocomplete" "email"
321+ , Attr.type_ "email"
322+ , Attr.value (Maybe.withDefault "" email)
323+ , Ev.onInput (\x -> edit { cipher | email = Just x })
324+ ]
325+ }
326+ , row
327+ { name = "Phone number"
328+ , nameIcon = ""
329+ , attrs =
330+ [ Attr.attribute "autocomplete" "tel"
331+ , Attr.type_ "tel"
332+ , Attr.value (Maybe.withDefault "" phone)
333+ , Ev.onInput (\x -> edit { cipher | phone = Just x })
334+ ]
335+ }
336+ , row
337+ { name = "Address line 1"
338+ , nameIcon = ""
339+ , attrs =
340+ [ Attr.attribute "autocomplete" "address-line1"
341+ , Attr.type_ "text"
342+ , Attr.value (Maybe.withDefault "" address1)
343+ , Ev.onInput (\x -> edit { cipher | address1 = Just x })
344+ ]
345+ }
346+ , row
347+ { name = "Address line 2"
348+ , nameIcon = ""
349+ , attrs =
350+ [ Attr.attribute "autocomplete" "address-line2"
351+ , Attr.type_ "text"
352+ , Attr.value (Maybe.withDefault "" address2)
353+ , Ev.onInput (\x -> edit { cipher | address2 = Just x })
354+ ]
355+ }
356+ , row
357+ { name = "Address line 3"
358+ , nameIcon = ""
359+ , attrs =
360+ [ Attr.attribute "autocomplete" "address-line3"
361+ , Attr.type_ "text"
362+ , Attr.value (Maybe.withDefault "" address3)
363+ , Ev.onInput (\x -> edit { cipher | address3 = Just x })
364+ ]
365+ }
354366 ]
355− }
356− ]
367+ )
357368
358369
359370hiddenPassword : String