@@ -11,14 +11,11 @@ import {
1111import { TranslateService } from '@ngx-translate/core' ;
1212import uniqueId from 'lodash/uniqueId' ;
1313
14- import {
15- SubmissionVisibilityType ,
16- SubmissionVisibilityValue ,
17- } from '../../../../core/config/models/config-submission-section.model' ;
14+ import { SubmissionVisibilityType } from '../../../../core/config/models/config-submission-section.model' ;
1815import { MetadataValue } from '../../../../core/shared/metadata.models' ;
1916import { Metadata } from '../../../../core/shared/metadata.utils' ;
20- import { SubmissionScopeType } from '../../../../core/submission/submission-scope-type' ;
2117import { VocabularyOptions } from '../../../../core/submission/vocabularies/models/vocabulary-options.model' ;
18+ import { SubmissionVisibility } from '../../../../submission/utils/visibility.util' ;
2219import { isNgbDateStruct } from '../../../date.util' ;
2320import {
2421 hasValue ,
@@ -330,7 +327,7 @@ export abstract class FieldParser {
330327
331328 // Set read only option
332329 controlModel . readOnly = this . parserOptions . readOnly
333- || this . isFieldReadOnly ( this . configData . visibility , 'test' , this . parserOptions . submissionScope ) ;
330+ || this . isFieldReadOnly ( this . configData . visibility , this . parserOptions . submissionScope ) ;
334331 controlModel . disabled = controlModel . readOnly ;
335332 controlModel . isModelOfInnerForm = this . parserOptions . isInnerForm ;
336333 if ( hasValue ( this . configData . selectableRelationship ) ) {
@@ -372,23 +369,12 @@ export abstract class FieldParser {
372369 }
373370
374371 /**
375- * Check if a field is read-only with the given scope
372+ * Check if a field is read-only within the given scope
376373 * @param visibility
377374 * @param submissionScope
378375 */
379- private isFieldReadOnly ( visibility : SubmissionVisibilityType , fieldScope : string , submissionScope : string ) {
380- return isNotEmpty ( submissionScope )
381- && isNotEmpty ( fieldScope )
382- && isNotEmpty ( visibility )
383- && ( (
384- submissionScope === SubmissionScopeType . WorkspaceItem . valueOf ( )
385- && visibility . main === SubmissionVisibilityValue . ReadOnly
386- )
387- ||
388- ( visibility . other === SubmissionVisibilityValue . ReadOnly
389- && submissionScope === SubmissionScopeType . WorkflowItem . valueOf ( )
390- )
391- ) ;
376+ private isFieldReadOnly ( visibility : SubmissionVisibilityType , submissionScope ) {
377+ return isNotEmpty ( submissionScope ) && SubmissionVisibility . isReadOnly ( visibility , submissionScope ) ;
392378 }
393379
394380 /**
0 commit comments