<ion-header>
    <ion-navbar core-back-button>
        <ion-title *ngIf="plan">{{plan.plan.name}}</ion-title>
    </ion-navbar>
</ion-header>
<ion-content>
    <ion-refresher [enabled]="planLoaded" (ionRefresh)="refreshLearningPlan($event)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="planLoaded">
        <ion-card *ngIf="user">
            <ion-item text-wrap>
                <ion-avatar core-user-avatar [user]="user" item-start></ion-avatar>
                <h2><core-format-text [text]="user.fullname"></core-format-text></h2>
            </ion-item>
       </ion-card>
        <ion-card *ngIf="plan">
            <ion-list>
                <ion-item text-wrap *ngIf="plan.plan.description">
                    <core-format-text [text]="plan.plan.description"></core-format-text>
                </ion-item>
                <ion-item text-wrap>
                    <strong>{{ 'addon.competency.status' | translate }}</strong>:
                    {{ plan.plan.statusname }}
                </ion-item>
                <ion-item text-wrap *ngIf="plan.plan.duedate > 0">
                    <strong>{{ 'addon.competency.duedate' | translate }}</strong>:
                    {{ plan.plan.duedate * 1000 | coreFormatDate }}
                </ion-item>
                <ion-item text-wrap *ngIf="plan.plan.template">
                    <strong>{{ 'addon.competency.template' | translate }}</strong>:
                    {{ plan.plan.template.shortname }}
                </ion-item>
                <ion-item text-wrap>
                    <strong>{{ 'addon.competency.progress' | translate }}</strong>:
                    {{ 'addon.competency.xcompetenciesproficientoutofy' | translate: {$a: {x: plan.proficientcompetencycount, y: plan.competencycount} } }}
                    <core-progress-bar [progress]="plan.proficientcompetencypercentage" [text]="plan.proficientcompetencypercentageformatted"></core-progress-bar>
                </ion-item>
            </ion-list>
        </ion-card>
        <ion-card *ngIf="plan">
            <ion-card-header text-wrap><h2>{{ 'addon.competency.learningplancompetencies' | translate }}</h2></ion-card-header>
            <ion-list>
                <ion-item text-wrap *ngIf="plan.competencycount == 0">
                    {{ 'addon.competency.nocompetencies' | translate }}
                </ion-item>
                <a ion-item text-wrap *ngFor="let competency of plan.competencies" (click)="openCompetency(competency.competency.id)" [title]="competency.competency.shortname">
                    <h2>{{competency.competency.shortname}} <em>{{competency.competency.idnumber}}</em></h2>
                    <ion-badge item-end [color]="competency.usercompetency.proficiency ? 'success' : 'danger'">{{ competency.usercompetency.gradename }}</ion-badge>
                </a>
            </ion-list>
        </ion-card>
    </core-loading>
</ion-content>
