fix #4628 - preserve Url for all ModuleActions
This commit is contained in:
parent
f8b58866dc
commit
49b971280f
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="ExportModule">@Localizer["Export"]</button>
|
<button type="button" class="btn btn-success" @onclick="ExportModule">@Localizer["Export"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@PageState.ReturnUrl">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string _content = string.Empty;
|
private string _content = string.Empty;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button>
|
<button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@PageState.ReturnUrl">@SharedLocalizer["Cancel"]</NavLink>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
|
@ -11,9 +11,6 @@ using System.Net;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Oqtane.UI;
|
using Oqtane.UI;
|
||||||
|
|
||||||
// ReSharper disable UnassignedGetOnlyAutoProperty
|
|
||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
|
|
||||||
namespace Oqtane.Themes.Controls
|
namespace Oqtane.Themes.Controls
|
||||||
{
|
{
|
||||||
public class ModuleActionsBase : ComponentBase
|
public class ModuleActionsBase : ComponentBase
|
||||||
|
@ -92,20 +89,17 @@ namespace Oqtane.Themes.Controls
|
||||||
return actionList;
|
return actionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> EditUrlAsync(string url, int moduleId, string import)
|
|
||||||
{
|
|
||||||
await Task.Yield();
|
|
||||||
return Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, moduleId, import, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task ModuleAction(ActionViewModel action)
|
protected async Task ModuleAction(ActionViewModel action)
|
||||||
{
|
{
|
||||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.PermissionList))
|
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.PermissionList))
|
||||||
{
|
{
|
||||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
var url = NavigationManager.Uri.Substring(NavigationManager.BaseUri.Length - 1);
|
||||||
|
if (!url.Contains("edit=true&refresh"))
|
||||||
string url = Utilities.NavigateUrl(PageState.Alias.Path, PageState.Page.Path, "edit=true&refresh");
|
{
|
||||||
|
url += (!url.Contains("?") ? "?" : "&") + "edit=true&refresh";
|
||||||
|
}
|
||||||
|
|
||||||
|
var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||||
if (action.Action != null)
|
if (action.Action != null)
|
||||||
{
|
{
|
||||||
url = await action.Action(url, pagemodule);
|
url = await action.Action(url, pagemodule);
|
||||||
|
@ -115,29 +109,9 @@ namespace Oqtane.Themes.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> MoveToPane(string url, string newPane, PageModule pagemodule)
|
|
||||||
{
|
|
||||||
string oldPane = pagemodule.Pane;
|
|
||||||
pagemodule.Pane = newPane;
|
|
||||||
pagemodule.Order = int.MaxValue; // add to bottom of pane
|
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, oldPane);
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<string> DeleteModule(string url, PageModule pagemodule)
|
|
||||||
{
|
|
||||||
pagemodule.IsDeleted = true;
|
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
|
||||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<string> Settings(string url, PageModule pagemodule)
|
private Task<string> Settings(string url, PageModule pagemodule)
|
||||||
{
|
{
|
||||||
var returnurl = NavigationManager.Uri.Substring(NavigationManager.BaseUri.Length - 1);
|
url = Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, pagemodule.ModuleId, "Settings", "returnurl=" + WebUtility.UrlEncode(url));
|
||||||
url = Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, pagemodule.ModuleId, "Settings", "returnurl=" + WebUtility.UrlEncode(returnurl));
|
|
||||||
return Task.FromResult(url);
|
return Task.FromResult(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +147,20 @@ namespace Oqtane.Themes.Controls
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> DeleteModule(string url, PageModule pagemodule)
|
||||||
|
{
|
||||||
|
pagemodule.IsDeleted = true;
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<string> EditUrlAsync(string url, int moduleId, string import)
|
||||||
|
{
|
||||||
|
url = Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, moduleId, import, "returnurl=" + WebUtility.UrlEncode(url));
|
||||||
|
return Task.FromResult(url);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<string> MoveTop(string url, PageModule pagemodule)
|
private async Task<string> MoveTop(string url, PageModule pagemodule)
|
||||||
{
|
{
|
||||||
pagemodule.Order = 0;
|
pagemodule.Order = 0;
|
||||||
|
@ -205,6 +193,17 @@ namespace Oqtane.Themes.Controls
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> MoveToPane(string url, string newPane, PageModule pagemodule)
|
||||||
|
{
|
||||||
|
string oldPane = pagemodule.Pane;
|
||||||
|
pagemodule.Pane = newPane;
|
||||||
|
pagemodule.Order = int.MaxValue; // add to bottom of pane
|
||||||
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||||
|
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, oldPane);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
public class ActionViewModel
|
public class ActionViewModel
|
||||||
{
|
{
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user