OrchardCore 1.7.2 workflow with Angular

OrchardCore 1.7.2 workflow with Angular


0

I am using angular and orchard 1.7.2
I have some issue connecting the workflow with Angular
I tried every thing and end up with create forms dynamically using GraphQL

WorkFlow

Http Request Event

Contact

Message

Angular Form

Role permissions

Angular

import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Apollo, gql } from 'apollo-angular';

@Component({
  selector: 'app-forms',
  templateUrl: './forms.component.html',
  styleUrls: ['./forms.component.css']
})
export class FormsComponent implements OnInit {

  formModel :any;

  form = new FormGroup({});

  constructor(private apollo:Apollo,private https:HttpClient) {}

  ngOnInit() {
    this.apollo.watchQuery({
      query: gql`
      query MyQuery {
        contact {
          flow {
            widgets {
              contentType
              ... on Form {
                displayText
                form {
                  method
                  action
                }
                flow {
                  widgets {
                    contentType
                    displayText
                    ... on Input {
                      displayText
                      input {
                        placeholder
                      }
                    }
                    ... on TextArea {
                      displayText
                      textArea {
                        placeholder
                      }
                    }
                    ... on Button {
                      displayText
                    }
                  }
                }
              }
            }
          }
        }
      }
      
      
      
      `

    }).valueChanges.subscribe((result:any) =>{
      const formss = result.data.contact;
      const flow = formss[0].flow;
      const widgets = flow.widgets;
      this.formModel = widgets[0].flow.widgets;  
        for (const widget of this.formModel) {
        console.log(widget.displayText)
        this.form.addControl(widget.displayText, new FormControl(''));
       }
      });
    }
  }

  onSubmit() {
    // Handle form submission
    this.AddNewData(this.form.value)
   .subscribe({
    next: (response:any) => {
       console.log("success")
  },
    error: (err: HttpErrorResponse) => {
     console.log(err.message)
    }}) 
  }
 
  AddNewData(model:any){
    //code?
   }
}

<div class="container px-5">
    <form [formGroup]="form" (ngSubmit)="onSubmit()">
        <div class="row" *ngFor="let field of formModel;let index=index">
            <div class="col" *ngIf="field.contentType=='Input' ||field.contentType=='TextArea'">
                <label for="{{field.displayText}}">{{field.displayText }}</label>
                <input [id]="field.displayText" type="{{field.contentType}}" formControlName="{{field.displayText}}" class="form-control">
            </div>

        </div>

        <button type="submit" name="Submit">Submit</button>
    </form>
    {{this.form.value | json}}
</div>

How can i send the json after submit to workflow of orchardcore cms in angular ?

New contributor

Mutaz Obeidat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *