Skip to content

Commit

Permalink
Support hydrated FormRowTextList
Browse files Browse the repository at this point in the history
This is needed to be able to use the component in our TT forms
until all forms are converted (and makes it easier to test
without having to fully convert the entity editors to React).
  • Loading branch information
reosarevok committed Sep 5, 2024
1 parent 3d5ebcc commit 1321c97
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions root/server/components.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export default {
'static/scripts/common/components/WarningIcon': (): Promise<mixed> => import('../static/scripts/common/components/WarningIcon.js'),
'static/scripts/edit/components/AddIcon': (): Promise<mixed> => import('../static/scripts/edit/components/AddIcon.js'),
'static/scripts/edit/components/FormRowNameWithGuessCase': (): Promise<mixed> => import('../static/scripts/edit/components/FormRowNameWithGuessCase.js'),
'static/scripts/edit/components/FormRowTextList': (): Promise<mixed> => import('../static/scripts/edit/components/FormRowTextList.js'),
'static/scripts/edit/components/GuessCaseIcon': (): Promise<mixed> => import('../static/scripts/edit/components/GuessCaseIcon.js'),
'static/scripts/edit/components/InformationIcon': (): Promise<mixed> => import('../static/scripts/edit/components/InformationIcon.js'),
'static/scripts/recording/RecordingName': (): Promise<mixed> => import('../static/scripts/recording/RecordingName.js'),
Expand Down
1 change: 1 addition & 0 deletions root/static/scripts/area/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import typeBubble from '../edit/typeBubble.js';
import '../edit/components/FormRowTextList.js';

const typeIdField = 'select[name=edit-area\\.type_id]';
typeBubble(typeIdField);
4 changes: 3 additions & 1 deletion root/static/scripts/edit/components/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

component FormRow(
children: React.Node,
className as passedClassname?: string,
hasNoLabel: boolean = false,
hasNoMargin: boolean = false,
rowRef?: {-current: HTMLDivElement | null},
Expand All @@ -18,7 +19,8 @@ component FormRow(
className={
'row' +
(hasNoLabel ? ' no-label' : '') +
(hasNoMargin ? ' no-margin' : '')
(hasNoMargin ? ' no-margin' : '') +
(nonEmpty(passedClassname) ? ' ' + passedClassname : '')
}
ref={rowRef}
>
Expand Down
21 changes: 19 additions & 2 deletions root/static/scripts/edit/components/FormRowTextList.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ component FormRowTextList(
};

return (
<FormRow>
<>
<FormLabel forField={repeatable} label={label} required={required} />

<div className="form-row-text-list">
Expand All @@ -132,8 +132,25 @@ component FormRowTextList(
</div>

<FieldErrors field={repeatable} />
</>
);
}

export component NonHydratedFormRowTextList(
...props: React.PropsOf<FormRowTextList>
) {
return (
<FormRow className="form-row-text-list-container">
<FormRowTextList {...props} />
</FormRow>
);
}

export default FormRowTextList;
/*
* Hydration must be moved higher up in the component hierarchy once
* more of the page is converted to React.
*/
export default (hydrate<React.PropsOf<FormRowTextList>>(
'div.row.form-row-text-list-container',
FormRowTextList,
): React.AbstractComponent<React.PropsOf<FormRowTextList>, void>);
1 change: 1 addition & 0 deletions webpack/client.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const entries = [
'common/components/WorkArtists',
'confirm-seed',
'edit',
'edit/components/FormRowTextList',
'edit/components/NewNotesAlertCheckbox',
'event/components/EventEditForm',
'event/edit',
Expand Down

0 comments on commit 1321c97

Please sign in to comment.