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

View File

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