Skip to content

Commit 56fba48

Browse files
committed
OT Forms: fix max length issue and provide setting as a new feature
1 parent 58fd44f commit 56fba48

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

open-ticket/ot-ticket-forms/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The `questions` array defines the form's questions. Each question object include
4646
> For questions of type `short` or `long`:
4747
> - **`optional`**: A boolean indicating if the question is optional (`true`) or required (`false`).
4848
> - **`placeholder`**: A text placeholder for the response input (optional).
49+
> - **`maxLength`**: A number to set the max length size of the response (optional, default 1023).
4950
5051
> #### Dropdown-Specific Properties
5152
> For questions of type `dropdown`:
@@ -86,7 +87,8 @@ The `questions` array defines the form's questions. Each question object include
8687
"question": "That's an example of paragraph answer question?",
8788
"type": "long",
8889
"optional": false,
89-
"placeholder": "Multiple lines response, paragraphs allowed. (or leave it empty)"
90+
"placeholder": "Multiple lines response, paragraphs allowed. (or leave it empty)",
91+
"maxLength": 500
9092
},
9193
{
9294
"number": 4,
@@ -122,4 +124,4 @@ The `questions` array defines the form's questions. Each question object include
122124
7. The forms will be sent automatically when a user creates a ticket from which the option id is on the `autoSendOptionIds` field.
123125
8. You can also send a form using the slash command `/form send <form> <channel>`.
124126

125-
By following this structure, you can create robust and flexible forms with the OT plugin.
127+
By following this structure, you can create robust and flexible forms with the OT plugin.

open-ticket/ot-ticket-forms/builders/modalBuilders.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ opendiscord.events.get("onModalBuilderLoad").listen((modals) => {
1919
style:question.type,
2020
required:!question.optional,
2121
placeholder:question.placeholder ? question.placeholder : undefined,
22+
maxLength: question.maxLength ?? 1023,
2223
});
2324
}
2425
})
2526
)
26-
});
27+
});

open-ticket/ot-ticket-forms/config.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"question":"This is an example of a short answer question. You can add as many questions as you want.",
1515
"type":"short",
1616
"optional":false,
17-
"placeholder":"Single line response, no paragraphs allowed. (or leave it empty)"
17+
"placeholder":"Single line response, no paragraphs allowed. (or leave it empty)",
18+
"maxLength": 50
1819
},
1920
{
2021
"position":2,
@@ -84,8 +85,9 @@
8485
"question":"Question Nr1",
8586
"type":"paragraph",
8687
"optional":false,
87-
"placeholder":"the placeholder (or leave it empty)"
88+
"placeholder":"the placeholder (or leave it empty)",
89+
"maxLength": 250
8890
}
8991
]
9092
}
91-
]
93+
]

open-ticket/ot-ticket-forms/types/configDefaults.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface OTForms_ModalQuestion extends OTForms_Question {
5151
type: "short" | "paragraph",
5252
placeholder: string,
5353
optional: boolean,
54+
maxLength: number,
5455
}
5556

5657
/** ## OTForms_Choice `interface`
@@ -80,4 +81,4 @@ export interface OTForms_DropdownChoice extends OTForms_Choice {
8081
*/
8182
export class ODJsonConfig_DefaultForms extends api.ODJsonConfig {
8283
declare data: OTForms_Form[]
83-
}
84+
}

0 commit comments

Comments
 (0)