Skip to content

Commit

Permalink
added changes from the review
Browse files Browse the repository at this point in the history
  • Loading branch information
rquazi committed Nov 20, 2024
1 parent e66ceea commit 524c258
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
67 changes: 34 additions & 33 deletions mscr-ui/src/modules/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ export default function FormModal({
usePutSchemaMscrCopyMutation();
const [submitAnimationVisible, setSubmitAnimationVisible] =
useState<boolean>(false);

const formDataFromInitialData = useCallback(() => {
if (!initialData) return;
const existingData: FormType = {
const existingData: FormType = {
format:
modalType == ModalType.MscrCopy? Format.Mscr : initialData.format,
modalType == ModalType.MscrCopy ? Format.Mscr : initialData.format,
languages: [
{
labelText: t('language-english-with-suffix'),
Expand Down Expand Up @@ -257,7 +256,7 @@ export default function FormModal({
resultSchemaRevision.data,
resultSchemaRevision.isSuccess,
resultMscrSchemaRevision.data,
resultMscrSchemaRevision.isSuccess
resultMscrSchemaRevision.isSuccess,
]
);

Expand Down Expand Up @@ -355,6 +354,7 @@ export default function FormModal({
modalType,
organizationPid
);

const newFormData = new FormData();
newFormData.append('metadata', JSON.stringify(payload));
if (fileUri && fileUri.length > 0) {
Expand All @@ -364,8 +364,6 @@ export default function FormModal({
} else if (formData.format !== Format.Mscr) {
return;
}


// Choose the api call and parameters according to content type and modal type
let makeApiCall;
if (modalType == ModalType.RegisterNewFull) {
Expand All @@ -376,7 +374,8 @@ export default function FormModal({
setSubmitAnimationVisible(false);
}
);
} else if (modalType == ModalType.RegisterNewMscr) {//what is register new MSCR?
} else if (modalType == ModalType.RegisterNewMscr) {
//what is register new MSCR?
Promise.all([spinnerDelay(), putCrosswalk(payload)]).then((_values) => {
setSubmitAnimationVisible(false);
});
Expand Down Expand Up @@ -413,16 +412,18 @@ export default function FormModal({
]).then((_values) => {
setSubmitAnimationVisible(false);
});
// Creating revision of MSCR format schemas
} else if (initialData &&
// 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);
});
contentType == Type.Schema
) {
Promise.all([
spinnerDelay(),
putMscrSchemaRevision({ pid: initialData.pid, data: payload }),
]).then((_values) => {
setSubmitAnimationVisible(false);
});
}
// Missing scenarios: MSCR copy of a crosswalk
}
Expand Down Expand Up @@ -588,19 +589,19 @@ export default function FormModal({
? modalType == ModalType.RegisterNewFull
? t('content-form.title.schema-register')
: modalType == ModalType.MscrCopy
? t('content-form.title.schema-mscr-copy')
: t('content-form.title.schema-revision')
? t('content-form.title.schema-mscr-copy')
: t('content-form.title.schema-revision')
: modalType == ModalType.RegisterNewFull
? t('content-form.title.crosswalk-register')
: modalType == ModalType.RegisterNewMscr
? t('content-form.title.crosswalk-create')
: modalType == ModalType.MscrCopy
? t('content-form.title.crosswalk-mscr-copy')
: t('content-form.title.crosswalk-revision')}
? t('content-form.title.crosswalk-register')
: modalType == ModalType.RegisterNewMscr
? t('content-form.title.crosswalk-create')
: modalType == ModalType.MscrCopy
? t('content-form.title.crosswalk-mscr-copy')
: t('content-form.title.crosswalk-revision')}
</ModalTitle>

{(modalType == ModalType.RegisterNewFull ||
modalType == ModalType.RevisionFull) &&
modalType == ModalType.RevisionFull) &&
renderFileDropArea()}

{contentType == Type.Schema && (
Expand Down Expand Up @@ -651,15 +652,15 @@ export default function FormModal({
? modalType == ModalType.RegisterNewFull
? t('content-form.button.schema-register')
: modalType == ModalType.MscrCopy
? t('content-form.button.mscr-copy')
: t('content-form.button.schema-revision')
? t('content-form.button.mscr-copy')
: t('content-form.button.schema-revision')
: modalType == ModalType.RegisterNewFull
? t('content-form.button.crosswalk-register')
: modalType == ModalType.RegisterNewMscr
? t('content-form.button.crosswalk-create')
: modalType == ModalType.MscrCopy
? t('content-form.button.mscr-copy')
: t('content-form.button.crosswalk-revision')}
? t('content-form.button.crosswalk-register')
: modalType == ModalType.RegisterNewMscr
? t('content-form.button.crosswalk-create')
: modalType == ModalType.MscrCopy
? t('content-form.button.mscr-copy')
: t('content-form.button.crosswalk-revision')}
</Button>
<Button variant="secondary" onClick={() => handleClose()}>
{userPosted ? t('close') : t('cancel')}
Expand Down
1 change: 0 additions & 1 deletion mscr-ui/src/modules/form/validate-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
formatsAvailableForSchemaRegistration,
} from '@app/common/interfaces/format.interface';


export interface InputErrors {
languageAmount: boolean;
titleAmount: string[];
Expand Down
1 change: 0 additions & 1 deletion mscr-ui/src/modules/schema-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ export default function SchemaView({ schemaId }: { schemaId: string }) {
text1={t('confirm-modal.unset-root-selection')}
/>
)}
{/*ToDo: When making a revision of an mscr copy is possible, take that into account here (Modaltype.RevisionMscr)*/}
{schemaData.format == Format.Mscr ? (
<FormModal
modalType={ModalType.RevisionMscr}
Expand Down

0 comments on commit 524c258

Please sign in to comment.