Fix to default value for various input control types

This commit is contained in:
axeleron007 2021-06-10 18:42:20 +03:00
parent 823eaf8a80
commit a886fab9b5
9 changed files with 60 additions and 12 deletions

View file

@ -59,6 +59,19 @@ namespace Elsa.Activities.Webhooks.ActivityTypes
Traits = ActivityTraits.Trigger,
InputProperties = new[]
{
new ActivityInputDescriptor(
nameof(HttpEndpoint.Path),
typeof(Microsoft.AspNetCore.Http.PathString),
ActivityInputUIHints.SingleLine,
"Path",
"The relative path that triggers this activity.",
null,
default,
0,
webhook.Path,
SyntaxNames.Literal,
new[] { SyntaxNames.Literal }
),
new ActivityInputDescriptor(
nameof(HttpEndpoint.Methods),
typeof(HashSet<string>),
@ -67,10 +80,20 @@ namespace Elsa.Activities.Webhooks.ActivityTypes
"Specify what request method this webhook should handle. Leave empty to handle both GET and POST requests",
new[] { "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD" },
default,
0,
"POST",
1,
new[] { "GET", "POST" },
SyntaxNames.Json,
new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid })
new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid }
)
},
OutputProperties = new[]
{
new ActivityOutputDescriptor
(
"Request",
typeof(Models.WebhookRequestModel),
"The received HTTP request."
)
}
};

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
namespace Elsa.Activities.Webhooks.Models
{
public record WebhookRequestModel(Uri Path, string Method, IDictionary<string, string> QueryString, IDictionary<string, string> Headers, object? Body = default)
{
public T GetBody<T>() => (T)Body!;
}
}

View file

@ -46,11 +46,17 @@ export class ElsaCheckListProperty {
}
render() {
debugger
const propertyDescriptor = this.propertyDescriptor;
const propertyModel = this.propertyModel;
const fieldId = propertyDescriptor.name;
const items = this.items;
const values = parseJson(this.currentValue) || [];
let values = parseJson(this.currentValue) || [];
if (values.length == 0) {
const defaultValue = this.propertyDescriptor.defaultValue;
values = defaultValue ? defaultValue : [];
}
return (
<elsa-property-editor propertyDescriptor={propertyDescriptor}

View file

@ -18,7 +18,7 @@ export class ElsaDropdownProperty {
async componentWillLoad() {
const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal;
this.currentValue = this.propertyModel.expressions[defaultSyntax] || '';
this.currentValue = this.propertyModel.expressions[defaultSyntax] || undefined;
this.items = await getSelectListItems(this.serverUrl, this.propertyDescriptor);
}
@ -33,14 +33,20 @@ export class ElsaDropdownProperty {
}
render() {
debugger
const propertyDescriptor = this.propertyDescriptor;
const propertyModel = this.propertyModel;
const propertyName = propertyDescriptor.name;
const fieldId = propertyName;
const fieldName = propertyName;
const currentValue = this.currentValue;
let currentValue = this.currentValue;
const items = this.items;
if (currentValue == undefined) {
const defaultValue = this.propertyDescriptor.defaultValue;
currentValue = defaultValue ? defaultValue.toString() : undefined;
}
return (
<elsa-property-editor propertyDescriptor={propertyDescriptor}
propertyModel={propertyModel}

View file

@ -13,7 +13,7 @@ export class ElsaMultiLineProperty {
componentWillLoad() {
const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal;
this.currentValue = this.propertyModel.expressions[defaultSyntax] || '';
this.currentValue = this.propertyModel.expressions[defaultSyntax] || undefined;
}
getEditorHeight(options: any) {

View file

@ -19,6 +19,7 @@ export class ElsaRadioListProperty {
items: any[];
async componentWillLoad() {
debugger
const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal;
this.currentValue = this.propertyModel.expressions[defaultSyntax] || null;
}

View file

@ -17,9 +17,9 @@ export class ElsaSingleLineProperty {
this.propertyModel.expressions[defaultSyntax] = this.currentValue = input.value;
}
componentWillLoad() {
componentWillLoad() {
const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal;
this.currentValue = this.propertyModel.expressions[defaultSyntax] || '';
this.currentValue = this.propertyModel.expressions[defaultSyntax] || undefined;
}
onDefaultSyntaxValueChanged(e: CustomEvent) {
@ -27,6 +27,7 @@ export class ElsaSingleLineProperty {
}
render() {
const propertyDescriptor = this.propertyDescriptor;
const propertyModel = this.propertyModel;
const propertyName = propertyDescriptor.name;

View file

@ -18,6 +18,7 @@ export class ElsaSwitchCasesProperty {
syntaxSwitchCount: number = 0;
async componentWillLoad() {
debugger
const propertyModel = this.propertyModel;
const casesJson = propertyModel.expressions['Switch']
this.cases = parseJson(casesJson) || [];

View file

@ -138,7 +138,7 @@ export const createElsaClient = function (serverUrl: string): ElsaClient {
const response = await httpClient.get<PagedList<WorkflowInstanceSummary>>(`v1/workflow-instances${queryStringText}`);
return response.data;
},
get: async id => {
get: async id => {
const response = await httpClient.get(`v1/workflow-instances/${id}`);
return response.data;
},
@ -175,8 +175,8 @@ export const createElsaClient = function (serverUrl: string): ElsaClient {
return response.data;
}
},
designerApi: {
runtimeSelectItemsApi: {
designerApi: {
runtimeSelectItemsApi: {
get: async (providerTypeName: string, context?: any): Promise<Array<SelectListItem>> => {
const response = await httpClient.post('v1/designer/runtime-select-list-items', {providerTypeName: providerTypeName, context: context});
return response.data;