fix issues with the image upload description markdown input

This commit is contained in:
SeinopSys 2021-10-01 02:31:25 +02:00
parent b5d9c0fee3
commit a1e848514e
No known key found for this signature in database
GPG key ID: 9BFB053C1BA6C5C4
3 changed files with 8 additions and 3 deletions

View file

@ -65,7 +65,7 @@
.field .field
.block .block
.communication-edit__wrap .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.", required: false = 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.", name: :description, class: "js-image-input", required: false
= render PhilomenaWeb.MarkdownView, "_anon_checkbox.html", conn: @conn, f: f, label: "Post anonymously" = render PhilomenaWeb.MarkdownView, "_anon_checkbox.html", conn: @conn, f: f, label: "Post anonymously"

View file

@ -3,6 +3,8 @@
- action_icon = assigns[:action_icon] || 'edit' - action_icon = assigns[:action_icon] || 'edit'
- field_name = assigns[:name] || :body - field_name = assigns[:name] || :body
- field_placeholder = assigns[:placeholder] || "Your message" - field_placeholder = assigns[:placeholder] || "Your message"
- is_required = assigns[:required]
- input_classes = assigns[:class]
.block__header.block__header--js-tabbed .block__header.block__header--js-tabbed
a.selected href="#" data-click-tab="write" a.selected href="#" data-click-tab="write"
i.fa> class="fa-#{action_icon}" i.fa> class="fa-#{action_icon}"
@ -18,7 +20,7 @@
= render PhilomenaWeb.MarkdownView, "_toolbar.html", conn: @conn = render PhilomenaWeb.MarkdownView, "_toolbar.html", conn: @conn
.field .field
= 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) = textarea form, field_name, class: add_classes("input input--wide input--text input--resize-vertical js-toolbar-input js-preview-input", input_classes), placeholder: field_placeholder, required: required?(is_required)
= error_tag form, field_name = error_tag form, field_name
.block__tab.communication-edit__tab.hidden.js-preview-content data-tab="preview" .block__tab.communication-edit__tab.hidden.js-preview-content data-tab="preview"

View file

@ -5,6 +5,9 @@ defmodule PhilomenaWeb.MarkdownView do
conn.assigns.current_user.anonymous_by_default conn.assigns.current_user.anonymous_by_default
end end
def required?(%{assigns: %{required: false}}), do: nil def required?(required) when required == false, do: nil
def required?(_), do: true def required?(_), do: true
def add_classes(base_classes, new_classes) when is_binary(new_classes), do: "#{base_classes} #{new_classes}"
def add_classes(base_classes, _), do: base_classes
end end