mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #3822 from DSpace/backport-3608-to-dspace-8_x
[Port dspace-8_x] Add button to allow free-text editing in the dropdown field of Edit Item
This commit is contained in:
@@ -3,20 +3,26 @@
|
|||||||
[ngClass]="{ 'ds-warning': mdValue.reordered || mdValue.change === DsoEditMetadataChangeTypeEnum.UPDATE, 'ds-danger': mdValue.change === DsoEditMetadataChangeTypeEnum.REMOVE, 'ds-success': mdValue.change === DsoEditMetadataChangeTypeEnum.ADD, 'h-100': isOnlyValue }">
|
[ngClass]="{ 'ds-warning': mdValue.reordered || mdValue.change === DsoEditMetadataChangeTypeEnum.UPDATE, 'ds-danger': mdValue.change === DsoEditMetadataChangeTypeEnum.REMOVE, 'ds-success': mdValue.change === DsoEditMetadataChangeTypeEnum.ADD, 'h-100': isOnlyValue }">
|
||||||
<div class="flex-grow-1 ds-flex-cell ds-value-cell d-flex flex-column" *ngVar="(mdRepresentation$ | async) as mdRepresentation" role="cell">
|
<div class="flex-grow-1 ds-flex-cell ds-value-cell d-flex flex-column" *ngVar="(mdRepresentation$ | async) as mdRepresentation" role="cell">
|
||||||
<div class="dont-break-out preserve-line-breaks" *ngIf="!mdValue.editing && !mdRepresentation">{{ mdValue.newValue.value }}</div>
|
<div class="dont-break-out preserve-line-breaks" *ngIf="!mdValue.editing && !mdRepresentation">{{ mdValue.newValue.value }}</div>
|
||||||
<textarea class="form-control" rows="5" *ngIf="mdValue.editing && !mdRepresentation && (isAuthorityControlled() | async) !== true" [(ngModel)]="mdValue.newValue.value"
|
<textarea class="form-control" rows="5" *ngIf="mdValue.editing && !mdRepresentation && ((isAuthorityControlled() | async) !== true || (enabledFreeTextEditing && (isSuggesterVocabulary() | async) !== true))" [(ngModel)]="mdValue.newValue.value"
|
||||||
[attr.aria-label]="(dsoType + '.edit.metadata.edit.value') | translate"
|
[attr.aria-label]="(dsoType + '.edit.metadata.edit.value') | translate"
|
||||||
[dsDebounce]="300" (onDebounce)="confirm.emit(false)"></textarea>
|
[dsDebounce]="300" (onDebounce)="confirm.emit(false)"></textarea>
|
||||||
<ds-dynamic-scrollable-dropdown *ngIf="mdValue.editing && (isScrollableVocabulary() | async)"
|
<ds-dynamic-scrollable-dropdown *ngIf="mdValue.editing && (isScrollableVocabulary() | async) && !enabledFreeTextEditing"
|
||||||
[bindId]="mdField"
|
[bindId]="mdField"
|
||||||
[group]="group"
|
[group]="group"
|
||||||
[model]="getModel()"
|
[model]="getModel()"
|
||||||
(change)="onChangeAuthorityField($event)">
|
(change)="onChangeAuthorityField($event)">
|
||||||
</ds-dynamic-scrollable-dropdown>
|
</ds-dynamic-scrollable-dropdown>
|
||||||
<ds-dynamic-onebox *ngIf="mdValue.editing && ((isHierarchicalVocabulary() | async) || (isSuggesterVocabulary() | async))"
|
<ds-dynamic-onebox *ngIf="mdValue.editing && (((isHierarchicalVocabulary() | async) && !enabledFreeTextEditing) || (isSuggesterVocabulary() | async))"
|
||||||
[group]="group"
|
[group]="group"
|
||||||
[model]="getModel()"
|
[model]="getModel()"
|
||||||
(change)="onChangeAuthorityField($event)">
|
(change)="onChangeAuthorityField($event)">
|
||||||
</ds-dynamic-onebox>
|
</ds-dynamic-onebox>
|
||||||
|
<button class="btn btn-secondary mt-2" *ngIf="mdValue.editing && ((isScrollableVocabulary() | async) || (isHierarchicalVocabulary() | async))"
|
||||||
|
[title]="enabledFreeTextEditing ? dsoType + '.edit.metadata.edit.buttons.disable-free-text-editing' : dsoType + '.edit.metadata.edit.buttons.enable-free-text-editing' | translate"
|
||||||
|
(click)="toggleFreeTextEdition()">
|
||||||
|
<i class="fas fa-fw" [ngClass]="enabledFreeTextEditing ? 'fa-lock' : 'fa-unlock'"></i>
|
||||||
|
{{ (enabledFreeTextEditing ? dsoType + '.edit.metadata.edit.buttons.disable-free-text-editing' : dsoType + '.edit.metadata.edit.buttons.enable-free-text-editing') | translate }}
|
||||||
|
</button>
|
||||||
<div *ngIf="!isVirtual && !mdValue.editing && mdValue.newValue.authority && mdValue.newValue.confidence !== ConfidenceTypeEnum.CF_UNSET && mdValue.newValue.confidence !== ConfidenceTypeEnum.CF_NOVALUE">
|
<div *ngIf="!isVirtual && !mdValue.editing && mdValue.newValue.authority && mdValue.newValue.confidence !== ConfidenceTypeEnum.CF_UNSET && mdValue.newValue.confidence !== ConfidenceTypeEnum.CF_NOVALUE">
|
||||||
<span class="badge badge-light border" >
|
<span class="badge badge-light border" >
|
||||||
<i dsAuthorityConfidenceState
|
<i dsAuthorityConfidenceState
|
||||||
|
@@ -191,6 +191,12 @@ export class DsoEditMetadataValueComponent implements OnInit, OnChanges {
|
|||||||
*/
|
*/
|
||||||
public editingAuthority = false;
|
public editingAuthority = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the free-text editing is enabled when scrollable dropdown or hierarchical vocabulary is used
|
||||||
|
*/
|
||||||
|
public enabledFreeTextEditing = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field group used by authority field
|
* Field group used by authority field
|
||||||
* @type {UntypedFormGroup}
|
* @type {UntypedFormGroup}
|
||||||
@@ -438,15 +444,23 @@ export class DsoEditMetadataValueComponent implements OnInit, OnChanges {
|
|||||||
* Process the change of authority field value updating the authority key and confidence as necessary
|
* Process the change of authority field value updating the authority key and confidence as necessary
|
||||||
*/
|
*/
|
||||||
onChangeAuthorityField(event): void {
|
onChangeAuthorityField(event): void {
|
||||||
this.mdValue.newValue.value = event.value;
|
if (event) {
|
||||||
if (event.authority) {
|
this.mdValue.newValue.value = event.value;
|
||||||
this.mdValue.newValue.authority = event.authority;
|
if (event.authority) {
|
||||||
this.mdValue.newValue.confidence = ConfidenceType.CF_ACCEPTED;
|
this.mdValue.newValue.authority = event.authority;
|
||||||
|
this.mdValue.newValue.confidence = ConfidenceType.CF_ACCEPTED;
|
||||||
|
} else {
|
||||||
|
this.mdValue.newValue.authority = null;
|
||||||
|
this.mdValue.newValue.confidence = ConfidenceType.CF_UNSET;
|
||||||
|
}
|
||||||
|
this.confirm.emit(false);
|
||||||
} else {
|
} else {
|
||||||
|
// The event is undefined when the user clears the selection in scrollable dropdown
|
||||||
|
this.mdValue.newValue.value = '';
|
||||||
this.mdValue.newValue.authority = null;
|
this.mdValue.newValue.authority = null;
|
||||||
this.mdValue.newValue.confidence = ConfidenceType.CF_UNSET;
|
this.mdValue.newValue.confidence = ConfidenceType.CF_UNSET;
|
||||||
|
this.confirm.emit(false);
|
||||||
}
|
}
|
||||||
this.confirm.emit(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -480,4 +494,17 @@ export class DsoEditMetadataValueComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the free-text ediitng mode
|
||||||
|
*/
|
||||||
|
toggleFreeTextEdition() {
|
||||||
|
if (this.enabledFreeTextEditing) {
|
||||||
|
if (this.getModel().value !== this.mdValue.newValue.value) {
|
||||||
|
// Reload the model to adapt it to the new possible value modified during free text editing
|
||||||
|
this.initAuthorityProperties();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.enabledFreeTextEditing = !this.enabledFreeTextEditing;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2406,6 +2406,10 @@
|
|||||||
|
|
||||||
"item.edit.metadata.edit.authority.key": "Edit authority key",
|
"item.edit.metadata.edit.authority.key": "Edit authority key",
|
||||||
|
|
||||||
|
"item.edit.metadata.edit.buttons.enable-free-text-editing": "Enable free-text editing",
|
||||||
|
|
||||||
|
"item.edit.metadata.edit.buttons.disable-free-text-editing": "Disable free-text editing",
|
||||||
|
|
||||||
"item.edit.metadata.edit.buttons.confirm": "Confirm",
|
"item.edit.metadata.edit.buttons.confirm": "Confirm",
|
||||||
|
|
||||||
"item.edit.metadata.edit.buttons.drag": "Drag to reorder",
|
"item.edit.metadata.edit.buttons.drag": "Drag to reorder",
|
||||||
|
Reference in New Issue
Block a user