send prefill for tasks and hide operations to hidden fields

This commit is contained in:
Matt Hill
2026-02-23 16:59:21 -07:00
parent 0724989792
commit bee8a0f9d8
2 changed files with 21 additions and 18 deletions

View File

@@ -66,7 +66,7 @@ export type PackageActionData = {
@if (requestInfo) {
<task-info
[originalValue]="res.originalValue || {}"
[operations]="res.operations || []"
[operations]="res.visibleOperations || []"
/>
}
@@ -156,18 +156,25 @@ export class ActionInputModal {
const originalValue = res.value || {}
this.eventId = res.eventId
const operations = this.requestInfo?.input
? compare(
JSON.parse(JSON.stringify(originalValue)),
utils.deepMerge(
JSON.parse(JSON.stringify(originalValue)),
this.requestInfo.input.value,
) as object,
)
: null
return {
spec: res.spec,
originalValue,
operations: this.requestInfo?.input
? compare(
JSON.parse(JSON.stringify(originalValue)),
utils.deepMerge(
JSON.parse(JSON.stringify(originalValue)),
this.requestInfo.input.value,
) as object,
)
: null,
operations,
visibleOperations:
operations?.filter(op => {
const key = op.path.split('/')[1]
return (res.spec[key!] as any)?.type !== 'hidden'
}) ?? null,
}
}),
catchError(e => {
@@ -180,14 +187,11 @@ export class ActionInputModal {
async execute(input: object) {
if (await this.checkConflicts(input)) {
const merged = this.context.data.prefill
? { ...input, ...this.context.data.prefill }
: input
await this.actionService.execute(
this.pkgInfo.id,
this.eventId,
this.actionId,
merged,
input,
)
this.context.$implicit.complete()
}

View File

@@ -27,6 +27,7 @@ export class ActionService {
private readonly formDialog = inject(FormDialogService)
async present(data: PackageActionData) {
data.prefill = data.prefill ?? data.requestInfo?.input?.value
const { pkgInfo, actionInfo } = data
if (actionInfo.metadata.hasInput) {
@@ -43,11 +44,9 @@ export class ActionService {
data,
})
.pipe(filter(Boolean))
.subscribe(() =>
this.execute(pkgInfo.id, null, actionInfo.id, data.prefill),
)
.subscribe(() => this.execute(pkgInfo.id, null, actionInfo.id))
} else {
this.execute(pkgInfo.id, null, actionInfo.id, data.prefill)
this.execute(pkgInfo.id, null, actionInfo.id)
}
}
}