Add the edit contact page

This commit is contained in:
jordi fita mas 2023-02-03 13:29:10 +01:00
parent 1ab48cfcbc
commit 7d17620f48
8 changed files with 452 additions and 208 deletions

View File

@ -2,12 +2,14 @@ package pkg
import (
"context"
"github.com/jackc/pgx/v4"
"github.com/julienschmidt/httprouter"
"html/template"
"net/http"
)
type ContactEntry struct {
Slug string
Name string
Email string
Phone string
@ -26,17 +28,37 @@ func IndexContacts(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
mustRenderAppTemplate(w, r, "contacts-index.gohtml", page)
}
func GetNewContactForm(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
func GetContactForm(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
locale := getLocale(r)
conn := getConn(r)
form := newContactForm(r.Context(), conn, locale)
mustRenderContactForm(w, r, form)
slug := params[0].Value
if slug == "new" {
w.WriteHeader(http.StatusOK)
mustRenderNewContactForm(w, r, form)
return
}
err := conn.QueryRow(r.Context(), "select business_name, substr(vatin::text, 3), trade_name, phone, email, web, address, city, province, postal_code, country_code from contact where slug = $1", slug).Scan(form.BusinessName, form.VATIN, form.TradeName, form.Phone, form.Email, form.Web, form.Address, form.City, form.Province, form.PostalCode, form.Country)
if err != nil {
if err == pgx.ErrNoRows {
http.NotFound(w, r)
return
} else {
panic(err)
}
}
w.WriteHeader(http.StatusOK)
mustRenderEditContactForm(w, r, form)
}
func mustRenderContactForm(w http.ResponseWriter, r *http.Request, form *contactForm) {
func mustRenderNewContactForm(w http.ResponseWriter, r *http.Request, form *contactForm) {
mustRenderAppTemplate(w, r, "contacts-new.gohtml", form)
}
func mustRenderEditContactForm(w http.ResponseWriter, r *http.Request, form *contactForm) {
mustRenderAppTemplate(w, r, "contacts-edit.gohtml", form)
}
func HandleAddContact(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
conn := getConn(r)
locale := getLocale(r)
@ -50,16 +72,40 @@ func HandleAddContact(w http.ResponseWriter, r *http.Request, _ httprouter.Param
return
}
if !form.Validate(r.Context(), conn) {
mustRenderContactForm(w, r, form)
mustRenderNewContactForm(w, r, form)
return
}
company := getCompany(r)
conn.MustExec(r.Context(), "insert into contact (company_id, business_name, vatin, trade_name, phone, email, web, address, province, city, postal_code, country_code) values ($1, $2, ($12 || $3)::vatin, $4, parse_packed_phone_number($5, $12), $6, $7, $8, $9, $10, $11, $12)", company.Id, form.BusinessName, form.VATIN, form.TradeName, form.Phone, form.Email, form.Web, form.Address, form.City, form.Province, form.PostalCode, form.Country)
conn.MustExec(r.Context(), "insert into contact (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code) values ($1, $2, ($12 || $3)::vatin, $4, parse_packed_phone_number($5, $12), $6, $7, $8, $9, $10, $11, $12)", company.Id, form.BusinessName, form.VATIN, form.TradeName, form.Phone, form.Email, form.Web, form.Address, form.City, form.Province, form.PostalCode, form.Country)
http.Redirect(w, r, "/company/"+company.Slug+"/contacts", http.StatusSeeOther)
}
func HandleUpdateContact(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
conn := getConn(r)
locale := getLocale(r)
form := newContactForm(r.Context(), conn, locale)
if err := form.Parse(r); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if err := verifyCsrfTokenValid(r); err != nil {
http.Error(w, err.Error(), http.StatusForbidden)
return
}
if !form.Validate(r.Context(), conn) {
mustRenderEditContactForm(w, r, form)
return
}
slug := conn.MustGetText(r.Context(), "", "update contact set business_name = $1, vatin = ($11 || $2)::vatin, trade_name = $3, phone = parse_packed_phone_number($4, $11), email = $5, web = $6, address = $7, city = $8, province = $9, postal_code = $10, country_code = $11 where slug = $12 returning slug", form.BusinessName, form.VATIN, form.TradeName, form.Phone, form.Email, form.Web, form.Address, form.City, form.Province, form.PostalCode, form.Country, params[0].Value)
if slug == "" {
http.NotFound(w, r)
}
company := getCompany(r)
http.Redirect(w, r, "/company/"+company.Slug+"/contacts/"+slug, http.StatusSeeOther)
}
func mustGetContactEntries(ctx context.Context, conn *Conn, company *Company) []*ContactEntry {
rows, err := conn.Query(ctx, "select business_name, email, phone from contact where company_id = $1 order by business_name", company.Id)
rows, err := conn.Query(ctx, "select slug, business_name, email, phone from contact where company_id = $1 order by business_name", company.Id)
if err != nil {
panic(err)
}
@ -68,7 +114,7 @@ func mustGetContactEntries(ctx context.Context, conn *Conn, company *Company) []
var entries []*ContactEntry
for rows.Next() {
entry := &ContactEntry{}
err = rows.Scan(&entry.Name, &entry.Email, &entry.Phone)
err = rows.Scan(&entry.Slug, &entry.Name, &entry.Email, &entry.Phone)
if err != nil {
panic(err)
}

View File

@ -16,7 +16,8 @@ func NewRouter(db *Db) http.Handler {
companyRouter.DELETE("/tax/:taxId", HandleDeleteCompanyTax)
companyRouter.GET("/contacts", IndexContacts)
companyRouter.POST("/contacts", HandleAddContact)
companyRouter.GET("/contacts/new", GetNewContactForm)
companyRouter.GET("/contacts/:slug", GetContactForm)
companyRouter.PUT("/contacts/:slug", HandleUpdateContact)
companyRouter.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
mustRenderAppTemplate(w, r, "dashboard.gohtml", nil)
})
@ -60,7 +61,7 @@ func MethodOverrider(next http.Handler) http.Handler {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
override := r.FormValue("_method")
override := r.FormValue(overrideMethodName)
if override == http.MethodDelete || override == http.MethodPut {
r2 := new(http.Request)
*r2 = *r

View File

@ -7,6 +7,8 @@ import (
"net/http"
)
const overrideMethodName = "_method"
func templateFile(name string) string {
return "web/template/" + name
}
@ -39,6 +41,12 @@ func mustRenderTemplate(wr io.Writer, r *http.Request, layout string, filename s
field.Attributes = append(field.Attributes, template.HTMLAttr(attr))
return field
},
"deleteMethod": func() template.HTML {
return overrideMethodField(http.MethodDelete)
},
"putMethod": func() template.HTML {
return overrideMethodField(http.MethodPut)
},
})
if _, err := t.ParseFiles(templateFile(filename), templateFile(layout), templateFile("form.gohtml")); err != nil {
panic(err)
@ -48,6 +56,9 @@ func mustRenderTemplate(wr io.Writer, r *http.Request, layout string, filename s
}
}
func overrideMethodField(method string) template.HTML {
return template.HTML(fmt.Sprintf(`<input type="hidden" name="%s" value="%s">`, overrideMethodName, method))
}
func mustRenderAppTemplate(w io.Writer, r *http.Request, filename string, data interface{}) {
mustRenderTemplate(w, r, "app.gohtml", filename, data)
}

270
po/ca.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-02-01 11:26+0100\n"
"POT-Creation-Date: 2023-02-03 13:18+0100\n"
"PO-Revision-Date: 2023-01-18 17:08+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -32,17 +32,17 @@ msgctxt "menu"
msgid "Tax Details"
msgstr "Configuració fiscal"
#: web/template/app.gohtml:33
#: web/template/app.gohtml:34
msgctxt "action"
msgid "Logout"
msgstr "Surt"
#: web/template/app.gohtml:42
#: web/template/app.gohtml:43
msgctxt "nav"
msgid "Dashboard"
msgstr "Tauler"
#: web/template/app.gohtml:43
#: web/template/app.gohtml:44
msgctxt "nav"
msgid "Contacts"
msgstr "Contactes"
@ -57,37 +57,47 @@ msgctxt "action"
msgid "Login"
msgstr "Entra"
#: web/template/profile.gohtml:2 web/template/profile.gohtml:7
#: web/template/profile.gohtml:2 web/template/profile.gohtml:8
msgctxt "title"
msgid "User Settings"
msgstr "Configuració usuari"
#: web/template/profile.gohtml:10
#: web/template/profile.gohtml:12
msgctxt "title"
msgid "User Access Data"
msgstr "Dades accés usuari"
#: web/template/profile.gohtml:16
#: web/template/profile.gohtml:18
msgctxt "title"
msgid "Password Change"
msgstr "Canvi contrasenya"
#: web/template/profile.gohtml:23
#: web/template/profile.gohtml:25
msgctxt "title"
msgid "Language"
msgstr "Idioma"
#: web/template/profile.gohtml:27 web/template/tax-details.gohtml:133
#: web/template/profile.gohtml:29 web/template/tax-details.gohtml:90
msgctxt "action"
msgid "Save changes"
msgstr "Desa canvis"
#: web/template/contacts-edit.gohtml:2 web/template/contacts-edit.gohtml:8
msgctxt "title"
msgid "Edit Contact “%s”"
msgstr "Edició del contacte «%s»"
#: web/template/contacts-edit.gohtml:26
msgctxt "action"
msgid "Update contact"
msgstr "Actualitza contacte"
#: web/template/contacts-index.gohtml:2
msgctxt "title"
msgid "Contacts"
msgstr "Contactes"
#: web/template/contacts-index.gohtml:6 web/template/contacts-new.gohtml:60
#: web/template/contacts-index.gohtml:6 web/template/contacts-new.gohtml:24
msgctxt "action"
msgid "New contact"
msgstr "Nou contacte"
@ -121,159 +131,227 @@ msgctxt "title"
msgid "Tax Details"
msgstr "Configuració fiscal"
#: web/template/tax-details.gohtml:11 web/template/contacts-new.gohtml:11
msgctxt "input"
msgid "Business name"
msgstr "Nom i cognom"
#: web/template/tax-details.gohtml:15 web/template/contacts-new.gohtml:15
msgctxt "input"
msgid "VAT number"
msgstr "DNI / NIF"
#: web/template/tax-details.gohtml:19 web/template/contacts-new.gohtml:19
msgctxt "input"
msgid "Trade name"
msgstr "Nom comercial"
#: web/template/tax-details.gohtml:23 web/template/contacts-new.gohtml:23
msgctxt "input"
msgid "Phone"
msgstr "Telèfon"
#: web/template/tax-details.gohtml:27 web/template/contacts-new.gohtml:27
#: pkg/login.go:33 pkg/profile.go:35
msgctxt "input"
msgid "Email"
msgstr "Correu-e"
#: web/template/tax-details.gohtml:31 web/template/contacts-new.gohtml:31
msgctxt "input"
msgid "Web"
msgstr "Web"
#: web/template/tax-details.gohtml:35 web/template/contacts-new.gohtml:35
msgctxt "input"
msgid "Address"
msgstr "Adreça"
#: web/template/tax-details.gohtml:39 web/template/contacts-new.gohtml:39
msgctxt "input"
msgid "City"
msgstr "Població"
#: web/template/tax-details.gohtml:43 web/template/contacts-new.gohtml:43
msgctxt "input"
msgid "Province"
msgstr "Província"
#: web/template/tax-details.gohtml:47 web/template/contacts-new.gohtml:47
msgctxt "input"
msgid "Postal code"
msgstr "Codi postal"
#: web/template/tax-details.gohtml:56 web/template/contacts-new.gohtml:56
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/template/tax-details.gohtml:60
msgctxt "input"
#: web/template/tax-details.gohtml:25
msgctxt "title"
msgid "Currency"
msgstr "Moneda"
#: web/template/tax-details.gohtml:78
#: web/template/tax-details.gohtml:41
msgctxt "title"
msgid "Tax Name"
msgstr "Nom import"
#: web/template/tax-details.gohtml:79
#: web/template/tax-details.gohtml:42
msgctxt "title"
msgid "Rate (%)"
msgstr "Percentatge"
#: web/template/tax-details.gohtml:100
#: web/template/tax-details.gohtml:65
msgid "No taxes added yet."
msgstr "No hi ha cap impost."
#: web/template/tax-details.gohtml:106
#: web/template/tax-details.gohtml:71
msgctxt "title"
msgid "New Line"
msgstr "Nova línia"
#: web/template/tax-details.gohtml:111
msgctxt "input"
msgid "Tax name"
msgstr "Nom impost"
#: web/template/tax-details.gohtml:118
msgctxt "input"
msgid "Rate (%)"
msgstr "Percentatge"
#: web/template/tax-details.gohtml:125
#: web/template/tax-details.gohtml:82
msgctxt "action"
msgid "Add new tax"
msgstr "Afegeix nou impost"
#: web/template/contacts-new.gohtml:2 web/template/contacts-new.gohtml:7
#: web/template/contacts-new.gohtml:2 web/template/contacts-new.gohtml:8
msgctxt "title"
msgid "New Contact"
msgstr "Nou contacte"
#: pkg/login.go:44 pkg/profile.go:41
#: pkg/login.go:36 pkg/profile.go:40 pkg/contacts.go:179
msgctxt "input"
msgid "Email"
msgstr "Correu-e"
#: pkg/login.go:47 pkg/profile.go:49
msgctxt "input"
msgid "Password"
msgstr "Contrasenya"
#: pkg/login.go:66 pkg/profile.go:71
#: pkg/login.go:69 pkg/profile.go:88 pkg/contacts.go:263
msgid "Email can not be empty."
msgstr "No podeu deixar el correu-e en blanc."
#: pkg/login.go:67 pkg/profile.go:72
#: pkg/login.go:70 pkg/profile.go:89 pkg/contacts.go:264
msgid "This value is not a valid email. It should be like name@domain.com."
msgstr "Aquest valor no és un correu-e vàlid. Hauria de ser similar a nom@domini.cat."
#: pkg/login.go:69
#: pkg/login.go:72
msgid "Password can not be empty."
msgstr "No podeu deixar la contrasenya en blanc."
#: pkg/login.go:95
#: pkg/login.go:108
msgid "Invalid user or password."
msgstr "Nom dusuari o contrasenya incorrectes."
#: pkg/profile.go:23
#: pkg/company.go:78
msgctxt "input"
msgid "Currency"
msgstr "Moneda"
#: pkg/company.go:95
msgid "Selected currency is not valid."
msgstr "Heu seleccionat una moneda que no és vàlida."
#: pkg/company.go:217
msgctxt "input"
msgid "Tax name"
msgstr "Nom impost"
#: pkg/company.go:223
msgctxt "input"
msgid "Rate (%)"
msgstr "Percentatge"
#: pkg/company.go:245
msgid "Tax name can not be empty."
msgstr "No podeu deixar el nom de limpost en blanc."
#: pkg/company.go:246
msgid "Tax rate can not be empty."
msgstr "No podeu deixar percentatge en blanc."
#: pkg/company.go:247
msgid "Tax rate must be an integer between -99 and 99."
msgstr "El percentatge ha de ser entre -99 i 99."
#: pkg/profile.go:25
msgctxt "language option"
msgid "Automatic"
msgstr "Automàtic"
#: pkg/profile.go:29
#: pkg/profile.go:31
msgctxt "input"
msgid "User name"
msgstr "Nom dusuari"
#: pkg/profile.go:46
#: pkg/profile.go:57
msgctxt "input"
msgid "Password Confirmation"
msgstr "Confirmació contrasenya"
#: pkg/profile.go:51
#: pkg/profile.go:65
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: pkg/profile.go:74
#: pkg/profile.go:91
msgid "Name can not be empty."
msgstr "No podeu deixar el nom en blanc."
#: pkg/profile.go:75
#: pkg/profile.go:92
msgid "Confirmation does not match password."
msgstr "La confirmació no és igual a la contrasenya."
#: pkg/profile.go:76
#: pkg/profile.go:93
msgid "Selected language is not valid."
msgstr "Heu seleccionat un idioma que no és vàlid."
#: pkg/contacts.go:150
msgctxt "input"
msgid "Business name"
msgstr "Nom i cognoms"
#: pkg/contacts.go:159
msgctxt "input"
msgid "VAT number"
msgstr "DNI / NIF"
#: pkg/contacts.go:165
msgctxt "input"
msgid "Trade name"
msgstr "Nom comercial"
#: pkg/contacts.go:170
msgctxt "input"
msgid "Phone"
msgstr "Telèfon"
#: pkg/contacts.go:188
msgctxt "input"
msgid "Web"
msgstr "Web"
#: pkg/contacts.go:196
msgctxt "input"
msgid "Address"
msgstr "Adreça"
#: pkg/contacts.go:205
msgctxt "input"
msgid "City"
msgstr "Població"
#: pkg/contacts.go:211
msgctxt "input"
msgid "Province"
msgstr "Província"
#: pkg/contacts.go:217
msgctxt "input"
msgid "Postal code"
msgstr "Codi postal"
#: pkg/contacts.go:226
msgctxt "input"
msgid "Country"
msgstr "País"
#: pkg/contacts.go:256
msgid "Business name can not be empty."
msgstr "No podeu deixar el nom i els cognoms en blanc."
#: pkg/contacts.go:257
msgid "VAT number can not be empty."
msgstr "No podeu deixar el DNI o NIF en blanc."
#: pkg/contacts.go:258
msgid "This value is not a valid VAT number."
msgstr "Aquest valor no és un DNI o NIF vàlid."
#: pkg/contacts.go:260
msgid "Phone can not be empty."
msgstr "No podeu deixar el telèfon en blanc."
#: pkg/contacts.go:261
msgid "This value is not a valid phone number."
msgstr "Aquest valor no és un telèfon vàlid."
#: pkg/contacts.go:267
msgid "This value is not a valid web address. It should be like https://domain.com/."
msgstr "Aquest valor no és una adreça web vàlida. Hauria de ser similar a https://domini.cat/."
#: pkg/contacts.go:269
msgid "Address can not be empty."
msgstr "No podeu deixar ladreça en blanc."
#: pkg/contacts.go:270
msgid "City can not be empty."
msgstr "No podeu deixar la població en blanc."
#: pkg/contacts.go:271
msgid "Province can not be empty."
msgstr "No podeu deixar la província en blanc."
#: pkg/contacts.go:272
msgid "Postal code can not be empty."
msgstr "No podeu deixar el codi postal en blanc."
#: pkg/contacts.go:273
msgid "This value is not a valid postal code."
msgstr "Aquest valor no és un codi postal vàlid."
#: pkg/contacts.go:275
msgid "Selected country is not valid."
msgstr "Heu seleccionat un país que no és vàlid."
#~ msgctxt "nav"
#~ msgid "Customers"
#~ msgstr "Clients"

276
po/es.po
View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-02-01 11:26+0100\n"
"POT-Creation-Date: 2023-02-03 13:18+0100\n"
"PO-Revision-Date: 2023-01-18 17:45+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -32,17 +32,17 @@ msgctxt "menu"
msgid "Tax Details"
msgstr "Configuración fiscal"
#: web/template/app.gohtml:33
#: web/template/app.gohtml:34
msgctxt "action"
msgid "Logout"
msgstr "Salir"
#: web/template/app.gohtml:42
#: web/template/app.gohtml:43
msgctxt "nav"
msgid "Dashboard"
msgstr "Panel"
#: web/template/app.gohtml:43
#: web/template/app.gohtml:44
msgctxt "nav"
msgid "Contacts"
msgstr "Contactos"
@ -57,37 +57,47 @@ msgctxt "action"
msgid "Login"
msgstr "Entrar"
#: web/template/profile.gohtml:2 web/template/profile.gohtml:7
#: web/template/profile.gohtml:2 web/template/profile.gohtml:8
msgctxt "title"
msgid "User Settings"
msgstr "Configuración usuario"
#: web/template/profile.gohtml:10
#: web/template/profile.gohtml:12
msgctxt "title"
msgid "User Access Data"
msgstr "Datos acceso usuario"
#: web/template/profile.gohtml:16
#: web/template/profile.gohtml:18
msgctxt "title"
msgid "Password Change"
msgstr "Cambio de contraseña"
#: web/template/profile.gohtml:23
#: web/template/profile.gohtml:25
msgctxt "title"
msgid "Language"
msgstr "Idioma"
#: web/template/profile.gohtml:27 web/template/tax-details.gohtml:133
#: web/template/profile.gohtml:29 web/template/tax-details.gohtml:90
msgctxt "action"
msgid "Save changes"
msgstr "Guardar cambios"
#: web/template/contacts-edit.gohtml:2 web/template/contacts-edit.gohtml:8
msgctxt "title"
msgid "Edit Contact “%s”"
msgstr "Edición del contacto «%s»"
#: web/template/contacts-edit.gohtml:26
msgctxt "action"
msgid "Update contact"
msgstr "Actualizar contacto"
#: web/template/contacts-index.gohtml:2
msgctxt "title"
msgid "Contacts"
msgstr "Contactos"
#: web/template/contacts-index.gohtml:6 web/template/contacts-new.gohtml:60
#: web/template/contacts-index.gohtml:6 web/template/contacts-new.gohtml:24
msgctxt "action"
msgid "New contact"
msgstr "Nuevo contacto"
@ -121,159 +131,227 @@ msgctxt "title"
msgid "Tax Details"
msgstr "Configuración fiscal"
#: web/template/tax-details.gohtml:11 web/template/contacts-new.gohtml:11
msgctxt "input"
msgid "Business name"
msgstr "Nombre y apellidos"
#: web/template/tax-details.gohtml:15 web/template/contacts-new.gohtml:15
msgctxt "input"
msgid "VAT number"
msgstr "DNI / NIF"
#: web/template/tax-details.gohtml:19 web/template/contacts-new.gohtml:19
msgctxt "input"
msgid "Trade name"
msgstr "Nombre comercial"
#: web/template/tax-details.gohtml:23 web/template/contacts-new.gohtml:23
msgctxt "input"
msgid "Phone"
msgstr "Teléfono"
#: web/template/tax-details.gohtml:27 web/template/contacts-new.gohtml:27
#: pkg/login.go:33 pkg/profile.go:35
msgctxt "input"
msgid "Email"
msgstr "Correo-e"
#: web/template/tax-details.gohtml:31 web/template/contacts-new.gohtml:31
msgctxt "input"
msgid "Web"
msgstr "Web"
#: web/template/tax-details.gohtml:35 web/template/contacts-new.gohtml:35
msgctxt "input"
msgid "Address"
msgstr "Dirección"
#: web/template/tax-details.gohtml:39 web/template/contacts-new.gohtml:39
msgctxt "input"
msgid "City"
msgstr "Población"
#: web/template/tax-details.gohtml:43 web/template/contacts-new.gohtml:43
msgctxt "input"
msgid "Province"
msgstr "Provincia"
#: web/template/tax-details.gohtml:47 web/template/contacts-new.gohtml:47
msgctxt "input"
msgid "Postal code"
msgstr "Código postal"
#: web/template/tax-details.gohtml:56 web/template/contacts-new.gohtml:56
msgctxt "input"
msgid "Country"
msgstr "País"
#: web/template/tax-details.gohtml:60
msgctxt "input"
#: web/template/tax-details.gohtml:25
msgctxt "title"
msgid "Currency"
msgstr "Moneda"
#: web/template/tax-details.gohtml:78
#: web/template/tax-details.gohtml:41
msgctxt "title"
msgid "Tax Name"
msgstr "Nombre impuesto"
#: web/template/tax-details.gohtml:79
#: web/template/tax-details.gohtml:42
msgctxt "title"
msgid "Rate (%)"
msgstr "Porcentage"
msgstr "Porcentaje"
#: web/template/tax-details.gohtml:100
#: web/template/tax-details.gohtml:65
msgid "No taxes added yet."
msgstr "No hay impuestos."
#: web/template/tax-details.gohtml:106
#: web/template/tax-details.gohtml:71
msgctxt "title"
msgid "New Line"
msgstr "Nueva línea"
#: web/template/tax-details.gohtml:111
msgctxt "input"
msgid "Tax name"
msgstr "Nombre impuesto"
#: web/template/tax-details.gohtml:118
msgctxt "input"
msgid "Rate (%)"
msgstr "Porcentage"
#: web/template/tax-details.gohtml:125
#: web/template/tax-details.gohtml:82
msgctxt "action"
msgid "Add new tax"
msgstr "Añadir nuevo impuesto"
#: web/template/contacts-new.gohtml:2 web/template/contacts-new.gohtml:7
#: web/template/contacts-new.gohtml:2 web/template/contacts-new.gohtml:8
msgctxt "title"
msgid "New Contact"
msgstr "Nuevo contacto"
#: pkg/login.go:44 pkg/profile.go:41
#: pkg/login.go:36 pkg/profile.go:40 pkg/contacts.go:179
msgctxt "input"
msgid "Email"
msgstr "Correo-e"
#: pkg/login.go:47 pkg/profile.go:49
msgctxt "input"
msgid "Password"
msgstr "Contraseña"
#: pkg/login.go:66 pkg/profile.go:71
#: pkg/login.go:69 pkg/profile.go:88 pkg/contacts.go:263
msgid "Email can not be empty."
msgstr "No podéis dejar el correo-e en blanco."
#: pkg/login.go:67 pkg/profile.go:72
#: pkg/login.go:70 pkg/profile.go:89 pkg/contacts.go:264
msgid "This value is not a valid email. It should be like name@domain.com."
msgstr "Este valor no es un correo-e válido. Tiene que ser parecido a nombre@dominio.es."
#: pkg/login.go:69
#: pkg/login.go:72
msgid "Password can not be empty."
msgstr "No podéis dejar la contaseña en blanco."
msgstr "No podéis dejar la contraseña en blanco."
#: pkg/login.go:95
#: pkg/login.go:108
msgid "Invalid user or password."
msgstr "Nombre de usuario o contraseña inválido."
#: pkg/profile.go:23
#: pkg/company.go:78
msgctxt "input"
msgid "Currency"
msgstr "Moneda"
#: pkg/company.go:95
msgid "Selected currency is not valid."
msgstr "Habéis escogido una moneda que no es válida."
#: pkg/company.go:217
msgctxt "input"
msgid "Tax name"
msgstr "Nombre impuesto"
#: pkg/company.go:223
msgctxt "input"
msgid "Rate (%)"
msgstr "Porcentaje"
#: pkg/company.go:245
msgid "Tax name can not be empty."
msgstr "No podéis dejar el nombre del impuesto en blanco."
#: pkg/company.go:246
msgid "Tax rate can not be empty."
msgstr "No podéis dejar el porcentaje en blanco."
#: pkg/company.go:247
msgid "Tax rate must be an integer between -99 and 99."
msgstr "El porcentaje tiene que estar entre -99 y 99."
#: pkg/profile.go:25
msgctxt "language option"
msgid "Automatic"
msgstr "Automático"
#: pkg/profile.go:29
#: pkg/profile.go:31
msgctxt "input"
msgid "User name"
msgstr "Nombre de usuario"
#: pkg/profile.go:46
#: pkg/profile.go:57
msgctxt "input"
msgid "Password Confirmation"
msgstr "Confirmación contrasenya"
msgstr "Confirmación contraseña"
#: pkg/profile.go:51
#: pkg/profile.go:65
msgctxt "input"
msgid "Language"
msgstr "Idioma"
#: pkg/profile.go:74
#: pkg/profile.go:91
msgid "Name can not be empty."
msgstr "No podéis dejar el nombre en blanco."
#: pkg/profile.go:75
#: pkg/profile.go:92
msgid "Confirmation does not match password."
msgstr "La confirmación no corresponde con la contraseña."
#: pkg/profile.go:76
#: pkg/profile.go:93
msgid "Selected language is not valid."
msgstr "Habéis escogido un idioma que no es válido."
#: pkg/contacts.go:150
msgctxt "input"
msgid "Business name"
msgstr "Nombre y apellidos"
#: pkg/contacts.go:159
msgctxt "input"
msgid "VAT number"
msgstr "DNI / NIF"
#: pkg/contacts.go:165
msgctxt "input"
msgid "Trade name"
msgstr "Nombre comercial"
#: pkg/contacts.go:170
msgctxt "input"
msgid "Phone"
msgstr "Teléfono"
#: pkg/contacts.go:188
msgctxt "input"
msgid "Web"
msgstr "Web"
#: pkg/contacts.go:196
msgctxt "input"
msgid "Address"
msgstr "Dirección"
#: pkg/contacts.go:205
msgctxt "input"
msgid "City"
msgstr "Población"
#: pkg/contacts.go:211
msgctxt "input"
msgid "Province"
msgstr "Provincia"
#: pkg/contacts.go:217
msgctxt "input"
msgid "Postal code"
msgstr "Código postal"
#: pkg/contacts.go:226
msgctxt "input"
msgid "Country"
msgstr "País"
#: pkg/contacts.go:256
msgid "Business name can not be empty."
msgstr "No podéis dejar el nombre y los apellidos en blanco."
#: pkg/contacts.go:257
msgid "VAT number can not be empty."
msgstr "No podéis dejar el DNI o NIF en blanco."
#: pkg/contacts.go:258
msgid "This value is not a valid VAT number."
msgstr "Este valor no es un DNI o NIF válido."
#: pkg/contacts.go:260
msgid "Phone can not be empty."
msgstr "No podéis dejar el teléfono en blanco."
#: pkg/contacts.go:261
msgid "This value is not a valid phone number."
msgstr "Este valor no es un teléfono válido."
#: pkg/contacts.go:267
msgid "This value is not a valid web address. It should be like https://domain.com/."
msgstr "Este valor no es una dirección web válida. Tiene que ser parecida a https://dominio.es/."
#: pkg/contacts.go:269
msgid "Address can not be empty."
msgstr "No podéis dejar la dirección en blanco."
#: pkg/contacts.go:270
msgid "City can not be empty."
msgstr "No podéis dejar la población en blanco."
#: pkg/contacts.go:271
msgid "Province can not be empty."
msgstr "No podéis dejar la provincia en blanco."
#: pkg/contacts.go:272
msgid "Postal code can not be empty."
msgstr "No podéis dejar el código postal en blanco."
#: pkg/contacts.go:273
msgid "This value is not a valid postal code."
msgstr "Este valor no es un código postal válido válido."
#: pkg/contacts.go:275
msgid "Selected country is not valid."
msgstr "Habéis escogido un país que no es válido."
#~ msgctxt "nav"
#~ msgid "Customers"
#~ msgstr "Clientes"

View File

@ -0,0 +1,30 @@
{{ define "title" -}}
{{printf (pgettext "Edit Contact “%s”" "title") .BusinessName.Val }}
{{- end }}
{{ define "content" }}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.contactForm*/ -}}
<section class="dialog-content">
<h2>{{printf (pgettext "Edit Contact “%s”" "title") .BusinessName.Val }}</h2>
<form method="POST">
{{ csrfToken }}
{{ putMethod }}
{{ template "input-field" .BusinessName | addInputAttr "autofocus" }}
{{ template "input-field" .VATIN }}
{{ template "input-field" .TradeName }}
{{ template "input-field" .Phone }}
{{ template "input-field" .Email }}
{{ template "input-field" .Web }}
{{ template "input-field" .Address | addInputAttr `class="width-2x"` }}
{{ template "input-field" .City }}
{{ template "input-field" .Province }}
{{ template "input-field" .PostalCode }}
{{ template "select-field" .Country | addSelectAttr `class="width-fixed"` }}
<fieldset>
<button type="submit">{{( pgettext "Update contact" "action" )}}</button>
</fieldset>
</form>
</section>
{{- end }}

View File

@ -19,9 +19,9 @@
{{- range $tax := . }}
<tr>
<td></td>
<td>{{ .Name }}</td>
<td>{{ .Email }}</td>
<td>{{ .Phone }}</td>
<td><a href="{{ companyURI "/contacts/"}}{{ .Slug }}">{{ .Name }}</a></td>
<td><a href="mailto:{{ .Email }}">{{ .Email }}</a></td>
<td><a href="tel:{{ .Phone }}">{{ .Phone }}</a></td>
</tr>
{{- end }}
{{ else }}

View File

@ -53,7 +53,7 @@
<td>
<form method="POST" action="{{ companyURI "/tax"}}/{{ .Id }}">
{{ csrfToken }}
<input type="hidden" name="_method" value="DELETE"/>
{{ deleteMethod }}
<button class="icon" aria-label="{{( gettext "Delete tax" )}}" type="submit"><i
class="ri-delete-back-2-line"></i></button>
</form>