Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Dec 22, 2023
1 parent f297231 commit 45b6f61
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 53 deletions.
20 changes: 15 additions & 5 deletions backend/files/system/workflows/get-arguments.post.hl
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,37 @@ for-each:x:@hyper2lambda/*/.arguments/*
.lambda

// Complete argument we can reference "absolutely".
get-name:x:@.dp/#
strings.concat
.:"Argument / "
get-value:x:@get-name
strings.concat
.:@.arguments/*/
get-name:x:@.dp/#
get-name:x:@.dp/#
unwrap:x:+/*/*/*
add:x:../*/return/*/candidates
.
.
name:x:@get-name
name:x:@strings.concat/@strings.concat
expression:x:@strings.concat
type:argument
complete:bool:true

else

// Incomplete argument we can NOT reference "absolutely".
get-name:x:@.dp/#
strings.concat
.:"Argument / "
get-value:x:@get-name
strings.concat
.:@.arguments/*/
get-name:x:@.dp/#
get-name:x:@.dp/#
unwrap:x:+/*/*/*
add:x:../*/return/*/candidates
.
.
name:x:@get-name
name:x:@strings.concat/@strings.concat
expression:x:@strings.concat
type:argument
complete:bool:false
Expand All @@ -77,6 +83,10 @@ for-each:x:@hyper2lambda/*/execute/*/name/./*/filename/.

// Finding complete arguments first, implying arguments we can reference absolutely.
for-each:x:@hyper2lambda/**/[yield|return]/*
strings.concat
get-value:x:@.dp/@.dp/#/*/name
.:" / "
get-name:x:@.dp/#
strings.concat
.:--/execute/=
get-value:x:@.dp/@.dp/#/*/name
Expand All @@ -86,7 +96,7 @@ for-each:x:@hyper2lambda/*/execute/*/name/./*/filename/.
add:x:../*/return/*/candidates
.
.
name:x:@.dp/@.dp/#/*/name
name:x:@strings.concat/@strings.concat
expression:x:@strings.concat
type:action-result
complete:bool:true
Expand Down
40 changes: 25 additions & 15 deletions backend/files/system/workflows/get-hyperlambda.post.hl
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,31 @@ if

// Making sure we correctly convert arguments according to type declaration.
for-each:x:@.arguments/*/args/*
get-name:x:@.dp/#
switch:x:@.action/*/.arguments/*/{@get-name}/*/type
case:long
case:decimal
case:int
case:float
case:double
set-value:x:@.dp/#
convert:x:@.dp/#
type:x:@.action/*/.arguments/*/{@get-name}/*/type
case:hyperlambda
add:x:@.dp/#
hyper2lambda:x:@.dp/#
comments:true
set-value:x:@.dp/#
if
strings.starts-with:x:@.dp/#
.:":x:"
.lambda
strings.substring:x:@.dp/#
.:int:3
set-x:x:@.dp/#
convert:x:@strings.substring
type:x
else
get-name:x:@.dp/#
switch:x:@.action/*/.arguments/*/{@get-name}/*/type
case:long
case:decimal
case:int
case:float
case:double
set-value:x:@.dp/#
convert:x:@.dp/#
type:x:@.action/*/.arguments/*/{@get-name}/*/type
case:hyperlambda
add:x:@.dp/#
hyper2lambda:x:@.dp/#
comments:true
set-value:x:@.dp/#

// Decorating action arguments according to [.arguments]/[args].
add:x:@.invocation/*/execute/*/arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ export class IdeTreeComponent implements OnInit {
width: '750px',
maxWidth: '80vw',
disableClose: true,
autoFocus: false,
data: {
input: result.input,
description: el.description,
name: el.name,
candidates: result.candidates,
},
}).afterClosed().subscribe((args: any) => {
if (args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

/*
* Copyright (c) 2023 Thomas Hansen - For license inquiries you can contact thomas@ainiro.io.
*/

// Angular and system imports.
import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Observable, map, startWith } from 'rxjs';

// Application specific imports

/**
* Formly SQL extension field.
*/
@Component({
selector: 'app-formly-autocomplete',
template: `
<mat-form-field class="w-100 standalone-field mb-4">
<mat-label>{{field.props.label}}</mat-label>
<input type="text"
[id]="field.key"
[placeholder]="field.props.label"
matInput
[formControl]="control"
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option
*ngFor="let option of filteredOptions | async;"
[value]="option.value">{{option.label}}</mat-option>
</mat-autocomplete>
</mat-form-field>
`,
styleUrls: ['./formly-autocomplete.scss']
})
export class FormlyAutocompleteComponent extends FieldType<FieldTypeConfig> implements OnInit {

control = new FormControl('');
filteredOptions: Observable<string[]>;

constructor() {

super();
}

ngOnInit() {

this.filteredOptions = this.control.valueChanges.pipe(
startWith(''),
map(value => this._filter(value || '')),
);
this.control.setValue(this.field.model[<string>this.field.key]);
this.control.valueChanges.subscribe((val: string) => {
this.model[<string>this.field.key] = val;
});
}

/*
* Private helper methods.
*/

private _filter(value: string): any[] {

const filterValue = value.toLowerCase();
return (<any[]>this.field.props.options).filter(option => option.label.toLowerCase().includes(filterValue));
}}
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,35 @@ export class ParametriseActionDialog implements OnInit {
field.type = 'array';
break;

case 'string':
add = true;
field.type = 'input';
field.props.attributes = {
autocomplete: 'off',
};
break;

case 'int':
case 'email':
case 'string':
case 'enum':
add = true;
field.type = 'input';
field.props.attributes = {
autocomplete: 'off',
type: 'number'
};
field.type = 'autocomplete';
field.props.options = [];
if (this.data.input[idx].default) {
field.props.options.push({
value: this.data.input[idx].default,
label: this.data.input[idx].default
});
}
if (this.data.input[idx].type === 'enum') {
for (let idxNo = 0; idxNo < this.data.input[idx].values.length; idxNo++) {
if (field.props.options.filter(x => x.value === this.data.input[idx].values[idxNo]).length === 0) {
field.props.options.push({
value: this.data.input[idx].values[idxNo],
label: this.data.input[idx].values[idxNo],
});
}
}
}
for (const idxCandidate of this.data.candidates) {
field.props.options.push({
value: ':x:' + idxCandidate.expression,
label: idxCandidate.name,
});
}
break;

case 'textarea':
Expand All @@ -101,31 +115,11 @@ export class ParametriseActionDialog implements OnInit {
field.type = 'hyperlambda';
break;

case 'email':
add = true;
field.type = 'input';
field.props.attributes = {
autocomplete: 'email',
};
break;

case 'bool':
add = true;
field.type = 'checkbox';
break;

case 'enum':
add = true;
field.type = 'select';
field.props.options = [];
for (let idxNo = 0; idxNo < this.data.input[idx].values.length; idxNo++) {
field.props.options.push({
value: this.data.input[idx].values[idxNo],
label: this.data.input[idx].values[idxNo],
});
}
break;

default:
field.type = 'input';
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { FormlyCSharpComponent } from '../components/parametrise-action-dialog/c
import { FormlyArrayComponent } from '../components/parametrise-action-dialog/components/formly-array/formly-array.component';
import { CreateArrayDialogComponent } from '../components/parametrise-action-dialog/components/formly-array/components/create-array-dialog/create-array-dialog.component';
import { FormlyHyperlambdaComponent } from '../components/parametrise-action-dialog/components/formly-hyperlambda/formly-hyperlambda.component';
import { FormlyAutocompleteComponent } from '../components/parametrise-action-dialog/components/formly-autocomplete/formly-autocomplete.component';

@NgModule({
declarations: [
Expand All @@ -52,6 +53,7 @@ import { FormlyHyperlambdaComponent } from '../components/parametrise-action-dia
FormlyHyperlambdaComponent,
FormlyKeyValueComponent,
FormlyArrayComponent,
FormlyAutocompleteComponent,
CreateKeyValueDialogComponent,
CreateArrayDialogComponent,
],
Expand All @@ -69,6 +71,7 @@ import { FormlyHyperlambdaComponent } from '../components/parametrise-action-dia
{ name: 'array', component: FormlyArrayComponent },
{ name: 'csharp', component: FormlyCSharpComponent },
{ name: 'hyperlambda', component: FormlyHyperlambdaComponent },
{ name: 'autocomplete', component: FormlyAutocompleteComponent },
],
}),
]
Expand Down

0 comments on commit 45b6f61

Please sign in to comment.