Implemented ContactInformationPartial for Manage Page
This commit is contained in:
parent
8d6cea2541
commit
342d985cc9
|
@ -35,6 +35,11 @@
|
||||||
<AboutMeFormPartial User="@User" />
|
<AboutMeFormPartial User="@User" />
|
||||||
}
|
}
|
||||||
</BoardCardComponent>
|
</BoardCardComponent>
|
||||||
|
<BoardCardComponent Heading="@Localizer["ContactInformation"]">
|
||||||
|
@if (User is not null) {
|
||||||
|
<ContactInformationPartial User="User" />
|
||||||
|
}
|
||||||
|
</BoardCardComponent>
|
||||||
<BoardCardComponent Heading="@Localizer["Permissions"]">
|
<BoardCardComponent Heading="@Localizer["Permissions"]">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="flex gap-2 content-center">
|
<li class="flex gap-2 content-center">
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
@using Wave.Data
|
||||||
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@using System.ComponentModel.DataAnnotations
|
||||||
|
@using Microsoft.AspNetCore.Mvc
|
||||||
|
@using Wave.Utilities
|
||||||
|
@using System.ComponentModel
|
||||||
|
|
||||||
|
@inject UserManager<ApplicationUser> UserManager
|
||||||
|
@inject IStringLocalizer<Wave.Components.Account.Pages.Manage.Index> Localizer
|
||||||
|
@inject IMessageDisplay Message
|
||||||
|
|
||||||
|
<EditForm FormName="update-contact" Model="@Model" OnValidSubmit="@OnValidSubmit" method="post" class="w-full">
|
||||||
|
<DataAnnotationsValidator />
|
||||||
|
|
||||||
|
<InputLabelComponent For="() => Model.ContactEmail" LabelText="@Localizer["Contact_Email_Label"]">
|
||||||
|
<InputText class="input input-bordered w-full" maxlength="128" type="email" autocomplete="email"
|
||||||
|
@bind-Value="@Model.ContactEmail" placeholder="@Localizer["Contact_Email_Placeholder"]" />
|
||||||
|
</InputLabelComponent>
|
||||||
|
<InputLabelComponent For="() => Model.ContactPhone" LabelText="@Localizer["Contact_Phone_Label"]">
|
||||||
|
<InputText class="input input-bordered w-full" maxlength="64" type="tel" autocomplete="tel"
|
||||||
|
@bind-Value="@Model.ContactPhone" placeholder="@Localizer["Contact_Phone_Placeholder"]" />
|
||||||
|
</InputLabelComponent>
|
||||||
|
<InputLabelComponent For="() => Model.ContactPhoneBusiness" LabelText="@Localizer["Contact_PhoneBusiness_Label"]">
|
||||||
|
<InputText class="input input-bordered w-full" maxlength="64" type="tel" autocomplete="tel"
|
||||||
|
@bind-Value="@Model.ContactPhoneBusiness" placeholder="@Localizer["Contact_PhoneBusiness_Placeholder"]" />
|
||||||
|
</InputLabelComponent>
|
||||||
|
<InputLabelComponent For="() => Model.ContactWebsite" LabelText="@Localizer["Contact_Website_Label"]">
|
||||||
|
<InputText class="input input-bordered w-full" maxlength="128" type="url" autocomplete="url"
|
||||||
|
@bind-Value="@Model.ContactWebsite" placeholder="@Localizer["Contact_Website_Placeholder"]" />
|
||||||
|
</InputLabelComponent>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary w-full">
|
||||||
|
@Localizer["Submit"]
|
||||||
|
</button>
|
||||||
|
</EditForm>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public required HttpContext HttpContext { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public required ApplicationUser User { get; set; }
|
||||||
|
|
||||||
|
[SupplyParameterFromForm(FormName = "update-contact")]
|
||||||
|
private InputModel Model { get; set; } = new();
|
||||||
|
|
||||||
|
protected override void OnInitialized() {
|
||||||
|
if (HttpContext.Request.Method.ToLower() == "post") return;
|
||||||
|
Model.ContactEmail = User.ContactEmail;
|
||||||
|
Model.ContactPhone = User.ContactPhone;
|
||||||
|
Model.ContactPhoneBusiness = User.ContactPhoneBusiness;
|
||||||
|
Model.ContactWebsite = User.ContactWebsite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnValidSubmit() {
|
||||||
|
try {
|
||||||
|
User.ContactEmail = Model.ContactEmail ?? "";
|
||||||
|
User.ContactPhone = Model.ContactPhone ?? "";
|
||||||
|
User.ContactPhoneBusiness = Model.ContactPhoneBusiness ?? "";
|
||||||
|
User.ContactWebsite = Model.ContactWebsite ?? "";
|
||||||
|
|
||||||
|
await UserManager.UpdateAsync(User);
|
||||||
|
Message.ShowSuccess(Localizer["Contact_Success"]);
|
||||||
|
} catch {
|
||||||
|
Message.ShowSuccess(Localizer["Contact_Error"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class InputModel {
|
||||||
|
private string? _contactEmail;
|
||||||
|
private string? _contactPhone;
|
||||||
|
private string? _contactPhoneBusiness;
|
||||||
|
private string? _contactWebsite;
|
||||||
|
|
||||||
|
[MaxLength(128), EmailAddress]
|
||||||
|
public string? ContactEmail {
|
||||||
|
get => string.IsNullOrWhiteSpace(_contactEmail) ? null : _contactEmail;
|
||||||
|
set => _contactEmail = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MaxLength(64), Phone]
|
||||||
|
public string? ContactPhone {
|
||||||
|
get => string.IsNullOrWhiteSpace(_contactPhone) ? null : _contactPhone;
|
||||||
|
set => _contactPhone = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MaxLength(64), Phone]
|
||||||
|
public string? ContactPhoneBusiness {
|
||||||
|
get => string.IsNullOrWhiteSpace(_contactPhoneBusiness) ? null : _contactPhoneBusiness;
|
||||||
|
set => _contactPhoneBusiness = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MaxLength(128), Url]
|
||||||
|
public string? ContactWebsite {
|
||||||
|
get => string.IsNullOrWhiteSpace(_contactWebsite) ? null : _contactWebsite;
|
||||||
|
set => _contactWebsite = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,6 +28,6 @@ public class ApplicationUser : IdentityUser {
|
||||||
public string ContactPhone { get; set; } = string.Empty;
|
public string ContactPhone { get; set; } = string.Empty;
|
||||||
[MaxLength(64), Phone, PersonalData]
|
[MaxLength(64), Phone, PersonalData]
|
||||||
public string ContactPhoneBusiness { get; set; } = string.Empty;
|
public string ContactPhoneBusiness { get; set; } = string.Empty;
|
||||||
[MaxLength(128), Phone, PersonalData]
|
[MaxLength(128), Url, PersonalData]
|
||||||
public string ContactWebsite { get; set; } = string.Empty;
|
public string ContactWebsite { get; set; } = string.Empty;
|
||||||
}
|
}
|
|
@ -168,4 +168,37 @@ Ich koche seit dem jungen Alter von 7...</value>
|
||||||
<data name="Profile_Link_Label" xml:space="preserve">
|
<data name="Profile_Link_Label" xml:space="preserve">
|
||||||
<value>Profil Öffnen</value>
|
<value>Profil Öffnen</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ContactInformation" xml:space="preserve">
|
||||||
|
<value>Kontaktinformation</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Error" xml:space="preserve">
|
||||||
|
<value>Fehler beim aktuallisieren der Kontaktinformationen</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Email_Label" xml:space="preserve">
|
||||||
|
<value>Öffentliche E-Mail</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Email_Placeholder" xml:space="preserve">
|
||||||
|
<value>anna.muster@example.de</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Success" xml:space="preserve">
|
||||||
|
<value>Kontaktinformationen aktuallisiert</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Website_Label" xml:space="preserve">
|
||||||
|
<value>Webseite</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Website_Placeholder" xml:space="preserve">
|
||||||
|
<value>https://example.de</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_PhoneBusiness_Label" xml:space="preserve">
|
||||||
|
<value>Telefon Geschäftlich</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Phone_Label" xml:space="preserve">
|
||||||
|
<value>Telefon</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_PhoneBusiness_Placeholder" xml:space="preserve">
|
||||||
|
<value>+49 555 5555 555</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Phone_Placeholder" xml:space="preserve">
|
||||||
|
<value>+49 555 5555 555</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -168,4 +168,37 @@ I started cooking at the young age of 7...</value>
|
||||||
<data name="Profile_Link_Label" xml:space="preserve">
|
<data name="Profile_Link_Label" xml:space="preserve">
|
||||||
<value>Go to Profile</value>
|
<value>Go to Profile</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ContactInformation" xml:space="preserve">
|
||||||
|
<value>Contact Information</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Email_Label" xml:space="preserve">
|
||||||
|
<value>Public Email</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Email_Placeholder" xml:space="preserve">
|
||||||
|
<value>john.doe@example.com</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Phone_Label" xml:space="preserve">
|
||||||
|
<value>Phone</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Phone_Placeholder" xml:space="preserve">
|
||||||
|
<value>+55 555 5555 555</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_PhoneBusiness_Label" xml:space="preserve">
|
||||||
|
<value>Business Phone</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_PhoneBusiness_Placeholder" xml:space="preserve">
|
||||||
|
<value>+55 555 5555 555</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Website_Label" xml:space="preserve">
|
||||||
|
<value>Website</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Website_Placeholder" xml:space="preserve">
|
||||||
|
<value>https://example.com</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Success" xml:space="preserve">
|
||||||
|
<value>Updated contact information</value>
|
||||||
|
</data>
|
||||||
|
<data name="Contact_Error" xml:space="preserve">
|
||||||
|
<value>Error updated contact information</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue