mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 11:33:04 +00:00
101654: Fixed relationship fields not being hidden when they are out of scope
This commit is contained in:
@@ -347,6 +347,22 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
} as FormFieldModel
|
||||
]
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workflow.relation' }],
|
||||
scope: 'WORKFLOW',
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workspace.relation' }],
|
||||
scope: 'WORKSPACE',
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
@@ -375,6 +391,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
it('should return false for fields scoped to workflow', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for relation fields scoped to workspace', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace.relation')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for relation fields scoped to workflow', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow.relation')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('in workflow scope', () => {
|
||||
@@ -394,6 +418,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
it('should return false for fields scoped to workspace', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace')).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for relation fields scoped to workflow', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow.relation')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for relation fields scoped to workspace', () => {
|
||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace.relation')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -38,6 +38,7 @@ import { WorkflowItem } from '../../../core/submission/models/workflowitem.model
|
||||
import { SubmissionObject } from '../../../core/submission/models/submission-object.model';
|
||||
import { SubmissionSectionObject } from '../../objects/submission-section-object.model';
|
||||
import { SubmissionSectionError } from '../../objects/submission-section-error.model';
|
||||
import { FormRowModel } from '../../../core/config/models/config-submission-form.model';
|
||||
|
||||
/**
|
||||
* This component represents a section that contains a Form.
|
||||
@@ -255,9 +256,15 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
* @private
|
||||
*/
|
||||
private inCurrentSubmissionScope(field: string): boolean {
|
||||
const scope = this.formConfig?.rows.find(row => {
|
||||
return row.fields?.[0]?.selectableMetadata?.[0]?.metadata === field;
|
||||
}).fields?.[0]?.scope;
|
||||
const scope = this.formConfig?.rows.find((row: FormRowModel) => {
|
||||
if (row.fields?.[0]?.selectableMetadata) {
|
||||
return row.fields?.[0]?.selectableMetadata?.[0]?.metadata === field;
|
||||
} else if (row.fields?.[0]?.selectableRelationship) {
|
||||
return row.fields?.[0]?.selectableRelationship.relationshipType === field.replace(/^relationship\./g, '');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})?.fields?.[0]?.scope;
|
||||
|
||||
switch (scope) {
|
||||
case SubmissionScopeType.WorkspaceItem: {
|
||||
|
Reference in New Issue
Block a user