fix #1319 - module title is required

This commit is contained in:
Shaun Walker 2021-05-07 12:14:54 -04:00
parent be38d2cd70
commit 15b0bed257

View File

@ -167,46 +167,53 @@
private async Task SaveModule() private async Task SaveModule()
{ {
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); if (!string.IsNullOrEmpty(_title))
pagemodule.PageId = int.Parse(_pageId);
pagemodule.Title = _title;
pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty;
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType)
{ {
pagemodule.ContainerType = string.Empty; var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
} pagemodule.PageId = int.Parse(_pageId);
if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) pagemodule.Title = _title;
{ pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty;
pagemodule.ContainerType = string.Empty; if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType)
}
await PageModuleService.UpdatePageModuleAsync(pagemodule);
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
var module = ModuleState;
module.AllPages = bool.Parse(_allPages);
module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module);
if (_moduleSettingsType != null)
{
if (_moduleSettings is ISettingsControl moduleSettingsControl)
{ {
// module settings updated using explicit interface pagemodule.ContainerType = string.Empty;
await moduleSettingsControl.UpdateSettings();
} }
else if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType)
{ {
// legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component ) pagemodule.ContainerType = string.Empty;
_moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null);
} }
} await PageModuleService.UpdatePageModuleAsync(pagemodule);
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) var module = ModuleState;
module.AllPages = bool.Parse(_allPages);
module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module);
if (_moduleSettingsType != null)
{
if (_moduleSettings is ISettingsControl moduleSettingsControl)
{
// module settings updated using explicit interface
await moduleSettingsControl.UpdateSettings();
}
else
{
// legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component )
_moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null);
}
}
if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl)
{
await containerSettingsControl.UpdateSettings();
}
NavigationManager.NavigateTo(NavigateUrl());
}
else
{ {
await containerSettingsControl.UpdateSettings(); AddModuleMessage(Localizer["You Must Provide A Title For The Module"], MessageType.Warning);
} }
NavigationManager.NavigateTo(NavigateUrl());
} }
} }