|
|
|
@ -111,8 +111,8 @@ namespace Volo.Abp.Http.ProxyScripting.Generators
|
|
|
|
|
public static string GetParamNameInJsFunc(ParameterApiDescriptionModel parameterInfo)
|
|
|
|
|
{
|
|
|
|
|
return parameterInfo.Name == parameterInfo.NameOnMethod
|
|
|
|
|
? NormalizeJsVariableName(parameterInfo.Name.ToCamelCase(), ".")
|
|
|
|
|
: NormalizeJsVariableName(parameterInfo.NameOnMethod.ToCamelCase()) + "." + NormalizeJsVariableName(parameterInfo.Name.ToCamelCase(), ".");
|
|
|
|
|
? NormalizeJsVariableName(parameterInfo.Name.ToCamelCase(), ".")
|
|
|
|
|
: NormalizeJsVariableName(parameterInfo.NameOnMethod.ToCamelCase()) + "." + NormalizeJsVariableName(parameterInfo.Name.ToCamelCase(), ".");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string CreateJsObjectLiteral(ParameterApiDescriptionModel[] parameters, int indent = 0)
|
|
|
|
@ -131,9 +131,37 @@ namespace Volo.Abp.Http.ProxyScripting.Generators
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetFormPostParamNameInJsFunc(ParameterApiDescriptionModel parameterInfo)
|
|
|
|
|
{
|
|
|
|
|
return parameterInfo.Name == parameterInfo.NameOnMethod
|
|
|
|
|
? NormalizeJsVariableName((parameterInfo.DescriptorName + parameterInfo.Name).ToCamelCase(), ".")
|
|
|
|
|
: NormalizeJsVariableName(parameterInfo.NameOnMethod.ToCamelCase()) + "." + NormalizeJsVariableName((parameterInfo.DescriptorName + parameterInfo.Name).ToCamelCase(), ".");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string CreateJsFormPostData(ParameterApiDescriptionModel[] parameters, int indent)
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < parameters.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var and = i < parameters.Length - 1 ? " + '&' + " : string.Empty;
|
|
|
|
|
|
|
|
|
|
var parameterName = parameters[i].DescriptorName.IsNullOrWhiteSpace()
|
|
|
|
|
? parameters[i].Name
|
|
|
|
|
: $"{parameters[i].DescriptorName}.{parameters[i].Name}";
|
|
|
|
|
|
|
|
|
|
sb.Append($"'{parameterName}=' + {GetFormPostParamNameInJsFunc(parameters[i])}{and}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GenerateJsFuncParameterList(ActionApiDescriptionModel action, string ajaxParametersName)
|
|
|
|
|
{
|
|
|
|
|
var methodParamNames = action.ParametersOnMethod.Select(p => p.Name).Distinct().ToList();
|
|
|
|
|
var paramsIsFromForm = action.Parameters.Any(x => x.BindingSourceId == ParameterBindingSources.Form);
|
|
|
|
|
var methodParamNames = paramsIsFromForm
|
|
|
|
|
? action.Parameters.Select(p => p.DescriptorName + p.Name).Distinct().ToList()
|
|
|
|
|
: action.ParametersOnMethod.Select(p => p.Name).Distinct().ToList();
|
|
|
|
|
methodParamNames.Add(ajaxParametersName);
|
|
|
|
|
return methodParamNames.Select(prmName => NormalizeJsVariableName(prmName.ToCamelCase())).JoinAsString(", ");
|
|
|
|
|
}
|
|
|
|
|