From 27af96fe3a78ce19d3cde02dbbc156cb308fb47d Mon Sep 17 00:00:00 2001 From: SeinopSys Date: Thu, 30 Sep 2021 23:56:38 +0200 Subject: [PATCH] unrequire editor fields that weren't previously required --- lib/philomena_web/templates/image/new.html.slime | 2 +- lib/philomena_web/templates/markdown/_input.html.slime | 2 +- .../templates/profile/description/edit.html.slime | 2 +- lib/philomena_web/templates/profile/scratchpad/edit.html.slime | 2 +- lib/philomena_web/templates/report/new.html.slime | 2 +- lib/philomena_web/views/markdown_view.ex | 3 +++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/philomena_web/templates/image/new.html.slime b/lib/philomena_web/templates/image/new.html.slime index dcb0d3de..dd5fef2e 100644 --- a/lib/philomena_web/templates/image/new.html.slime +++ b/lib/philomena_web/templates/image/new.html.slime @@ -65,7 +65,7 @@ .field .block .communication-edit__wrap - = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_icon: "pencil-alt", action_text: "Description", placeholder: "Describe this image in plain words - this should generally be info about the image that doesn't belong in the tags or source." + = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_icon: "pencil-alt", action_text: "Description", placeholder: "Describe this image in plain words - this should generally be info about the image that doesn't belong in the tags or source.", required: false = render PhilomenaWeb.MarkdownView, "_anon_checkbox.html", conn: @conn, f: f, label: "Post anonymously" diff --git a/lib/philomena_web/templates/markdown/_input.html.slime b/lib/philomena_web/templates/markdown/_input.html.slime index 96f10bb7..72b1182a 100644 --- a/lib/philomena_web/templates/markdown/_input.html.slime +++ b/lib/philomena_web/templates/markdown/_input.html.slime @@ -18,7 +18,7 @@ = render PhilomenaWeb.MarkdownView, "_toolbar.html", conn: @conn .field - = textarea form, field_name, class: "input input--wide input--text input--resize-vertical js-toolbar-input js-preview-input", placeholder: field_placeholder, required: true + = textarea form, field_name, class: "input input--wide input--text input--resize-vertical js-toolbar-input js-preview-input", placeholder: field_placeholder, required: required?(@conn) = error_tag form, field_name .block__tab.communication-edit__tab.hidden.js-preview-content data-tab="preview" diff --git a/lib/philomena_web/templates/profile/description/edit.html.slime b/lib/philomena_web/templates/profile/description/edit.html.slime index 6820bd0a..bc09393a 100644 --- a/lib/philomena_web/templates/profile/description/edit.html.slime +++ b/lib/philomena_web/templates/profile/description/edit.html.slime @@ -15,7 +15,7 @@ h1 Updating Profile Description .block div - = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_text: "About Me", placeholder: "Description (up to 10000 characters)", name: :description + = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_text: "About Me", placeholder: "Description (up to 10000 characters)", name: :description, required: false .block__content.communication-edit__actions => submit "Update", class: "button" diff --git a/lib/philomena_web/templates/profile/scratchpad/edit.html.slime b/lib/philomena_web/templates/profile/scratchpad/edit.html.slime index e458fa25..bb4ca474 100644 --- a/lib/philomena_web/templates/profile/scratchpad/edit.html.slime +++ b/lib/philomena_web/templates/profile/scratchpad/edit.html.slime @@ -6,7 +6,7 @@ h1 Updating Moderation Scratchpad p Oops, something went wrong! Please check the errors below. .block div - = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_text: "Scratchpad", placeholder: "Scratchpad Contents", name: :scratchpad + = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_text: "Scratchpad", placeholder: "Scratchpad Contents", name: :scratchpad, required: false .block__content.communication-edit__actions => submit "Update", class: "button" diff --git a/lib/philomena_web/templates/report/new.html.slime b/lib/philomena_web/templates/report/new.html.slime index eb90739d..15f2a32a 100644 --- a/lib/philomena_web/templates/report/new.html.slime +++ b/lib/philomena_web/templates/report/new.html.slime @@ -45,7 +45,7 @@ p .field = select f, :category, report_categories(), class: "input" .block - = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, placeholder: "Provide anything else we should know here.", name: :reason + = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, placeholder: "Provide anything else we should know here.", name: :reason, required: false = render PhilomenaWeb.CaptchaView, "_captcha.html", name: "report", conn: @conn diff --git a/lib/philomena_web/views/markdown_view.ex b/lib/philomena_web/views/markdown_view.ex index f3d15437..95996133 100644 --- a/lib/philomena_web/views/markdown_view.ex +++ b/lib/philomena_web/views/markdown_view.ex @@ -4,4 +4,7 @@ defmodule PhilomenaWeb.MarkdownView do def anonymous_by_default?(conn) do conn.assigns.current_user.anonymous_by_default end + + def required?(%{assigns: %{required: false}}), do: nil + def required?(_), do: true end