Localize non components in users pages

This commit is contained in:
hishamco
2020-11-17 23:04:16 +03:00
parent 261f48e842
commit 086e3623c3
4 changed files with 90 additions and 85 deletions

View File

@ -4,6 +4,7 @@
@inject IUserService UserService @inject IUserService UserService
@inject IProfileService ProfileService @inject IProfileService ProfileService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Add> Localizer
<TabStrip> <TabStrip>
<TabPanel Name="Identity" ResourceKey="Identity"> <TabPanel Name="Identity" ResourceKey="Identity">
@ -12,15 +13,15 @@
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<label class="control-label">Username: </label> <label class="control-label">@Localizer["Username:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@username" /> <input class="form-control" @bind="@username" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Password: </label> <label class="control-label">@Localizer["Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@password" /> <input type="password" class="form-control" @bind="@password" />
@ -28,7 +29,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Confirm Password: </label> <label class="control-label">@Localizer["Confirm Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@confirm" /> <input type="password" class="form-control" @bind="@confirm" />
@ -36,7 +37,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Email: </label> <label class="control-label">@Localizer["Email:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@email" /> <input class="form-control" @bind="@email" />
@ -44,7 +45,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Full Name: </label> <label class="control-label">@Localizer["Full Name:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@displayname" /> <input class="form-control" @bind="@displayname" />
@ -56,42 +57,42 @@
<TabPanel Name="Profile" ResourceKey="Profile"> <TabPanel Name="Profile" ResourceKey="Profile">
@if (profiles != null) @if (profiles != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
@foreach (Profile profile in profiles) @foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
{ {
var p = profile;
if (p.Category != category)
{
<tr>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
</tr>
category = p.Category;
}
<tr> <tr>
<th colspan="2" style="text-align: center;"> <td>
@p.Category <Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</th> </td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr> </tr>
category = p.Category;
} }
<tr> </table>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
}
</table>
} }
</TabPanel> </TabPanel>
</TabStrip> </TabStrip>
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button> <button type="button" class="btn btn-primary" @onclick="SaveUser">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
@code { @code {
private string username = string.Empty; private string username = string.Empty;

View File

@ -4,6 +4,7 @@
@inject IUserService UserService @inject IUserService UserService
@inject IProfileService ProfileService @inject IProfileService ProfileService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Edit> Localizer
@if (PageState.User != null && photofileid != -1) @if (PageState.User != null && photofileid != -1)
{ {
@ -20,7 +21,7 @@ else
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<label class="control-label">Username: </label> <label class="control-label">@Localizer["Username:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@username" readonly /> <input class="form-control" @bind="@username" readonly />
@ -28,7 +29,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Password: </label> <label class="control-label">@Localizer["Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@password" /> <input type="password" class="form-control" @bind="@password" />
@ -36,7 +37,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Confirm Password: </label> <label class="control-label">@Localizer["Confirm Password:"] </label>
</td> </td>
<td> <td>
<input type="password" class="form-control" @bind="@confirm" /> <input type="password" class="form-control" @bind="@confirm" />
@ -44,7 +45,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Email: </label> <label class="control-label">@Localizer["Email:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@email" /> <input class="form-control" @bind="@email" />
@ -52,7 +53,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Full Name: </label> <label class="control-label">@Localizer["Full Name:"] </label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@displayname" /> <input class="form-control" @bind="@displayname" />
@ -60,7 +61,7 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Photo: </label> <label class="control-label">@Localizer["Photo:"] </label>
</td> </td>
<td> <td>
<FileManager FileId="@photofileid" @ref="filemanager" /> <FileManager FileId="@photofileid" @ref="filemanager" />
@ -68,12 +69,12 @@ else
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Is Deleted? </label> <label class="control-label">@Localizer["Is Deleted?"] </label>
</td> </td>
<td> <td>
<select class="form-control" @bind="@isdeleted"> <select class="form-control" @bind="@isdeleted">
<option value="True">Yes</option> <option value="True">@Localizer["Yes"]</option>
<option value="False">No</option> <option value="False">@Localizer["No"]</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -83,43 +84,44 @@ else
<TabPanel Name="Profile" ResourceKey="Profile"> <TabPanel Name="Profile" ResourceKey="Profile">
@if (profiles != null) @if (profiles != null)
{ {
<table class="table table-borderless"> <table class="table table-borderless">
@foreach (Profile profile in profiles) @foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
{ {
var p = profile;
if (p.Category != category)
{
<tr>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
</tr>
category = p.Category;
}
<tr> <tr>
<th colspan="2" style="text-align: center;"> <td>
@p.Category <Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</th> </td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr> </tr>
category = p.Category;
} }
<tr> </table>
<td>
<Label For="@p.Name" HelpText="@p.Description">@p.Title</Label>
</td>
<td>
@if (p.IsRequired)
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" required @onchange="@(e => ProfileChanged(e, p.Name))" />
}
else
{
<input id="@p.Name" class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" @onchange="@(e => ProfileChanged(e, p.Name))" />
}
</td>
</tr>
}
</table>
} }
</TabPanel> </TabPanel>
</TabStrip> </TabStrip>
<button type="button" class="btn btn-primary" @onclick="SaveUser">Save</button> <button type="button" class="btn btn-primary" @onclick="SaveUser">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<br /><br /> <br />
<br />
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo> <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
@code { @code {

View File

@ -3,11 +3,12 @@
@inject IUserRoleService UserRoleService @inject IUserRoleService UserRoleService
@inject IUserService UserService @inject IUserService UserService
@inject ISettingService SettingService @inject ISettingService SettingService
@inject IStringLocalizer<Index> Localizer
@if (userroles == null) @if (userroles == null)
{ {
<p> <p>
<em>Loading...</em> <em>@Localizer["Loading..."]</em>
</p> </p>
} }
else else
@ -15,7 +16,7 @@ else
<ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" /> <ActionLink Action="Add" Text="Add User" ResourceKey="AddUser" />
<div class="d-flex p-1"> <div class="d-flex p-1">
<input class="form-control mr-4" @bind="@_search"/><button class="btn btn-outline-primary ml-1" @onclick="OnSearch">Search</button> <input class="form-control mr-4" @bind="@_search" /><button class="btn btn-outline-primary ml-1" @onclick="OnSearch">@Localizer["Search"]</button>
</div> </div>
<Pager Items="@userroles"> <Pager Items="@userroles">
@ -23,11 +24,11 @@ else
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th>Name</th> <th>@Localizer["Name"]</th>
</Header> </Header>
<Row> <Row>
<td> <td>
<ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser"/> <ActionLink Action="Edit" Parameters="@($"id=" + context.UserId.ToString())" ResourceKey="EditUser" />
</td> </td>
<td> <td>
<ActionDialog Header="Delete User" Message="@("Are You Sure You Wish To Delete " + context.User.DisplayName + "?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" ResourceKey="DeleteUser" /> <ActionDialog Header="Delete User" Message="@("Are You Sure You Wish To Delete " + context.User.DisplayName + "?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" ResourceKey="DeleteUser" />

View File

@ -3,10 +3,11 @@
@inject IRoleService RoleService @inject IRoleService RoleService
@inject IUserService UserService @inject IUserService UserService
@inject IUserRoleService UserRoleService @inject IUserRoleService UserRoleService
@inject IStringLocalizer<Roles> Localizer
@if (userroles == null) @if (userroles == null)
{ {
<p><em>Loading...</em></p> <p><em>@Localizer["Loading..."]</em></p>
} }
else else
{ {
@ -50,23 +51,23 @@ else
</td> </td>
</tr> </tr>
</table> </table>
<button type="button" class="btn btn-success" @onclick="SaveUserRole">Save</button> <button type="button" class="btn btn-success" @onclick="SaveUserRole">@Localizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
<hr class="app-rule" /> <hr class="app-rule" />
<p align="center"> <p align="center">
<Pager Items="@userroles"> <Pager Items="@userroles">
<Header> <Header>
<th>Roles</th> <th>@Localizer["Roles"]</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</Header> </Header>
<Row> <Row>
<td>@context.Role.Name</td> <td>@context.Role.Name</td>
<td> <td>
@if (context.Role.Name != RoleNames.Registered) @if (context.Role.Name != RoleNames.Registered)
{ {
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>Delete</button> <button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteUserRole(context.UserRoleId))>@Localizer["Delete"]</button>
} }
</td> </td>
</Row> </Row>
</Pager> </Pager>