dynaform.component.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <ng-container *ngFor="let rowName of dynaFormRows">
  2. <ng-container *ngTemplateOutlet="template ? template : default; context: getTemplateContext(rowName)"></ng-container>
  3. </ng-container>
  4. <!-- Default template for form field
  5. used when a TemplateRef is NOT supplied to component -->
  6. <ng-template let-control="control" let-meta="meta" #default>
  7. <ng-container *ngIf="meta.type !== 'Hidden'">
  8. <ng-container *ngIf="!meta.noLabel; else fullWidth">
  9. <ng-template *ngIf="isContainer(meta)">
  10. <div *ngIf="meta.label" class="row">
  11. <h3 class="col-sm-12 h-dyna" [ngClass]="'h-dyna-' + (path.length + 2)">{{ meta.label }}</h3>
  12. </div>
  13. <app-dynaform [formGroup]="control" [meta]="meta.meta" [template]="template" (call)="handleCallback($event)"></app-dynaform>
  14. </ng-template>
  15. <ng-template *ngIf="isRepeatingContainer(meta)">
  16. <div *ngFor="let group of meta.meta">
  17. <div *ngIf="group.label" class="row">
  18. <h3 class="col-sm-12 h-dyna" [ngClass]="'h-dyna-' + (path.length + 2)">{{ meta.label }}</h3>
  19. </div>
  20. <app-dynaform [formGroup]="control" [meta]="group.meta" [template]="template" (call)="handleCallback($event)"></app-dynaform>
  21. </div>
  22. </ng-template>
  23. <ng-template *ngIf="isField(meta)">
  24. <div class="form-group row" [ngClass]="getRowClass(control, meta)">
  25. <label class="col-sm-4" [ngClass]="meta.class" [for]="meta.name" title="">
  26. {{ meta.rowLabel !== null ? meta.rowLabel : meta.label }}
  27. <span *ngIf="control && control.touched && control.invalid" class="fas fa-exclamation-triangle"
  28. [ngbTooltip]="getValidationFailureMessage(control, meta)"
  29. ></span>
  30. </label>
  31. <div class="col-sm-8">
  32. <ng-container dynafield [control]="control" [meta]="meta" (call)="handleCallback($event)"></ng-container>
  33. </div>
  34. </div>
  35. </ng-template>
  36. </ng-container>
  37. <ng-template #fullWidth>
  38. <div class="row" [ngClass]="getRowClass(control, meta.type)">
  39. <ng-container dynafield [control]="control" [meta]="meta" (call)="handleCallback($event)"></ng-container>
  40. </div>
  41. </ng-template>
  42. </ng-container>
  43. </ng-template>
  44. <!-- Display validation status if debugging and not nested -->
  45. <div *ngIf="debug && path.length === 0">
  46. <pre [ngClass]="{
  47. 'alert-success' : formGroup.valid && formGroup.dirty,
  48. 'alert-danger' : !formGroup.valid && formGroup.dirty,
  49. 'alert-secondary' : !formGroup.dirty
  50. }"
  51. class="alert mt-4"
  52. role="alert">{{ formGroup.pristine ? 'Untouched' : getValidationErrors() | json }}</pre>
  53. </div>