diff --git a/app/http/endpoints/api/forms/createinput.go b/app/http/endpoints/api/forms/createinput.go
index ded425d..a6b1581 100644
--- a/app/http/endpoints/api/forms/createinput.go
+++ b/app/http/endpoints/api/forms/createinput.go
@@ -13,6 +13,7 @@ type inputCreateBody struct {
Style component.TextStyleTypes `json:"style"`
Label string `json:"label"`
Placeholder *string `json:"placeholder"`
+ Optional bool `json:"optional"`
}
func CreateInput(ctx *gin.Context) {
@@ -69,11 +70,11 @@ func CreateInput(ctx *gin.Context) {
// 2^30 chance of collision
customId := utils.RandString(30)
- formInputId, err := dbclient.Client.FormInput.Create(formId, customId, uint8(data.Style), data.Label, data.Placeholder)
+ formInputId, err := dbclient.Client.FormInput.Create(formId, customId, uint8(data.Style), data.Label, data.Placeholder, !data.Optional)
if err != nil {
- ctx.JSON(500, utils.ErrorJson(err))
- return
- }
+ ctx.JSON(500, utils.ErrorJson(err))
+ return
+ }
ctx.JSON(200, database.FormInput{
Id: formInputId,
@@ -82,13 +83,14 @@ func CreateInput(ctx *gin.Context) {
Style: uint8(data.Style),
Label: data.Label,
Placeholder: data.Placeholder,
+ Required: !data.Optional,
})
}
func (b *inputCreateBody) Validate(ctx *gin.Context) bool {
if b.Style != component.TextStyleShort && b.Style != component.TextStyleParagraph {
ctx.JSON(400, utils.ErrorStr("Invalid style"))
- return false
+ return false
}
if len(b.Label) == 0 || len(b.Label) > 45 {
@@ -115,5 +117,5 @@ func getFormInputCount(formId int) (int, error) {
return 0, err
}
- return len(inputs), nil
+ return len(inputs), nil
}
diff --git a/app/http/endpoints/api/forms/updateinput.go b/app/http/endpoints/api/forms/updateinput.go
index 9a3927a..066d9d9 100644
--- a/app/http/endpoints/api/forms/updateinput.go
+++ b/app/http/endpoints/api/forms/updateinput.go
@@ -72,6 +72,7 @@ func UpdateInput(ctx *gin.Context) {
Style: uint8(data.Style),
Label: data.Label,
Placeholder: data.Placeholder,
+ Required: !data.Optional,
}
if err := dbclient.Client.FormInput.Update(newInput); err != nil {
diff --git a/frontend/src/components/form/Textarea.svelte b/frontend/src/components/form/Textarea.svelte
index 3f593b4..82525aa 100644
--- a/frontend/src/components/form/Textarea.svelte
+++ b/frontend/src/components/form/Textarea.svelte
@@ -1,4 +1,4 @@
-
+
@@ -14,11 +14,13 @@
export let col4 = false;
export let col3_4 = false;
+
+ export let minHeight = "100px";
\ No newline at end of file
diff --git a/frontend/src/components/manage/FormInputRow.svelte b/frontend/src/components/manage/FormInputRow.svelte
index 54773b8..3cb8b59 100644
--- a/frontend/src/components/manage/FormInputRow.svelte
+++ b/frontend/src/components/manage/FormInputRow.svelte
@@ -19,12 +19,19 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
{#if windowWidth <= 950}
@@ -59,6 +66,7 @@
import Dropdown from "../form/Dropdown.svelte";
import Button from "../Button.svelte";
import Textarea from "../form/Textarea.svelte";
+ import Checkbox from "../form/Checkbox.svelte";
export let withCreateButton = false;
export let withSaveButton = false;
diff --git a/frontend/src/views/Forms.svelte b/frontend/src/views/Forms.svelte
index f4d7845..203be88 100644
--- a/frontend/src/views/Forms.svelte
+++ b/frontend/src/views/Forms.svelte
@@ -146,6 +146,7 @@
async function editInput(formId, inputId, data) {
let mapped = {...data, style: parseInt(data.style)};
+ console.log(mapped);
const res = await axios.patch(`${API_URL}/api/${guildId}/forms/${formId}/${inputId}`, mapped);
if (res.status !== 200) {
@@ -183,6 +184,11 @@
}
forms = res.data || [];
+ forms.flatMap(f => f.inputs).forEach(i => i.optional = !i.required);
+
+ if (forms.length > 0) {
+ activeFormId = forms[0].form_id;
+ }
}
withLoadingScreen(async () => {
diff --git a/go.mod b/go.mod
index a676114..5ab7c10 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
github.com/TicketsBot/common v0.0.0-20220311020409-8068ba1c2ea3
- github.com/TicketsBot/database v0.0.0-20220217133004-d190910ad66f
+ github.com/TicketsBot/database v0.0.0-20220531134243-da3320960cd4
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
github.com/TicketsBot/worker v0.0.0-20220411233045-a69c2a4c8b30
github.com/apex/log v1.1.2
diff --git a/go.sum b/go.sum
index c8c7e46..727f0d8 100644
--- a/go.sum
+++ b/go.sum
@@ -13,14 +13,13 @@ github.com/TicketsBot/common v0.0.0-20220311020409-8068ba1c2ea3 h1:wcmBzDWg68gum
github.com/TicketsBot/common v0.0.0-20220311020409-8068ba1c2ea3/go.mod h1:SVwX6gKkxRCMbp+qwJIgvQiy/Ut0fUddexEqRB/NTzc=
github.com/TicketsBot/database v0.0.0-20200516170158-fd8a949aec2c/go.mod h1:eky4tBL+IZ0svPgTT0N/9i6j7ygHDQH3784DW+HgfcA=
github.com/TicketsBot/database v0.0.0-20210902172951-4e1f8ced84b7/go.mod h1:A4T2uQFIWC/ttCYpfgv7AkPjR09mMRgzG13lgoV/+aI=
-github.com/TicketsBot/database v0.0.0-20220217133004-d190910ad66f h1:kBIHaAxyIGqxgwz/ZRggNGjyIdZ3ctWZqjJ9Svrn4L4=
github.com/TicketsBot/database v0.0.0-20220217133004-d190910ad66f/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
+github.com/TicketsBot/database v0.0.0-20220531134243-da3320960cd4 h1:x8MkiL+E4w61otY7dJUSXTrqm0SqgsJbH8lovkSgZHk=
+github.com/TicketsBot/database v0.0.0-20220531134243-da3320960cd4/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=
-github.com/TicketsBot/worker v0.0.0-20220327033131-a7330f793044 h1:6yIgtfOJ9xjeZBgzXJT3B59NUcv75Kq0WDvfGhxW1HE=
-github.com/TicketsBot/worker v0.0.0-20220327033131-a7330f793044/go.mod h1:ljMAQMiB5Gf3jgI9EGugAPAErjh2Ykwx3toD8z33KGY=
github.com/TicketsBot/worker v0.0.0-20220411233045-a69c2a4c8b30 h1:gfW/cIeA1DyH53q96Jqq+gqdIsuzIYYGHljwbHrChWY=
github.com/TicketsBot/worker v0.0.0-20220411233045-a69c2a4c8b30/go.mod h1:ljMAQMiB5Gf3jgI9EGugAPAErjh2Ykwx3toD8z33KGY=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=