-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cscfc4 emscr 591 remove file upload from add revision modal for mscr format #230
Changes from 5 commits
4d6838c
44e9285
c14f983
56f3839
6cee1df
e66ceea
524c258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import { useTranslation } from 'next-i18next'; | |
import getApiError from '@app/common/utils/getApiErrors'; | ||
import { useRouter } from 'next/router'; | ||
import { | ||
usePutMscrSchemaRevisionMutation, | ||
usePutSchemaFullMutation, | ||
usePutSchemaMscrCopyMutation, | ||
usePutSchemaRevisionMutation, | ||
|
@@ -100,6 +101,8 @@ export default function FormModal({ | |
const [putCrosswalkFull, resultCrosswalkFull] = usePutCrosswalkFullMutation(); | ||
const [putSchemaRevision, resultSchemaRevision] = | ||
usePutSchemaRevisionMutation(); | ||
const [putMscrSchemaRevision, resultMscrSchemaRevision] = | ||
usePutMscrSchemaRevisionMutation(); | ||
const [putCrosswalkRevision, resultCrosswalkRevision] = | ||
usePutCrosswalkRevisionMutation(); | ||
const [putCrosswalkFullRevision, resultCrosswalkFullRevision] = | ||
|
@@ -108,12 +111,12 @@ export default function FormModal({ | |
usePutSchemaMscrCopyMutation(); | ||
const [submitAnimationVisible, setSubmitAnimationVisible] = | ||
useState<boolean>(false); | ||
|
||
const formDataFromInitialData = useCallback(() => { | ||
if (!initialData) return; | ||
const existingData: FormType = { | ||
format: | ||
modalType == ModalType.MscrCopy ? Format.Mscr : initialData.format, | ||
modalType == ModalType.MscrCopy? Format.Mscr : initialData.format, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a space between the conditional operators and the operands, so restore space between 'ModalType.MscrCopy' and '?' |
||
languages: [ | ||
{ | ||
labelText: t('language-english-with-suffix'), | ||
|
@@ -202,6 +205,12 @@ export default function FormModal({ | |
resultCrosswalkRevision.data | ||
) { | ||
pid = resultCrosswalkRevision.data.pid; | ||
} else if ( | ||
contentType == Type.Schema && | ||
resultMscrSchemaRevision.isSuccess && | ||
resultMscrSchemaRevision.data | ||
) { | ||
pid = resultMscrSchemaRevision.data.pid; | ||
} | ||
break; | ||
case ModalType.RevisionFull: | ||
|
@@ -247,6 +256,8 @@ export default function FormModal({ | |
resultSchemaMscrCopy.isSuccess, | ||
resultSchemaRevision.data, | ||
resultSchemaRevision.isSuccess, | ||
resultMscrSchemaRevision.data, | ||
resultMscrSchemaRevision.isSuccess | ||
] | ||
); | ||
|
||
|
@@ -325,6 +336,7 @@ export default function FormModal({ | |
fileData, | ||
fileUri | ||
); | ||
|
||
setErrors(formErrors); | ||
|
||
if ( | ||
|
@@ -352,6 +364,7 @@ export default function FormModal({ | |
} else if (formData.format !== Format.Mscr) { | ||
return; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be its my problem to add always some extra new lines as things look congested in my eye :) |
||
|
||
// Choose the api call and parameters according to content type and modal type | ||
let makeApiCall; | ||
|
@@ -363,7 +376,7 @@ export default function FormModal({ | |
setSubmitAnimationVisible(false); | ||
} | ||
); | ||
} else if (modalType == ModalType.RegisterNewMscr) { | ||
} else if (modalType == ModalType.RegisterNewMscr) {//what is register new MSCR? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the definition of the ModalType:
RegisterNewMscr is registering something in MSCR-format, where there's no file sent, as opposed to RegisterNewFull, where there should also be a file attached. In practice it always means creating (and registering) a new crosswalk, since that's always MSCR-format. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks :) I was wondering what this action :) |
||
Promise.all([spinnerDelay(), putCrosswalk(payload)]).then((_values) => { | ||
setSubmitAnimationVisible(false); | ||
}); | ||
|
@@ -400,8 +413,18 @@ export default function FormModal({ | |
]).then((_values) => { | ||
setSubmitAnimationVisible(false); | ||
}); | ||
// Creating revision of MSCR format schemas | ||
} else if (initialData && | ||
modalType == ModalType.RevisionMscr && | ||
contentType == Type.Schema) { | ||
Promise.all([ | ||
spinnerDelay(), | ||
putMscrSchemaRevision({ pid: initialData.pid, data: payload }), | ||
]).then((_values) => { | ||
setSubmitAnimationVisible(false); | ||
}); | ||
} | ||
// Missing scenarios: MSCR copy of a crosswalk, revision of an MSCR copy | ||
// Missing scenarios: MSCR copy of a crosswalk | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
formatsAvailableForSchemaRegistration, | ||
} from '@app/common/interfaces/format.interface'; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for adding extra empty lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, just accidental !! |
||
export interface InputErrors { | ||
languageAmount: boolean; | ||
titleAmount: string[]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,15 +352,28 @@ export default function SchemaView({ schemaId }: { schemaId: string }) { | |
/> | ||
)} | ||
{/*ToDo: When making a revision of an mscr copy is possible, take that into account here (Modaltype.RevisionMscr)*/} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ToDo is completed with your changes! :) |
||
<FormModal | ||
modalType={ModalType.RevisionFull} | ||
contentType={Type.Schema} | ||
visible={formModalIsOpen.version} | ||
setVisible={(value) => | ||
dispatch(setFormModalState({ key: 'version', value: value })) | ||
} | ||
initialData={schemaData} | ||
/> | ||
{schemaData.format == Format.Mscr ? ( | ||
<FormModal | ||
modalType={ModalType.RevisionMscr} | ||
contentType={Type.Schema} | ||
visible={formModalIsOpen.version} | ||
setVisible={(value) => | ||
dispatch(setFormModalState({ key: 'version', value: value })) | ||
} | ||
initialData={schemaData} | ||
/> | ||
) : ( | ||
<FormModal | ||
modalType={ModalType.RevisionFull} | ||
contentType={Type.Schema} | ||
visible={formModalIsOpen.version} | ||
setVisible={(value) => | ||
dispatch(setFormModalState({ key: 'version', value: value })) | ||
} | ||
initialData={schemaData} | ||
/> | ||
)} | ||
|
||
<FormModal | ||
modalType={ModalType.MscrCopy} | ||
contentType={Type.Schema} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace