Fix for PR#1822 - Fix is in section-form-component.ts. Adjusted two equality checks for scope type which always returned false.

This commit is contained in:
Félix Jolin-Nicol
2022-09-15 14:48:57 -04:00
parent 6d361beb88
commit fcae738db6
4 changed files with 9 additions and 6 deletions

View File

@@ -0,0 +1,3 @@
import { ResourceType } from '../../shared/resource-type';
export const WORKSPACEITEM = new ResourceType('workspaceitem');

View File

@@ -2,7 +2,7 @@ import { deserializeAs, inheritSerialization } from 'cerialize';
import { inheritLinkAnnotations, typedObject } from '../../cache/builders/build-decorators'; import { inheritLinkAnnotations, typedObject } from '../../cache/builders/build-decorators';
import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer'; import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer';
import { SubmissionObject } from './submission-object.model'; import { SubmissionObject } from './submission-object.model';
import { ResourceType } from '../../shared/resource-type'; import { WORKSPACEITEM } from '../../eperson/models/workspaceitem.resource-type';
/** /**
* A model class for a WorkspaceItem. * A model class for a WorkspaceItem.
@@ -11,7 +11,7 @@ import { ResourceType } from '../../shared/resource-type';
@inheritSerialization(SubmissionObject) @inheritSerialization(SubmissionObject)
@inheritLinkAnnotations(SubmissionObject) @inheritLinkAnnotations(SubmissionObject)
export class WorkspaceItem extends SubmissionObject { export class WorkspaceItem extends SubmissionObject {
static type = new ResourceType('workspaceitem'); static type = WORKSPACEITEM;
/** /**
* The universally unique identifier of this WorkspaceItem * The universally unique identifier of this WorkspaceItem

View File

@@ -357,7 +357,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
describe('in workspace scope', () => { describe('in workspace scope', () => {
beforeEach(() => { beforeEach(() => {
// @ts-ignore // @ts-ignore
comp.submissionObject = { type: WorkspaceItem.type }; comp.submissionObject = { type: WorkspaceItem.type.value };
}); });
it('should return true for unscoped fields', () => { it('should return true for unscoped fields', () => {
@@ -376,7 +376,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
describe('in workflow scope', () => { describe('in workflow scope', () => {
beforeEach(() => { beforeEach(() => {
// @ts-ignore // @ts-ignore
comp.submissionObject = { type: WorkflowItem.type }; comp.submissionObject = { type: WorkflowItem.type.value };
}); });
it('should return true when field is unscoped', () => { it('should return true when field is unscoped', () => {

View File

@@ -261,10 +261,10 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
switch (scope) { switch (scope) {
case SubmissionScopeType.WorkspaceItem: { case SubmissionScopeType.WorkspaceItem: {
return this.submissionObject.type === WorkspaceItem.type; return (this.submissionObject as any).type === WorkspaceItem.type.value;
} }
case SubmissionScopeType.WorkflowItem: { case SubmissionScopeType.WorkflowItem: {
return this.submissionObject.type === WorkflowItem.type; return (this.submissionObject as any).type === WorkflowItem.type.value;
} }
default: { default: {
return true; return true;