All files / projects/organization-management/src/app/pages/cost-centers cost-centers-page.component.html

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 1791x                                                                                                                                                                                                                                                                                                                                                                    
<h1>
  {{ 'account.organization.cost_center_management' | translate }}
  <a
    *ngIf="!!(error$ | async) === false"
    routerLink="create"
    class="btn btn-secondary"
    data-testing-id="add-cost-center-link"
    >{{ 'account.costcenter.list.link.add' | translate }}</a
  >
</h1>
 
<div class="loading-container">
  <ng-container *ngIf="costCenters$ | async as costCenters">
    <ng-container *ngIf="costCenters.length > 0; else emptyList">
      <table
        cdk-table
        [dataSource]="costCenters"
        class="table table-lg mobile-optimized"
        data-testing-id="costCenter-list"
      >
        <!-- Cost Center Id -->
        <ng-container cdkColumnDef="costCenterId">
          <th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-costCenter-id">
            {{ 'account.costcenter.list.header.no' | translate }}
          </th>
          <td cdk-cell *cdkCellDef="let costCenter" [attr.data-label]="'account.costcenter.list.header.no' | translate">
            <a [routerLink]="[costCenter.id]">{{ costCenter.costCenterId }}</a
            ><span *ngIf="costCenter.active === false" class="input-help">
              {{ 'account.costCenter.status.inactive' | translate }}</span
            >
          </td>
        </ng-container>
 
        <!-- Cost Center Name -->
        <ng-container cdkColumnDef="costCenterName">
          <th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-costCenter-name">
            {{ 'account.costcenter.list.header.name' | translate }}
          </th>
          <td
            cdk-cell
            *cdkCellDef="let costCenter"
            [attr.data-label]="'account.costcenter.list.header.name' | translate"
          >
            <a [routerLink]="[costCenter.id]">{{ costCenter.name }}</a>
          </td>
        </ng-container>
 
        <!-- Cost Center Manager -->
        <ng-container cdkColumnDef="costCenterManager">
          <th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-costCenter-manager">
            {{ 'account.costcenter.list.header.manager' | translate }}
          </th>
          <td
            cdk-cell
            *cdkCellDef="let costCenter"
            [attr.data-label]="'account.costcenter.list.header.manager' | translate"
          >
            {{ costCenter.costCenterOwner.firstName }} {{ costCenter.costCenterOwner.lastName }}
          </td>
        </ng-container>
 
        <!-- Cost Center Budget -->
        <ng-container cdkColumnDef="costCenterBudget">
          <th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-costCenter-budget">
            {{ 'account.costcenter.list.header.budgetspent' | translate }}
          </th>
          <td
            cdk-cell
            *cdkCellDef="let costCenter"
            [attr.data-label]="'account.costcenter.list.header.budgetspent' | translate"
          >
            <ish-cost-center-budget [costCenter]="costCenter" />
          </td>
        </ng-container>
 
        <!-- Actions -->
        <ng-container cdkColumnDef="actions">
          <th cdk-header-cell *cdkHeaderCellDef data-testing-id="th-costCenter-actions"></th>
          <td cdk-cell *cdkCellDef="let costCenter" class="column-price">
            <ng-container *ngIf="isDeletable(costCenter) | async">
              <!-- Deactivate -->
              <button
                *ngIf="costCenter.active; else activateCostCenter"
                type="button"
                class="btn-tool btn-link"
                title="{{ 'account.costcenter.deactivate.button.title' | translate }}"
                (click)="openConfirmationDialog(costCenter, deactivateDialog)"
                data-testing-id="deactivate-cost-center"
              >
                <fa-icon [icon]="['fas', 'ban']" />
              </button>
 
              <!-- Activate -->
              <ng-template #activateCostCenter>
                <button
                  type="button"
                  class="btn-tool btn-link"
                  title="{{ 'account.costcenter.activate.button.title' | translate }}"
                  (click)="activate(costCenter)"
                  data-testing-id="activate-cost-center"
                >
                  <fa-icon [icon]="['fas', 'check-circle']" />
                </button>
              </ng-template>
 
              <!-- Delete -->
              <button
                *ngIf="!(costCenter.pendingOrders + costCenter.approvedOrders); else deleteButtonDisabled"
                type="button"
                class="btn-tool btn-link"
                title="{{ 'account.costcenter.delete.link' | translate }}"
                (click)="openConfirmationDialog(costCenter, deleteDialog)"
                data-testing-id="delete-cost-center"
              >
                <fa-icon [icon]="['fas', 'trash-alt']" />
              </button>
              <ng-template #deleteButtonDisabled>
                <span
                  class="btn-tool btn-link inactive"
                  title="{{ 'account.costcenter.delete.disabled.icon' | translate }}"
                >
                  <fa-icon [icon]="['fas', 'trash-alt']" />
                </span>
              </ng-template>
            </ng-container>
          </td>
        </ng-container>
 
        <!-- Header and Row Declarations -->
        <tr cdk-header-row *cdkHeaderRowDef="columnsToDisplay"></tr>
        <tr cdk-row *cdkRowDef="let row; columns: columnsToDisplay"></tr>
      </table>
    </ng-container>
 
    <!-- Empty List -->
    <ng-template #emptyList>
      <p data-testing-id="emptyList">{{ 'account.costcenter.list.noitems' | translate }}</p>
    </ng-template>
  </ng-container>
 
  <ish-loading *ngIf="loading$ | async" />
</div>
 
<!--  dialogs -->
<ish-modal-dialog
  #deleteDialog
  [options]="{
    confirmText: 'account.costcenter.delete.button.label' | translate,
    rejectText: 'account.cancel.button.label' | translate,
    titleText: 'account.costcenter.delete_dialog.header' | translate : { '0': selectedCostCenter?.name }
  }"
  (confirmed)="delete()"
>
  {{ 'account.costcenter.delete.question' | translate }}
</ish-modal-dialog>
 
<ish-modal-dialog
  #deactivateDialog
  [options]="{
    confirmText: 'account.costcenter.deactivate.button.label' | translate,
    rejectText: 'account.cancel.button.label' | translate,
    titleText: 'account.costcenter.deactivate_dialog.header' | translate : { '0': selectedCostCenter?.name }
  }"
  (confirmed)="deactivate()"
>
  <p *ngIf="selectedCostCenter?.pendingOrders || selectedCostCenter?.approvedOrders">
    {{
      'account.costcenter.deactivate.text'
        | translate
          : {
              '0': selectedCostCenter?.pendingOrders,
              '1': selectedCostCenter.approvedOrders,
              '2': selectedCostCenter?.name
            }
    }}
  </p>
  {{ 'account.costcenter.deactivate.question' | translate }}
</ish-modal-dialog>