2020-07-01 17:25:16 +02:00
|
|
|
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
|
2019-04-26 18:03:38 +02:00
|
|
|
import { DatasetService } from '../../../core/services/dataset/dataset.service';
|
|
|
|
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
|
|
|
import { DatasetCriteria } from '../../../core/query/dataset/dataset-criteria';
|
|
|
|
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
|
|
|
|
import { AuthService } from '../../../core/services/auth/auth.service';
|
|
|
|
import { RecentActivityType } from '../../../core/common/enum/recent-activity-type';
|
2020-07-10 15:52:35 +02:00
|
|
|
import { Router } from '@angular/router';
|
2019-06-25 11:16:37 +02:00
|
|
|
import { DmpStatus } from '../../../core/common/enum/dmp-status';
|
2020-07-01 17:25:16 +02:00
|
|
|
import { Principal } from '@app/core/model/auth/principal';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2020-10-30 16:51:07 +01:00
|
|
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
2020-07-01 17:25:16 +02:00
|
|
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
|
|
|
import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
|
2020-07-10 15:52:35 +02:00
|
|
|
import { FormControl, FormBuilder } from '@angular/forms';
|
2020-07-01 17:25:16 +02:00
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2021-09-24 20:52:14 +02:00
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
2020-07-01 17:25:16 +02:00
|
|
|
import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service';
|
|
|
|
import { SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service';
|
|
|
|
import * as FileSaver from 'file-saver';
|
|
|
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
|
|
|
import { UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
2020-07-20 15:57:57 +02:00
|
|
|
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component';
|
2020-07-13 12:01:03 +02:00
|
|
|
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
2020-07-22 13:26:49 +02:00
|
|
|
import { Location } from '@angular/common';
|
2020-07-23 11:35:08 +02:00
|
|
|
import { Role } from '@app/core/common/enum/role';
|
|
|
|
import { LockService } from '@app/core/services/lock/lock.service';
|
2020-12-14 18:28:13 +01:00
|
|
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
2019-04-24 11:26:53 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-04-26 18:03:38 +02:00
|
|
|
selector: 'app-drafts',
|
|
|
|
templateUrl: './drafts.component.html',
|
|
|
|
styleUrls: ['./drafts.component.css']
|
2019-04-24 11:26:53 +02:00
|
|
|
})
|
2020-07-01 17:25:16 +02:00
|
|
|
export class DraftsComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input() routerLink: string;
|
|
|
|
@Output() totalCountDraftDatasets: EventEmitter<any> = new EventEmitter();
|
|
|
|
|
2019-04-26 18:03:38 +02:00
|
|
|
datasetDrafts: DatasetListingModel[];
|
|
|
|
datasetDraftsTypeEnum = RecentActivityType;
|
|
|
|
status: number;
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2020-07-01 17:25:16 +02:00
|
|
|
totalCount: number;
|
2020-07-10 15:52:35 +02:00
|
|
|
startIndex: number = 0;
|
2020-07-01 17:25:16 +02:00
|
|
|
pageSize: number = 5;
|
2020-07-10 15:52:35 +02:00
|
|
|
public formGroup = new FormBuilder().group({
|
2020-07-13 12:01:03 +02:00
|
|
|
like: new FormControl(),
|
|
|
|
order: new FormControl()
|
2020-07-10 15:52:35 +02:00
|
|
|
});
|
2020-07-01 17:25:16 +02:00
|
|
|
|
2020-07-13 12:01:03 +02:00
|
|
|
order = RecentActivityOrder;
|
|
|
|
|
2019-04-26 18:03:38 +02:00
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private datasetService: DatasetService,
|
2020-07-01 17:25:16 +02:00
|
|
|
private authentication: AuthService,
|
|
|
|
private language: TranslateService,
|
|
|
|
public dialog: MatDialog,
|
|
|
|
private datasetWizardService: DatasetWizardService,
|
|
|
|
public enumUtils: EnumUtils,
|
2020-07-22 13:26:49 +02:00
|
|
|
private uiNotificationService: UiNotificationService,
|
2020-07-23 11:35:08 +02:00
|
|
|
private location: Location,
|
2020-12-14 18:28:13 +01:00
|
|
|
private lockService: LockService,
|
|
|
|
private httpClient: HttpClient,
|
|
|
|
private matomoService: MatomoService
|
2020-07-01 17:25:16 +02:00
|
|
|
) {
|
|
|
|
super();
|
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2019-04-26 18:03:38 +02:00
|
|
|
ngOnInit() {
|
2020-12-14 18:28:13 +01:00
|
|
|
this.matomoService.trackPageView('Drafts');
|
2020-07-13 12:01:03 +02:00
|
|
|
// const fields: Array<string> = [];
|
|
|
|
// fields.push('-modified');
|
|
|
|
this.formGroup.get('order').setValue(this.order.MODIFIED);
|
2020-07-29 17:35:12 +02:00
|
|
|
const fields: Array<string> = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value];
|
2020-07-01 17:25:16 +02:00
|
|
|
const dmpDataTableRequest: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 5, { fields: fields });
|
2019-04-26 18:03:38 +02:00
|
|
|
dmpDataTableRequest.criteria = new DatasetCriteria();
|
2019-06-25 11:16:37 +02:00
|
|
|
dmpDataTableRequest.criteria.status = DmpStatus.Draft;
|
2021-07-09 12:03:09 +02:00
|
|
|
this.datasetService.getPaged(dmpDataTableRequest)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
2019-04-26 18:03:38 +02:00
|
|
|
this.datasetDrafts = response.data;
|
2020-07-01 17:25:16 +02:00
|
|
|
this.totalCount = response.totalCount;
|
2020-07-10 15:52:35 +02:00
|
|
|
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
|
2019-04-26 18:03:38 +02:00
|
|
|
});
|
2020-07-10 15:52:35 +02:00
|
|
|
this.formGroup.get('like').valueChanges
|
2020-10-30 16:51:07 +01:00
|
|
|
.pipe(takeUntil(this._destroyed), debounceTime(500))
|
2020-07-10 15:52:35 +02:00
|
|
|
.subscribe(x => this.refresh());
|
2020-07-13 12:01:03 +02:00
|
|
|
this.formGroup.get('order').valueChanges
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(x => this.refresh());
|
2019-04-26 18:03:38 +02:00
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2019-04-26 18:03:38 +02:00
|
|
|
redirect(id: string, type: RecentActivityType) {
|
|
|
|
switch (type) {
|
2019-08-01 09:54:40 +02:00
|
|
|
case RecentActivityType.Grant: {
|
|
|
|
this.router.navigate(["grants/edit/" + id]);
|
2019-04-26 18:03:38 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case RecentActivityType.Dataset: {
|
|
|
|
this.router.navigate(["datasets/edit/" + id]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case RecentActivityType.Dmp: {
|
|
|
|
this.router.navigate(["plans/edit/" + id]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw new Error("Unsupported Activity Type ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
return !!this.authentication.current();
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateToUrl() {
|
|
|
|
if (!this.isAuthenticated()) { return; }
|
|
|
|
this.router.navigate(['/datasets'], { queryParams: { status: 0 } });
|
|
|
|
}
|
2020-07-01 17:25:16 +02:00
|
|
|
|
|
|
|
roleDisplay(value: any) {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
let role: number;
|
|
|
|
if (principal) {
|
|
|
|
value.forEach(element => {
|
|
|
|
if (principal.id === element.id) {
|
|
|
|
role = element.role;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (role === 0) {
|
|
|
|
return this.language.instant('DMP-LISTING.OWNER');
|
|
|
|
}
|
|
|
|
else if (role === 1) {
|
|
|
|
return this.language.instant('DMP-LISTING.MEMBER');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.language.instant('DMP-LISTING.OWNER');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openDmpSearchDialogue(dataset: DatasetListingModel) {
|
|
|
|
const formControl = new FormControl();
|
|
|
|
const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, {
|
|
|
|
width: '500px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
formControl: formControl,
|
|
|
|
datasetId: dataset.id,
|
2020-07-24 11:43:09 +02:00
|
|
|
datasetProfileId: dataset.profile.id,
|
2020-07-01 17:25:16 +02:00
|
|
|
datasetProfileExist: false,
|
|
|
|
confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'),
|
|
|
|
cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(result => {
|
|
|
|
if (result && result.datasetProfileExist) {
|
2020-07-27 10:52:42 +02:00
|
|
|
const newDmpId = result.formControl.value.id;
|
2020-09-29 16:33:16 +02:00
|
|
|
this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } });
|
|
|
|
// let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId } ]);
|
|
|
|
// window.open(url.toString(), '_blank');
|
2020-07-01 17:25:16 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-24 16:40:53 +02:00
|
|
|
deleteClicked(id: string) {
|
|
|
|
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(lockStatus => {
|
|
|
|
if (!lockStatus) {
|
|
|
|
this.openDeleteDialog(id);
|
|
|
|
} else {
|
|
|
|
this.openLockedByUserDialog();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
openDeleteDialog(id: string): void {
|
2020-07-01 17:25:16 +02:00
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
maxWidth: '300px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
|
|
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
|
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
isDeleteConfirmation: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.datasetWizardService.delete(id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2020-07-22 13:26:49 +02:00
|
|
|
complete => this.onDeleteCallbackSuccess(),
|
|
|
|
error => this.onDeleteCallbackError(error)
|
2020-07-01 17:25:16 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-24 16:40:53 +02:00
|
|
|
openLockedByUserDialog() {
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
maxWidth: '400px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-02 10:25:06 +02:00
|
|
|
openShareDialog(dmpRowId: any, dmpRowName: any) {
|
|
|
|
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
|
|
|
// height: '250px',
|
|
|
|
// width: '700px',
|
2020-10-29 10:44:17 +01:00
|
|
|
autoFocus: false,
|
2020-07-02 10:25:06 +02:00
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
dmpId: dmpRowId,
|
|
|
|
dmpName: dmpRowName
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:35:08 +02:00
|
|
|
isUserOwner(activity: DatasetListingModel): boolean {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
if (principal) return principal.id === activity.users.find(x => x.role === Role.Owner).id;
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:25:16 +02:00
|
|
|
onCallbackSuccess(id?: String): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
|
|
|
id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']);
|
|
|
|
}
|
|
|
|
|
|
|
|
onCallbackError(error: any) {
|
|
|
|
// this.setErrorModel(error.error);
|
|
|
|
}
|
|
|
|
|
2020-07-22 13:26:49 +02:00
|
|
|
reloadPage(): void {
|
|
|
|
const path = this.location.path();
|
|
|
|
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
|
|
|
|
this.router.navigate([path]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteCallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
|
|
|
this.reloadPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:25:16 +02:00
|
|
|
downloadPDF(dataset: DatasetListingModel): void {
|
|
|
|
this.datasetWizardService.downloadPDF(dataset.id as string)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
|
|
|
const blob = new Blob([response.body], { type: 'application/pdf' });
|
|
|
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
downloadDOCX(dataset: DatasetListingModel): void {
|
|
|
|
this.datasetWizardService.downloadDOCX(dataset.id as string)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
|
|
|
const blob = new Blob([response.body], { type: 'application/msword' });
|
|
|
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
downloadXML(dataset: DatasetListingModel): void {
|
|
|
|
this.datasetWizardService.downloadXML(dataset.id as string)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
|
|
|
const blob = new Blob([response.body], { type: 'application/xml' });
|
|
|
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getFilenameFromContentDispositionHeader(header: string): string {
|
|
|
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
|
|
|
|
|
|
|
const matches = header.match(regex);
|
|
|
|
let filename: string;
|
|
|
|
for (let i = 0; i < matches.length; i++) {
|
|
|
|
const match = matches[i];
|
|
|
|
if (match.includes('filename="')) {
|
|
|
|
filename = match.substring(10, match.length - 1);
|
|
|
|
break;
|
|
|
|
} else if (match.includes('filename=')) {
|
|
|
|
filename = match.substring(9);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2020-07-10 15:52:35 +02:00
|
|
|
refresh(): void {
|
2020-07-13 12:01:03 +02:00
|
|
|
// const fields: Array<string> = [];
|
|
|
|
// fields.push('-modified');
|
2020-07-29 17:35:12 +02:00
|
|
|
const fields: Array<string> = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value];
|
2020-07-10 15:52:35 +02:00
|
|
|
this.startIndex = 0;
|
|
|
|
const dmpDataTableRequest: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 5, { fields: fields });
|
|
|
|
dmpDataTableRequest.criteria = new DatasetCriteria();
|
|
|
|
dmpDataTableRequest.criteria.status = DmpStatus.Draft;
|
|
|
|
dmpDataTableRequest.criteria.like = this.formGroup.get("like").value;
|
2021-07-09 12:03:09 +02:00
|
|
|
this.datasetService.getPaged(dmpDataTableRequest)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
2020-07-10 15:52:35 +02:00
|
|
|
this.datasetDrafts = response.data;
|
|
|
|
this.totalCount = response.totalCount;
|
|
|
|
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-01 17:25:16 +02:00
|
|
|
public loadMore() {
|
2020-07-10 15:52:35 +02:00
|
|
|
this.startIndex = this.startIndex + this.pageSize;
|
2020-07-13 12:01:03 +02:00
|
|
|
// const fields: Array<string> = ["-modified"];
|
2020-07-29 17:35:12 +02:00
|
|
|
const fields: Array<string> = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value];
|
2020-07-01 17:25:16 +02:00
|
|
|
const request = new DataTableRequest<DatasetCriteria>(this.startIndex, this.pageSize, { fields: fields });
|
|
|
|
request.criteria = new DatasetCriteria();
|
2020-07-10 15:52:35 +02:00
|
|
|
request.criteria.status = DmpStatus.Draft;
|
|
|
|
request.criteria.like = this.formGroup.get("like").value;;
|
2020-07-01 17:25:16 +02:00
|
|
|
|
|
|
|
this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (!result) { return []; }
|
2020-07-28 14:54:21 +02:00
|
|
|
// this.datasetDrafts = this.datasetDrafts.concat(result.data);
|
|
|
|
this.datasetDrafts = this.datasetDrafts.length > 0 ? this.mergeTwoSortedLists(this.datasetDrafts, result.data, this.formGroup.get('order').value) : result.data;
|
2020-07-10 15:52:35 +02:00
|
|
|
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
|
2020-07-01 17:25:16 +02:00
|
|
|
});
|
|
|
|
}
|
2020-07-28 14:54:21 +02:00
|
|
|
|
|
|
|
private mergeTwoSortedLists(arr1: DatasetListingModel[], arr2: DatasetListingModel[], order: string): DatasetListingModel[] {
|
|
|
|
let merged = [];
|
|
|
|
let index1 = 0;
|
|
|
|
let index2 = 0;
|
|
|
|
let current = 0;
|
|
|
|
|
|
|
|
while (current < (arr1.length + arr2.length)) {
|
|
|
|
|
|
|
|
let isArr1Depleted = index1 >= arr1.length;
|
|
|
|
let isArr2Depleted = index2 >= arr2.length;
|
|
|
|
|
|
|
|
if (order === 'modified') {
|
|
|
|
if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modified) > new Date(arr2[index2].modified)))) {
|
|
|
|
merged[current] = arr1[index1];
|
|
|
|
index1++;
|
|
|
|
} else {
|
|
|
|
merged[current] = arr2[index2];
|
|
|
|
index2++;
|
|
|
|
}
|
|
|
|
} else if (order === 'created') {
|
|
|
|
if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].created) > new Date(arr2[index2].created)))) {
|
|
|
|
merged[current] = arr1[index1];
|
|
|
|
index1++;
|
|
|
|
} else {
|
|
|
|
merged[current] = arr2[index2];
|
|
|
|
index2++;
|
|
|
|
}
|
|
|
|
} else if (order === 'label') {
|
|
|
|
if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].label < arr2[index2].label))) {
|
|
|
|
merged[current] = arr1[index1];
|
|
|
|
index1++;
|
|
|
|
} else {
|
|
|
|
merged[current] = arr2[index2];
|
|
|
|
index2++;
|
|
|
|
}
|
|
|
|
} else if (order === 'status') {
|
|
|
|
if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) {
|
|
|
|
merged[current] = arr1[index1];
|
|
|
|
index1++;
|
|
|
|
} else {
|
|
|
|
merged[current] = arr2[index2];
|
|
|
|
index2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current++;
|
|
|
|
}
|
|
|
|
return merged;
|
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
}
|