change on description-template-editor ui for easier reordering

This commit is contained in:
Sofia Papacharalampous 2024-05-20 14:46:20 +03:00
parent b094261136
commit 49eb10aaa8
6 changed files with 251 additions and 225 deletions

View File

@ -27,6 +27,7 @@
</div> </div>
</div> </div>
</div> </div>
<ng-container *ngIf="!reorderingMode">
<div style="position: relative;" class="col-12" *ngIf="hasFocus" [@fade-in]> <div style="position: relative;" class="col-12" *ngIf="hasFocus" [@fade-in]>
<div *ngIf="showDescription" class="mb-4"> <div *ngIf="showDescription" class="mb-4">
<h5 style="font-weight: bold" class="row">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}}</h5> <h5 style="font-weight: bold" class="row">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}}</h5>
@ -268,4 +269,5 @@
</div> </div>
</div> </div>
</ng-container> </ng-container>
</ng-container>
</div> </div>

View File

@ -50,6 +50,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
@Input() numbering: string; @Input() numbering: string;
@Input() hasFocus: boolean = false; @Input() hasFocus: boolean = false;
@Input() reorderingMode: boolean = false;
@ViewChild("inputs") inputs: TransitionGroupComponent; @ViewChild("inputs") inputs: TransitionGroupComponent;
@Input() validationErrorModel: ValidationErrorModel; @Input() validationErrorModel: ValidationErrorModel;
@Input() validationRootPath: string; @Input() validationRootPath: string;
@ -483,9 +484,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
} }
addNewInput(type: DescriptionTemplateFieldType) { addNewInput(type: DescriptionTemplateFieldType) {
const fieldsArray = this.form.get('fields') as UntypedFormArray; const fieldsArray = this.form.get('fields') as UntypedFormArray;

View File

@ -49,18 +49,18 @@
<div style="margin-bottom: 2em; position: relative;" class="row fieldset" <div style="margin-bottom: 2em; position: relative;" class="row fieldset"
*ngFor="let fieldset of form.get('fieldSets')?.controls ; let i=index" *ngFor="let fieldset of form.get('fieldSets')?.controls ; let i=index"
[id]="dragula_prefix+fieldset.get('id').value"> [id]="dragula_prefix+fieldset.get('id').value">
<div [id]="idprefix+fieldset.get('id').value" style="position: absolute; top: -7em; visibility: hidden;"> <div [id]="idprefix+fieldset.get('id').value" style="position: absolute; top: -13.5em; visibility: hidden;">
</div> </div>
<div class="col-9 p-0"> <div class="col-9 p-0">
<mat-card (click)="selectedFieldSetId = fieldset.get('id').value" <mat-card (click)="selectedFieldSetId = fieldset.get('id').value"
[ngClass]="{'field-container-active': fieldset.get('id').value === selectedFieldSetId}"> [ngClass]="{'field-container-active': fieldset.get('id').value === selectedFieldSetId}">
<mat-card-content> <mat-card-content>
<mat-card-header *ngIf="(fieldset.get('id').value === selectedFieldSetId) && !viewOnly"> <mat-card-header *ngIf="(fieldset.get('id').value === selectedFieldSetId) && !viewOnly && reorderingMode">
<mat-icon class="handle" <mat-icon class="handle"
style="display:inline-block; margin: 0px auto; cursor: grab;transform: rotate(90deg); opacity: 0.3;">drag_indicator</mat-icon> style="display:inline-block; margin: 0px auto; cursor: grab;transform: rotate(90deg); opacity: 0.3;">drag_indicator</mat-icon>
</mat-card-header> </mat-card-header>
<app-description-template-editor-composite-field-component [form]="fieldset" <app-description-template-editor-composite-field-component [reorderingMode]="reorderingMode" [form]="fieldset"
[viewOnly]="viewOnly" [numbering]="numbering + '.'+ (i+1)" [viewOnly]="viewOnly" [numbering]="numbering + '.'+ (i+1)"
[hasFocus]="fieldset.get('id').value === selectedFieldSetId" [hasFocus]="fieldset.get('id').value === selectedFieldSetId"
[datasetProfileId]="datasetProfileId" [datasetProfileId]="datasetProfileId"
@ -107,6 +107,20 @@
translate}}</span> translate}}</span>
</div> </div>
</li> </li>
<li *ngIf="!reorderingMode" class="mli" (click)="enableReordering()">
<div class="action-list-item">
<mat-icon class="action-list-icon">unfold_more</mat-icon>
<span class="action-list-text">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.TOOLKIT.REORDER-QUESTION' |
translate}}</span>
</div>
</li>
<li *ngIf="reorderingMode" class="mli" (click)="exitReordering()">
<div class="action-list-item">
<mat-icon class="action-list-icon">unfold_more</mat-icon>
<span class="action-list-text">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.TOOLKIT.EXIT-REORDERING-MODE' |
translate}}</span>
</div>
</li>
</ul> </ul>
</nav> </nav>
</div> </div>

View File

@ -33,6 +33,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
idprefix = "id"; idprefix = "id";
reorderingMode = false;
readonly dragula_prefix = "dragulaid"; readonly dragula_prefix = "dragulaid";
private subs = new Subscription(); private subs = new Subscription();
private FIELDSETS = 'FIELDSETS'; private FIELDSETS = 'FIELDSETS';
@ -228,6 +229,16 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
}, 200); }, 200);
} }
enableReordering(): void {
this.reorderingMode = true;
this.scroller.next(this.selectedFieldSetId);
}
exitReordering(): void {
this.reorderingMode = false;
this.scroller.next(this.selectedFieldSetId);
}
private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry {
if (!tocentries) { if (!tocentries) {
return null; return null;

View File

@ -331,7 +331,6 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
public restartTour(): void { public restartTour(): void {
this.setDashboardTourDmpText(); this.setDashboardTourDmpText();
console.log('lalala');
this.setDashboardTourDescriptionText(); this.setDashboardTourDescriptionText();
console.log(this.dashboardTour); console.log(this.dashboardTour);
this.guidedTourService.startTour(this.dashboardTour); this.guidedTourService.startTour(this.dashboardTour);

View File

@ -557,7 +557,9 @@
"GENERAL-TOOLS": "Questions tools", "GENERAL-TOOLS": "Questions tools",
"NEW-INPUT-SET": "Add Question", "NEW-INPUT-SET": "Add Question",
"CLONE": "Clone", "CLONE": "Clone",
"DELETE": "Delete" "DELETE": "Delete",
"REORDER-QUESTION": "Reorder",
"EXIT-REORDERING-MODE": "I am done reordering"
} }
}, },
"ACTIONS": { "ACTIONS": {