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
|
} as FormFieldModel
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
selectableMetadata: [{ metadata: 'scoped.workflow.relation' }],
|
||||||
|
scope: 'WORKFLOW',
|
||||||
|
} as FormFieldModel,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
selectableMetadata: [{ metadata: 'scoped.workspace.relation' }],
|
||||||
|
scope: 'WORKSPACE',
|
||||||
|
} as FormFieldModel,
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -375,6 +391,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
|||||||
it('should return false for fields scoped to workflow', () => {
|
it('should return false for fields scoped to workflow', () => {
|
||||||
expect((comp as any).inCurrentSubmissionScope('scoped.workflow')).toBe(false);
|
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', () => {
|
describe('in workflow scope', () => {
|
||||||
@@ -394,6 +418,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
|||||||
it('should return false for fields scoped to workspace', () => {
|
it('should return false for fields scoped to workspace', () => {
|
||||||
expect((comp as any).inCurrentSubmissionScope('scoped.workspace')).toBe(false);
|
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 { SubmissionObject } from '../../../core/submission/models/submission-object.model';
|
||||||
import { SubmissionSectionObject } from '../../objects/submission-section-object.model';
|
import { SubmissionSectionObject } from '../../objects/submission-section-object.model';
|
||||||
import { SubmissionSectionError } from '../../objects/submission-section-error.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.
|
* This component represents a section that contains a Form.
|
||||||
@@ -255,9 +256,15 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private inCurrentSubmissionScope(field: string): boolean {
|
private inCurrentSubmissionScope(field: string): boolean {
|
||||||
const scope = this.formConfig?.rows.find(row => {
|
const scope = this.formConfig?.rows.find((row: FormRowModel) => {
|
||||||
return row.fields?.[0]?.selectableMetadata?.[0]?.metadata === field;
|
if (row.fields?.[0]?.selectableMetadata) {
|
||||||
}).fields?.[0]?.scope;
|
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) {
|
switch (scope) {
|
||||||
case SubmissionScopeType.WorkspaceItem: {
|
case SubmissionScopeType.WorkspaceItem: {
|
||||||
|
Reference in New Issue
Block a user