Commit c25b3452 authored by Shruti3004's avatar Shruti3004
Browse files

Implemented recursive strategy for nested prefills

Showing with 9 additions and 2 deletions
+9 -2
......@@ -63,10 +63,11 @@ export class AppService {
}*/
for (const key in prefillSpec) {
if (prefillSpec.hasOwnProperty(key)) {
const element = instance.getElementsByTagName(key)[0];
const key_arr = key.split('_*_');
const element = this.findElementRecursively(0, key_arr, instance);
if (element) {
console.log(prefillSpec[key]);
console.log(eval(prefillSpec[key]));
// console.log(eval(prefillSpec[key]));
element.textContent = eval(prefillSpec[key]);
}
}
......@@ -74,6 +75,12 @@ export class AppService {
return doc.toString();
}
findElementRecursively(start: number, key_arr: any, instance: any) {
if (!instance) return null;
if (!key_arr[start + 1]) return instance.getElementsByTagName(key_arr[start])?.[0]
return this.findElementRecursively(start + 1, key_arr, instance.getElementsByTagName(key_arr[start])?.[0])
}
prefillFormXML(form: string, onFormSuccessData: any, prefillSpec: any): string {
console.log("MAI YAHAN AA GAYA");
const formFilePath = join(__dirname, `forms/${form}.xml`);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment