Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Dec 21, 2023
1 parent f43f0e9 commit 33d03a4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
4 changes: 2 additions & 2 deletions backend/files/misc/workflows/actions/sql-execute.hl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
params
type:key-value
default
@name:some-role-name
@description:Some role description
name:some-role-name
description:Some role description
mandatory:bool:false
.icon:backup

Expand Down
4 changes: 2 additions & 2 deletions backend/files/misc/workflows/actions/sql-select.hl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
mandatory:bool:true
sql
type:sql
default:select name from roles where name like @arg1 limit 2
default:select name from roles where name like @filter limit 2
mandatory:bool:true
params
type:key-value
default
@arg1:a%
filter:a%
.icon:cloud_download

// Sanity checking invocation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h3 mat-dialog-title>New key/value pair</h3>
<input
matInput
placeholder="Key of your pair ..."
[disabled]="data"
name="key"
[(ngModel)]="key"
autocomplete="off">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

// Angular and system imports.
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';

// Application specific imports.
import { GeneralService } from 'src/app/services/general.service';
Expand All @@ -18,14 +18,23 @@ import { GeneralService } from 'src/app/services/general.service';
templateUrl: './create-key-value-dialog.component.html',
styleUrls: ['./create-key-value-dialog.component.scss']
})
export class CreateKeyValueDialogComponent {
export class CreateKeyValueDialogComponent implements OnInit {

key: string;
value: string;

constructor(
private generalService: GeneralService,
private dialogRef: MatDialogRef<CreateKeyValueDialogComponent>) {}
@Inject(MAT_DIALOG_DATA) public data: any,
private dialogRef: MatDialogRef<CreateKeyValueDialogComponent>) { }

ngOnInit() {

if (this.data) {
this.key = this.data.key;
this.value = this.data.value;
}
}

onSubmit() {

Expand All @@ -38,6 +47,7 @@ export class CreateKeyValueDialogComponent {
this.dialogRef.close({
key: this.key,
value: this.value,
edit: !!this.data
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { GeneralService } from 'src/app/services/general.service';
<mat-chip
*ngFor="let item of items"
(removed)="removeArgument(item)"
(click)="editArgument(item)"
[removable]="true">
{{item.name}}:{{item.value}}
{{item.key}}:{{item.value}}
<mat-icon matChipRemove>cancel</mat-icon>
</mat-chip>
<mat-chip (click)="addItem()">
Expand Down Expand Up @@ -51,7 +52,7 @@ export class FormlyKeyValueComponent extends FieldType<FieldTypeConfig> implemen

removeArgument(el: any) {

delete this.model[<string>this.field.key][el.name];
delete this.model[<string>this.field.key][el.key];
this.createItems();
}

Expand All @@ -74,7 +75,23 @@ export class FormlyKeyValueComponent extends FieldType<FieldTypeConfig> implemen
this.createItems();
}
});
}
}

editArgument(item: any) {

this.dialog.open(CreateKeyValueDialogComponent, {
width: '80vw',
maxWidth: '512px',
data: item,
}).afterClosed().subscribe((result: any) => {

if (result) {

this.model[<string>this.field.key][result.key] = result.value;
this.createItems();
}
});
}

/*
* Private helpers.
Expand All @@ -85,7 +102,7 @@ export class FormlyKeyValueComponent extends FieldType<FieldTypeConfig> implemen
this.items = [];
for (var idx in this.model[<string>this.field.key]) {
this.items.push({
name: idx,
key: idx,
value: this.model[<string>this.field.key][idx],
});
}
Expand Down

0 comments on commit 33d03a4

Please sign in to comment.