-
Notifications
You must be signed in to change notification settings - Fork 0
Updates for Research Output Table question type in Plan Creator #1078
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
Updates for Research Output Table question type in Plan Creator #1078
Conversation
…textArea question
…show form if there is only one. Also added a new SingleSearchOutputComponent to display just the one form
…iptions in metadata standards list in modal and fixed Delete button
…re are no answers. Added use of default licenses and output types when the question didn't save any custom ones.Fixed issue with both data flags showing all the time.Added Loading spinner.Added form field validation.Updated styles for RO list so that they are consistent with sitewide styles.Added scroll after updating or adding form
…ion to build out RO form state
…n compoents. Moved shared actions to the common app/actions location for addRepositoryAction and addMetaDataStandardAction
…oent to not show empty selections for repositories when it is enabled with no selections, and also updated to not show the Data Flags label when it is enabled but no chcekboxes have been checked. Made sure that help text appears for repositories and metadatastandards
… button only appears at the bottom of the SingleReseearchOutputComponent form
…fixed the getRowTitle which would be empty and fall back to default when first adding
…. Updated some broken unit tests
… increase coverage
…nswer and fixed some lintnig issues
…d not recognize that it needed to call update instead of add for answer. made improvements to ResearchOutputAnswerComponent and SingleResearchOutputComponent
| onChange={(selected) => | ||
| dispatch({ type: 'SET_SELECTED_PLAN_MEMBER', payload: selected as string }) | ||
| } selectedKey={selectedPlanMember} | ||
| } selectedKey={selectedPlanMember ?? undefined} |
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.
Fixed type error
| import mockQuestionDataForTypeAheadSearch from '@/__mocks__/common/mockPublishedQuestionDataForAffiliationSearch.json'; | ||
| import mockQuestionDataForURL from '@/__mocks__/common/mockPublishedQuestionDataForURL.json'; | ||
| import mockOtherQuestion from '../__mocks__/mockOtherQuestionData.json'; | ||
| import mockQuestionDataForResearchOutput from '../__mocks__/mockROPublishedQuestion.json'; |
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.
Updated to include the new code to support researchOutputTable question in PlanOverviewQuestionPage
| import React, { useEffect, useRef, useState } from 'react'; | ||
| import { useParams, useRouter } from 'next/navigation'; | ||
| import Image from 'next/image'; | ||
| import { useTranslations } from "next-intl"; |
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.
Updated this component to support researchOutputTable question type
| const prefillAnswer = (answer: any, type: string) => { | ||
| switch (type) { | ||
| case 'text': | ||
| case TYPEAHEAD_QUESTION_TYPE: |
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.
Updated prefillAnswer to use constants
| @@ -1,12 +1,17 @@ | |||
| import React from "react"; | |||
| import { act, fireEvent, render, screen, waitFor } from '@/utils/test-utils'; | |||
| import { act, fireEvent, render, screen, waitFor, within } from '@/utils/test-utils'; | |||
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.
Updated with unit tests for researchOutputTable question type
| @@ -0,0 +1,20 @@ | |||
| "use server"; | |||
|
|
|||
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.
Updated an existing graphql mutation call to use server actions instead
| @@ -0,0 +1,46 @@ | |||
| "use server"; | |||
|
|
|||
| import { executeGraphQLMutation } from "@/utils/server/graphqlServerActionHandler"; | |||
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.
Updated an existing graphql mutation call to use server actions instead
| handleSelect={handleSelect} | ||
| /> | ||
| ))} | ||
| {/** This is temporary, until we add research output question type to questionTypes */} |
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.
Replaced this with the actual researchOutputTable question type code.
| OutputTypeInterface, | ||
| StandardField, | ||
| RepositoryInterface, | ||
| MetaDataStandardInterface, |
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.
Moved this to shared useResearchOutTable hook
| 'use client' | ||
|
|
||
| import { useState } from 'react'; | ||
| import { useState, useCallback, useMemo } from 'react'; |
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.
Moved location of this file and made some updates to memoize functions, and also move out utilities to a separate utils/researchOutputTransformations.ts file
|
|
||
| type ErrorMessagesProps = { | ||
| errors: string[] | Record<string, string | null | undefined>; | ||
| noScroll?: boolean; |
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.
Updated to allow passing of ref so that users can be scrolled to first invalid field
| attributes: { | ||
| checked: true, | ||
| labelTranslationKey: "questions.use_existing_data" | ||
| label: "Use existing data", |
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.
I know that we will not be displaying the Boolean question type soon, but I fixed a bug with it, because I'm thinking of hanging on to the component, just in case.
| @@ -0,0 +1,830 @@ | |||
| 'use client' | |||
|
|
|||
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.
The new Question answer page in the Plan builder flow for researchOutputTable questions, uses a parent ResearchOutputAnswerComponent that either shows a list of all answers under the question, or displays just the form. This SingleResearchOutputComponent is used to display just the form by default when the user hasn't answer the question yet, or when users are editing their answers.
| import { | ||
| addMetaDataStandardsAction | ||
| } from "./actions"; | ||
| } from "@/app/actions"; |
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.
L26: This is because I moved some shared actions under @/app/actions
| type: "boolean", | ||
| attributes: { | ||
| checked: false | ||
| label: "Boolean Question", |
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.
Fixed a bug in Preview mode for Boolean questions
| } from '@/app/types'; | ||
| import styles from './repoSelectorForAnswer.module.scss'; | ||
|
|
||
| // TODO: There is some overlap with components/QuestionAdd/RepoSelector.tsx - consider refactoring shared logic |
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.
This is the new RepoSelector selection code for the Answer page. It has lots of overlap with the RepoSelector.tsx component, but there were enough differences that, for now, I created this separate component. At some point, I will separate out common code into a shared location.
| QuestionFormatsEnum, | ||
| QuestionFormatsUsage, | ||
| QuestionFormatsUsageInterface, | ||
| DefaultAffiliationSearchQuestion, |
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.
Updated questionTypeHandlers to use defaults from @dmptool/types and added support for researchOutputTable question type
| @@ -0,0 +1,712 @@ | |||
| import { | |||
| CURRENT_SCHEMA_VERSION, | |||
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.
Moved many research output helper functions into one utility
|
Switching to Draft because I just noticed a weird issue with the form not saving |
|
Actually, I'm reopening. I can't save any answers for any question type |
briri
left a comment
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.
This was a ton of work! It looks great @jupiter007
We're currently on @dmptool/types 2.1.0 which is the Zod upgrade (with clearer/cleaner defaults). Let's get this merged though with 2.0.0 since, as you noted in the PR its getting really big. I will create a ticket to upgrade to 2.1.0 with all of the things I think will need to be addressed in this repo (e.g. Maps of the type to default are available).
|
|
||
| // Transform subject areas data for FormSelect - add empty option for deselection | ||
| const subjectAreas = [ | ||
| { id: 'none', name: '-- None --' }, |
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.
Good idea!
Description
Made lots of changes to support the Research Outputs from Plan Creator View. I'm sure some areas could still use refinement, but this PR was getting really big, and I thought it best to get these changes through and create follow up tickets.
ResearchOutputAnswerComponent,SingleResearchOutputComponent,RepoSelectorForAnswerandMetaDataStandardForAnswercomponents for the rendering ofresearchOutputTablequestion type answer formutils/researchOutputTransformations.tsto group utilities forresearchOutputTableQuestionAddand associated unit tests to include tests for newresearchOutputTablequestion typePlanOverviewQuestionPagecomponent and related unit test in template builder flow to addresearchOutputTablequestion type supportQuestionEditpage and related unit test to improve theresearchOutputTablequestion type application by moving hydration out to hookhooks/useResearchOutputTableto memoize some functions and moved some code out to newresearchOutputTransformationsutilResearchOutputQuestionComponentandResearchOutputAnswerComponentundercomponents/FormErrorMessagesto pass inrefso we can control which field error to scroll tohooks/useRenderQuestionFieldhook to include rendering ofresearchOutputTableanswer formutils/questionTypeHandlerswith use ofDefaulttypes from@dmptool/typesFixes # (787)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Include any relevant details for your test configuration.
Checklist:
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.
Testing
developmentbranch of backend app to test this.editan answer or select+ Outputbutton.Screen recording
Adding answers to a Research Output question
Screen.Recording.2026-01-02.at.8.55.13.AM.mov