Handle multiple mail values

This commit is contained in:
Chris Mann 2023-07-27 21:34:58 +02:00
parent 641e080789
commit b60040113c
3 changed files with 63 additions and 49 deletions

View file

@ -8,34 +8,45 @@
<h2>Modifier mon profil</h2>
</div>
{{if .Common.ErrorMessage}}
<div class="alert alert-danger mt-4">Impossible d'effectuer la modification.
<div style="font-size: 0.8em">{{ .Common.ErrorMessage }}</div>
{{if .Common.ErrorMessage}}
<div class="alert alert-danger mt-4">Impossible d'effectuer la modification.
<div style="font-size: 0.8em">{{ .Common.ErrorMessage }}</div>
</div>
{{end}}
{{if .Common.Success}}
<div class="alert alert-success mt-4">
Profil enregistré.
</div>
{{end}}
<form method="POST" class="mt-4" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group col-md-6">
<label>Identifiant:</label>
<input type="text" disabled="true" class="form-control" value="{{ .Login.Status.Info.Username }}" />
</div>
{{end}}
{{if .Common.Success}}
<div class="alert alert-success mt-4">
Profil enregistré.
<div class="form-group col-md-6">
<label for="mail">Adresse e-mail:</label>
<input type="text" id="mail" disabled="true" name="mail" class="form-control" value="{{ .Data.Mail }}" />
</div>
{{end}}
<form method="POST" class="mt-4" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group col-md-6">
<label>Identifiant:</label>
<input type="text" disabled="true" class="form-control" value="{{ .Login.Status.Info.Username }}" />
</div>
<div class="form-group col-md-6">
<label for="mail">Adresse e-mail:</label>
<input type="text" id="mail" disabled="true" name="mail" class="form-control" value="{{ .Mail }}" />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
{{range $index, $email := .Data.MailValues }}
<input type="email" name="email" value="{{$email}}" required>
<input type="submit" name="delete" value="Delete">
<input type="hidden" name="index" value="{{$index}}">
<br>
{{end}}
<input type="email" name="email" required>
<input type="submit" name="add" value="Add">
</div>
<div class="form-group">
<label for="display_name">Nom complet:</label>
<input type="text" id="display_name" name="display_name" class="form-control" value="{{ .DisplayName }}" />
</div>
{{/*
<!--
</div>
<div class="form-group">
<label for="display_name">Nom complet:</label>
<input type="text" id="display_name" name="display_name" class="form-control" value="{{ .Data.DisplayName }}" />
</div>
{{/*
<!--
<h4>Informations complémentaires</h4>
{{if .ProfilePicture}}
<div class="float-right">
@ -45,7 +56,7 @@
</div>
{{end}}
-->
<!--
<!--
<div class="form-group form-check">
{{if .Visibility}}
<input class="form-check-input" name="visibility" type="checkbox" id="visibility" value="on" checked>
@ -55,7 +66,7 @@
<label class="form-check-label" for="visibility">Apparaître sur l'annuaire</label>
</div>
-->
<!--
<!--
<div class="form-row">
<div class="form-group col-md-8 input-group mb-3 custom-file">
<label for="image">Photo de profil:</label>
@ -64,23 +75,23 @@
</div>
</div>
-->
*/}}
<div class="form-row">
<div class="form-group col-md-6">
<label for="given_name">Prénom:</label>
<input type="text" id="given_name" name="given_name" class="form-control" value="{{ .GivenName }}" />
</div>
<div class="form-group col-md-6">
<label for="surname">Nom de famille:</label>
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" />
</div>
*/}}
<div class="form-row">
<div class="form-group col-md-6">
<label for="given_name">Prénom:</label>
<input type="text" id="given_name" name="given_name" class="form-control" value="{{ .Data.GivenName }}" />
</div>
<div class="form-group col-md-6">
<label for="surname">Nom de famille:</label>
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Data.Surname }}" />
</div>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" class="form-control">{{ .Description }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Enregistrer les modifications</button>
</form>
<script src="/static/javascript/minio.js"></script>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" class="form-control">{{ .Data.Description }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Enregistrer les modifications</button>
</form>
<script src="/static/javascript/minio.js"></script>
{{end}}

View file

@ -10,8 +10,8 @@ import (
)
func handleUserWait(w http.ResponseWriter, r *http.Request) {
templateProfile := getTemplate("user/wait.html")
templateProfile.Execute(w, HomePageData{
templateUser := getTemplate("user/wait.html")
templateUser.Execute(w, HomePageData{
Common: NestedCommonTplData{
CanAdmin: false,
LoggedIn: false,
@ -20,7 +20,7 @@ func handleUserWait(w http.ResponseWriter, r *http.Request) {
}
func handleUser(w http.ResponseWriter, r *http.Request) {
templateProfile := getTemplate("user.html")
templateUser := getTemplate("user.html")
login := checkLogin(w, r)
if login == nil {
@ -46,6 +46,7 @@ func handleUser(w http.ResponseWriter, r *http.Request) {
data.GivenName = login.UserEntry.GetAttributeValue("givenName")
data.Surname = login.UserEntry.GetAttributeValue("sn")
data.OtherMailbox = login.UserEntry.GetAttributeValue("carLicense")
data.MailValues = login.UserEntry.GetAttributeValues("mail")
// data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY)
data.Description = login.UserEntry.GetAttributeValue("description")
//data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE)
@ -122,5 +123,6 @@ func handleUser(w http.ResponseWriter, r *http.Request) {
}
templateProfile.Execute(w, data)
// templateUser.Execute(w, data)
execTemplate(w, templateUser, data.Common, data.Login, *config, data)
}

View file

@ -190,6 +190,7 @@ type CodeMailFields struct {
}
type ProfileTplData struct {
Mail string
MailValues []string
DisplayName string
GivenName string
Surname string