Add option to add or remove users from Dataset Templates

This commit is contained in:
George Kalampokis 2021-04-07 19:03:22 +03:00
parent 037e246262
commit bc3c8b44d2
17 changed files with 201 additions and 117 deletions

View File

@ -119,6 +119,14 @@ public class Users extends BaseController {
ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
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

@ -239,5 +239,10 @@ public class UserManager {
Files.deleteIfExists(file.toPath());
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 { UserInfoListingModel } from "../../user/user-info-listing";
export interface DatasetProfile {
label: string;
@ -8,6 +9,7 @@ export interface DatasetProfile {
version: number;
description: string;
language: string;
users: UserInfoListingModel[];
}
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 });
}
getFromEmail(email: string): Observable<UserListingModel> {
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
}
public hasDOIToken(): Observable<any> {
const url = this.actionUrl + 'hasDOIToken';
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 { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component';
import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
@NgModule({
imports: [
@ -68,7 +69,8 @@ import { FinalPreviewComponent } from './editor/components/final-preview/final-p
AngularStickyThingsModule,
DragDropModule,
MatBadgeModule,
DragulaModule
DragulaModule,
AutoCompleteModule
],
declarations: [
DatasetProfileListingComponent,

View File

@ -1,4 +1,5 @@
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 { BaseFormModel } from '../../../../core/model/base-form-model';
import { PageEditorModel } from '../admin/page-editor-model';
@ -15,6 +16,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
public version: number;
private description: string;
private language: string;
private users: UserInfoListingModel[] = [];
fromModel(item: DatasetProfile): DatasetProfileEditorModel {
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.description = item.description;
this.language = item.language;
this.users = item.users;
return this;
}
@ -33,7 +36,8 @@ export class DatasetProfileEditorModel extends BaseFormModel {
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
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>();

View File

@ -3,12 +3,12 @@
<div class="main-content">
<div class="container-fluid dataset-profile-editor" *ngIf="form" [formGroup]='form'>
<!-- Total steps: {{stepper.steps.length}} -->
<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;">
@ -43,33 +43,33 @@
<mat-icon style="font-size:0.7em; height: 0px;">done</mat-icon>
</ng-container>
<ng-template #numberLabel>
{{idx+1}}
{{idx+1}}
</ng-template>
{{step.label}}
</span>
</div>
</div>
</div>
<div class="col d-flex justify-content-end">
<button [@previous_btn] mat-button class="navigate-btn" (click)="stepper.previous()" *ngIf="stepper.selectedIndex !=0">
<!-- <mat-icon>navigate_before</mat-icon> -->
{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}
{{'DMP-EDITOR.STEPPER.PREVIOUS' | translate}}
</button>
<button mat-button class="navigate-btn ml-3"
<button mat-button class="navigate-btn ml-3"
[@next_btn]
(click)="validateStep(stepper.selectedIndex);stepper.next();"
(click)="validateStep(stepper.selectedIndex);stepper.next();"
*ngIf="stepper.selectedIndex != (steps.length-1)"
[ngClass]="{'navigate-btn-disabled': !isStepCompleted(stepper.selectedIndex)}">
<mat-icon style="font-size: 1.66em;">navigate_next</mat-icon>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
</button>
<ng-container *ngIf="steps.length-1 === stepper.selectedIndex">
<!-- <ng-container *ngIf="stepper.selectedIndex === (steps.length-1)"> -->
<ng-container *ngIf="!viewOnly">
<!-- <button mat-button class="navigate-btn ml-2"
(click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' |
translate}}</button> -->
@ -77,10 +77,10 @@
(click)='finalize()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' |
translate}}</button> -->
</ng-container>
<!-- //TODO -->
<ng-container *ngIf="true">
<!-- <button mat-button class="navigate-btn ml-2"
(click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.SAVE' |
translate}}</button> -->
@ -90,13 +90,13 @@
<button [@finalize_btn] mat-button class="finalize-btn ml-3"
[disabled]="!form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.FINALIZE' |
translate}}</button>
</ng-container>
<!-- SAVE BUTTON WHEN FINALIZED-->
<ng-container *ngIf="false">
<ng-container *ngIf="showUpdateButton()">
<!-- <button mat-button class="navigate-btn ml-2"
(click)='checkFormValidation()'
[disabled]="form.valid">{{'DATASET-PROFILE-EDITOR.ACTIONS.VALIDATE' | translate}}</button> -->
@ -106,16 +106,16 @@
</ng-container>
</ng-container>
</ng-container>
</div>
</div>
</div>
<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) -->
@ -164,6 +164,29 @@
</mat-form-field>
</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">
<button mat-button class="full-width" (click)="addPage()"
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.NEXT' | translate}}</button>
@ -190,7 +213,7 @@
<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"
(itemClick)="displayItem($event)"
(createEntry) = "addNewEntry($event)"
@ -212,7 +235,7 @@
<div class="col">
<div class="row" *ngIf="selectedTocEntry">
<!-- PAGE INFO -->
<div class="col-12 content-displayer" *ngIf="selectedTocEntry.type === tocEntryEnumValues.Page">
<form [formGroup]="selectedTocEntry.form" class="page-infos">
@ -226,7 +249,7 @@
<mat-error >{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12" *ngIf="!viewOnly && (!selectedTocEntry?.subEntries?.length)">
<button class="create-section-btn" (click)="addNewEntry({parent:selectedTocEntry, childType: tocEntryEnumValues.Section})">Create section</button>
</div>
@ -248,7 +271,7 @@
</div> -->
</form>
</div>
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)" >
<app-dataset-profile-editor-section-fieldset-component
[tocentry]="selectedTocEntry"
@ -262,10 +285,10 @@
</app-dataset-profile-editor-section-fieldset-component>
</div>
</div>
<div class="content-displayer row justify-content-center" *ngIf="!numOfPages" style="min-height: 30em;">
<div class="col-auto align-self-center">
<div class="row w-100 justify-content-center">
@ -276,7 +299,7 @@
<div class="row justify-content-center">
<div class="col-auto d-flex aling-contents-center">
{{'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>
<strong style="cursor: pointer;" (click)="addNewEntry({childType: tocEntryEnumValues.Page,parent: null})">
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-END'| translate}}
@ -285,12 +308,12 @@
</div>
</div>
</div>
</div>
<!-- TOOLBAR -->
<!-- <div class="col-auto"
<!-- <div class="col-auto"
*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;">
<nav *ngIf="!viewOnly">
@ -319,7 +342,7 @@
<span class="action-list-text">{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.CLONE' | translate}}</span>
</div>
</li>
<li *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli">
<div class="action-list-item" (click)="onRemoveEntry(selectedTocEntry)">
<mat-icon class="action-list-icon">delete</mat-icon>
@ -328,7 +351,7 @@
</li>
</ul>
</nav> -->
<!-- <ng-container *ngIf="!viewOnly">
<h3 matSubheader>{{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.GENERAL-TOOLS' | translate}}</h3>
<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>
</div>
</mat-list-item>
<mat-list-item *ngIf="selectedTocEntry.type === tocEntryEnumValues.FieldSet" class="mli">
<div class="action-list-item">
<mat-icon class="action-list-icon">delete</mat-icon>
@ -359,12 +382,12 @@
</div>
</mat-list-item>
</ng-container> -->
<!-- </div>
</div> -->
</div>
</div>
<!--
<!--
<mat-accordion class="col-12" [multi]="true">
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<mat-expansion-panel-header>
@ -400,16 +423,16 @@
</app-final-preview-component>
<!--
<!--
<app-dataset-description [form]="formGroup" [visibilityRules]="visibilityRules" *ngIf="formGroup">
</app-dataset-description> -->
</ng-container>
</mat-step>
</mat-horizontal-stepper>
<ng-container *ngIf="true">
@ -425,7 +448,7 @@
</ng-container>
<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' |
translate}}</button>
@ -480,8 +503,8 @@
print errors
</button>
</div> -->
<!-- <div class="row">
<!-- <div class="row">
<button (click)="foo()">foo</button>
</div> -->
</div>
</div>
</div>

View File

@ -174,14 +174,14 @@ $blue-color-light: #5cf7f2;
.mat-list-item-content{
padding: 0px;
}
.action-list-item{
display: flex;
align-items: center;
cursor: pointer;
.action-list-icon{
font-size: 1.2em;
// padding-right: 1em;
@ -227,4 +227,9 @@ $blue-color-light: #5cf7f2;
.basic-info-input{
margin-top: 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 { STEPPER_ANIMATIONS } from './animations/animations';
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');
@ -75,6 +81,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
nestedIndex: number = 0;
errorMessages: string[] = [];
tocEntryEnumValues = ToCEntryType;
public userChipList:any[] = [];
displayedColumns: String[] = ['name', 'email', 'button'];
colorizeInvalid:boolean = false;
@ -101,7 +109,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
private datasetWizardService: DatasetWizardService,
private visibilityRulesService: VisibilityRulesService,
private fb: FormBuilder,
private sidenavService: SideNavService
private sidenavService: SideNavService,
private userService: UserService
) {
super();
// this.profileID = route.snapshot.params['id'];
@ -194,7 +203,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.dataModel = new DatasetProfileEditorModel();
this.form = this.dataModel.buildForm();
// this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]);
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
this.form.disable();
this.viewOnly = true;
@ -203,13 +212,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// this.addPage();
this.visibilityRulesService.buildVisibilityRules([],this.form);
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() {
this.visibilityRulesService.buildVisibilityRules([],this.form);
@ -245,9 +254,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// });
});
setTimeout(() => {
this.steps = this.stepper.steps;
this.steps = this.stepper.steps;
});
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.
* Tocentries that are on the same level have distinct ordinal value
*
* @param tocentries
*
*
* @param tocentries
*
*/
private _updateOrdinals(tocentries: ToCEntry[]){
@ -749,7 +760,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(tocEntryFound){
return tocEntryFound;
}
}
for(let entry of tocentries){
const result = this._findTocEntryById(id, entry.subEntries);
@ -758,7 +769,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break;
}
}
return tocEntryFound? tocEntryFound: null;
}
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)
.map(control=>control.get('ordinal').value)
.reduce((a,b)=>Math.max(a,b));
section.ordinal = max + 1;
}catch{
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');
}
const sectionAdded = sectionsArray.at(sectionsArray.length -1) as FormGroup;
// sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections'));
// sectionAdded.updateValueAndValidity();
@ -834,7 +845,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break;
case ToCEntryType.FieldSet:
//create one field form fieldset
const field: FieldEditorModel = new FieldEditorModel();
field.id = Guid.create().toString();
@ -842,12 +853,12 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const fieldForm = field.buildForm();
// fieldForm.setValidators(this.customFieldValidator());
// fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required);
// fieldSet.fields.push(field);
// field.ordinal = fieldSet.fields.length-1;
const fieldSetsArray = parent.form.get('fieldSets') as FormArray
//give fieldset id and ordinal
const fieldSet: FieldSetEditorModel = new FieldSetEditorModel();
const fieldSetId = Guid.create().toString();
@ -860,7 +871,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
fieldSet.ordinal = fieldSetsArray.length;
}
const fieldsetForm = fieldSet.buildForm();
(fieldsetForm.get('fields') as FormArray).push(fieldForm);
@ -881,7 +892,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
onRemoveEntry(tce: ToCEntry){
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
restoreFocus: false,
data: {
@ -896,7 +907,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
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++){
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
//LOOK FOR SUBSECTION CASE
//LOOK FOR SUBSECTION CASE
let parentFormArray = tce.form.parent as FormArray;
for (let i = 0; i < parentFormArray.length; i++) {
@ -1010,10 +1021,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
break;
case ToCEntryType.FieldSet:
const parentFormArray = tce.form.parent as FormArray;
let idx = -1;
for(let i =0; i< parentFormArray.length; i++){
let inspectingField = parentFormArray.at(i);
@ -1075,7 +1086,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(parentId){
const tocentries = this.getTocEntries();
const parent = this._findTocEntryById(parentId, tocentries);
if(parent){
this.selectedTocEntry = parent;
}else{
@ -1191,7 +1202,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// generatePreviewForm(){
// const model = new DatasetDescriptionFormEditorModel();
@ -1207,14 +1218,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// pageModel.ordinal = entry.form.get('ordinal').value;
// pageModel.title = entry.label;
// if(entry.subEntries){
// pageModel.sections = entry.subEntries.map(section=>{
// const sectionModel = new DatasetDescriptionSectionEditorModel();
// sectionModel.id = section.id;
// 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.title = section.label;
// sectionModel.numbering = (idx+1).toString();
@ -1255,10 +1266,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// });
// }
// });
// model.rules = rules;
// this.visibilityRules = rules;
// this.previewForm = model.buildForm();
// }
@ -1284,14 +1295,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
});
}
});
this.visibilityRules = rules;
}
visibilityRules:Rule[];
private _buildSectionsRecursively( tocentries: ToCEntry[], parentNumbering:string): DatasetDescriptionSectionEditorModel[]{
if(!tocentries) return null;
@ -1303,15 +1314,15 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const sectionModel = new DatasetDescriptionSectionEditorModel();
sectionModel.id = tocentry.id;
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.title = tocentry.label;
// sectionModel.numbering = tocentry.numbering;
sectionModel.numbering = parentNumbering+"."+(idx+1);;
if(tocentry.subEntriesType == ToCEntryType.Section){
sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries, sectionModel.numbering);
}else{
sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries, sectionModel.numbering);
}
@ -1326,7 +1337,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(!tocentries) return null;
const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = [];
tocentries.forEach((fs, idx)=>{
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
// this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE
@ -1473,11 +1484,11 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}
isStepCompleted(stepIndex: number){
let stepCompleted = false;
this.steps.forEach((step,index)=>{
if(stepIndex === index){
@ -1499,7 +1510,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
this.steps.forEach((step,index)=>{
if(index+1 == stepIndex){//previous step
if(step.completed){
stepUnlocked = true;
}
@ -1525,7 +1536,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// getFormValidationErrors() {
// Object.keys(this.form.controls).forEach(key => {
// const controlErrors: ValidationErrors = this.form.get(key).errors;
// if (controlErrors != null) {
// Object.keys(controlErrors).forEach(keyError => {
@ -1565,7 +1576,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}
}
});
return errmess;
@ -1583,13 +1594,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
const errmess:string[] = [];
if(result.length){
form.markAllAsTouched();
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)=>{
const entry = this._findTocEntryById(err.id, this.toCEntries);
if(entry){
// errmess.push(`Error on ${entry.numbering} ${entry.label} . ${err.key}`);
errmess.push(...this._buildErrorMessage(err.errors, entry.numbering, err.key));
indexes.push(i);
@ -1598,7 +1609,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
indexes.reverse().forEach(index=>{
result.splice(index,1);
});
indexes = [];
//searching in fields
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));
});
});
indexes.reverse().forEach(index=>{
result.splice(index,1);
});
result.forEach(err=>{
// console.log(err);
if(err.key){
@ -1655,7 +1666,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
* @returns The tocentries that are Fieldsets provided in the entries
*/
private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{
const fieldsets:ToCEntry[] = [];
if(!entries || !entries.length) return fieldsets;
@ -1677,21 +1688,21 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(aControl.valid) return;
let controlType = 'control';
if(aControl instanceof FormGroup) controlType="fg"
if(aControl instanceof FormControl) controlType="fc";
if(aControl instanceof FormArray) controlType="fa";
const invalidControls:InvalidControl[] = [];
//invalid
switch (controlType){
case 'fg':
const controls = (aControl as FormGroup).controls;
const keys = Object.keys(controls);
const keys = Object.keys(controls);
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 instanceof FormControl){
@ -1703,7 +1714,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
invalidSubControls: [],
key: key
});
}else{
// if(aControl.errors){
// invalidControls.push({
@ -1732,7 +1743,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
// });
// }
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
});
}
break;
case 'fa':
// const fa = (aControl as FormArray);
const ctrls = (aControl as FormArray).controls;
const keys_ = Object.keys(ctrls);
const keys_ = Object.keys(ctrls);
keys_.forEach(key=>{
const control = ctrls[key];
if(control.valid) return;
@ -1779,7 +1790,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
}
})
return invalidControls;
}
@ -1799,18 +1810,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
if(fieldsF){
fieldsF.controls.forEach(field=>{
const renderStyleValue = field.get('viewStyle').get('renderStyle').value;
if(renderStyleValue === DatasetProfileFieldViewStyle.CheckBox){
field.get('defaultValue').get('value').setValidators(Validators.required);
field.get('defaultValue').get('value').setValidators(Validators.required);
}else if(renderStyleValue === 'combobox'){
const comboType = field.get('data').get('type').value;
if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI
field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList'));
}else if(comboType === DatasetProfileComboBoxType.WordList){
field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options'));
}
}else if(renderStyleValue === DatasetProfileFieldViewStyle.RadioBox){
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{
@ -1831,4 +1854,4 @@ interface InvalidControl{
errors: any,
id: string,
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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"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-LANGUAGE": "Dataset template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DATASET-TEMPLATE-USERS": "Users",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",