if (!this.policyInstanceId) {
this.fetchRics();
}
+ if (this.isSchemaEmpty()) {
+ // Empty schema, hide form, show json instead
+ this.isVisible.form = false;
+ this.isVisible.json = true;
+ }
}
ngAfterViewInit() {
}
+ private isSchemaEmpty(): boolean {
+ return Object.keys(this.jsonSchemaObject).length === 0;
+ }
+
onSubmit() {
if (this.policyInstanceId == null) {
this.policyInstanceId = uuid.v4();
this.liveFormData = formData;
}
- get prettyLiveFormData() {
+ get prettyLiveFormData(): string {
+ if (this.isSchemaEmpty()) {
+ return this.jsonAsString;
+ }
return JSON.stringify(this.liveFormData, null, 2);
}
- get schemaAsString() {
+ get schemaAsString(): string {
return JSON.stringify(this.jsonSchemaObject, null, 2);
}
- get jsonAsString() {
+ get jsonAsString(): string {
return JSON.stringify(this.jsonObject, null, 2);
}