Rework
Not to display the number of instances of the module on those pages. Name the tab "Pages".
This commit is contained in:
parent
e0b0302f5a
commit
652d42aa6b
|
@ -133,24 +133,22 @@
|
||||||
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">@SharedLocalizer["Save"]</button>
|
<button type="button" class="btn btn-success" @onclick="SaveModuleDefinition">@SharedLocalizer["Save"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="OnPages" ResourceKey="OnPages" Heading="Pages">
|
<TabPanel Name="Pages" ResourceKey="Pages" Heading="Pages">
|
||||||
<Pager Items="@_groupedModules">
|
<Pager Items="@_pagesWithModules" RowClass="align-middle">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<th>@Localizer["Count"]</th>
|
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><button type="button" class="btn btn-secondary" @onclick="@(async () => NavigationManager.NavigateTo(Browse(context)))">@Localizer["Browse"]</button></td>
|
<td><button type="button" class="btn btn-secondary" @onclick="@(async () => NavigationManager.NavigateTo(Browse(context)))">@Localizer["Browse"]</button></td>
|
||||||
<td>@(string.IsNullOrEmpty(context.Title) ? @context.Name : @context.Title )</td>
|
<td>@(string.IsNullOrEmpty(context.Title) ? @context.Name : @context.Title )</td>
|
||||||
<td>@context.Count</td>
|
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel Name="Translations" ResourceKey="Translations" Heading="Translations">
|
<TabPanel Name="Translations" ResourceKey="Translations" Heading="Translations">
|
||||||
@if (_languages != null && _languages.Count > 0)
|
@if (_languages != null && _languages.Count > 0)
|
||||||
{
|
{
|
||||||
<Pager Items="@_languages">
|
<Pager Items="@_languages">
|
||||||
<Header>
|
<Header>
|
||||||
<th>@SharedLocalizer["Name"]</th>
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
<th>@Localizer["Code"]</th>
|
<th>@Localizer["Code"]</th>
|
||||||
|
@ -256,7 +254,8 @@
|
||||||
private DateTime _createdon;
|
private DateTime _createdon;
|
||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
private List<GroupedModule> _groupedModules;
|
private List<Page> _pagesWithModules
|
||||||
|
;
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
private PermissionGrid _permissionGrid;
|
private PermissionGrid _permissionGrid;
|
||||||
|
@ -309,18 +308,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group modules by PageId
|
// Group modules by PageId
|
||||||
_groupedModules = PageState.Modules
|
// Get distinct PageIds where modules are present
|
||||||
.Where(md => md.ModuleDefinition.ModuleDefinitionId == _moduleDefinitionId && md.IsDeleted == false)
|
var distinctPageIds = PageState.Modules
|
||||||
.GroupBy(md => md.PageId)
|
.Where(md => md.ModuleDefinition.ModuleDefinitionId == _moduleDefinitionId && md.IsDeleted == false)
|
||||||
.Select(group => new GroupedModule
|
.Select(md => md.PageId)
|
||||||
{
|
.Distinct();
|
||||||
Name = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key && pg.IsDeleted == false)?.Name,
|
|
||||||
Title = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key && pg.IsDeleted == false)?.Title,
|
// Filter and retrieve the corresponding pages
|
||||||
PagePath = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key && pg.IsDeleted == false)?.Path,
|
_pagesWithModules = PageState.Pages
|
||||||
PageUrl = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key && pg.IsDeleted == false)?.Url,
|
.Where(pg => distinctPageIds.Contains(pg.PageId) && pg.IsDeleted == false)
|
||||||
Count = group.Count()
|
.ToList();
|
||||||
}).Where(gm => gm.Name != null)
|
|
||||||
.ToList();
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,15 +467,5 @@
|
||||||
AddModuleMessage(Localizer["Error.Validate"], MessageType.Error);
|
AddModuleMessage(Localizer["Error.Validate"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string Browse(GroupedModule page) => string.IsNullOrEmpty(page.PageUrl) ? NavigateUrl(page.PagePath) : page.PageUrl;
|
private string Browse(Page page) => string.IsNullOrEmpty(page.Url) ? NavigateUrl(page.Path) : page.Url;
|
||||||
|
|
||||||
private class GroupedModule
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public string PagePath { get; set; }
|
|
||||||
public string PageUrl { get; set; }
|
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@
|
||||||
<data name="Count" xml:space="preserve">
|
<data name="Count" xml:space="preserve">
|
||||||
<value>Module Count</value>
|
<value>Module Count</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="OnPages.Heading" xml:space="preserve">
|
<data name="Pages.Heading" xml:space="preserve">
|
||||||
<value>On Pages</value>
|
<value>Pages</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user