Loading editor/src/assets/pageContent/injectSpecification.ts +5 −0 Original line number Diff line number Diff line Loading @@ -119,4 +119,9 @@ export const QUESTIONNAIRE_QUESTION_FORM: Form = { tooltip: '', optional: true, }, note: { label: 'Note', tooltip: '', optional: true, }, } editor/src/components/InjectSpecification/QuestionnaireForm/FreeformForm.tsx +20 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ type State< text: string valid: boolean multiline: boolean note?: string update: (id?: number) => Promise<void> }, > = S & ZustandSetterSingle<S> Loading @@ -59,12 +60,13 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ computed((set, get) => ({ text: '', multiline: false, note: '', ...compute(get, state => ({ valid: state.text !== '', })), set: (item, value) => set({ [item]: value }), update: async id => { const { multiline, text } = get() const { multiline, text, note } = get() const relatedMilestones = ( await db.questionnaireMilestones Loading @@ -78,6 +80,7 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ injectInfoId, type: 'free-form', text, note, }, { multiline, Loading @@ -98,6 +101,7 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ state.setState({ text: questionnaireQuestion?.text, multiline: freeformQuestion?.multiline, note: questionnaireQuestion?.note, }) }, [isOpen, state, questionnaireQuestion, freeformQuestion]) Loading Loading @@ -166,6 +170,21 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ questionId={freeformQuestion?.id} injectInfoId={injectInfoId} /> <TooltipLabel label={QUESTIONNAIRE_QUESTION_FORM.note}> <ShallowGetSet store={state} get={({ note }) => note} set={({ set }) => set} > {(note, set) => ( <InputGroup placeholder='Input note' value={note} onChange={e => set('note', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> </DialogBody> <DialogFooter actions={ Loading editor/src/components/InjectSpecification/QuestionnaireForm/QuestionnaireQuestion.tsx +7 −1 Original line number Diff line number Diff line import { Button, ButtonGroup, Card } from '@blueprintjs/core' import { Button, ButtonGroup, Card, Classes } from '@blueprintjs/core' import { notify } from '@inject/shared' import { useLiveQuery } from 'dexie-react-hooks' import { range } from 'lodash' Loading Loading @@ -95,6 +95,9 @@ const QuestionnaireQuestionRadio: FC<QuestionnaireQuestionProps> = ({ </li> ))} </ol> <span className={Classes.TEXT_MUTED} style={{ flexGrow: 1 }}> {questionnaireQuestion.note} </span> </Card> ) } Loading Loading @@ -159,6 +162,9 @@ const QuestionnaireQuestionFreeform: FC<QuestionnaireQuestionProps> = ({ /> </ButtonGroup> </div> <span className={Classes.TEXT_MUTED} style={{ flexGrow: 1 }}> {questionnaireQuestion.note} </span> </Card> ) } Loading editor/src/components/InjectSpecification/QuestionnaireForm/RadioForm.tsx +22 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ type State< customLabels: boolean labels: string valid: boolean note?: string }, > = S & ZustandSetterSingle<S> Loading @@ -61,6 +62,7 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ correct: 0, customLabels: false, labels: '', note: '', ...compute(get, state => ({ valid: state.text !== '' && Loading @@ -78,6 +80,7 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ correct: radioQuestion?.correct, customLabels: !!radioQuestion?.labels, labels: radioQuestion?.labels, note: questionnaireQuestion?.note, }) }, [ isOpen, Loading @@ -86,17 +89,20 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ radioQuestion?.correct, radioQuestion?.labels, questionnaireQuestion?.text, questionnaireQuestion?.note, ]) const handleUpdateButton = useCallback(async () => { try { const { correct, customLabels, text, labels, max } = state.getState() const { correct, customLabels, text, labels, max, note } = state.getState() await updateQuestionnaireQuestion( { id: questionnaireQuestion?.id, injectInfoId, type: 'radio', text, note, }, { max: customLabels ? labels.split(', ').length : max, Loading Loading @@ -213,6 +219,21 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ } </ShallowGet> <TooltipLabel label={QUESTIONNAIRE_QUESTION_FORM.note}> <ShallowGetSet store={state} get={({ note }) => note} set={({ set }) => set} > {(note, set) => ( <InputGroup placeholder='Input note' value={note} onChange={e => set('note', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> {} </DialogBody> <DialogFooter Loading editor/src/indexeddb/types.ts +1 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ export type QuestionnaireQuestion = { text: string injectInfoId: number type: 'free-form' | 'radio' note?: string } export type QuestionnaireQuestionFreeForm = { Loading Loading
editor/src/assets/pageContent/injectSpecification.ts +5 −0 Original line number Diff line number Diff line Loading @@ -119,4 +119,9 @@ export const QUESTIONNAIRE_QUESTION_FORM: Form = { tooltip: '', optional: true, }, note: { label: 'Note', tooltip: '', optional: true, }, }
editor/src/components/InjectSpecification/QuestionnaireForm/FreeformForm.tsx +20 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ type State< text: string valid: boolean multiline: boolean note?: string update: (id?: number) => Promise<void> }, > = S & ZustandSetterSingle<S> Loading @@ -59,12 +60,13 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ computed((set, get) => ({ text: '', multiline: false, note: '', ...compute(get, state => ({ valid: state.text !== '', })), set: (item, value) => set({ [item]: value }), update: async id => { const { multiline, text } = get() const { multiline, text, note } = get() const relatedMilestones = ( await db.questionnaireMilestones Loading @@ -78,6 +80,7 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ injectInfoId, type: 'free-form', text, note, }, { multiline, Loading @@ -98,6 +101,7 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ state.setState({ text: questionnaireQuestion?.text, multiline: freeformQuestion?.multiline, note: questionnaireQuestion?.note, }) }, [isOpen, state, questionnaireQuestion, freeformQuestion]) Loading Loading @@ -166,6 +170,21 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({ questionId={freeformQuestion?.id} injectInfoId={injectInfoId} /> <TooltipLabel label={QUESTIONNAIRE_QUESTION_FORM.note}> <ShallowGetSet store={state} get={({ note }) => note} set={({ set }) => set} > {(note, set) => ( <InputGroup placeholder='Input note' value={note} onChange={e => set('note', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> </DialogBody> <DialogFooter actions={ Loading
editor/src/components/InjectSpecification/QuestionnaireForm/QuestionnaireQuestion.tsx +7 −1 Original line number Diff line number Diff line import { Button, ButtonGroup, Card } from '@blueprintjs/core' import { Button, ButtonGroup, Card, Classes } from '@blueprintjs/core' import { notify } from '@inject/shared' import { useLiveQuery } from 'dexie-react-hooks' import { range } from 'lodash' Loading Loading @@ -95,6 +95,9 @@ const QuestionnaireQuestionRadio: FC<QuestionnaireQuestionProps> = ({ </li> ))} </ol> <span className={Classes.TEXT_MUTED} style={{ flexGrow: 1 }}> {questionnaireQuestion.note} </span> </Card> ) } Loading Loading @@ -159,6 +162,9 @@ const QuestionnaireQuestionFreeform: FC<QuestionnaireQuestionProps> = ({ /> </ButtonGroup> </div> <span className={Classes.TEXT_MUTED} style={{ flexGrow: 1 }}> {questionnaireQuestion.note} </span> </Card> ) } Loading
editor/src/components/InjectSpecification/QuestionnaireForm/RadioForm.tsx +22 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ type State< customLabels: boolean labels: string valid: boolean note?: string }, > = S & ZustandSetterSingle<S> Loading @@ -61,6 +62,7 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ correct: 0, customLabels: false, labels: '', note: '', ...compute(get, state => ({ valid: state.text !== '' && Loading @@ -78,6 +80,7 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ correct: radioQuestion?.correct, customLabels: !!radioQuestion?.labels, labels: radioQuestion?.labels, note: questionnaireQuestion?.note, }) }, [ isOpen, Loading @@ -86,17 +89,20 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ radioQuestion?.correct, radioQuestion?.labels, questionnaireQuestion?.text, questionnaireQuestion?.note, ]) const handleUpdateButton = useCallback(async () => { try { const { correct, customLabels, text, labels, max } = state.getState() const { correct, customLabels, text, labels, max, note } = state.getState() await updateQuestionnaireQuestion( { id: questionnaireQuestion?.id, injectInfoId, type: 'radio', text, note, }, { max: customLabels ? labels.split(', ').length : max, Loading Loading @@ -213,6 +219,21 @@ const RadioForm: FC<QuestionnaireQuestionFormProps> = ({ } </ShallowGet> <TooltipLabel label={QUESTIONNAIRE_QUESTION_FORM.note}> <ShallowGetSet store={state} get={({ note }) => note} set={({ set }) => set} > {(note, set) => ( <InputGroup placeholder='Input note' value={note} onChange={e => set('note', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> {} </DialogBody> <DialogFooter Loading
editor/src/indexeddb/types.ts +1 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ export type QuestionnaireQuestion = { text: string injectInfoId: number type: 'free-form' | 'radio' note?: string } export type QuestionnaireQuestionFreeForm = { Loading