diff --git a/src/components/form-control/index.tsx b/src/components/form-control/index.tsx index 2d8ff109..f6cf4019 100644 --- a/src/components/form-control/index.tsx +++ b/src/components/form-control/index.tsx @@ -59,7 +59,6 @@ const FormControl = ({ const dispatch = useAppDispatch(); const conceptForm = useAppSelector(state => state.conceptForm); const { concept } = conceptForm; - const erSistPublisert = concept?.erSistPublisert ?? false; const published = concept?.erPublisert ?? false; const isSaving = conceptForm.isSaving ?? false; const justChangedStatus = conceptForm.justChangedStatus ?? false; @@ -109,7 +108,7 @@ const FormControl = ({ return concept ? ( - {isFormDirty && published && erSistPublisert && ( + {isFormDirty && published && ( {localization.saveDraft} diff --git a/src/lib/concept/index.ts b/src/lib/concept/index.ts index 6b8ffb97..8f2c10d6 100644 --- a/src/lib/concept/index.ts +++ b/src/lib/concept/index.ts @@ -1,12 +1,9 @@ -import { Concept } from '../../types'; +import {Concept} from '../../types'; export const isConceptEditable = (concept: Concept | undefined) => { if (concept == null) { return false; } - const { id, erPublisert, erSistPublisert, revisjonAvSistPublisert } = concept; - const editable = - id == null || (erPublisert && erSistPublisert) || revisjonAvSistPublisert; - - return editable; + const { id, erPublisert } = concept; + return id == null || !erPublisert; }; diff --git a/src/pages/concept-registration-page/form-concept/form-concept.schema.ts b/src/pages/concept-registration-page/form-concept/form-concept.schema.ts index 851925dd..a206897b 100644 --- a/src/pages/concept-registration-page/form-concept/form-concept.schema.ts +++ b/src/pages/concept-registration-page/form-concept/form-concept.schema.ts @@ -240,8 +240,11 @@ export const schema = Yup.object().shape({ context.parent.id ? getRevisions(context.parent.id) .then(revisions => { - const latestPublishedRevision = revisions.find( - rev => rev.erSistPublisert + const latestPublishedRevision = revisions.reduce( + (prev, current) => + compareVersion(prev.versjonsnr, current.versjonsnr) < 0 + ? prev + : current ); return ( compareVersion(