Skip to content

Commit 1e4864f

Browse files
authored
Merge pull request DSpace#3722 from alexandrevryghem/w2p-119915_made-edit-metadata-tab-fields-dynamic_contribute-main
Made edit metadata tab fields dynamic and added entity type support
2 parents bb18278 + 41ac417 commit 1e4864f

30 files changed

Lines changed: 1422 additions & 835 deletions

File tree

src/app/core/shared/context.model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ export enum Context {
4444
Bitstream = 'bitstream',
4545

4646
CoarNotify = 'coarNotify',
47+
48+
/**
49+
* The Edit Metadata field Context values that are used in the Edit Item Metadata tab.
50+
*/
51+
AddMetadata = 'addMetadata',
52+
EditMetadata = 'editMetadata',
4753
}

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-field-values/dso-edit-metadata-field-values.component.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
<ds-dso-edit-metadata-value-headers role="presentation" [dsoType]="dsoType"></ds-dso-edit-metadata-value-headers>
33
@for (mdValue of form.fields[mdField]; track mdValue; let idx = $index) {
44
<ds-dso-edit-metadata-value role="presentation"
5-
[dso]="dso"
6-
[mdValue]="mdValue"
7-
[mdField]="mdField"
8-
[dsoType]="dsoType"
9-
[saving$]="saving$"
10-
[isOnlyValue]="form.fields[mdField].length === 1"
11-
(edit)="mdValue.editing = true"
12-
(confirm)="mdValue.confirmChanges($event); form.resetReinstatable(); valueSaved.emit()"
13-
(remove)="mdValue.change === DsoEditMetadataChangeTypeEnum.ADD ? form.remove(mdField, idx) : mdValue.change = DsoEditMetadataChangeTypeEnum.REMOVE; form.resetReinstatable(); valueSaved.emit()"
14-
(undo)="mdValue.change === DsoEditMetadataChangeTypeEnum.ADD ? form.remove(mdField, idx) : mdValue.discard(); valueSaved.emit()"
15-
(dragging)="$event ? draggingMdField$.next(mdField) : draggingMdField$.next(null)">
5+
[dso]="dso"
6+
[context]="Context.EditMetadata"
7+
[mdValue]="mdValue"
8+
[mdField]="mdField"
9+
[dsoType]="dsoType"
10+
[saving$]="saving$"
11+
[isOnlyValue]="form.fields[mdField].length === 1"
12+
(edit)="mdValue.editing = true"
13+
(confirm)="mdValue.confirmChanges($event); form.resetReinstatable(); valueSaved.emit()"
14+
(remove)="mdValue.change === DsoEditMetadataChangeTypeEnum.ADD ? form.remove(mdField, idx) : mdValue.change = DsoEditMetadataChangeTypeEnum.REMOVE; form.resetReinstatable(); valueSaved.emit()"
15+
(undo)="mdValue.change === DsoEditMetadataChangeTypeEnum.ADD ? form.remove(mdField, idx) : mdValue.discard(); valueSaved.emit()"
16+
(dragging)="$event ? draggingMdField$.next(mdField) : draggingMdField$.next(null)">
1617
</ds-dso-edit-metadata-value>
1718
}
1819
</div>

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-field-values/dso-edit-metadata-field-values.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Observable,
1616
} from 'rxjs';
1717

18+
import { Context } from '../../../core/shared/context.model';
1819
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
1920
import {
2021
DsoEditMetadataChangeType,
@@ -78,6 +79,8 @@ export class DsoEditMetadataFieldValuesComponent {
7879
*/
7980
public DsoEditMetadataChangeTypeEnum = DsoEditMetadataChangeType;
8081

82+
public readonly Context = Context;
83+
8184
/**
8285
* Drop a value into a new position
8386
* Update the form's value array for the current field to match the dropped position
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {
2+
Component,
3+
EventEmitter,
4+
Input,
5+
Output,
6+
} from '@angular/core';
7+
8+
import { Context } from '../../../core/shared/context.model';
9+
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
10+
import { DsoEditMetadataValue } from '../dso-edit-metadata-form';
11+
import { EditMetadataValueFieldType } from './dso-edit-metadata-field-type.enum';
12+
13+
/**
14+
* Abstract base component for editing metadata fields.
15+
*
16+
* This abstract component is only designed to contain the common `@Input()` & `@Output()` fields, that the
17+
* {@link DsoEditMetadataValueFieldLoaderComponent} passes to its dynamically generated components. This class should
18+
* not contain any methods or any other type of logic. Such logic should instead be created in
19+
* {@link DsoEditMetadataFieldService}.
20+
*/
21+
@Component({
22+
selector: 'ds-abstract-dso-edit-metadata-value-field',
23+
template: '',
24+
standalone: true,
25+
})
26+
export abstract class AbstractDsoEditMetadataValueFieldComponent {
27+
28+
/**
29+
* The optional context
30+
*/
31+
@Input() context: Context;
32+
33+
/**
34+
* The {@link DSpaceObject}
35+
*/
36+
@Input() dso: DSpaceObject;
37+
38+
/**
39+
* The type of the DSO, used to determines i18n messages
40+
*/
41+
@Input() dsoType: string;
42+
43+
/**
44+
* The type of the field
45+
*/
46+
@Input() type: EditMetadataValueFieldType;
47+
48+
/**
49+
* The metadata field
50+
*/
51+
@Input() mdField: string;
52+
53+
/**
54+
* Editable metadata value to show
55+
*/
56+
@Input() mdValue: DsoEditMetadataValue;
57+
58+
/**
59+
* Emits when the user clicked confirm
60+
*/
61+
@Output() confirm: EventEmitter<boolean> = new EventEmitter();
62+
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@if (mdValue.editing) {
2+
@if ((isAuthorityControlled$ | async) !== true || (enabledFreeTextEditing && (isSuggesterVocabulary$ | async) !== true)) {
3+
<textarea class="form-control" rows="5" [(ngModel)]="mdValue.newValue.value"
4+
[attr.aria-label]="(dsoType + '.edit.metadata.edit.value') | translate"
5+
[dsDebounce]="300" (onDebounce)="confirm.emit(false)">
6+
</textarea>
7+
}
8+
@if ((isScrollableVocabulary$ | async) && !enabledFreeTextEditing) {
9+
<ds-dynamic-scrollable-dropdown [bindId]="mdField"
10+
[group]="group"
11+
[model]="getModel()"
12+
(change)="onChangeAuthorityField($event)">
13+
</ds-dynamic-scrollable-dropdown>
14+
}
15+
@if (((isHierarchicalVocabulary$ | async) && !enabledFreeTextEditing) || (isSuggesterVocabulary$ | async)) {
16+
<ds-dynamic-onebox
17+
[group]="group"
18+
[model]="getModel()"
19+
(change)="onChangeAuthorityField($event)">
20+
</ds-dynamic-onebox>
21+
}
22+
@if ((isHierarchicalVocabulary$ | async) || (isScrollableVocabulary$ | async)) {
23+
<button class="btn btn-secondary w-100 mt-2"
24+
[title]="enabledFreeTextEditing ? dsoType + '.edit.metadata.edit.buttons.disable-free-text-editing' : dsoType + '.edit.metadata.edit.buttons.enable-free-text-editing' | translate"
25+
(click)="toggleFreeTextEdition()">
26+
<i class="fas fa-fw" [ngClass]="enabledFreeTextEditing ? 'fa-lock' : 'fa-unlock'"></i>
27+
{{ (enabledFreeTextEditing ? dsoType + '.edit.metadata.edit.buttons.disable-free-text-editing' : dsoType + '.edit.metadata.edit.buttons.enable-free-text-editing') | translate }}
28+
</button>
29+
}
30+
@if ((isAuthorityControlled$ | async) && (isSuggesterVocabulary$ | async)) {
31+
<div class="mt-2">
32+
<div class="btn-group w-75">
33+
<i dsAuthorityConfidenceState
34+
class="fas fa-fw p-0 me-1 mt-auto mb-auto"
35+
aria-hidden="true"
36+
[authorityValue]="mdValue.newValue.confidence"
37+
[iconMode]="true"
38+
></i>
39+
<input class="form-control form-outline" data-test="authority-input" [(ngModel)]="mdValue.newValue.authority"
40+
[disabled]="!editingAuthority"
41+
[attr.aria-label]="(dsoType + '.edit.metadata.edit.authority.key') | translate"
42+
(change)="onChangeAuthorityKey()"/>
43+
@if (editingAuthority) {
44+
<button class="btn btn-outline-success btn-sm ng-star-inserted" id="metadata-confirm-btn"
45+
[title]="dsoType + '.edit.metadata.edit.buttons.close-authority-edition' | translate"
46+
ngbTooltip="{{ dsoType + '.edit.metadata.edit.buttons.close-authority-edition' | translate }}"
47+
(click)="onChangeEditingAuthorityStatus(false)">
48+
<i class="fas fa-lock-open fa-fw"></i>
49+
</button>
50+
} @else {
51+
<button class="btn btn-outline-secondary btn-sm ng-star-inserted" id="metadata-confirm-btn"
52+
[title]="dsoType + '.edit.metadata.edit.buttons.open-authority-edition' | translate"
53+
ngbTooltip="{{ dsoType + '.edit.metadata.edit.buttons.open-authority-edition' | translate }}"
54+
(click)="onChangeEditingAuthorityStatus(true)">
55+
<i class="fas fa-lock fa-fw"></i>
56+
</button>
57+
}
58+
</div>
59+
</div>
60+
}
61+
}

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value-field/dso-edit-metadata-authority-field/dso-edit-metadata-authority-field.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)