2019-01-18 18:03:45 +01:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { MatDialog } from '@angular/material';
|
|
|
|
import { GrantListingModel } from '@app/core/model/grant/grant-listing';
|
|
|
|
import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria';
|
|
|
|
import { DmpProfileCriteria } from '@app/core/query/dmp/dmp-profile-criteria';
|
|
|
|
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
|
|
|
import { DialodConfirmationUploadDmpProfiles } from '@app/ui/admin/dmp-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
|
|
|
import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component';
|
|
|
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
2019-02-25 17:53:36 +01:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-dmp-profile-criteria-component',
|
|
|
|
templateUrl: './dmp-profile-criteria.component.html',
|
|
|
|
styleUrls: ['./dmp-profile-criteria.component.scss'],
|
|
|
|
})
|
|
|
|
export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input()
|
2019-08-01 09:54:40 +02:00
|
|
|
showGrant: boolean;
|
2019-01-18 18:03:45 +01:00
|
|
|
public criteria: DmpProfileCriteria = new DmpProfileCriteria();
|
2019-08-01 09:54:40 +02:00
|
|
|
filteringGrantsAsync = false;
|
|
|
|
filteredGrants: GrantListingModel[];
|
2019-01-18 18:03:45 +01:00
|
|
|
constructor(
|
2019-02-25 17:53:36 +01:00
|
|
|
private dmpProfileService: DmpProfileService,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private language: TranslateService
|
2019-01-18 18:03:45 +01:00
|
|
|
) {
|
|
|
|
super(new ValidationErrorModel());
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
super.ngOnInit();
|
|
|
|
if (this.criteria == null) { this.criteria = new DmpCriteria(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
setCriteria(criteria: DmpProfileCriteria): void {
|
|
|
|
this.criteria = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
onCallbackError(error: any) {
|
|
|
|
this.setErrorModel(error.error);
|
|
|
|
}
|
|
|
|
|
|
|
|
controlModified(): void {
|
|
|
|
this.clearErrorModel();
|
|
|
|
if (this.refreshCallback != null &&
|
|
|
|
(this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2)
|
|
|
|
) {
|
|
|
|
this.refreshCallback();
|
|
|
|
}
|
|
|
|
}
|
2019-02-25 17:53:36 +01:00
|
|
|
|
|
|
|
|
2021-06-22 12:00:58 +02:00
|
|
|
// openDialog(): void {
|
|
|
|
// const dialogRef = this.dialog.open(DialodConfirmationUploadDmpProfiles, {
|
|
|
|
// restoreFocus: false,
|
|
|
|
// data: {
|
|
|
|
// message: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-FILE-TITLE'),
|
|
|
|
// confirmButton: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML'),
|
|
|
|
// cancelButton: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-FILE-CANCEL'),
|
|
|
|
// name: '',
|
|
|
|
// file: FileList,
|
|
|
|
// sucsess: false
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => {
|
|
|
|
// if (data && data.sucsess && data.name != null && data.file != null) {
|
|
|
|
// this.dmpProfileService.uploadFile(data.file, data.name)
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|