-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add generate document action configuration
- Loading branch information
1 parent
c99c5c9
commit 3ee39f2
Showing
10 changed files
with
181 additions
and
24 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...nd/plugin/src/main/kotlin/com/ritense/valtimo/xential/model/GenerateDocumentProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.ritense.valtimo.xential.model | ||
|
||
data class GenerateDocumentProperties( | ||
val templateId: String, | ||
val fileFormat: FileFormat, | ||
val documentId: String, | ||
val templateData: Map<String, String> | ||
) | ||
|
||
enum class FileFormat { | ||
DOCX, HTML, PDF, XML | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...components/generate-document-configuration/generate-document-configuration.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<v-form | ||
(valueChange)="formValueChange($event)" | ||
*ngIf="{ | ||
disabled: disabled$ | async, | ||
prefill: prefillConfiguration$ ? (prefillConfiguration$ | async) : null, | ||
fileFormats: fileFormats$ | async, | ||
} as obs" | ||
> | ||
<v-input | ||
name="templateId" | ||
[title]="'templateId' | pluginTranslate: pluginId | async" | ||
[margin]="true" | ||
[defaultValue]="obs.prefill?.templateId" | ||
[disabled]="obs.disabled" | ||
[required]="true" | ||
/> | ||
<v-select | ||
name="fileFormat" | ||
[title]="'fileFormat' | pluginTranslate: pluginId | async" | ||
[margin]="true" | ||
[defaultSelectionId]="obs.prefill?.fileFormat" | ||
[disabled]="obs.disabled" | ||
[required]="true" | ||
[items]="obs.fileFormats" | ||
/> | ||
<v-input | ||
name="documentId" | ||
[title]="'documentId' | pluginTranslate: pluginId | async" | ||
[margin]="true" | ||
[defaultValue]="obs.prefill?.documentId" | ||
[disabled]="obs.disabled" | ||
[required]="true" | ||
/> | ||
<valtimo-carbon-multi-input | ||
name="templateData" | ||
[title]="'templateData' | pluginTranslate: pluginId | async" | ||
type="keyValue" | ||
[disabled]="obs.disabled" | ||
[defaultValues]="obs.prefill?.templateData" | ||
[margin]="true" | ||
[required]="false" | ||
></valtimo-carbon-multi-input> | ||
</v-form> |
71 changes: 71 additions & 0 deletions
71
...b/components/generate-document-configuration/generate-document-configuration.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core'; | ||
import {FunctionConfigurationComponent} from '@valtimo/plugin'; | ||
import {BehaviorSubject, combineLatest, Observable, Subscription, take} from 'rxjs'; | ||
import {FileFormat, GenerateDocumentConfig} from "../../models"; | ||
import {SelectItem} from "@valtimo/components"; | ||
|
||
@Component({ | ||
selector: 'xential-generate-document-configuration', | ||
templateUrl: './generate-document-configuration.component.html' | ||
}) | ||
export class GenerateDocumentConfigurationComponent implements FunctionConfigurationComponent, OnInit, OnDestroy { | ||
@Input() save$: Observable<void>; | ||
@Input() disabled$: Observable<boolean>; | ||
@Input() pluginId: string; | ||
@Input() prefillConfiguration$: Observable<GenerateDocumentConfig>; | ||
@Output() valid: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
@Output() configuration: EventEmitter<GenerateDocumentConfig> = | ||
new EventEmitter<GenerateDocumentConfig>(); | ||
|
||
public fileFormats$ = new BehaviorSubject<SelectItem[]>( | ||
['DOCX', 'HTML', 'PDF', 'XML'] | ||
.map(format => { | ||
return { | ||
id: format, | ||
text: format | ||
} | ||
}) | ||
); | ||
|
||
private saveSubscription!: Subscription; | ||
|
||
private readonly formValue$ = new BehaviorSubject<GenerateDocumentConfig | null>(null); | ||
private readonly valid$ = new BehaviorSubject<boolean>(false); | ||
|
||
ngOnInit(): void { | ||
this.openSaveSubscription(); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.saveSubscription?.unsubscribe(); | ||
} | ||
|
||
formValueChange(formValue: GenerateDocumentConfig): void { | ||
this.formValue$.next(formValue); | ||
this.handleValid(formValue); | ||
} | ||
|
||
private handleValid(formValue: GenerateDocumentConfig): void { | ||
const valid = !!( | ||
formValue.templateId && | ||
formValue.documentId && | ||
formValue.fileFormat && | ||
!formValue.templateData.find((entry) => !(entry.key && entry.value)) | ||
); | ||
|
||
this.valid$.next(valid); | ||
this.valid.emit(valid); | ||
} | ||
|
||
private openSaveSubscription(): void { | ||
this.saveSubscription = this.save$?.subscribe(save => { | ||
combineLatest([this.formValue$, this.valid$]) | ||
.pipe(take(1)) | ||
.subscribe(([formValue, valid]) => { | ||
if (valid) { | ||
this.configuration.emit(formValue); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
...imo/xential/src/lib/components/xential-configuration/xential-configuration.component.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
frontend/projects/valtimo/xential/src/lib/models/generate-document-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface GenerateDocumentConfig { | ||
templateId: string; | ||
fileFormat: FileFormat; | ||
documentId: string; | ||
templateData: Array<{key: string; value: string}> | ||
} | ||
|
||
type FileFormat = 'DOCX' | 'PDF' | 'XML' | 'HTML'; | ||
|
||
export {GenerateDocumentConfig, FileFormat} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
*/ | ||
|
||
export * from './config'; | ||
export * from './generate-document-config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters