<div *ngIf="dmpActivities != null">
	<div class="d-flex flex-direction-row pt-4">
		<!-- Sort by -->
		<span class="d-flex align-items-center">{{'DMP-LISTING.SORT-BY' | translate}}:</span>
		<mat-form-field appearance="outline" class="sort-form col-auto">
			<mat-select placeholder="{{'CRITERIA.LIKE'| translate}}" [formControl]="formGroup.get('order')">
				<mat-option *ngIf="!publicMode" [value]="order.MODIFIED">{{enumUtils.toRecentActivityOrderString(order.MODIFIED)}}</mat-option>
				<mat-option *ngIf="publicMode" [value]="order.PUBLISHED">{{enumUtils.toRecentActivityOrderString(order.PUBLISHED)}}</mat-option>
				<mat-option [value]="order.LABEL">{{enumUtils.toRecentActivityOrderString(order.LABEL)}}</mat-option>
				<mat-option *ngIf="!publicMode" [value]="order.STATUS">{{enumUtils.toRecentActivityOrderString(order.STATUS)}}</mat-option>
				<!-- <mat-option [value]="order.CREATED">{{enumUtils.toRecentActivityOrderString(order.CREATED)}}</mat-option> -->
			</mat-select>
		</mat-form-field>
		<!-- End of Sort by -->
		<!-- Search Filter-->
		<mat-form-field appearance="outline" class="search-form ml-auto col-auto pr-0" floatLabel="never">
			<mat-icon matSuffix>search</mat-icon>
			<input matInput placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="likeCriteria" [formControl]="formGroup.get('like')">
			<mat-error *ngIf="formGroup.get('like').hasError('backendError')">{{formGroup.get('like').getError('backendError').message}}</mat-error>
		</mat-form-field>
		<!-- End of Search Filter -->
	</div>
	<div *ngFor="let activity of dmpActivities">
		<div class="dmp-card">
			<a [routerLink]="navigateToUrl(activity.id)" class="pointer">
				<div class="d-flex flex-direction-row">
					<div class="col-auto dmp-label">{{ 'DMP-LISTING.DMP' | translate }}</div>
					<div *ngIf="!publicMode" class="col-auto ml-auto edited-date">{{ 'DMP-LISTING.EDITED' | translate }}: {{ activity.modifiedTime | dateTimeCultureFormatter: "d MMMM y" }}</div>
					<div *ngIf="publicMode" class="col-auto ml-auto edited-date">{{ 'DMP-LISTING.PUBLISHED' | translate }}: {{ activity.publishedAt | dateTimeCultureFormatter: "d MMMM y" }}</div>
				</div>
				<div class="col-auto" [ngClass]="{'dmp-title': activity.status === 1, 'dmp-title-draft': activity.status === 0}">{{activity.label}}</div>
				<div class="dmp-subtitle">
					<span class="col-auto">{{ roleDisplay(activity.users) }}</span>
					<span>.</span>
					<span class="col-auto" *ngIf="activity.status === 1 && activity.public === true"><span class="material-icons icon-align">public</span>{{'TYPES.DMP-VISIBILITY.PUBLIC' | translate}}</span>
					<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
					<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
					<span>.</span>
					<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{activity.version}}</span>
					<span>.</span>
					<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}}</span>
				</div>
				<div class="col-auto dmp-dataset-descriptions-title">{{'DMP-LISTING.CONTAINED-DATASETS' | translate}}: ({{ activity.datasets.length }})
				</div>
				<div *ngFor="let dataset of activity.datasets; let i = index; let last = last" [ngClass]="{'pb-3': i === activity.datasets.length - 1}">
					<div *ngIf="i < 3">
						<div class="col-auto dmp-dataset-descriptions-name" *ngIf="!last && i !== 2">{{dataset.label}},</div>
						<div class="col-auto dmp-dataset-descriptions-name" *ngIf="last || i == 2">{{dataset.label}}</div>
					</div>
				</div>
				<a class="d-flex justify-content-center pb-3 show-more" *ngIf="activity.datasets.length > 3" [routerLink]="navigateToUrl(activity.id)"><u>{{'GENERAL.ACTIONS.SHOW-MORE' | translate}}</u></a>
			</a>
			<div class="dmp-card-actions">
				<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
				<a class="col-auto border-right pointer" *ngIf="isDraftDmp(activity)" [routerLink]="['/datasets/new/' + activity.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
				<a class="col-auto border-right pointer" *ngIf="isUserOwner(activity)" (click)="openShareDialog(activity.id, activity.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
				<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneOrNewVersionClicked(activity, false)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
				<a class="col-auto border-right pointer" *ngIf="!isAuthenticated()" (click)="viewVersions(activity.groupId, activity.label, activity)"><span class="material-icons icon-align pr-2">library_books</span>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}</a>

				<a class="col-auto border-right pointer" *ngIf="!isDraftDmp(activity) && isUserOwner(activity)" (click)="deleteClicked(activity.id)"><span class="material-icons icon-align pr-2">delete</span>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}</a>
				<a class="col-auto pointer" *ngIf="isAuthenticated()" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
			</div>

			<mat-menu #exportMenu="matMenu" xPosition="before">
				<button mat-menu-item (click)="downloadPDF(activity.id)">
					<i class="fa fa-file-pdf-o pr-2"></i>
					<span>{{'GENERAL.FILE-TYPES.PDF' | translate}}</span>
				</button>
				<button mat-menu-item (click)="downloadDocx(activity.id)">
					<i class="fa fa-file-word-o pr-2"></i>
					<span>{{'GENERAL.FILE-TYPES.DOC' | translate}}</span>
				</button>
				<button mat-menu-item (click)="downloadXml(activity.id)">
					<i class="fa fa-file-code-o pr-2"></i>
					<span>{{'GENERAL.FILE-TYPES.XML' | translate}}</span>
				</button>
				<button mat-menu-item (click)="downloadJson(activity.id)">
					<i class="fa fa-file-o pr-2"></i>
					<span>{{'GENERAL.FILE-TYPES.JSON' | translate}}</span>
				</button>
			</mat-menu>
			<mat-menu #actionsMenu="matMenu" xPosition="before">
				<button *ngIf="isUserOwner(activity)" mat-menu-item (click)="cloneOrNewVersionClicked(activity, true)">
					<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
				</button>
				<button mat-menu-item (click)="viewVersions(activity.groupId, activity.label, activity)">
					<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
				</button>
				<button mat-menu-item *ngIf="isDraftDmp(activity) && isUserOwner(activity)" (click)="deleteClicked(activity.id)" class="menu-item">
					<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
				</button>
			</mat-menu>
		</div>
	</div>
	<div *ngIf="dmpActivities && dmpActivities.length > 0 && this.startIndex < this.totalCount - 1 && this.pageSize < this.totalCount - 1" class="d-flex justify-content-center">
		<button type="button" class="btn-load-more" (click)="loadMore()">{{'GENERAL.ACTIONS.LOAD-MORE' | translate}}</button>
	</div>
</div>
