Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div [formArrayName]="doc.typeSelector">
- {{ doc.typeSelector }}
- </div>
- <div *ngIf="documents[doc.typeSelector]">
- <mat-table
- [dataSource]="documents[doc.typeSelector]"
- *ngFor="let col of docColumns">
- <ng-container [matColumnDef]="col">
- <th mat-header-cell *matHeaderCellDef> {{ col | uppercase }} </th>
- <td mat-cell *matCellDef="let element"> {{ element[col] }} </td>
- </ng-container>
- <tr mat-header-row *matHeaderRowDef="docColumns"></tr>
- <tr mat-row *matRowDef="let row; columns: docColumns;"></tr>
- </mat-table>
- </div>
- documents: object = {};
- docColumns: string[] = ["name", "uploadDate", "uri", "comments"];
- docs = [];
- docForm: FormGroup;
- docTypes: object = {
- fs: 'Financial Statements',
- id: 'Identity Document',
- ad: 'Bank Account Details',
- cd: 'Constitutional Document',
- pd: 'Power Document',
- };
- [...] this.docForm = this.fb.group({});
- Object.keys(this.docTypes).map(
- type => {
- this.docForm.addControl(type, this.fb.array([]));
- this.docs.push({
- typeName: this.docTypes[type],
- typeSelector: type
- });
- }
- );
- // Info for the docForm:
- const cusDocs = this.customer.docRefs;
- Object.keys(cusDocs).map(docType => {
- const currDocs = [];
- cusDocs[docType].forEach(doc => {
- currDocs.push(this.customerService.createNewDoc(doc));
- });
- const matchForm = this.docForm.get(docType) as FormArray;
- currDocs.forEach(form => {
- matchForm.push(form);
- });
- });
- Object.keys(this.docForm.value).map(docType => {
- const currForm = this.docForm.get(docType) as FormArray;
- if (currForm.value.length > 0) {
- Object.keys(currForm.value).map(doc => {
- const currentDoc = currForm.at(+doc).value;
- const newDocRow = {
- name: currentDoc.name,
- uploadDate: currentDoc.uploadDate,
- uri: currentDoc.uri,
- comments: currentDoc.comment
- };
- if (!this.documents[docType]) {
- this.documents[docType] = [];
- }
- this.documents[docType].push(newDocRow);
- console.log(this.documents[docType]);
- });
- }
- });
- console.log(this.documents);
- console.log(this.docColumns);
- <div *ngIf="documents[doc.typeSelector]">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement