From 038894cf64f8bed8cb4c81d41d4512efd31ac852 Mon Sep 17 00:00:00 2001 From: Michael Atwood Date: Wed, 1 Jul 2020 01:35:06 -0700 Subject: [PATCH] Enhancement to url parameters helper in modulebase --- Oqtane.Client/Modules/ModuleBase.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Oqtane.Client/Modules/ModuleBase.cs b/Oqtane.Client/Modules/ModuleBase.cs index 236fe779..7f2faeda 100644 --- a/Oqtane.Client/Modules/ModuleBase.cs +++ b/Oqtane.Client/Modules/ModuleBase.cs @@ -44,6 +44,26 @@ namespace Oqtane.Modules public virtual List Resources { get; set; } + public virtual string UrlParametersTemplate { get; set; } = ""; + public virtual Dictionary UrlParamerters + { + get + { + var urlparameters = new Dictionary(); + + var templates = UrlParametersTemplate.Split(',', StringSplitOptions.RemoveEmptyEntries); + foreach (var template in templates) + { + urlparameters = GetUrlParameters(template); + + if (urlparameters.Count > 0) goto Return; + } + + Return: + return urlparameters; + } + } + // base lifecycle method for handling JSInterop script registration protected override async Task OnAfterRenderAsync(bool firstRender) @@ -116,7 +136,7 @@ namespace Oqtane.Modules return Utilities.ContentUrl(PageState.Alias, fileid); } - public Dictionary GetUrlParameters(string parameterTemplate) + public virtual Dictionary GetUrlParameters(string parameterTemplate) { var urlParameters = new Dictionary(); @@ -131,7 +151,7 @@ namespace Oqtane.Modules { if (templateSegments[i] == parameters[i]) { - urlParameters.TryAdd("action" + actionId, parameters[i]); + urlParameters.TryAdd("parameter" + actionId, parameters[i]); actionId += 1; } else if (templateSegments[i].StartsWith("{") && templateSegments[i].EndsWith("}"))