Skip to content

Commit

Permalink
Merge pull request #404 from zendesk/luis.organization_field
Browse files Browse the repository at this point in the history
feat: organization field
  • Loading branch information
luis-almeida authored Aug 9, 2023
2 parents a22f075 + 1b63712 commit 9ce5c96
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 59 deletions.
9 changes: 6 additions & 3 deletions assets/new-request-form.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 13 additions & 21 deletions assets/vendor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/modules/new-request-form/NewRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export function NewRequestForm({
onSubmit={handleSubmit}
>
{errors && <Alert type="error">{errors}</Alert>}
<TicketFormField
label={ticket_forms_instructions}
ticketFormField={ticket_form_field}
ticketForms={ticketForms}
/>
{ticketForms.length > 0 && (
<TicketFormField
label={ticket_forms_instructions}
ticketFormField={ticket_form_field}
ticketForms={ticketForms}
/>
)}
{fields.map((field) => {
switch (field.type) {
case "anonymous_requester_email":
Expand All @@ -61,13 +63,14 @@ export function NewRequestForm({
case "textarea":
return <TextArea field={field} />;
case "priority":
case "organization_id":
return <DropDown field={field} />;
default:
return <></>;
}
})}
<Footer>
{ticket_form_field.value && (
{(ticketForms.length === 0 || ticket_form_field.value) && (
<Button isPrimary type="submit">
Submit
</Button>
Expand Down
7 changes: 6 additions & 1 deletion src/modules/new-request-form/fields/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ export function DropDown({ field }: DropDownProps): JSX.Element {
inputProps={{ name, required }}
isEditable={false}
validation={error ? "error" : undefined}
renderValue={({ selection }) =>
selection && "value" in selection
? options.find((option) => option.value === selection.value)?.name
: "-"
}
>
{options.map((option) => (
<Option
key={option.value}
value={option.value}
isSelected={option.value === value}
isSelected={option.value?.toString() === value?.toString()}
>
{option.name}
</Option>
Expand Down
28 changes: 0 additions & 28 deletions templates/new_request_page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,6 @@
</h1>

<div id="main-content" class="form">
{{#with new_request_form}}
<form data-form action="{{action}}" method="{{http_method}}" accept-charset="{{accept_charset}}">
{{#if errors}}
<p>{{errors}}</p>
{{/if}}
<input type="hidden" name="{{ticket_form_field.name}}" value="{{ticket_form_field.value}}">
{{#each fields}}
<div class="form-field {{#if required}} required {{else}} optional {{/if}} {{id}}" {{#is type 'due_at'}} data-due-date hidden {{/is}}>
<label for="{{id}}">{{label}}</label>
{{#is type 'description'}}
{{text_area wysiwyg=true}}
{{else}}
<input type="text" name="{{name}}" id="{{id}}" maxlength="150" size="150">
{{/is}}
{{#if error}}
<div class="notification notification-error notification-inline">{{error}}</div>
{{/if}}
{{#if description}}
<p>{{description}}<p>
{{/if}}
</div>
{{/each}}
<footer>
<input type="submit" value="Submit">
</footer>
</form>
{{/with}}
<hr />
<div id="new-request-form"></div>
</div>
</div>
Expand Down

0 comments on commit 9ce5c96

Please sign in to comment.