All files / src/app/components/campaign campaign.component.html

98.27% Statements 114/116
100% Branches 4/4
75% Functions 3/4
100% Lines 52/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87                  1200x 11x 11x 11x   1200x 1200x 11x 11x 1200x 332x 2x 2x 1200x 268x 1200x 268x 9x 9x   11x   1200x   11x 11x 11x   11x   11x 11x 11x   11x 1200x 268x 160x   160x     5x 5x 5x 5x 5x 5x 5x   5x   591x 591x 591x 591x 591x 7x 7x     5x 536x   536x   9x                   11x  
<section class="container">
  <div class="columns is-multiline">
    <div class="column is-10 is-offset-1 profile">
      <div class="columns">
        <div class="column right has-text-centered">
 
          <div>
            <div class="level">
              <div class="level-left">
                <button [routerLink]="['/campaigns']" class="button is-rounded">
                  <i class="pi pi-chevron-left"></i>
                  <span>Campaigns</span>
              </button>
 
                <h1 *ngIf="this.campaignId === null" class="title is-4">Add New Campaign</h1>
                <h1 *ngIf="this.campaignId !== null" class="title is-4">Edit Campaign</h1>
                </div>
              <div class="level-right">
                <button *ngIf="this.campaignId === null" (click)="addCampaign()" class="button" id="addCampaign"
                  [disabled]="campaignForm.invalid">
                  Add new Campaign
                </button>
                <button *ngIf="this.campaignId !== null" (click)="editCampaign()" class="button is-primary" id="editCampaign"
                  [disabled]="campaignForm.invalid">Save Campaign</button>
                <button *ngIf="this.campaignId !== null" (click)="deleteCampaign()" class="button is-danger" id="deleteCampaign"
                  [disabled]="campaignForm.invalid">
                  Delete Campaign
                </button>
              </div>
            </div>
            <div>
              <form [formGroup]="campaignForm">
                <div class="field">
                  <label class="label" htmlFor="campaignName">Name</label>
                  <div class="control has-icons-right">
                    <input class="input" formControlName="campaignName" type="text" id="campaignName">
                  </div>
                </div>
                <div class="field">
                  <label class="label" htmlFor="campaignDescription">Description</label>
                  <div class="control has-icons-right">
                    <textarea class="input" formControlName="campaignDescription" id="campaignDescription"></textarea>
                  </div>
                </div>
                @if (this.campaignId !== null) {
                <div class="container" *ngIf="phases !== null && phases.length > 0">
                  <p-table [value]="phases" [paginator]="true" [rows]="5" [rowsPerPageOptions]="[5, 10, 20]"
                    [showCurrentPageReport]="true" currentPageReportTemplate="{first} - {last} of {totalRecords} phases"
                    [rowHover]="true" sortField="start_at">
                    <ng-template pTemplate="header">
                      <tr>
                        <th pSortableColumn="id">id <p-sortIcon field="id"></p-sortIcon></th>
                        <th pSortableColumn="name">Phase name <p-sortIcon field="name"></p-sortIcon></th>
                        <th>Phase description</th>
                        <th pSortableColumn="start_at">Phase starting Date <p-sortIcon field="start_at"></p-sortIcon></th>
                        <th pSortableColumn="end_at">Phase ending Date <p-sortIcon field="end_at"></p-sortIcon></th>
                        <th></th>
                      </tr>
                    </ng-template>
                    <ng-template pTemplate="body" let-phase let-i="rowIndex">
                      <tr>
                        <td [routerLink]="['/phases', phase.id]">{{ phase.id.substr(-4) }}</td>
                        <td [routerLink]="['/phases', phase.id]">{{ phase.name }}</td>
                        <td [routerLink]="['/phases', phase.id]">{{ phase.description }}</td>
                        <td [routerLink]="['/phases', phase.id]">{{ phase.start_at | date: 'dd/MM/yyyy HH:mm' }}</td>
                        <td [routerLink]="['/phases', phase.id]">{{ phase.end_at | date: 'dd/MM/yyyy HH:mm' }}</td>
                        <td><button (click)="deletePhase(phase.id, phase.name)" class="button is-inline-flex is-warning is-small" id="deletePhase">Delete Phase</button></td>
                      </tr>
                    </ng-template>
                  </p-table>
                </div>
                <div *ngIf="this.campaignId !== null" class="field row">
                  <div class="column">
                    <button [routerLink]="['/campaigns', this.campaignId,  'phases', 'new']" class="button" id="addPhase">Add new Phase</button>
                  </div>
                </div>
                }
 
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>