Skip to content

Conversation

@jupiter007
Copy link
Collaborator

@jupiter007 jupiter007 commented Jan 2, 2026

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.

  • Added new ResearchOutputAnswerComponent, SingleResearchOutputComponent, RepoSelectorForAnswer and MetaDataStandardForAnswer components for the rendering of researchOutputTable question type answer form
  • Added utils/researchOutputTransformations.ts to group utilities for researchOutputTable
  • Updated QuestionAdd and associated unit tests to include tests for new researchOutputTable question type
  • Update PlanOverviewQuestionPage component and related unit test in template builder flow to add researchOutputTable question type support
  • Updated QuestionEdit page and related unit test to improve the researchOutputTable question type application by moving hydration out to hook
  • Update hooks/useResearchOutputTable to memoize some functions and moved some code out to new researchOutputTransformations util
  • Moved ResearchOutputQuestionComponent and ResearchOutputAnswerComponent under components/Form
  • Updated shared ErrorMessages to pass in ref so we can control which field error to scroll to
  • Updated hooks/useRenderQuestionField hook to include rendering of researchOutputTable answer form
  • Updated utils/questionTypeHandlers with use of Default types from @dmptool/types

Fixes # (787)

Type of change

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

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:

  • 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
  • [NA] Any dependent changes have been merged and published in downstream modules

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

  • Use development branch of backend app to test this.
  • Create a template with a Research Output question type
  • Then a project off of that and select that template for the plan
  • When you go in to answer the question, you should see the Research Output form, instead of the List view
  • Once you have at least one answer, you would see the list view, and only see the form when you edit an answer or select + Output button.

Screen recording

Adding answers to a Research Output question

Screen.Recording.2026-01-02.at.8.55.13.AM.mov

…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
…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
…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}
Copy link
Collaborator Author

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';
Copy link
Collaborator Author

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";
Copy link
Collaborator Author

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:
Copy link
Collaborator Author

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';
Copy link
Collaborator Author

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";

Copy link
Collaborator Author

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";
Copy link
Collaborator Author

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 */}
Copy link
Collaborator Author

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.

@jupiter007 jupiter007 changed the base branch from main to development January 2, 2026 17:11
OutputTypeInterface,
StandardField,
RepositoryInterface,
MetaDataStandardInterface,
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 this to shared useResearchOutTable hook

'use client'

import { useState } from 'react';
import { useState, useCallback, useMemo } from 'react';
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 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;
Copy link
Collaborator Author

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",
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 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'

Copy link
Collaborator Author

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";
Copy link
Collaborator Author

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",
Copy link
Collaborator Author

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
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 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,
Copy link
Collaborator Author

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,
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 many research output helper functions into one utility

@jupiter007 jupiter007 requested review from briri and sfisher January 2, 2026 17:28
@jupiter007 jupiter007 marked this pull request as draft January 5, 2026 16:54
@jupiter007
Copy link
Collaborator Author

Switching to Draft because I just noticed a weird issue with the form not saving

@jupiter007
Copy link
Collaborator Author

Actually, I'm reopening. I can't save any answers for any question type

@jupiter007 jupiter007 marked this pull request as ready for review January 5, 2026 17:04
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 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 --' },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good idea!

@jupiter007 jupiter007 merged commit e61fcb3 into development Jan 5, 2026
@jupiter007 jupiter007 deleted the feature/787/JS-with-changes-for-new-dmptools-version branch January 6, 2026 23:20
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.

3 participants