update file formatters to use exportEntityTypes importEntityTypes
This commit is contained in:
parent
3ec12fdf59
commit
ed96403d25
|
@ -61,7 +61,7 @@
|
|||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>file-transformer-base</artifactId>
|
||||
<version>0.0.11</version>
|
||||
<version>0.0.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package eu.eudat.model.file;
|
||||
|
||||
import eu.eudat.file.transformer.enums.FileTransformerEntityType;
|
||||
import eu.eudat.file.transformer.models.misc.FileFormat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RepositoryFileFormat {
|
||||
private String format;
|
||||
private Boolean hasLogo;
|
||||
private String icon;
|
||||
private String repositoryId;
|
||||
|
||||
public RepositoryFileFormat(String repositoryId, FileFormat format) {
|
||||
private List<FileTransformerEntityType> entityTypes;
|
||||
|
||||
public RepositoryFileFormat(String repositoryId, FileFormat format, List<FileTransformerEntityType> entityTypes) {
|
||||
this.repositoryId = repositoryId;
|
||||
this.format = format.getFormat();
|
||||
this.hasLogo = format.getHasLogo();
|
||||
this.icon = format.getIcon();
|
||||
this.entityTypes = entityTypes;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
|
@ -46,4 +52,12 @@ public class RepositoryFileFormat {
|
|||
public void setRepositoryId(String repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public List<FileTransformerEntityType> getEntityTypes() {
|
||||
return entityTypes;
|
||||
}
|
||||
|
||||
public void setEntityTypes(List<FileTransformerEntityType> entityTypes) {
|
||||
this.entityTypes = entityTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class FileTransformerServiceImpl implements FileTransformerService {
|
|||
List<FileTransformerConfiguration> configurations = this.getAvailableConfigurations();
|
||||
if(configurations != null){
|
||||
for (FileTransformerConfiguration configuration : configurations){
|
||||
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants().stream().map(x-> new RepositoryFileFormat(configuration.getFileTransformerId(), x)).toList());
|
||||
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants().stream().map(x-> new RepositoryFileFormat(configuration.getFileTransformerId(), x, configuration.getExportEntityTypes())).toList());
|
||||
}
|
||||
}
|
||||
return formats;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export enum FileTransformerEntityType {
|
||||
Dmp = 0,
|
||||
Description = 1
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
import { FileTransformerEntityType } from "@app/core/common/enum/file-transformer-entity-type";
|
||||
|
||||
export interface RepositoryFileFormat {
|
||||
format: string;
|
||||
hasLogo: boolean;
|
||||
icon: string;
|
||||
repositoryId: string;
|
||||
entityTypes: FileTransformerEntityType[];
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import { MatomoService } from '../matomo/matomo-service';
|
|||
import { FileUtils } from '../utilities/file-utils.service';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { RepositoryFileFormat } from '@app/core/model/file/file-format.model';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
@Injectable()
|
||||
export class FileTransformerService extends BaseService {
|
||||
|
@ -32,6 +33,13 @@ export class FileTransformerService extends BaseService {
|
|||
return this._availableFormats;
|
||||
}
|
||||
|
||||
public availableFormatsFor(entityType: FileTransformerEntityType) {
|
||||
if (this.availableFormats) {
|
||||
return this.availableFormats.filter(x => x.entityTypes.includes(entityType));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
init() {
|
||||
this._loading = true;
|
||||
// console.log('init');
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<mat-icon [disabled]="isDirty()" style="width: 14px;">expand_more</mat-icon>
|
||||
</button>
|
||||
<mat-menu #exportMenu="matMenu" xPosition="before">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(formGroup.get('id').value, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(formGroup.get('id').value, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
|
||||
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer?.format?.toUpperCase() | translate}}</span>
|
||||
</button>
|
||||
|
|
|
@ -46,6 +46,7 @@ import { FileTransformerService } from '@app/core/services/file-transformer/file
|
|||
import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
||||
import { DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-description-editor-component',
|
||||
|
@ -59,6 +60,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
|||
isDeleted = false;
|
||||
item: Description;
|
||||
fieldsetIdWithFocus: string;
|
||||
fileTransformerEntityTypeEnum = FileTransformerEntityType;
|
||||
|
||||
viewOnly = false;
|
||||
lockStatus: Boolean;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
</a>
|
||||
<div class="description-card-actions">
|
||||
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormats && fileTransformerService.availableFormats.length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description) && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description).length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="canInviteDmpUsers" (click)="openShareDialog()"><span class="material-icons icon-align pr-2">group_add</span>{{'DESCRIPTION-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="copyToDmp(description)"><span class="material-icons icon-align pr-2">file_copy</span>{{'DESCRIPTION-LISTING.ACTIONS.COPY-DESCRIPTION' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="canDelete" (click)="deleteClicked(description.id)"><span class="material-icons icon-align pr-2">delete</span>{{ 'DESCRIPTION-LISTING.ACTIONS.DELETE' | translate }}</a>
|
||||
|
@ -38,7 +38,7 @@
|
|||
</button>
|
||||
</mat-menu>
|
||||
<mat-menu #exportMenu="matMenu" xPosition="before">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
|
||||
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
|
||||
</button>
|
||||
|
|
|
@ -27,6 +27,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||
import { DescriptionStatus } from '../../../../core/common/enum/description-status';
|
||||
import { DescriptionCopyDialogComponent } from '../../description-copy-dialog/description-copy-dialog.component';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-description-listing-item-component',
|
||||
|
@ -44,6 +45,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
|
|||
isDeleted: boolean;
|
||||
isUserOwner: boolean;
|
||||
descriptionStatusEnum = DescriptionStatus;
|
||||
fileTransformerEntityTypeEnum = FileTransformerEntityType;
|
||||
dmpAccessTypeEnum = DmpAccessType;
|
||||
canDelete: boolean = false;
|
||||
canEdit: boolean = false;
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="fileTransformerService.availableFormats.length > 0">
|
||||
<ng-container *ngIf="fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description).length > 0">
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-auto pr-0">
|
||||
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
|
||||
|
@ -160,7 +160,7 @@
|
|||
</div>
|
||||
</ng-container>
|
||||
<mat-menu #exportMenu="matMenu" xPosition="before">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Description)' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
|
||||
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
|
||||
</button>
|
||||
|
|
|
@ -40,6 +40,7 @@ import { PopupNotificationDialogComponent } from '@app/library/notification/popu
|
|||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component';
|
||||
import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -62,6 +63,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
|
|||
dmpAccessTypeEnum = DmpAccessType;
|
||||
dmpStatusEnum = DmpStatus;
|
||||
dmpUserRoleEnum = DmpUserRole;
|
||||
fileTransformerEntityTypeEnum = FileTransformerEntityType;
|
||||
|
||||
canEdit = false;
|
||||
canDelete = false;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<a class="d-flex justify-content-center pb-3 show-more" *ngIf="dmp.descriptions?.length > 3" [routerLink]="isPublic ? ['/explore-plans/overview/public/' + dmp.id] : ['/plans/overview/' + dmp.id]"><u>{{'GENERAL.ACTIONS.SHOW-MORE' | translate}}</u></a>
|
||||
</a>
|
||||
<div class="dmp-card-actions">
|
||||
<a class="col-auto border-right pointer" *ngIf="canExportDmp(dmp) && fileTransformerService.availableFormats.length > 0" [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="canExportDmp(dmp) && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp).length > 0" [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(dmp) && canEditDmp(dmp)" [routerLink]="['/plans/edit/' + dmp.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}}</a>
|
||||
<a class="col-auto border-right pointer" *ngIf="canInviteDmpUsers(dmp)" (click)="inviteToDmp()"><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="canCloneDmp(dmp)" (click)="cloneClicked()"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<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 *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp)' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<i class="fa pr-2" [ngClass]="fileTransformer.hasLogo ? fileTransformer.icon : 'fa-file-o'"></i>
|
||||
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
|
||||
</button>
|
||||
|
|
|
@ -27,6 +27,7 @@ import { CloneDmpDialogComponent } from '../../clone-dialog/dmp-clone-dialog.com
|
|||
import { DmpInvitationDialogComponent } from '../../invitation/dialog/dmp-invitation-dialog.component';
|
||||
import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-listing-item-component',
|
||||
|
@ -44,6 +45,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
|
|||
isFinalized: boolean;
|
||||
isPublished: boolean;
|
||||
dmpStatusEnum = DmpStatus;
|
||||
fileTransformerEntityTypeEnum = FileTransformerEntityType;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
|
|
|
@ -196,7 +196,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="canExportDmp() && fileTransformerService.availableFormats.length > 0">
|
||||
<ng-container *ngIf="canExportDmp() && fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp).length > 0">
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-auto pr-0">
|
||||
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
|
||||
|
@ -221,7 +221,7 @@
|
|||
</div>
|
||||
</ng-container>
|
||||
<mat-menu #exportMenu="matMenu" xPosition="before">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormatsFor(fileTransformerEntityTypeEnum.Dmp)' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.repositoryId, fileTransformer.format)">
|
||||
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
|
||||
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer?.format?.toUpperCase() | translate}}</span>
|
||||
</button>
|
||||
|
|
|
@ -46,6 +46,7 @@ import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
|||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { DmpFinalizeDialogComponent, DmpFinalizeDialogOutput } from '../dmp-finalize-dialog/dmp-finalize-dialog.component';
|
||||
import { DmpEditorResolver } from '../dmp-editor-blueprint/dmp-editor.resolver';
|
||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-overview',
|
||||
|
@ -67,6 +68,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
textMessage: any;
|
||||
pastVersions: Dmp[]; //TODO: get these from the backend
|
||||
selectedModel: EntityDoi;
|
||||
fileTransformerEntityTypeEnum = FileTransformerEntityType;
|
||||
|
||||
@ViewChild('doi')
|
||||
doi: ElementRef;
|
||||
|
|
Loading…
Reference in New Issue