This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
forked from XGovFormBuilder/digital-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into FS-4382-duplicate-heading-upload-quotes-othe…
…r-costs-v1
- Loading branch information
Showing
11 changed files
with
146 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
designer/client/components/FieldEditors/__tests__/website-field-edit.jest.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { WebsiteFieldEdit } from "../website-field-edit"; | ||
import { RenderWithContext } from "../../../__tests__/helpers/renderers"; | ||
|
||
describe("Website field edit", () => { | ||
describe("Website field edit fields", () => { | ||
let stateProps; | ||
let textFieldEditPage; | ||
|
||
beforeEach(() => { | ||
stateProps = { | ||
component: { | ||
type: "websiteFieldEdit", | ||
name: "websiteFieldEditClass", | ||
options: {}, | ||
}, | ||
}; | ||
|
||
textFieldEditPage = render( | ||
<RenderWithContext stateProps={stateProps}> | ||
<WebsiteFieldEdit /> | ||
</RenderWithContext> | ||
); | ||
}); | ||
|
||
test("should display prefix help text ", () => { | ||
const text = "Specifies the prefix of the field."; | ||
expect(textFieldEditPage.getByText(text)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
designer/client/components/FieldEditors/website-field-edit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useContext } from "react"; | ||
import { ComponentContext } from "../../reducers/component/componentReducer"; | ||
import { Actions } from "../../reducers/component/types"; | ||
|
||
import { CssClasses } from "../CssClasses"; | ||
import { i18n } from "../../i18n"; | ||
|
||
type Props = { | ||
context: any; // TODO | ||
}; | ||
|
||
export function WebsiteFieldEdit({ context = ComponentContext }: Props) { | ||
// If you are editing a component, the default context will be ComponentContext because props.context is undefined, | ||
// but if you editing a component which is a children of a list based component, then the props.context is the ListContext. | ||
const { state, dispatch } = useContext(context); | ||
const { selectedComponent } = state; | ||
const { options = {} } = selectedComponent; | ||
|
||
return ( | ||
<details className="govuk-details"> | ||
<summary className="govuk-details__summary"> | ||
<span className="govuk-details__summary-text"> | ||
{i18n("common.detailsLink.title")} | ||
</span> | ||
</summary> | ||
|
||
<div className="govuk-form-group"> | ||
<label | ||
className="govuk-label govuk-label--s" | ||
htmlFor="field-options-prefix" | ||
> | ||
{i18n("websiteFieldEditComponent.prefixField.title")} | ||
</label> | ||
<span className="govuk-hint"> | ||
{i18n("websiteFieldEditComponent.prefixField.helpText")} | ||
</span> | ||
<input | ||
className="govuk-input govuk-input--width-3" | ||
data-cast="string" | ||
id="field-options-prefix" | ||
name="opions.prefix" | ||
value={options.prefix} | ||
type="string" | ||
onBlur={(e) => | ||
dispatch({ | ||
type: Actions.EDIT_OPTIONS_PREFIX, | ||
payload: e.target.value, | ||
}) | ||
} | ||
/> | ||
</div> | ||
|
||
<CssClasses /> | ||
</details> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION=0.1.265 | ||
VERSION=0.1.265 |