mirror of
https://github.com/ClaperCo/Claper.git
synced 2025-12-17 04:17:59 +01:00
Fix scroll on mobile + minor fix form management
This commit is contained in:
@@ -3,9 +3,10 @@
|
|||||||
- Add ARM Docker image
|
- Add ARM Docker image
|
||||||
- Refactor all runtime configuration
|
- Refactor all runtime configuration
|
||||||
- Improve local storage with PRESENTATION_STORAGE_DIR environment variable
|
- Improve local storage with PRESENTATION_STORAGE_DIR environment variable
|
||||||
- Fix poll panel scroll on mobile
|
- Fix poll/form panel scroll on mobile
|
||||||
- Fix message length validation
|
- Fix message length validation
|
||||||
- Fix message word break
|
- Fix message word break
|
||||||
|
- Minor fixes on form management
|
||||||
|
|
||||||
## v1.5.0
|
## v1.5.0
|
||||||
|
|
||||||
|
|||||||
@@ -484,19 +484,6 @@ window.addEventListener("phx:page-loading-stop", info => {
|
|||||||
topbar.hide()
|
topbar.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Used to fix the scroll issue on mobile on poll panel
|
|
||||||
window.addEventListener("claper:toggle-poll", (event) => {
|
|
||||||
let extended = document.getElementById("extended-poll")
|
|
||||||
let parent = document.getElementById("poll-wrapper-parent")
|
|
||||||
if (extended.style.display == "block") {
|
|
||||||
parent.classList.add("overflow-y-auto")
|
|
||||||
parent.classList.add("h-full")
|
|
||||||
} else {
|
|
||||||
parent.classList.remove("overflow-y-auto")
|
|
||||||
parent.classList.remove("h-full")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const renderOnlineUsers = function(presences) {
|
const renderOnlineUsers = function(presences) {
|
||||||
let onlineUsers = Presence.list(presences, (_id, {metas: [user, ...rest]}) => {
|
let onlineUsers = Presence.list(presences, (_id, {metas: [user, ...rest]}) => {
|
||||||
return onlineUserTemplate(user);
|
return onlineUserTemplate(user);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ defmodule ClaperWeb.EventLive.Manage do
|
|||||||
timeout: 500
|
timeout: 500
|
||||||
})
|
})
|
||||||
|> poll_at_position(false)
|
|> poll_at_position(false)
|
||||||
|
|> form_at_position(false)
|
||||||
|
|
||||||
{:ok, socket, temporary_assigns: [posts: [], form_submits: []]}
|
{:ok, socket, temporary_assigns: [posts: [], form_submits: []]}
|
||||||
end
|
end
|
||||||
@@ -157,7 +158,8 @@ defmodule ClaperWeb.EventLive.Manage do
|
|||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:state, new_state)
|
|> assign(:state, new_state)
|
||||||
|> poll_at_position}
|
|> poll_at_position
|
||||||
|
|> form_at_position}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -493,6 +495,27 @@ defmodule ClaperWeb.EventLive.Manage do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp form_at_position(
|
||||||
|
%{assigns: %{event: event, state: state}} = socket,
|
||||||
|
broadcast \\ true
|
||||||
|
) do
|
||||||
|
with form <-
|
||||||
|
Claper.Forms.get_form_current_position(
|
||||||
|
event.presentation_file.id,
|
||||||
|
state.position
|
||||||
|
) do
|
||||||
|
if broadcast do
|
||||||
|
Phoenix.PubSub.broadcast(
|
||||||
|
Claper.PubSub,
|
||||||
|
"event:#{event.uuid}",
|
||||||
|
{:current_form, form}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
socket |> assign(:current_form, form)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp ban(user, %{assigns: %{event: event, state: state}} = socket) do
|
defp ban(user, %{assigns: %{event: event, state: state}} = socket) do
|
||||||
{:ok, new_state} =
|
{:ok, new_state} =
|
||||||
Claper.Presentations.update_presentation_state(state, %{
|
Claper.Presentations.update_presentation_state(state, %{
|
||||||
|
|||||||
@@ -714,7 +714,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<div
|
<div
|
||||||
id="form-list"
|
id="form-list"
|
||||||
class={"overflow-y-auto #{if Enum.count(@form_submits) > 0, do: 'max-h-full'} pb-5 px-5"}
|
class={"overflow-y-auto #{if Enum.count(@form_submits) > 0, do: 'max-h-full'} pb-5 pt-8 px-5"}
|
||||||
phx-update="append"
|
phx-update="append"
|
||||||
data-forms-nb={Enum.count(@form_submits)}
|
data-forms-nb={Enum.count(@form_submits)}
|
||||||
phx-hook="ScrollIntoDiv"
|
phx-hook="ScrollIntoDiv"
|
||||||
|
|||||||
@@ -134,6 +134,5 @@ defmodule ClaperWeb.EventLive.PollComponent do
|
|||||||
in: "animate__animated animate__zoomIn",
|
in: "animate__animated animate__zoomIn",
|
||||||
to: "#extended-poll"
|
to: "#extended-poll"
|
||||||
)
|
)
|
||||||
|> JS.dispatch("claper:toggle-poll", to: "#poll-wrapper-parent")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ defmodule ClaperWeb.EventLive.Presenter do
|
|||||||
|> assign(:posts, list_posts(socket, event.uuid))
|
|> assign(:posts, list_posts(socket, event.uuid))
|
||||||
|> assign(:reacts, [])
|
|> assign(:reacts, [])
|
||||||
|> poll_at_position
|
|> poll_at_position
|
||||||
|
|> form_at_position
|
||||||
|
|
||||||
{:ok, socket, temporary_assigns: [posts: []]}
|
{:ok, socket, temporary_assigns: [posts: []]}
|
||||||
end
|
end
|
||||||
@@ -201,6 +202,16 @@ defmodule ClaperWeb.EventLive.Presenter do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp form_at_position(%{assigns: %{event: event, state: state}} = socket) do
|
||||||
|
with form <-
|
||||||
|
Claper.Forms.get_form_current_position(
|
||||||
|
event.presentation_file.id,
|
||||||
|
state.position
|
||||||
|
) do
|
||||||
|
socket |> assign(:current_form, form)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp list_posts(_socket, event_id) do
|
defp list_posts(_socket, event_id) do
|
||||||
Claper.Posts.list_posts(event_id, [:event, :reactions])
|
Claper.Posts.list_posts(event_id, [:event, :reactions])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<%= if @current_poll do %>
|
<%= if @current_poll do %>
|
||||||
<div
|
<div
|
||||||
id="poll-wrapper-parent"
|
id="poll-wrapper-parent"
|
||||||
class="animate__animated animate__zoomInDown w-full lg:w-1/3 lg:mx-auto fixed top-16 z-10 px-2 lg:px-7 pb-6 h-full overflow-y-auto"
|
class="animate__animated animate__zoomInDown w-full lg:w-1/3 lg:mx-auto fixed top-16 z-10 px-2 lg:px-7 pb-6 max-h-screen overflow-y-auto"
|
||||||
>
|
>
|
||||||
<div class="transition-all" id="poll-wrapper">
|
<div class="transition-all" id="poll-wrapper">
|
||||||
<.live_component
|
<.live_component
|
||||||
@@ -70,7 +70,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= if @current_form do %>
|
<%= if @current_form do %>
|
||||||
<div class="animate__animated animate__zoomInDown w-full lg:w-1/3 lg:mx-auto fixed top-16 z-10 px-2 lg:px-7">
|
<div
|
||||||
|
id="form-wrapper-parent"
|
||||||
|
class="animate__animated animate__zoomInDown w-full lg:w-1/3 lg:mx-auto fixed top-16 z-10 px-2 pb-6 lg:px-7 max-h-screen overflow-y-auto"
|
||||||
|
>
|
||||||
<div class="transition-all" id="form-wrapper">
|
<div class="transition-all" id="form-wrapper">
|
||||||
<.live_component
|
<.live_component
|
||||||
module={ClaperWeb.EventLive.FormComponent}
|
module={ClaperWeb.EventLive.FormComponent}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ defmodule ClaperWeb.FormLive.FormComponent do
|
|||||||
form_params
|
form_params
|
||||||
|> Map.put("presentation_file_id", socket.assigns.presentation_file.id)
|
|> Map.put("presentation_file_id", socket.assigns.presentation_file.id)
|
||||||
|> Map.put("position", socket.assigns.position)
|
|> Map.put("position", socket.assigns.position)
|
||||||
|> maybe_enable(socket)
|
|> Map.put("enabled", false)
|
||||||
) do
|
) do
|
||||||
{:ok, form} ->
|
{:ok, form} ->
|
||||||
{:noreply,
|
{:noreply,
|
||||||
@@ -104,14 +104,6 @@ defmodule ClaperWeb.FormLive.FormComponent do
|
|||||||
|
|
||||||
defp maybe_change_current_form(socket, _), do: socket
|
defp maybe_change_current_form(socket, _), do: socket
|
||||||
|
|
||||||
defp maybe_enable(form_params, socket) do
|
|
||||||
has_current_form =
|
|
||||||
socket.assigns.forms
|
|
||||||
|> Enum.count(fn f -> f.position == socket.assigns.position && f.enabled == true end) > 0
|
|
||||||
|
|
||||||
form_params |> Map.put("enabled", !has_current_form)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp list_forms(assigns) do
|
defp list_forms(assigns) do
|
||||||
Forms.list_forms(assigns.presentation_file.id)
|
Forms.list_forms(assigns.presentation_file.id)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ defmodule ClaperWeb.PollLive.FormComponent do
|
|||||||
poll_params
|
poll_params
|
||||||
|> Map.put("presentation_file_id", socket.assigns.presentation_file.id)
|
|> Map.put("presentation_file_id", socket.assigns.presentation_file.id)
|
||||||
|> Map.put("position", socket.assigns.position)
|
|> Map.put("position", socket.assigns.position)
|
||||||
|> maybe_enable(socket)
|
|> Map.put("enabled", false)
|
||||||
) do
|
) do
|
||||||
{:ok, poll} ->
|
{:ok, poll} ->
|
||||||
{:noreply,
|
{:noreply,
|
||||||
@@ -104,14 +104,6 @@ defmodule ClaperWeb.PollLive.FormComponent do
|
|||||||
|
|
||||||
defp maybe_change_current_poll(socket, _), do: socket
|
defp maybe_change_current_poll(socket, _), do: socket
|
||||||
|
|
||||||
defp maybe_enable(poll_params, socket) do
|
|
||||||
has_current_poll =
|
|
||||||
socket.assigns.polls
|
|
||||||
|> Enum.count(fn p -> p.position == socket.assigns.position && p.enabled == true end) > 0
|
|
||||||
|
|
||||||
poll_params |> Map.put("enabled", !has_current_poll)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp list_polls(assigns) do
|
defp list_polls(assigns) do
|
||||||
Polls.list_polls(assigns.presentation_file.id)
|
Polls.list_polls(assigns.presentation_file.id)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user