Skip to content

Commit 386078e

Browse files
[DURACOM-453] refactor, hide *-edit forms, fix cache issue, add type docs
1 parent 7746789 commit 386078e

30 files changed

Lines changed: 376 additions & 81 deletions

config/config.example.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,20 @@ homePage:
403403
item:
404404
edit:
405405
undoTimeout: 10000 # 10 seconds
406+
# Defines the security levels available for metadata fields.
407+
# Each level maps to a numeric value stored on the metadata field in the backend and controls visibility of that field based on the user's role.
408+
# Levels are displayed as toggle buttons in the metadata edit UI.
409+
security:
410+
levels:
411+
- value: 0 # Public — visible to everyone
412+
icon: fa fa-globe
413+
color: green
414+
- value: 1 # Registered users — visible to authenticated users only
415+
icon: fa fa-key
416+
color: orange
417+
- value: 2 # Administrators only — restricted to admin users
418+
icon: fa fa-lock
419+
color: red
406420
# Show the item access status label in items lists
407421
showAccessStatuses: false
408422
bitstream:

src/app/app.menus.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { CurationMenuProvider } from './shared/menu/providers/curation.menu';
2121
import { DSpaceObjectEditMenuProvider } from './shared/menu/providers/dso-edit.menu';
2222
import { DsoOptionMenuProvider } from './shared/menu/providers/dso-option.menu';
2323
import { EditMenuProvider } from './shared/menu/providers/edit.menu';
24-
import { EditItemDetailsMenuProvider } from './shared/menu/providers/edit-item-details.menu';
24+
import { EditItemMenuProvider } from './shared/menu/providers/edit-item-details.menu';
2525
import { ExportMenuProvider } from './shared/menu/providers/export.menu';
2626
import { HealthMenuProvider } from './shared/menu/providers/health.menu';
2727
import { ImportMenuProvider } from './shared/menu/providers/import.menu';
@@ -79,6 +79,9 @@ export const MENUS = buildMenuStructure({
7979
],
8080
[MenuID.DSO_EDIT]: [
8181
DsoOptionMenuProvider.withSubs([
82+
EditItemMenuProvider.onRoute(
83+
MenuRoute.ITEM_PAGE,
84+
),
8285
SubscribeMenuProvider.onRoute(
8386
MenuRoute.COMMUNITY_PAGE,
8487
MenuRoute.COLLECTION_PAGE,
@@ -105,9 +108,6 @@ export const MENUS = buildMenuStructure({
105108
ClaimMenuProvider.onRoute(
106109
MenuRoute.ITEM_PAGE,
107110
),
108-
EditItemDetailsMenuProvider.onRoute(
109-
MenuRoute.ITEM_PAGE,
110-
),
111111
]),
112112
],
113113
});

src/app/collection-page/collection-form/collection-form.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
173173
}
174174
});
175175

176-
definitions.forEach((definition: SubmissionDefinitionModel, index: number) => {
176+
definitions.filter(def => !def.id.includes('-edit')).forEach((definition: SubmissionDefinitionModel, index: number) => {
177177
this.submissionDefinitionSelection.add({
178178
disabled: false,
179179
label: definition.name,

src/app/core/config/submission-definitions-config-data.service.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
19
import { Injectable } from '@angular/core';
210
import { FollowLinkConfig } from '@dspace/core/shared/follow-link-config.model';
311
import { Observable } from 'rxjs';
@@ -16,6 +24,13 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
1624
import { ConfigDataService } from './config-data.service';
1725
import { ConfigObject } from './models/config.model';
1826

27+
/**
28+
* Data service responsible for retrieving submission definition configurations from the REST API.
29+
* Submission definitions describe the structure of submission forms (steps, sections, and fields)
30+
* used when depositing or editing items.
31+
*
32+
* It extends {@link ConfigDataService} targeting the `submissiondefinitions` endpoint.
33+
*/
1934
@Injectable({ providedIn: 'root' })
2035
export class SubmissionDefinitionsConfigDataService extends ConfigDataService {
2136
constructor(
@@ -27,6 +42,15 @@ export class SubmissionDefinitionsConfigDataService extends ConfigDataService {
2742
super('submissiondefinitions', requestService, rdbService, objectCache, halService);
2843
}
2944

45+
/**
46+
* Retrieves the full list of submission definition configurations from the REST API.
47+
*
48+
* @param options
49+
* @param useCachedVersionIfAvailable
50+
* @param reRequestOnStale
51+
* @param linksToFollow
52+
* @returns An {@link Observable} emitting a {@link RemoteData} wrapper around a {@link PaginatedList} of {@link ConfigObject} entries.
53+
*/
3054
findAll(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<ConfigObject>[]): Observable<RemoteData<PaginatedList<ConfigObject>>> {
3155
return this.getBrowseEndpoint(options).pipe(
3256
take(1),

src/app/core/submission/models/edititem-mode.model.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ import { ResourceType } from '../../shared/resource-type';
1919
import { excludeFromEquals } from '../../utilities/equals.decorators';
2020

2121
/**
22-
* Describes a EditItem mode
22+
* Represents a single edit mode available for an existing {@link Item}.
23+
*
24+
* Edit modes are returned by the REST API (`/api/submission/edititems/:id/modes`) and define
25+
* the different ways in which an item can be edited (e.g. full edit, correction, withdraw).
26+
* Each mode references a specific submission definition that determines which sections and
27+
* fields are shown in the edit form.
28+
*
29+
* Consumed by {@link EditItemDataService} to retrieve available modes for a given item, and
30+
* used by the edit-item page to build the appropriate submission form via
31+
* {@link EditItemMenuProvider}.
2332
*/
2433
@typedObject
2534
export class EditItemMode extends CacheableObject {

src/app/core/submission/models/edititem.model.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import { EditItemMode } from './edititem-mode.model';
2424
import { SubmissionObject } from './submission-object.model';
2525

2626
/**
27-
* A model class for a EditItem.
27+
* Represents the object type of the edit submission object.
28+
*
29+
* Used to map responses from {@link EditItemDataService} wich is used to retrieve available edit modes for a given item.
30+
* {@link EditItemMenuProvider}.
2831
*/
2932
@typedObject
3033
@inheritSerialization(SubmissionObject)

src/app/core/submission/models/metadata-security-configuration.ts

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
19
import {
210
autoserialize,
311
deserialize,
@@ -16,7 +24,15 @@ interface MetadataCustomSecurityEntries {
1624
[metadata: string]: number[];
1725
}
1826
/**
19-
* A model class for a security configuration of metadata.
27+
* Model class representing the metadata security configuration associated with a given entity type.
28+
* This class is used to determine which security levels are applied
29+
* to metadata fields — either globally via a default, or on a per-field
30+
* basis via custom entries.
31+
*
32+
* Security levels are represented as integers:
33+
* - `0` → Public (visible to everyone)
34+
* - `1` → Registered users (visible to authenticated users only)
35+
* - `2` → Administrator (visible to administrators only)
2036
*/
2137
@typedObject
2238
export class MetadataSecurityConfiguration extends CacheableObject {
@@ -29,17 +45,37 @@ export class MetadataSecurityConfiguration extends CacheableObject {
2945
@deserializeAs(new IDToUUIDSerializer(MetadataSecurityConfiguration.type.value), 'id')
3046
uuid: string;
3147
/**
32-
* List of security configurations for all of the metadatas of the entity type
48+
* Array of security levels applied by default to all metadata fields
49+
* of the entity type, when no custom rule is defined for a specific field.
50+
*
51+
* Each element is an integer representing a security level
52+
* (0 = public, 1 = registered users, 2 = administrators).
53+
*
54+
* @example [0, 1]
3355
*/
3456
@autoserialize
3557
metadataSecurityDefault: number[];
3658
/**
37-
* List of security configurations for all of the metadatas of the entity type
59+
* Map of custom security configurations for individual metadata fields
60+
* of the entity type.
61+
*
62+
* Allows overriding the default behavior (`metadataSecurityDefault`)
63+
* for specific fields. The key is the qualified metadata field name
64+
* (e.g. `dc.title`), and the value is the array of security levels applied.
65+
*
66+
* @see MetadataCustomSecurityEntries
67+
*
68+
* @example
69+
* {
70+
* "dc.title": [0,1],
71+
* "dc.rights": [1,2]
72+
* }
3873
*/
3974
@autoserialize
4075
metadataCustomSecurity: MetadataCustomSecurityEntries;
4176
/**
42-
* The object type
77+
* The REST resource type, automatically populated during
78+
* deserialization from the backend response.
4379
*/
4480
@excludeFromEquals
4581
@autoserialize

src/app/core/testing/submission-service.stub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class SubmissionServiceStub {
2626
isSubmissionLoading = jasmine.createSpy('isSubmissionLoading');
2727
notifyNewSection = jasmine.createSpy('notifyNewSection');
2828
redirectToMyDSpace = jasmine.createSpy('redirectToMyDSpace');
29-
redirectToItemPage = jasmine.createSpy('redirectToItemPage');
29+
invalidateCacheAndRedirectToItemPage = jasmine.createSpy('redirectToItemPage');
3030
resetAllSubmissionObjects = jasmine.createSpy('resetAllSubmissionObjects');
3131
resetSubmissionObject = jasmine.createSpy('resetSubmissionObject');
3232
retrieveSubmission = jasmine.createSpy('retrieveSubmission');

src/app/item-page/edit-item-page/edit-metadata-security/edit-metadata-security.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<div class="switch-opt"
66
[ngStyle]="{'background-color': securityLevel === $any(secLevel).value ? 'white' : 'rgb(204,204,204)' }">
77
<button class="btn btn-link text-primary" data-test="switch-btn"
8-
title="Metadata security level {{ $any(secLevel).value }}"
8+
[title]="'metadata.security.level.title' | translate: { level: $any(secLevel).value }"
99
[dsBtnDisabled]="readOnly"
1010
(click)="changeSelectedSecurityLevel($any(secLevel).value)">
1111
<i [class]="$any(secLevel).icon"
12+
aria-hidden="true"
1213
[ngStyle]="{'color': securityLevel === $any(secLevel).value ? $any(secLevel).color : '' }"></i>
1314
</button>
1415
</div>

src/app/item-page/edit-item-page/edit-metadata-security/edit-metadata-security.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
TestBed,
44
} from '@angular/core/testing';
55
import { By } from '@angular/platform-browser';
6+
import { TranslateModule } from '@ngx-translate/core';
67

78
import { EditMetadataSecurityComponent } from './edit-metadata-security.component';
89

@@ -12,7 +13,7 @@ describe('EditMetadataSecurityComponent', () => {
1213

1314
beforeEach(async () => {
1415
await TestBed.configureTestingModule({
15-
imports: [EditMetadataSecurityComponent],
16+
imports: [TranslateModule.forRoot(), EditMetadataSecurityComponent],
1617
})
1718
.compileComponents();
1819
});

0 commit comments

Comments
 (0)