@@ -24,6 +24,7 @@ import { RelationshipOptions } from '../models/relationship-options.model';
2424import { VocabularyOptions } from '../../../../core/submission/vocabularies/models/vocabulary-options.model' ;
2525import { ParserType } from './parser-type' ;
2626import { isNgbDateStruct } from '../../../date.util' ;
27+ import { SubmissionScopeType } from '../../../../core/submission/submission-scope-type' ;
2728
2829export const SUBMISSION_ID : InjectionToken < string > = new InjectionToken < string > ( 'submissionId' ) ;
2930export const CONFIG_DATA : InjectionToken < FormFieldModel > = new InjectionToken < FormFieldModel > ( 'configData' ) ;
@@ -282,7 +283,7 @@ export abstract class FieldParser {
282283 controlModel . id = ( this . fieldId ) . replace ( / \. / g, '_' ) ;
283284
284285 // Set read only option
285- controlModel . readOnly = this . parserOptions . readOnly || this . isFieldReadOnly ( this . configData . visibility , this . parserOptions . submissionScope ) ;
286+ controlModel . readOnly = this . parserOptions . readOnly || this . isFieldReadOnly ( this . configData . visibility , this . configData . scope , this . parserOptions . submissionScope ) ;
286287 controlModel . disabled = controlModel . readOnly ;
287288 if ( hasValue ( this . configData . selectableRelationship ) ) {
288289 controlModel . relationship = Object . assign ( new RelationshipOptions ( ) , this . configData . selectableRelationship ) ;
@@ -322,14 +323,25 @@ export abstract class FieldParser {
322323 }
323324
324325 /**
325- * Check if a field is read-only with the given scope
326+ * Checks if a field is read-only with the given scope.
327+ * The field is readonly when submissionScope is WORKSPACE and the main visibility is READONLY
328+ * or when submissionScope is WORKFLOW and the other visibility is READONLY
326329 * @param visibility
327330 * @param submissionScope
328331 */
329- private isFieldReadOnly ( visibility : SectionVisibility , submissionScope : string ) {
332+ private isFieldReadOnly ( visibility : SectionVisibility , fieldScope : string , submissionScope : string ) {
330333 return isNotEmpty ( submissionScope )
331- && isNotEmpty ( visibility )
332- && visibility . main === VisibilityType . READONLY ;
334+ && isNotEmpty ( fieldScope )
335+ && isNotEmpty ( visibility )
336+ && ( (
337+ submissionScope === SubmissionScopeType . WorkspaceItem
338+ && visibility . main === VisibilityType . READONLY
339+ )
340+ ||
341+ ( visibility . other === VisibilityType . READONLY
342+ && submissionScope === SubmissionScopeType . WorkflowItem
343+ )
344+ ) ;
333345 }
334346
335347 /**
0 commit comments