This commit is contained in:
Kristian Ntavidi 2021-04-07 19:20:32 +03:00
commit 45227cca10
19 changed files with 237 additions and 159 deletions

View File

@ -1,6 +1,5 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.dao.entities.UserDatasetProfileDao;
import eu.eudat.data.entities.UserDatasetProfile; import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
@ -17,7 +16,6 @@ import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.UserInfoListingModel; import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import org.springframework.core.env.Environment;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
@ -70,16 +68,7 @@ public class Admin extends BaseController {
userDatasetProfile.setUser(userInfo); userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0); userDatasetProfile.setRole(0);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile); getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
if (profile.getUsers() != null && !profile.getUsers().isEmpty()) { datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
profile.getUsers().forEach(userInfoListingModel -> {
UserDatasetProfile userDatasetProfile1 = new UserDatasetProfile();
userDatasetProfile1.setDatasetProfile(datasetProfile);
UserInfo userInfo1 = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
userDatasetProfile1.setUser(userInfo1);
userDatasetProfile1.setRole(1);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
});
}
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId()); return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
} }
@ -95,16 +84,7 @@ public class Admin extends BaseController {
datasetprofile.setDescription(modelDefinition.getDescription()); datasetprofile.setDescription(modelDefinition.getDescription());
datasetprofile.setLanguage(modelDefinition.getLanguage()); datasetprofile.setLanguage(modelDefinition.getLanguage());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile); eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
if (profile.getUsers() != null && !profile.getUsers().isEmpty()) { datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
profile.getUsers().forEach(userInfoListingModel -> {
UserDatasetProfile userDatasetProfile1 = new UserDatasetProfile();
userDatasetProfile1.setDatasetProfile(datasetProfile);
UserInfo userInfo1 = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
userDatasetProfile1.setUser(userInfo1);
userDatasetProfile1.setRole(1);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
});
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
} }
@ -148,16 +128,7 @@ public class Admin extends BaseController {
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel() + " new "); datasetprofile.setLabel(profile.getLabel() + " new ");
datasetprofile.setLanguage(profile.getLanguage()); datasetprofile.setLanguage(profile.getLanguage());
if (profile.getUsers() != null && !profile.getUsers().isEmpty()) { datasetProfileManager.retrieveUsers(profile, datasetprofile);
datasetprofile.setUsers(profile.getUsers().stream().map(userDatasetProfile -> {
UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
userInfoListingModel.setId(userDatasetProfile.getUser().getId());
userInfoListingModel.setName(userDatasetProfile.getUser().getName());
userInfoListingModel.setEmail(userDatasetProfile.getUser().getEmail());
userInfoListingModel.setRole(userDatasetProfile.getRole());
return userInfoListingModel;
}).collect(Collectors.toList()));
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
} }

View File

@ -119,6 +119,14 @@ public class Users extends BaseController {
ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception { ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
return userManager.exportToCsv(principal); return userManager.exportToCsv(principal);
} }
@RequestMapping(method = RequestMethod.POST, value = {"/find"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UserProfile>> find(@Valid @RequestBody String email) throws Exception {
UserProfile userProfile = userManager.getFromEmail(email);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().payload(userProfile).status(ApiMessageCode.NO_MESSAGE));
}
} }

View File

@ -4,6 +4,8 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException; import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
@ -72,16 +74,7 @@ public class DatasetProfileManager {
datasetprofile.setDescription(profile.getDescription()); datasetprofile.setDescription(profile.getDescription());
datasetprofile.setLanguage(profile.getLanguage()); datasetprofile.setLanguage(profile.getLanguage());
datasetprofile.setUsers(new ArrayList<>()); datasetprofile.setUsers(new ArrayList<>());
if (profile.getUsers() != null && !profile.getUsers().isEmpty()) { retrieveUsers(profile, datasetprofile);
datasetprofile.getUsers().addAll(profile.getUsers().stream().map(userDatasetProfile -> {
UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
userInfoListingModel.setId(userDatasetProfile.getUser().getId());
userInfoListingModel.setName(userDatasetProfile.getUser().getName());
userInfoListingModel.setEmail(userInfoListingModel.getEmail());
userInfoListingModel.setRole(userInfoListingModel.getRole());
return userInfoListingModel;
}).collect(Collectors.toList()));
}
return datasetprofile; return datasetprofile;
} }
@ -276,4 +269,34 @@ public class DatasetProfileManager {
throw new DatasetProfileNewVersionException("Version to update not the latest."); throw new DatasetProfileNewVersionException("Version to update not the latest.");
} }
} }
public void storeDatasetProfileUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (model.getUsers() != null && !model.getUsers().isEmpty()) {
model.getUsers().stream().filter(userInfoListingModel -> entity.getUsers().stream().filter(userDatasetProfile -> userDatasetProfile.getUser().getId().equals(userInfoListingModel.getId())).count() == 0).forEach(userInfoListingModel -> {
UserDatasetProfile userDatasetProfile1 = new UserDatasetProfile();
userDatasetProfile1.setDatasetProfile(entity);
UserInfo userInfo1 = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userInfoListingModel.getId());
userDatasetProfile1.setUser(userInfo1);
userDatasetProfile1.setRole(1);
apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile1);
});
}
entity.getUsers().stream().filter(userDatasetProfile -> model.getUsers().stream().filter(userInfoListingModel -> userDatasetProfile.getUser().getId().equals(userInfoListingModel.getId())).count() == 0).forEach(userDatasetProfile -> {
userDatasetProfile.setRole(2);
apiContext.getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
});
}
public void retrieveUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (entity.getUsers() != null && !entity.getUsers().isEmpty()) {
model.setUsers(entity.getUsers().stream().filter(userDatasetProfile -> userDatasetProfile.getRole() < 2).map(userDatasetProfile -> {
UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
userInfoListingModel.setId(userDatasetProfile.getUser().getId());
userInfoListingModel.setName(userDatasetProfile.getUser().getName());
userInfoListingModel.setEmail(userDatasetProfile.getUser().getEmail());
userInfoListingModel.setRole(userDatasetProfile.getRole());
return userInfoListingModel;
}).collect(Collectors.toList()));
}
}
} }

View File

@ -239,5 +239,10 @@ public class UserManager {
Files.deleteIfExists(file.toPath()); Files.deleteIfExists(file.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK); return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
} }
public UserProfile getFromEmail(String email) {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), email)).getSingle();
return new UserProfile().fromDataModel(user);
}
} }

View File

@ -1,4 +1,5 @@
import { ValidationType } from "../../../common/enum/validation-type"; import { ValidationType } from "../../../common/enum/validation-type";
import { UserInfoListingModel } from "../../user/user-info-listing";
export interface DatasetProfile { export interface DatasetProfile {
label: string; label: string;
@ -8,6 +9,7 @@ export interface DatasetProfile {
version: number; version: number;
description: string; description: string;
language: string; language: string;
users: UserInfoListingModel[];
} }
export interface Page { export interface Page {

View File

@ -53,6 +53,10 @@ export class UserService {
return this.http.post<DataTableData<UserListingModel>>(this.actionUrl + 'getCollaboratorsPaged', JSON.stringify(dataTableRequest), { headers: this.headers }); return this.http.post<DataTableData<UserListingModel>>(this.actionUrl + 'getCollaboratorsPaged', JSON.stringify(dataTableRequest), { headers: this.headers });
} }
getFromEmail(email: string): Observable<UserListingModel> {
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
}
public hasDOIToken(): Observable<any> { public hasDOIToken(): Observable<any> {
const url = this.actionUrl + 'hasDOIToken'; const url = this.actionUrl + 'hasDOIToken';
return this.http.get(url, { headers: this.headers }); return this.http.get(url, { headers: this.headers });

View File

@ -54,6 +54,7 @@ import {DragulaModule} from 'ng2-dragula';
import {MatBadgeModule} from '@angular/material/badge'; import {MatBadgeModule} from '@angular/material/badge';
import { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component'; import { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component';
import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component'; import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
@NgModule({ @NgModule({
imports: [ imports: [
@ -68,7 +69,8 @@ import { FinalPreviewComponent } from './editor/components/final-preview/final-p
AngularStickyThingsModule, AngularStickyThingsModule,
DragDropModule, DragDropModule,
MatBadgeModule, MatBadgeModule,
DragulaModule DragulaModule,
AutoCompleteModule
], ],
declarations: [ declarations: [
DatasetProfileListingComponent, DatasetProfileListingComponent,

View File

@ -1,4 +1,5 @@
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
import { DatasetProfile } from '../../../../core/model/admin/dataset-profile/dataset-profile'; import { DatasetProfile } from '../../../../core/model/admin/dataset-profile/dataset-profile';
import { BaseFormModel } from '../../../../core/model/base-form-model'; import { BaseFormModel } from '../../../../core/model/base-form-model';
import { PageEditorModel } from '../admin/page-editor-model'; import { PageEditorModel } from '../admin/page-editor-model';
@ -15,6 +16,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
public version: number; public version: number;
private description: string; private description: string;
private language: string; private language: string;
private users: UserInfoListingModel[] = [];
fromModel(item: DatasetProfile): DatasetProfileEditorModel { fromModel(item: DatasetProfile): DatasetProfileEditorModel {
if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); }
@ -24,6 +26,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
this.version = item.version; this.version = item.version;
this.description = item.description; this.description = item.description;
this.language = item.language; this.language = item.language;
this.users = item.users;
return this; return this;
} }
@ -33,7 +36,8 @@ export class DatasetProfileEditorModel extends BaseFormModel {
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]], description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]], language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }], status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }] version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }],
users: [{ value: this.users, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.users')) }]
}); });
const sectionsFormArray = new Array<FormGroup>(); const sectionsFormArray = new Array<FormGroup>();

View File

@ -3,12 +3,12 @@
<div class="main-content"> <div class="main-content">
<div class="container-fluid dataset-profile-editor" *ngIf="form" [formGroup]='form'> <div class="container-fluid dataset-profile-editor" *ngIf="form" [formGroup]='form'>
<!-- Total steps: {{stepper.steps.length}} --> <!-- Total steps: {{stepper.steps.length}} -->
<div class="row" style="padding: 2em; margin-bottom: 1em; background: #F5F5F5 0% 0% no-repeat padding-box;" > <div class="row" style="padding: 2em; margin-bottom: 1em; background: #F5F5F5 0% 0% no-repeat padding-box;" >
<div class="col-12" style="margin-bottom: 2em;"> <div class="col-12" style="margin-bottom: 2em;">
@ -43,33 +43,33 @@
<mat-icon style="font-size:0.7em; height: 0px;">done</mat-icon> <mat-icon style="font-size:0.7em; height: 0px;">done</mat-icon>
</ng-container> </ng-container>
<ng-template #numberLabel> <ng-template #numberLabel>
{{idx+1}} {{idx+1}}
</ng-template> </ng-template>
{{step.label}} {{step.label}}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="col d-flex justify-content-end"> <div class="col d-flex justify-content-end">
<button [@previous_btn] mat-button class="navigate-btn" (click)="stepper.previous()" *ngIf="stepper.selectedIndex !=0"> <button [@previous_btn] mat-button class="navigate-btn" (click)="stepper.previous()" *ngIf="stepper.selectedIndex !=0">
<!-- <mat-icon>navigate_before</mat-icon> --> <!-- <mat-icon>navigate_before</mat-icon> -->
{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}} {{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}
</button> </button>
<button mat-button class="navigate-btn ml-3" <button mat-button class="navigate-btn ml-3"
[@next_btn] [@next_btn]
(click)="validateStep(stepper.selectedIndex);stepper.next();" (click)="validateStep(stepper.selectedIndex);stepper.next();"
*ngIf="stepper.selectedIndex != (steps.length-1)" *ngIf="stepper.selectedIndex != (steps.length-1)"
[ngClass]="{'navigate-btn-disabled': !isStepCompleted(stepper.selectedIndex)}"> [ngClass]="{'navigate-btn-disabled': !isStepCompleted(stepper.selectedIndex)}">
<mat-icon style="font-size: 1.66em;">navigate_next</mat-icon>{{'DMP-EDITOR.STEPPER.NEXT' | translate}} <mat-icon style="font-size: 1.66em;">navigate_next</mat-icon>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
</button> </button>
<ng-container *ngIf="steps.length-1 === stepper.selectedIndex"> <ng-container *ngIf="steps.length-1 === stepper.selectedIndex">
<!-- <ng-container *ngIf="stepper.selectedIndex === (steps.length-1)"> --> <!-- <ng-container *ngIf="stepper.selectedIndex === (steps.length-1)"> -->
<ng-container *ngIf="!viewOnly"> <ng-container *ngIf="!viewOnly">
<!-- <button mat-button class="navigate-btn ml-2" <!-- <button mat-button class="navigate-btn ml-2"
(click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' | (click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' |
translate}}</button> --> translate}}</button> -->
@ -77,10 +77,10 @@
(click)='finalize()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' | (click)='finalize()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' |
translate}}</button> --> translate}}</button> -->
</ng-container> </ng-container>
<!-- //TODO --> <!-- //TODO -->
<ng-container *ngIf="true"> <ng-container *ngIf="true">
<!-- <button mat-button class="navigate-btn ml-2" <!-- <button mat-button class="navigate-btn ml-2"
(click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' | (click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' |
translate}}</button> --> translate}}</button> -->
@ -90,13 +90,13 @@
<button [@finalize_btn] mat-button class="finalize-btn ml-3" <button [@finalize_btn] mat-button class="finalize-btn ml-3"
[disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' | [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' |
translate}}</button> translate}}</button>
</ng-container> </ng-container>
<!-- SAVE BUTTON WHEN FINALIZED--> <!-- SAVE BUTTON WHEN FINALIZED-->
<ng-container *ngIf="false"> <ng-container *ngIf="false">
<ng-container *ngIf="showUpdateButton()"> <ng-container *ngIf="showUpdateButton()">
<!-- <button mat-button class="navigate-btn ml-2" <!-- <button mat-button class="navigate-btn ml-2"
(click)='checkFormValidation()' (click)='checkFormValidation()'
[disabled]="form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.VALIDATE' | translate}}</button> --> [disabled]="form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.VALIDATE' | translate}}</button> -->
@ -106,16 +106,16 @@
</ng-container> </ng-container>
</ng-container> </ng-container>
</ng-container> </ng-container>
</div> </div>
</div> </div>
</div> </div>
<mat-horizontal-stepper [linear]="true" #stepper class="stepper" (selectionChange)="onMatStepperSelectionChange($event)" style="padding-left: 8px; padding-right: 15px;"> <mat-horizontal-stepper [linear]="true" #stepper class="stepper" (selectionChange)="onMatStepperSelectionChange($event)" style="padding-left: 8px; padding-right: 15px;">
<!-- IMPORTANT TO BE !INVALID (WHEN THE TEMPLATE IS FINALIZED THE CONTORLS ARE DISABLED) --> <!-- IMPORTANT TO BE !INVALID (WHEN THE TEMPLATE IS FINALIZED THE CONTORLS ARE DISABLED) -->
@ -164,6 +164,29 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-12">
<!-- <div class="heading">1.3 {{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}</div> -->
<div class="heading">1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="full-width basic-info-input">
<table class="col-12">
<tr class="row">
<th class="col-4">{{'USERS.LISTING.NAME' | translate}}</th>
<th class="col-4">{{'USERS.LISTING.EMAIL' | translate}}</th>
<th class="col-4"></th>
</tr>
<tr *ngFor="let user of userChipList" class="row">
<td class="col-4">{{user.name}}</td>
<td class="col-4">{{user.email}}</td>
<td class="col-4">
<button mat-raised-button class="delete-btn" (click)="removeUser(user)">delete</button>
</td>
</tr>
</table>
</div>
<input matInput #email class = "col-8" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}">
<button mat-raised-button color="primary" (click)="checkAndAdd(email.value)">Add and Validate</button>
</div>
<!-- <div class="col-12"> <!-- <div class="col-12">
<button mat-button class="full-width" (click)="addPage()" <button mat-button class="full-width" (click)="addPage()"
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.NEXT' | translate}}</button> [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.NEXT' | translate}}</button>
@ -190,7 +213,7 @@
<div class="row sticky-top" style="top : 2em;"> <div class="row sticky-top" style="top : 2em;">
<dataset-profile-table-of-contents class="toc-pane-container col" <dataset-profile-table-of-contents class="toc-pane-container col"
[links]="toCEntries" [links]="toCEntries"
(itemClick)="displayItem($event)" (itemClick)="displayItem($event)"
(createEntry) = "addNewEntry($event)" (createEntry) = "addNewEntry($event)"
@ -212,7 +235,7 @@
<div class="col"> <div class="col">
<div class="row" *ngIf="selectedTocEntry"> <div class="row" *ngIf="selectedTocEntry">
<!-- PAGE INFO --> <!-- PAGE INFO -->
<div class="col-12 content-displayer" *ngIf="selectedTocEntry.type === tocEntryEnumValues.Page"> <div class="col-12 content-displayer" *ngIf="selectedTocEntry.type === tocEntryEnumValues.Page">
<form [formGroup]="selectedTocEntry.form" class="page-infos"> <form [formGroup]="selectedTocEntry.form" class="page-infos">
@ -226,7 +249,7 @@
<mat-error >{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error >{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-12" *ngIf="!viewOnly && (!selectedTocEntry?.subEntries?.length)"> <div class="col-12" *ngIf="!viewOnly && (!selectedTocEntry?.subEntries?.length)">
<button class="create-section-btn" (click)="addNewEntry({parent:selectedTocEntry, childType: tocEntryEnumValues.Section})">Create section</button> <button class="create-section-btn" (click)="addNewEntry({parent:selectedTocEntry, childType: tocEntryEnumValues.Section})">Create section</button>
</div> </div>
@ -248,7 +271,7 @@
</div> --> </div> -->
</form> </form>
</div> </div>
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)" > <div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)" >
<app-dataset-profile-editor-section-fieldset-component <app-dataset-profile-editor-section-fieldset-component
[tocentry]="selectedTocEntry" [tocentry]="selectedTocEntry"
@ -262,10 +285,10 @@
</app-dataset-profile-editor-section-fieldset-component> </app-dataset-profile-editor-section-fieldset-component>
</div> </div>
</div> </div>
<div class="content-displayer row justify-content-center" *ngIf="!numOfPages" style="min-height: 30em;"> <div class="content-displayer row justify-content-center" *ngIf="!numOfPages" style="min-height: 30em;">
<div class="col-auto align-self-center"> <div class="col-auto align-self-center">
<div class="row w-100 justify-content-center"> <div class="row w-100 justify-content-center">
@ -276,7 +299,7 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-auto d-flex aling-contents-center"> <div class="col-auto d-flex aling-contents-center">
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-START'| translate}} {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-START'| translate}}
<mat-icon color="accent" style="font-size: 1.5em; text-align: center; width: 1.5em;">add</mat-icon> <mat-icon color="accent" style="font-size: 1.5em; text-align: center; width: 1.5em;">add</mat-icon>
<strong style="cursor: pointer;" (click)="addNewEntry({childType: tocEntryEnumValues.Page,parent: null})"> <strong style="cursor: pointer;" (click)="addNewEntry({childType: tocEntryEnumValues.Page,parent: null})">
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-END'| translate}} {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-END'| translate}}
@ -285,12 +308,12 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- TOOLBAR --> <!-- TOOLBAR -->
<!-- <div class="col-auto" <!-- <div class="col-auto"
*ngIf="((selectedTocEntry?.type == tocEntryEnumValues.Section)||(selectedTocEntry?.type == tocEntryEnumValues.FieldSet) )&&(selectedTocEntry?.subEntriesType != tocEntryEnumValues.Section) && !viewOnly"> *ngIf="((selectedTocEntry?.type == tocEntryEnumValues.Section)||(selectedTocEntry?.type == tocEntryEnumValues.FieldSet) )&&(selectedTocEntry?.subEntriesType != tocEntryEnumValues.Section) && !viewOnly">
<div class="row" class="actions-list bg-white sticky-top" style="top: 2em;"> <div class="row" class="actions-list bg-white sticky-top" style="top: 2em;">
<nav *ngIf="!viewOnly"> <nav *ngIf="!viewOnly">
@ -319,7 +342,7 @@
<span class="action-list-text">{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.CLONE' | translate}}</span> <span class="action-list-text">{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.CLONE' | translate}}</span>
</div> </div>
</li> </li>
<li *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli"> <li *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli">
<div class="action-list-item" (click)="onRemoveEntry(selectedTocEntry)"> <div class="action-list-item" (click)="onRemoveEntry(selectedTocEntry)">
<mat-icon class="action-list-icon">delete</mat-icon> <mat-icon class="action-list-icon">delete</mat-icon>
@ -328,7 +351,7 @@
</li> </li>
</ul> </ul>
</nav> --> </nav> -->
<!-- <ng-container *ngIf="!viewOnly"> <!-- <ng-container *ngIf="!viewOnly">
<h3 matSubheader>{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.GENERAL-TOOLS' | translate}}</h3> <h3 matSubheader>{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.GENERAL-TOOLS' | translate}}</h3>
<mat-list-item *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli"> <mat-list-item *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli">
@ -351,7 +374,7 @@
<span class="action-list-text" (click)="cloneFieldSet(selectedTocEntry.form)">{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.CLONE' | translate}}</span> <span class="action-list-text" (click)="cloneFieldSet(selectedTocEntry.form)">{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.CLONE' | translate}}</span>
</div> </div>
</mat-list-item> </mat-list-item>
<mat-list-item *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli"> <mat-list-item *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli">
<div class="action-list-item"> <div class="action-list-item">
<mat-icon class="action-list-icon">delete</mat-icon> <mat-icon class="action-list-icon">delete</mat-icon>
@ -359,12 +382,12 @@
</div> </div>
</mat-list-item> </mat-list-item>
</ng-container> --> </ng-container> -->
<!-- </div> <!-- </div>
</div> --> </div> -->
</div> </div>
<!-- <!--
<mat-accordion class="col-12" [multi]="true"> <mat-accordion class="col-12" [multi]="true">
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel> <mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -400,16 +423,16 @@
</app-final-preview-component> </app-final-preview-component>
<!-- <!--
<app-dataset-description [form]="formGroup" [visibilityRules]="visibilityRules" *ngIf="formGroup"> <app-dataset-description [form]="formGroup" [visibilityRules]="visibilityRules" *ngIf="formGroup">
</app-dataset-description> --> </app-dataset-description> -->
</ng-container> </ng-container>
</mat-step> </mat-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>
<ng-container *ngIf="true"> <ng-container *ngIf="true">
@ -425,7 +448,7 @@
</ng-container> </ng-container>
<button mat-raised-button class="col-auto mr-2" color="primary" type="button col-auto" <button mat-raised-button class="col-auto mr-2" color="primary" type="button col-auto"
(click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' | (click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' |
translate}}</button> translate}}</button>
@ -480,8 +503,8 @@
print errors print errors
</button> </button>
</div> --> </div> -->
<!-- <div class="row"> <!-- <div class="row">
<button (click)="foo()">foo</button> <button (click)="foo()">foo</button>
</div> --> </div> -->
</div> </div>
</div> </div>

View File

@ -174,14 +174,14 @@ $blue-color-light: #5cf7f2;
.mat-list-item-content{ .mat-list-item-content{
padding: 0px; padding: 0px;
} }
.action-list-item{ .action-list-item{
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
.action-list-icon{ .action-list-icon{
font-size: 1.2em; font-size: 1.2em;
// padding-right: 1em; // padding-right: 1em;
@ -227,4 +227,9 @@ $blue-color-light: #5cf7f2;
.basic-info-input{ .basic-info-input{
margin-top: 2em; margin-top: 2em;
margin-bottom: 2em; margin-bottom: 2em;
} }
.delete-btn {
background-color: rgba(255, 0, 0, 0.76);
color: white;
}

View File

@ -45,6 +45,12 @@ import { EditorCustomValidators, EditorCustomValidatorsEnum } from './custom-val
import { CustomErrorValidator } from '@common/forms/validation/custom-validator'; import { CustomErrorValidator } from '@common/forms/validation/custom-validator';
import { STEPPER_ANIMATIONS } from './animations/animations'; import { STEPPER_ANIMATIONS } from './animations/animations';
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { DmpInvitationUser } from '@app/core/model/dmp/invitation/dmp-invitation-user';
import { RequestItem } from '@app/core/query/request-item';
import { DmpInvitationUserCriteria } from '@app/core/query/dmp/dmp-invitation-user-criteria';
import { DmpInvitationService } from '@app/core/services/dmp/dmp-invitation.service';
import { UserService } from '@app/core/services/user/user.service';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json'); const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@ -75,6 +81,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
nestedIndex: number = 0; nestedIndex: number = 0;
errorMessages: string[] = []; errorMessages: string[] = [];
tocEntryEnumValues = ToCEntryType; tocEntryEnumValues = ToCEntryType;
public userChipList:any[] = [];
displayedColumns: String[] = ['name', 'email', 'button'];
colorizeInvalid:boolean = false; colorizeInvalid:boolean = false;
@ -101,7 +109,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
private datasetWizardService: DatasetWizardService, private datasetWizardService: DatasetWizardService,
private visibilityRulesService: VisibilityRulesService, private visibilityRulesService: VisibilityRulesService,
private fb: FormBuilder, private fb: FormBuilder,
private sidenavService: SideNavService private sidenavService: SideNavService,
private userService: UserService
) { ) {
super(); super();
// this.profileID = route.snapshot.params['id']; // this.profileID = route.snapshot.params['id'];
@ -194,7 +203,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.dataModel = new DatasetProfileEditorModel(); this.dataModel = new DatasetProfileEditorModel();
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
// this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]); // this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]);
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
this.form.disable(); this.form.disable();
this.viewOnly = true; this.viewOnly = true;
@ -203,13 +212,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// this.addPage(); // this.addPage();
this.visibilityRulesService.buildVisibilityRules([],this.form); this.visibilityRulesService.buildVisibilityRules([],this.form);
setTimeout(() => { setTimeout(() => {
this.steps = this.stepper.steps; this.steps = this.stepper.steps;
}); });
this._initializeToCEntries(); this._initializeToCEntries();
} }
}); });
} }
@ -225,7 +234,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
prepareForm() { prepareForm() {
this.visibilityRulesService.buildVisibilityRules([],this.form); this.visibilityRulesService.buildVisibilityRules([],this.form);
@ -245,9 +254,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// }); // });
}); });
setTimeout(() => { setTimeout(() => {
this.steps = this.stepper.steps; this.steps = this.stepper.steps;
}); });
this._initializeToCEntries(); this._initializeToCEntries();
console.log(this.form.get('users').value);
this.userChipList = [...this.form.get('users').value];
} }
@ -582,12 +593,12 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
/** /**
* Updates entries ordinal form value * Updates entries ordinal form value
* based on the index they have on the tocentry array. * based on the index they have on the tocentry array.
* Tocentries that are on the same level have distinct ordinal value * Tocentries that are on the same level have distinct ordinal value
* *
* @param tocentries * @param tocentries
* *
*/ */
private _updateOrdinals(tocentries: ToCEntry[]){ private _updateOrdinals(tocentries: ToCEntry[]){
@ -749,7 +760,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(tocEntryFound){ if(tocEntryFound){
return tocEntryFound; return tocEntryFound;
} }
for(let entry of tocentries){ for(let entry of tocentries){
const result = this._findTocEntryById(id, entry.subEntries); const result = this._findTocEntryById(id, entry.subEntries);
@ -758,7 +769,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break; break;
} }
} }
return tocEntryFound? tocEntryFound: null; return tocEntryFound? tocEntryFound: null;
} }
addNewEntry(tce: NewEntryType) { addNewEntry(tce: NewEntryType) {
@ -795,7 +806,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const max = sectionsArray.controls.filter(control=>control.get('page').value === parent.id) const max = sectionsArray.controls.filter(control=>control.get('page').value === parent.id)
.map(control=>control.get('ordinal').value) .map(control=>control.get('ordinal').value)
.reduce((a,b)=>Math.max(a,b)); .reduce((a,b)=>Math.max(a,b));
section.ordinal = max + 1; section.ordinal = max + 1;
}catch{ }catch{
section.ordinal = sectionsArray.length; section.ordinal = sectionsArray.length;
@ -823,7 +834,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
console.error('Section can only be child of a page or another section'); console.error('Section can only be child of a page or another section');
} }
const sectionAdded = sectionsArray.at(sectionsArray.length -1) as FormGroup; const sectionAdded = sectionsArray.at(sectionsArray.length -1) as FormGroup;
// sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections')); // sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections'));
// sectionAdded.updateValueAndValidity(); // sectionAdded.updateValueAndValidity();
@ -834,7 +845,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break; break;
case ToCEntryType.FieldSet: case ToCEntryType.FieldSet:
//create one field form fieldset //create one field form fieldset
const field: FieldEditorModel = new FieldEditorModel(); const field: FieldEditorModel = new FieldEditorModel();
field.id = Guid.create().toString(); field.id = Guid.create().toString();
@ -842,12 +853,12 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const fieldForm = field.buildForm(); const fieldForm = field.buildForm();
// fieldForm.setValidators(this.customFieldValidator()); // fieldForm.setValidators(this.customFieldValidator());
// fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required);
// fieldSet.fields.push(field); // fieldSet.fields.push(field);
// field.ordinal = fieldSet.fields.length-1; // field.ordinal = fieldSet.fields.length-1;
const fieldSetsArray = parent.form.get('fieldSets') as FormArray const fieldSetsArray = parent.form.get('fieldSets') as FormArray
//give fieldset id and ordinal //give fieldset id and ordinal
const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); const fieldSet: FieldSetEditorModel = new FieldSetEditorModel();
const fieldSetId = Guid.create().toString(); const fieldSetId = Guid.create().toString();
@ -860,7 +871,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
fieldSet.ordinal = fieldSetsArray.length; fieldSet.ordinal = fieldSetsArray.length;
} }
const fieldsetForm = fieldSet.buildForm(); const fieldsetForm = fieldSet.buildForm();
(fieldsetForm.get('fields') as FormArray).push(fieldForm); (fieldsetForm.get('fields') as FormArray).push(fieldForm);
@ -881,7 +892,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
onRemoveEntry(tce: ToCEntry){ onRemoveEntry(tce: ToCEntry){
const dialogRef = this.dialog.open(ConfirmationDialogComponent, { const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false, restoreFocus: false,
data: { data: {
@ -896,7 +907,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this._deleteEntry(tce); this._deleteEntry(tce);
} }
}); });
} }
@ -939,7 +950,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}); });
} }
//update page ordinals //update page ordinals
for(let i=0; i<pages.length; i++){ for(let i=0; i<pages.length; i++){
pages.at(i).get('ordinal').patchValue(i); pages.at(i).get('ordinal').patchValue(i);
} }
@ -983,7 +994,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
} else {//NOT FOUND IN FIRST LEVEL CASE } else {//NOT FOUND IN FIRST LEVEL CASE
//LOOK FOR SUBSECTION CASE //LOOK FOR SUBSECTION CASE
let parentFormArray = tce.form.parent as FormArray; let parentFormArray = tce.form.parent as FormArray;
for (let i = 0; i < parentFormArray.length; i++) { for (let i = 0; i < parentFormArray.length; i++) {
@ -1010,10 +1021,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break; break;
case ToCEntryType.FieldSet: case ToCEntryType.FieldSet:
const parentFormArray = tce.form.parent as FormArray; const parentFormArray = tce.form.parent as FormArray;
let idx = -1; let idx = -1;
for(let i =0; i< parentFormArray.length; i++){ for(let i =0; i< parentFormArray.length; i++){
let inspectingField = parentFormArray.at(i); let inspectingField = parentFormArray.at(i);
@ -1075,7 +1086,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(parentId){ if(parentId){
const tocentries = this.getTocEntries(); const tocentries = this.getTocEntries();
const parent = this._findTocEntryById(parentId, tocentries); const parent = this._findTocEntryById(parentId, tocentries);
if(parent){ if(parent){
this.selectedTocEntry = parent; this.selectedTocEntry = parent;
}else{ }else{
@ -1191,7 +1202,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// generatePreviewForm(){ // generatePreviewForm(){
// const model = new DatasetDescriptionFormEditorModel(); // const model = new DatasetDescriptionFormEditorModel();
@ -1207,14 +1218,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// pageModel.ordinal = entry.form.get('ordinal').value; // pageModel.ordinal = entry.form.get('ordinal').value;
// pageModel.title = entry.label; // pageModel.title = entry.label;
// if(entry.subEntries){ // if(entry.subEntries){
// pageModel.sections = entry.subEntries.map(section=>{ // pageModel.sections = entry.subEntries.map(section=>{
// const sectionModel = new DatasetDescriptionSectionEditorModel(); // const sectionModel = new DatasetDescriptionSectionEditorModel();
// sectionModel.id = section.id; // sectionModel.id = section.id;
// sectionModel.ordinal = section.form.get('ordinal').value; // sectionModel.ordinal = section.form.get('ordinal').value;
// sectionModel.description = section.form.get('description').value; // sectionModel.description = section.form.get('description').value;
// sectionModel.page = entry.form.get('ordinal').value; // sectionModel.page = entry.form.get('ordinal').value;
// sectionModel.title = section.label; // sectionModel.title = section.label;
// sectionModel.numbering = (idx+1).toString(); // sectionModel.numbering = (idx+1).toString();
@ -1255,10 +1266,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// }); // });
// } // }
// }); // });
// model.rules = rules; // model.rules = rules;
// this.visibilityRules = rules; // this.visibilityRules = rules;
// this.previewForm = model.buildForm(); // this.previewForm = model.buildForm();
// } // }
@ -1284,14 +1295,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}); });
} }
}); });
this.visibilityRules = rules; this.visibilityRules = rules;
} }
visibilityRules:Rule[]; visibilityRules:Rule[];
private _buildSectionsRecursively( tocentries: ToCEntry[], parentNumbering:string): DatasetDescriptionSectionEditorModel[]{ private _buildSectionsRecursively( tocentries: ToCEntry[], parentNumbering:string): DatasetDescriptionSectionEditorModel[]{
if(!tocentries) return null; if(!tocentries) return null;
@ -1303,15 +1314,15 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const sectionModel = new DatasetDescriptionSectionEditorModel(); const sectionModel = new DatasetDescriptionSectionEditorModel();
sectionModel.id = tocentry.id; sectionModel.id = tocentry.id;
sectionModel.ordinal = tocentry.form.get('ordinal').value; sectionModel.ordinal = tocentry.form.get('ordinal').value;
sectionModel.description = tocentry.form.get('description').value; sectionModel.description = tocentry.form.get('description').value;
// sectionModel.page = entry.form.get('ordinal').value; // sectionModel.page = entry.form.get('ordinal').value;
sectionModel.title = tocentry.label; sectionModel.title = tocentry.label;
// sectionModel.numbering = tocentry.numbering; // sectionModel.numbering = tocentry.numbering;
sectionModel.numbering = parentNumbering+"."+(idx+1);; sectionModel.numbering = parentNumbering+"."+(idx+1);;
if(tocentry.subEntriesType == ToCEntryType.Section){ if(tocentry.subEntriesType == ToCEntryType.Section){
sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries, sectionModel.numbering); sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries, sectionModel.numbering);
}else{ }else{
sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries, sectionModel.numbering); sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries, sectionModel.numbering);
} }
@ -1326,7 +1337,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(!tocentries) return null; if(!tocentries) return null;
const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = []; const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = [];
tocentries.forEach((fs, idx)=>{ tocentries.forEach((fs, idx)=>{
const fieldset = new DatasetDescriptionCompositeFieldEditorModel(); const fieldset = new DatasetDescriptionCompositeFieldEditorModel();
@ -1406,7 +1417,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
onMatStepperSelectionChange(event: StepperSelectionEvent){ onMatStepperSelectionChange(event: StepperSelectionEvent){
if(event.selectedIndex === (this.steps.length -1)){//preview selected if(event.selectedIndex === (this.steps.length -1)){//preview selected
// this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE // this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE
@ -1473,11 +1484,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
isStepCompleted(stepIndex: number){ isStepCompleted(stepIndex: number){
let stepCompleted = false; let stepCompleted = false;
this.steps.forEach((step,index)=>{ this.steps.forEach((step,index)=>{
if(stepIndex === index){ if(stepIndex === index){
@ -1499,7 +1510,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.steps.forEach((step,index)=>{ this.steps.forEach((step,index)=>{
if(index+1 == stepIndex){//previous step if(index+1 == stepIndex){//previous step
if(step.completed){ if(step.completed){
stepUnlocked = true; stepUnlocked = true;
} }
@ -1525,7 +1536,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// getFormValidationErrors() { // getFormValidationErrors() {
// Object.keys(this.form.controls).forEach(key => { // Object.keys(this.form.controls).forEach(key => {
// const controlErrors: ValidationErrors = this.form.get(key).errors; // const controlErrors: ValidationErrors = this.form.get(key).errors;
// if (controlErrors != null) { // if (controlErrors != null) {
// Object.keys(controlErrors).forEach(keyError => { // Object.keys(controlErrors).forEach(keyError => {
@ -1565,7 +1576,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
} }
}); });
return errmess; return errmess;
@ -1583,13 +1594,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const errmess:string[] = []; const errmess:string[] = [];
if(result.length){ if(result.length){
form.markAllAsTouched(); form.markAllAsTouched();
let indexes:number[] = []; let indexes:number[] = [];
///search in pages,sections and fieldsets for the id ///search in pages,sections and fieldsets for the id
result.forEach((err,i)=>{ result.forEach((err,i)=>{
const entry = this._findTocEntryById(err.id, this.toCEntries); const entry = this._findTocEntryById(err.id, this.toCEntries);
if(entry){ if(entry){
// errmess.push(`Error on ${entry.numbering} ${entry.label} . ${err.key}`); // errmess.push(`Error on ${entry.numbering} ${entry.label} . ${err.key}`);
errmess.push(...this._buildErrorMessage(err.errors, entry.numbering, err.key)); errmess.push(...this._buildErrorMessage(err.errors, entry.numbering, err.key));
indexes.push(i); indexes.push(i);
@ -1598,7 +1609,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
indexes.reverse().forEach(index=>{ indexes.reverse().forEach(index=>{
result.splice(index,1); result.splice(index,1);
}); });
indexes = []; indexes = [];
//searching in fields //searching in fields
const fieldsets = this._getAllFieldSets(this.toCEntries); const fieldsets = this._getAllFieldSets(this.toCEntries);
@ -1619,11 +1630,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
errmess.push(...this._buildErrorMessage(err.errors, fs.numbering, err.key)); errmess.push(...this._buildErrorMessage(err.errors, fs.numbering, err.key));
}); });
}); });
indexes.reverse().forEach(index=>{ indexes.reverse().forEach(index=>{
result.splice(index,1); result.splice(index,1);
}); });
result.forEach(err=>{ result.forEach(err=>{
// console.log(err); // console.log(err);
if(err.key){ if(err.key){
@ -1655,7 +1666,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
* @returns The tocentries that are Fieldsets provided in the entries * @returns The tocentries that are Fieldsets provided in the entries
*/ */
private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{ private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{
const fieldsets:ToCEntry[] = []; const fieldsets:ToCEntry[] = [];
if(!entries || !entries.length) return fieldsets; if(!entries || !entries.length) return fieldsets;
@ -1677,21 +1688,21 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(aControl.valid) return; if(aControl.valid) return;
let controlType = 'control'; let controlType = 'control';
if(aControl instanceof FormGroup) controlType="fg" if(aControl instanceof FormGroup) controlType="fg"
if(aControl instanceof FormControl) controlType="fc"; if(aControl instanceof FormControl) controlType="fc";
if(aControl instanceof FormArray) controlType="fa"; if(aControl instanceof FormArray) controlType="fa";
const invalidControls:InvalidControl[] = []; const invalidControls:InvalidControl[] = [];
//invalid //invalid
switch (controlType){ switch (controlType){
case 'fg': case 'fg':
const controls = (aControl as FormGroup).controls; const controls = (aControl as FormGroup).controls;
const keys = Object.keys(controls); const keys = Object.keys(controls);
keys.forEach(key=>{ keys.forEach(key=>{
const control = controls[key]; const control = controls[key];
if(!control.invalid) return; //// !!!!! Important to be !invalid. (In case the template is finalized) if(!control.invalid) return; //// !!!!! Important to be !invalid. (In case the template is finalized)
if(control instanceof FormControl){ if(control instanceof FormControl){
@ -1703,7 +1714,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
invalidSubControls: [], invalidSubControls: [],
key: key key: key
}); });
}else{ }else{
// if(aControl.errors){ // if(aControl.errors){
// invalidControls.push({ // invalidControls.push({
@ -1732,7 +1743,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// }); // });
// } // }
invalidControls.push(...this._getErrors(control)) ; invalidControls.push(...this._getErrors(control)) ;
} }
}); });
@ -1745,12 +1756,12 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
key: aControl.get('title')?aControl.get('title').value: null key: aControl.get('title')?aControl.get('title').value: null
}); });
} }
break; break;
case 'fa': case 'fa':
// const fa = (aControl as FormArray); // const fa = (aControl as FormArray);
const ctrls = (aControl as FormArray).controls; const ctrls = (aControl as FormArray).controls;
const keys_ = Object.keys(ctrls); const keys_ = Object.keys(ctrls);
keys_.forEach(key=>{ keys_.forEach(key=>{
const control = ctrls[key]; const control = ctrls[key];
if(control.valid) return; if(control.valid) return;
@ -1779,7 +1790,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
}) })
return invalidControls; return invalidControls;
} }
@ -1799,18 +1810,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(fieldsF){ if(fieldsF){
fieldsF.controls.forEach(field=>{ fieldsF.controls.forEach(field=>{
const renderStyleValue = field.get('viewStyle').get('renderStyle').value; const renderStyleValue = field.get('viewStyle').get('renderStyle').value;
if(renderStyleValue === DatasetProfileFieldViewStyle.CheckBox){ if(renderStyleValue === DatasetProfileFieldViewStyle.CheckBox){
field.get('defaultValue').get('value').setValidators(Validators.required); field.get('defaultValue').get('value').setValidators(Validators.required);
}else if(renderStyleValue === 'combobox'){ }else if(renderStyleValue === 'combobox'){
const comboType = field.get('data').get('type').value; const comboType = field.get('data').get('type').value;
if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI
field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList'));
}else if(comboType === DatasetProfileComboBoxType.WordList){ }else if(comboType === DatasetProfileComboBoxType.WordList){
field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options'));
} }
}else if(renderStyleValue === DatasetProfileFieldViewStyle.RadioBox){ }else if(renderStyleValue === DatasetProfileFieldViewStyle.RadioBox){
field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options'));
} }
@ -1824,6 +1835,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
} }
checkAndAdd(ev: any) {
this.userService.getFromEmail(ev).pipe(takeUntil(this._destroyed)).subscribe((result) => {
this.userChipList.push(result);
this.form.patchValue({'users': this.userChipList});
});
}
removeUser(user: any) {
this.userChipList.splice(this.userChipList.indexOf(user), 1);
this.form.patchValue({'users': this.userChipList});
}
} }
interface InvalidControl{ interface InvalidControl{
@ -1831,4 +1854,4 @@ interface InvalidControl{
errors: any, errors: any,
id: string, id: string,
invalidSubControls: InvalidControl[] invalidSubControls: InvalidControl[]
} }

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",

View File

@ -289,6 +289,7 @@
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.", "DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-LANGUAGE": "Dataset template language", "DATASET-TEMPLATE-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language", "DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description", "DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled", "UNTITLED": "Untitled",
"QUESTION": "Question", "QUESTION": "Question",