added in GetUrlParameters route to Module Index action
This commit is contained in:
parent
c5037e7084
commit
cb2d529689
|
@ -17,7 +17,7 @@ namespace Oqtane.Modules
|
|||
private Logger _logger;
|
||||
|
||||
protected Logger logger => _logger ?? (_logger = new Logger(this));
|
||||
|
||||
|
||||
[Inject]
|
||||
protected ILogService LoggingService { get; set; }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Oqtane.Modules
|
|||
[CascadingParameter]
|
||||
protected Module ModuleState { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
[CascadingParameter]
|
||||
protected ModuleInstance ModuleInstance { get; set; }
|
||||
|
||||
// optional interface properties
|
||||
|
@ -62,7 +62,7 @@ namespace Oqtane.Modules
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// path method
|
||||
|
||||
public string ModulePath()
|
||||
|
@ -116,6 +116,38 @@ namespace Oqtane.Modules
|
|||
return Utilities.ContentUrl(PageState.Alias, fileid);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetUrlParameters(string parameterTemplate)
|
||||
{
|
||||
var urlParameters = new Dictionary<string, string>();
|
||||
|
||||
var templateSegments = parameterTemplate.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||
var parameters = PageState.UrlParameters.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parameters.Length == templateSegments.Length)
|
||||
{
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
if (parameters.Length > i)
|
||||
{
|
||||
if (templateSegments[i] == parameters[i])
|
||||
{
|
||||
}
|
||||
else if (templateSegments[i].StartsWith("[") && templateSegments[i].EndsWith("]"))
|
||||
{
|
||||
var key = templateSegments[i].Replace("[", "");
|
||||
key = key.Replace("]", "");
|
||||
urlParameters.TryAdd(key, parameters[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = parameters.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return urlParameters;
|
||||
}
|
||||
|
||||
// user feedback methods
|
||||
public void AddModuleMessage(string message, MessageType type)
|
||||
{
|
||||
|
@ -154,12 +186,15 @@ namespace Oqtane.Modules
|
|||
case "add":
|
||||
logFunction = LogFunction.Create;
|
||||
break;
|
||||
|
||||
case "edit":
|
||||
logFunction = LogFunction.Update;
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
logFunction = LogFunction.Delete;
|
||||
break;
|
||||
|
||||
default:
|
||||
logFunction = LogFunction.Read;
|
||||
break;
|
||||
|
@ -241,4 +276,4 @@ namespace Oqtane.Modules
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -209,7 +209,15 @@
|
|||
{
|
||||
modIdPos = i + 1;
|
||||
actionPos = modIdPos + 1;
|
||||
action = segments[actionPos];
|
||||
if (actionPos > segments.Length - 1)
|
||||
{
|
||||
action = Constants.DefaultAction;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = segments[actionPos];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -219,7 +227,14 @@
|
|||
{
|
||||
int.TryParse(segments[modIdPos], out result);
|
||||
moduleid = result;
|
||||
path = path.Replace("/" + segments[modIdPos - 1] + "/" + segments[modIdPos] + "/" + segments[actionPos], "");
|
||||
if (actionPos > segments.Length - 1)
|
||||
{
|
||||
path = path.Replace("/" + segments[modIdPos - 1] + "/" + segments[modIdPos], "");
|
||||
}
|
||||
else
|
||||
{
|
||||
path = path.Replace("/" + segments[modIdPos - 1] + "/" + segments[modIdPos] + "/" + segments[actionPos], "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user