Enhancment to the Module Managment to show where module is used.
Added a new tab that lists all the pages where there is a module instance with the count of the number of instances. This helps when making a decision to delete the module from the framework.
This commit is contained in:
parent
4688e49454
commit
b02584bec6
|
@ -8,6 +8,8 @@
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||||
|
@inject IPageModuleService PageModuleService
|
||||||
|
@inject IModuleService ModuleService
|
||||||
|
|
||||||
@if (_initialized)
|
@if (_initialized)
|
||||||
{
|
{
|
||||||
|
@ -131,6 +133,20 @@
|
||||||
<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">
|
||||||
|
<Pager Items="@_groupedModules">
|
||||||
|
<Header>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
|
<th>@SharedLocalizer["Name"]</th>
|
||||||
|
<th>@Localizer["Count"]</th>
|
||||||
|
</Header>
|
||||||
|
<Row>
|
||||||
|
<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>@context.Count</td>
|
||||||
|
</Row>
|
||||||
|
</Pager>
|
||||||
|
</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)
|
||||||
{
|
{
|
||||||
|
@ -240,6 +256,7 @@
|
||||||
private DateTime _createdon;
|
private DateTime _createdon;
|
||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
|
private List<GroupedModule> _groupedModules;
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
private PermissionGrid _permissionGrid;
|
private PermissionGrid _permissionGrid;
|
||||||
|
@ -291,6 +308,19 @@
|
||||||
_languages = _languages.OrderBy(item => item.Name).ToList();
|
_languages = _languages.OrderBy(item => item.Name).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Group modules by PageId
|
||||||
|
_groupedModules = PageState.Modules
|
||||||
|
.Where(md => md.ModuleDefinition.ModuleDefinitionId == _moduleDefinitionId)
|
||||||
|
.GroupBy(md => md.PageId)
|
||||||
|
.Select(group => new GroupedModule
|
||||||
|
{
|
||||||
|
Name = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key)?.Name,
|
||||||
|
Title = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key)?.Title,
|
||||||
|
PagePath = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key)?.Path,
|
||||||
|
PageUrl = PageState.Pages.FirstOrDefault(pg => pg.PageId == group.Key)?.Url,
|
||||||
|
Count = group.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,5 +469,15 @@
|
||||||
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 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; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,4 +240,13 @@
|
||||||
<data name="Validate" xml:space="preserve">
|
<data name="Validate" xml:space="preserve">
|
||||||
<value>Validate</value>
|
<value>Validate</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Browse" xml:space="preserve">
|
||||||
|
<value>Browse</value>
|
||||||
|
</data>
|
||||||
|
<data name="Count" xml:space="preserve">
|
||||||
|
<value>Module Count</value>
|
||||||
|
</data>
|
||||||
|
<data name="OnPages.Heading" xml:space="preserve">
|
||||||
|
<value>On Pages</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user