<ion-header>
    <ion-navbar core-back-button>
        <ion-title><core-format-text [text]="title"></core-format-text></ion-title>
    </ion-navbar>
</ion-header>
<ion-content>
    <ion-refresher [enabled]="eventLoaded" (ionRefresh)="refreshEvent($event)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="eventLoaded">
        <ion-card>
            <ion-card-content *ngIf="event">
                <ion-card-title text-wrap>
                    <core-icon *ngIf="event.icon && !event.moduleIcon" [name]="event.icon" item-start></core-icon>
                    <core-format-text [text]="event.name"></core-format-text>
                </ion-card-title>
                <ion-item text-wrap>
                    <h2>{{ 'addon.calendar.eventstarttime' | translate}}</h2>
                    <p>{{ event.timestart | coreToLocaleString }}</p>
                </ion-item>
                <ion-item text-wrap *ngIf="event.timeduration > 0">
                    <h2>{{ 'addon.calendar.eventendtime' | translate}}</h2>
                    <p>{{ (event.timestart + event.timeduration) |  coreToLocaleString }}</p>
                </ion-item>
                <a ion-item text-wrap *ngIf="courseName" [href]="courseUrl" core-link capture="true">
                    <h2>{{ 'core.course' | translate}}</h2>
                    <p><core-format-text [text]="courseName"></core-format-text></p>
                </a>
                <a ion-item text-wrap *ngIf="categoryPath">
                    <h2>{{ 'core.category' | translate}}</h2>
                    <p><core-format-text [text]="categoryPath"></core-format-text></p>
                </a>
                <ion-item text-wrap *ngIf="event.moduleIcon">
                    <img *ngIf="event.moduleIcon" src="{{event.moduleIcon}}" item-start alt="" role="presentation" class="core-module-icon"> {{event.moduleName}}
                </ion-item>
                <ion-item text-wrap *ngIf="event.description">
                    <p>
                        <core-format-text [text]="event.description"></core-format-text>
                    </p>
                </ion-item>
                <ion-item text-wrap *ngIf="event.location">
                    <h2>{{ 'core.location' | translate}}</h2>
                    <p>
                        <a [href]="event.encodedLocation" core-link auto-login="no">
                            <core-format-text [text]="event.location"></core-format-text>
                        </a>
                    </p>
                </ion-item>
                <ion-item *ngIf="moduleUrl">
                    <a ion-button block color="primary" [href]="moduleUrl" core-link capture="true">{{ 'addon.calendar.gotoactivity' | translate }}</a>
                </ion-item>
            </ion-card-content>
        </ion-card>

        <ion-card list *ngIf="notificationsEnabled">
            <ion-item>
                <ion-label>{{ 'addon.calendar.notifications' | translate }}</ion-label>
                <ion-select [(ngModel)]="notificationTime" (ionChange)="updateNotificationTime($event)" interface="popover">
                    <ion-option value="-1">{{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }}</ion-option>
                    <ion-option value="0">{{ 'core.settings.disabled' | translate }}</ion-option>
                    <ion-option value="10">{{ 600 | coreDuration }}</ion-option>
                    <ion-option value="30">{{ 1800 | coreDuration }}</ion-option>
                    <ion-option value="60">{{ 3600 | coreDuration }}</ion-option>
                    <ion-option value="120">{{ 7200 | coreDuration }}</ion-option>
                    <ion-option value="360">{{ 21600 | coreDuration }}</ion-option>
                    <ion-option value="720">{{ 43200 | coreDuration }}</ion-option>
                    <ion-option value="1440">{{ 86400 | coreDuration }}</ion-option>
                </ion-select>
            </ion-item>
        </ion-card>
    </core-loading>
</ion-content>
