Fix input length validation for polls

This commit is contained in:
Alex
2024-07-27 15:48:48 +02:00
parent d40f3ad261
commit f1b732f450
5 changed files with 8 additions and 1 deletions

1
.gitignore vendored
View File

@@ -42,3 +42,4 @@ test/e2e/node_modules
.DS_Store .DS_Store
priv/static/.well-known/apple-developer-merchantid-domain-association priv/static/.well-known/apple-developer-merchantid-domain-association
priv/static/loaderio-eb3b956a176cdd4f54eb8570ce8bbb06.txt priv/static/loaderio-eb3b956a176cdd4f54eb8570ce8bbb06.txt
.elixir_ls

View File

@@ -5,6 +5,10 @@
- LTI 1.3 support - LTI 1.3 support
- New layout for presentation manager - New layout for presentation manager
### Fixes and improvements
- Fix input length validation for polls
## v2.0.1 ## v2.0.1
### Features ### Features

View File

@@ -37,5 +37,6 @@ defmodule Claper.Polls.Poll do
|> cast(attrs, [:title, :presentation_file_id, :position, :enabled, :total, :multiple]) |> cast(attrs, [:title, :presentation_file_id, :position, :enabled, :total, :multiple])
|> cast_assoc(:poll_opts, required: true) |> cast_assoc(:poll_opts, required: true)
|> validate_required([:title, :presentation_file_id, :position]) |> validate_required([:title, :presentation_file_id, :position])
|> validate_length(:title, max: 255)
end end
end end

View File

@@ -31,5 +31,6 @@ defmodule Claper.Polls.PollOpt do
poll_opt poll_opt
|> cast(attrs, [:content, :vote_count, :poll_id]) |> cast(attrs, [:content, :vote_count, :poll_id])
|> validate_required([:content]) |> validate_required([:content])
|> validate_length(:content, max: 255)
end end
end end

View File

@@ -26,7 +26,7 @@
<%= inputs_for f, :poll_opts, fn i -> %> <%= inputs_for f, :poll_opts, fn i -> %>
<div class="flex space-x-3 mt-3 items-center justify-start"> <div class="flex space-x-3 mt-3 items-center justify-start">
<div> <div class="flex-1">
<ClaperWeb.Component.Input.text <ClaperWeb.Component.Input.text
form={i} form={i}
labelClass={if @dark, do: "text-white"} labelClass={if @dark, do: "text-white"}