0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 17:00:36 -05:00

Minor change on translation approach on form errors.

This commit is contained in:
Andrey Antukh 2016-04-12 22:57:00 +03:00
parent 63e5e68fc6
commit c314a4cde9
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
5 changed files with 13 additions and 7 deletions

View file

@ -76,9 +76,13 @@
(defrecord UpdatePassword [data]
rs/WatchEvent
(-apply-watch [_ state s]
(letfn [(on-error [err]
(uum/error (tr "errors.profile.update-password") {:timeout 3000})
(rx/empty))]
(letfn [(on-error [{payload :payload :as data}]
(if (= (:type payload) :form/validation)
(rx/of
(forms/assign-errors :profile/password (:payload payload)))
(do
(uum/error (tr "errors.profile.update-password") {:timeout 3000})
(rx/empty))))]
(let [params {:old-password (:old-password data)
:password (:password-1 data)}]
(->> (rp/req :update/password params)

View file

@ -40,6 +40,9 @@
"profile.password-saved" "Password saved successfully!"
"history.alert-message" "You are seeng version %s"
"errors.api.form.old-password-not-match" "Incorrect old password"
"errors.form.required" "This field is mandatory"
"errors.form.string" "Should be string"
"errors.form.number" "Invalid number"

View file

@ -73,8 +73,7 @@
([data schema]
(validate data schema nil))
([data schema opts]
(let [opts (merge {:strip true
:translate tr}
(let [opts (merge {:strip true}
opts)]
(st/validate data schema opts))))

View file

@ -1,5 +1,6 @@
(ns uxbox.ui.forms
(:require [sablono.core :refer-macros [html]]
[uxbox.locales :refer (tr)]
[uxbox.schema :as sc]))
(defn input-error
@ -8,7 +9,7 @@
(html
[:ul.form-errors
(for [error errors]
[:li {:key error} error])])))
[:li {:key error} (tr error)])])))
(defn error-class
[errors field]

View file

@ -42,7 +42,6 @@
(let [form (rum/react formdata)
errors (rum/react formerrors)
valid? (sc/valid? form udu/update-password-schema)]
(println valid?)
(letfn [(on-field-change [field event]
(let [value (dom/event->value event)]
(rs/emit! (assign-field-value field value))))