<div id="page_content">
  <div id="page_content_inner">
    <div class="uk-padding-small md-bg-white" uk-grid>
      <div *ngIf="filters" class="uk-width-2-3@m uk-width-1-1 uk-child-width-1-3@m uk-child-width-1-1" uk-grid>
        <div>
          <div dashboard-input [formInput]="filters.get('privacy')"
               type="select" [options]="[all].concat(stakeholderUtils.isPublic)"
               label="Privacy"></div>
        </div>
        <div>
          <div dashboard-input [formInput]="filters.get('status')"
               type="select" [options]="[all].concat(stakeholderUtils.isActive)"
               label="Status"></div>
        </div>
      </div>
      <div class="uk-width-expand@m uk-width-1-1 uk-flex uk-flex-middle uk-flex-right">
        <div class="uk-inline uk-width-medium">
          <span class="uk-position-center-right"><i class="material-icons">search</i></span>
          <div dashboard-input [formInput]="filters.get('keyword')" label="Locate profile"></div>
        </div>
        <div [class.uk-active]="grid" class="uk-margin-small-left">
          <a [routerLink]="" class="uk-icon-button" (click)="changeGrid(true)"><i
            class="material-icons">view_module</i></a>
        </div>
        <div [class.uk-active]="!grid" class="uk-margin-small-left">
          <a [routerLink]="" class="uk-icon-button" (click)="changeGrid(false)"><i class="material-icons">list</i></a>
        </div>
      </div>
    </div>
    <h4 class="uk-text-bold main">Default Profiles</h4>
    <div [class.uk-child-width-1-4@m]="grid"
         [class.uk-child-width-1-3@s]="grid"
         [class.uk-child-width-1-1]="!grid"
         [class.list-view]="!grid"
         class="uk-grid-match uk-grid-small"
         uk-grid>
      <loading *ngIf="loading"></loading>
      <ng-template ngFor [ngForOf]="defaultStakeholders" let-stakeholder let-i="index">
        <a *ngIf="stakeholder" [routerLink]="stakeholder.alias+'/indicators'+(stakeholder.topics.length > 0 ?
           '/' + stakeholder.topics[0].alias:'')">
          <div class="uk-card uk-card-default">
            <div class=" uk-padding-small uk-card-header">
              <div class="md-card-toolbar-actions uk-float-right" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
                <span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
                  <i class="material-icons md-24 uk-margin-small-right">{{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
                  {{(stakeholder.isPublic) ? 'Public' : 'Private'}}
                </span>
                <span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
                  <i class="material-icons md-24 uk-margin-small-right"
                     [class.md-color-green-300]="stakeholder.isActive">{{stakeholderUtils.isActiveIcon}}</i>
                  {{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
                </span>
                <div class="md-card-dropdown uk-inline">
                  <i uk-icon="more-vertical"
                     (click)="$event.stopPropagation();$event.preventDefault()"></i>
                  <div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false">
                    <ul class="uk-nav uk-dropdown-nav">
                      <li><a (click)="$event.stopPropagation();editStakeholder(stakeholder, true);hide(element);$event.preventDefault()">Edit</a>
                      </li>
                      <li><a (click)="$event.stopPropagation();toggleStakeholderStatus(stakeholder);hide(element);$event.preventDefault()">
                        {{stakeholder.isActive ? 'Inactive' : 'Active'}}</a>
                      </li>
                      <li><a (click)="$event.stopPropagation();toggleStakeholderAccess(stakeholder);hide(element);$event.preventDefault()">
                        {{stakeholder.isPublic ? 'Private' : 'Public'}}</a>
                      </li>
                      <hr *ngIf="isAdministrator()" class="uk-nav-divider">
                      <li *ngIf="isAdministrator()"><a
                        (click)="$event.stopPropagation();deleteStakeholderOpen(stakeholder);hide(element);$event.preventDefault()">Delete</a>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
              <div class="uk-card-title">{{stakeholder.name}}</div>
            </div>
            <div *ngIf="grid" class="uk-card-body">
              <div class="uk-flex uk-flex-center" uk-grid>
                <div class="uk-width-1-2 uk-text-center">
                  <i class="material-icons md-24">{{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
                  <div>{{(stakeholder.isPublic) ? 'Public' : 'Private'}}</div>
                </div>
                <div class="uk-width-1-2 uk-text-center">
                  <i class="material-icons md-24"
                     [class.md-color-green-300]="stakeholder.isActive">{{stakeholderUtils.isActiveIcon}}</i>
                  <div>{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}</div>
                </div>
              </div>
            </div>
          </div>
        </a>
      </ng-template>
      <div *ngIf="!loading">
        <div class="uk-card uk-card-default clickable" (click)="editStakeholder(null, true)">
          <div class=" uk-padding-small uk-card-header">
            <div class="uk-card-title"
                 [class.uk-flex-middle]="!grid"
                 [class.uk-flex]="!grid"
                 [class.uk-flex-center]="!grid">
              <i *ngIf="!grid" class="material-icons md-36" uk-icon="plus"></i>
              <span>Create a default profile</span>
            </div>
          </div>
          <div *ngIf="grid" class="uk-card-body">
            <div uk-grid>
              <div class="uk-width-1-1">
                Create a new default profile.
              </div>
              <div class="uk-width-1-1 uk-flex uk-flex-center">
                <i class="material-icons md-48" uk-icon="plus"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <h4 class="uk-text-bold">Profiles</h4>
    <div [class.uk-child-width-1-4@m]="grid"
         [class.uk-child-width-1-3@s]="grid"
         [class.uk-child-width-1-1]="!grid"
         [class.list-view]="!grid"
         class="uk-grid-match uk-grid-small"
         uk-grid>
      <loading *ngIf="loading"></loading>
      <ng-template ngFor [ngForOf]="displayStakeholders" let-stakeholder let-i="index">
        <a *ngIf="stakeholder"
           [routerLink]="stakeholder.alias+'/indicators'+(stakeholder.topics.length > 0 ?
           '/' + stakeholder.topics[0].alias:'')">
          <div class="uk-card uk-card-default">
            <div class=" uk-padding-small uk-card-header">
              <div class="md-card-toolbar-actions uk-float-right" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
                <span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
                  <i class="material-icons md-24 uk-margin-small-right">{{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
                  {{(stakeholder.isPublic) ? 'Public' : 'Private'}}
                </span>
                <span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
                  <i class="material-icons md-24 uk-margin-small-right"
                     [class.md-color-green-300]="stakeholder.isActive">{{stakeholderUtils.isActiveIcon}}</i>
                  {{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
                </span>
                <div class="md-card-dropdown uk-inline">
                  <i uk-icon="more-vertical"
                     (click)="$event.stopPropagation();$event.preventDefault()"></i>
                  <div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false">
                    <ul class="uk-nav uk-dropdown-nav">
                      <li><a
                        (click)="$event.stopPropagation();editStakeholder(stakeholder);hide(element);$event.preventDefault()">Edit</a>
                      </li>
                      <li><a (click)="$event.stopPropagation();toggleStakeholderStatus(stakeholder);hide(element);$event.preventDefault()">
                        {{stakeholder.isActive ? 'Inactive' : 'Active'}}</a>
                      </li>
                      <li><a (click)="$event.stopPropagation();toggleStakeholderAccess(stakeholder);hide(element);$event.preventDefault()">
                        {{stakeholder.isPublic ? 'Private' : 'Public'}}</a>
                      </li>
                      <hr class="uk-nav-divider">
                      <li><a
                        (click)="$event.stopPropagation();deleteStakeholderOpen(stakeholder);hide(element);$event.preventDefault()">Delete</a>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
              <div class="uk-card-title">{{stakeholder.name}}</div>
            </div>
            <div *ngIf="grid" class="uk-card-body">
              <div class="uk-flex uk-flex-center" uk-grid>
                <div class="uk-width-1-2 uk-text-center">
                  <i class="material-icons md-24">{{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
                  <div>{{(stakeholder.isPublic) ? 'Public' : 'Private'}}</div>
                </div>
                <div class="uk-width-1-2 uk-text-center">
                  <i class="material-icons md-24"
                     [class.md-color-green-300]="stakeholder.isActive">{{stakeholderUtils.isActiveIcon}}</i>
                  <div>{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}</div>
                </div>
              </div>
            </div>
          </div>
        </a>
      </ng-template>
      <div *ngIf="!loading">
        <div class="uk-card uk-card-default clickable" (click)="editStakeholder()">
          <div class=" uk-padding-small uk-card-header">
            <div class="uk-card-title"
                 [class.uk-flex-middle]="!grid"
                 [class.uk-flex]="!grid"
                 [class.uk-flex-center]="!grid">
              <i *ngIf="!grid" class="material-icons md-36" uk-icon="plus"></i>
              <span>Create a profile</span>
            </div>
          </div>
          <div *ngIf="grid" class="uk-card-body">
            <div uk-grid>
              <div class="uk-width-1-1">
                Create a new profile by selecting the type (Funder, Organization, Research Initiative or Project) and
                select indicators based on a default or a blank profile.
              </div>
              <div class="uk-width-1-1 uk-flex uk-flex-center">
                <i class="material-icons md-48" uk-icon="plus"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<modal-alert #editStakeholderModal
             id="edit_modal" [large]="true"
             (alertOutput)="editStakeholderComponent.save(callback)"
             [okDisabled]="editStakeholderComponent.disabled">
  <edit-stakeholder #editStakeholderComponent [maxHeight]="'70vh'"></edit-stakeholder>
</modal-alert>
<modal-alert #deleteStakeholderModal (alertOutput)="deleteStakeholder()"></modal-alert>
