Skip to content

Feature/929/js custom question pages#1193

Open
jupiter007 wants to merge 9 commits intodevelopmentfrom
feature/929/JS-custom-question-pages
Open

Feature/929/js custom question pages#1193
jupiter007 wants to merge 9 commits intodevelopmentfrom
feature/929/JS-custom-question-pages

Conversation

@jupiter007
Copy link
Collaborator

@jupiter007 jupiter007 commented Mar 12, 2026

Description

  • Added new CustomQuestionEdit page
  • Added new QuestionCustomize page
  • Added new CustomQuestionNew page
  • Added new AddCustomQuestion, UpdateCustomQuestion, RemoveCustomQuestion, AddQuestionCustomization, UpdateQuestionCustomization, RemoveQuestionCustomization mutations
  • Added CustomQuestion and QuestionCustomizationByVersionedQuestion mutations
  • Added new routes for Custom Queries to utils/routes.ts
  • Moved addQuestionMutation out of QuestionView so that QuestionView can be shared for both BASE and CUSTOM questions
  • Updated QuestionTypeSelectPage to include the addQuestionMutation and getDisplayOrder and pass those to QuestionAdd
  • Added use of Loading component in TemplateCreatePage
  • Added fetchPolicy of cache-and-network to TemplateCustomiationOverview query so that we get updated data when user returns from editing section or question
  • Updated form components with isDisabled prop so that users customizing existing questions can see a disabled version of the form fields
  • Updated QuestionAdd to accept more props and be more flexible for shared use with Custom Questions
  • Updated QuestionView to accept more props like orgGuidance so it can be shared with Custom Questions

Fixes # (929)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manually tested with backend PR, CDLUC3/dmptool-apollo-server#636, and added unit tests

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I updated the CHANGELOG.md and added documentation if necessary
  • I have added tests that prove my fix is effective or that my feature works
  • I have completed manual or automated accessibility testing for my changes
  • New and existing unit tests pass locally with my changes
  • [*] Any dependent changes have been merged and published in downstream modules
    *Note: backend PR that goes with this branch: Updates for Custom Questions dmptool-apollo-server#636

Important Note:

Please make sure to do a careful merge of development branch into yours, to make sure you aren't reverting or effecting any previous commits to the development branch.

Screenshots

Custom Questions are given different styles

image

Question Customization of a BASE Text area question

image

Customization of an existing Radio Button question. Note that the form fields are disabled

image

When Question Customization is going to be deleted, a confirmation modal appears

image

givenName: 'John',
surName: 'Doe',
affiliation: { name: 'Test Institution', uri: 'test-uri' },
affiliation: { name: 'Test Institution', uri: 'test-uri', displayName: 'Test Institution' },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the affiliationName.displayName to the MeQuery for the QuestionPreview so that we could be explicit about which Org added the guidance, therefore I was required to add it to some unit test mocks.

isOptionsType,
getOverrides,
} from './hooks/useEditQuestion';
} from '@/app/hooks/useEditQuestion';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the useEditQuestion to a shared location since the new Custom Question pages use it too

Text
} from "react-aria-components";


Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page was updated to pass in new props to the shared QuestionAdd, because it is now shared with the Custom Question pages

// TODO: Need to implement a shared loading component
if (step === null) {
return <div>...{Global('messaging.loading')}</div>
return <Loading />;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Loading component here

<Button
type="submit"
aria-disabled={isSubmitting}
isDisabled={isSubmitting}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding disabling of Submit button when submit request is still active

'use client';

import React, { useEffect, useRef, useState } from 'react';
import Link from 'next/link';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to using next/link because it's much faster than using React Aria Component's

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that something we'll want to do site wide? If so, make sure you create a ticket so we don't lose track!

Seems like a perfect task for the Reeves team at some point

@@ -0,0 +1,6 @@
import Loading from '@/components/Loading';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this new component just in case, so page loads can fall back to this if it takes longer than 300ms

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is a good idea

onChange?: (value: string) => void;
isRequired?: boolean;
isRequiredVisualOnly?: boolean;
isDisabled?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Question Customization pages, all form fields will be disabled in the page, so I updated all form fields with the isDisabled prop

questionName,
questionJSON,
sectionId }:
sectionId,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New props were added so that we can more easily share this component between BASE and CUSTOM questions

interface QuestionPreviewProps extends React.HTMLAttributes<HTMLDivElement> {
buttonLabel?: string,
previewDisabled?: boolean,
onOpenChange?: (isOpen: boolean) => void,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just passing an onOpenChange callback that helps re-render the fields in the previous page when the Preview modal is closed.

@jupiter007 jupiter007 requested a review from briri March 13, 2026 15:16
Copy link
Collaborator

@briri briri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

'use client';

import React, { useEffect, useRef, useState } from 'react';
import Link from 'next/link';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that something we'll want to do site wide? If so, make sure you create a ticket so we don't lose track!

Seems like a perfect task for the Reeves team at some point

@@ -0,0 +1,6 @@
import Loading from '@/components/Loading';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants