simple form: refactor DText form fields to use SimpleForm.

* Refactors DText form fields to use a custom SimpleForm input instead
  of manually generated html. This fixes it so that DText fields use the
  same markup as normal SimpleForm fields, which lets us apply browser
  maxlength validations to DText input fields.

* Fixes autocomplete for @-mentions only working in comments and forum posts.
  Now @-mention autocomplete works in all DText fields, including dmails.
  Known bug: it applies in artist commentary fields when it shouldn't.
This commit is contained in:
evazion
2020-06-25 15:54:06 -05:00
parent fccdcbe7cc
commit 883856d4af
22 changed files with 75 additions and 77 deletions

View File

@@ -5,7 +5,7 @@
<%= f.input :title, error: false, input_html: { data: { autocomplete: "tag" } }, hint: "Change to rename this wiki page. Update any wikis linking to this page first." %>
<%= f.input :other_names_string, as: :text, input_html: { size: "30x1" }, label: "Other names (#{link_to_wiki "help", "help:translated_tags"})".html_safe, hint: "Names used for this tag on other sites such as Pixiv. Separate with spaces." %>
<%= dtext_field "wiki_page", "body" %>
<%= f.input :body, as: :dtext %>
<% if policy(@wiki_page).can_edit_locked? %>
<%= f.input :is_locked, label: "Locked", hint: "Locked wikis can only be edited by Builders." %>
@@ -14,6 +14,6 @@
<%= f.input :is_deleted, label: "Deleted", hint: "Check to mark this wiki page as deleted." %>
<%= f.submit "Submit" %>
<%= dtext_preview_button "wiki_page", "body" %>
<%= dtext_preview_button "wiki_page_body" %>
<% end %>
</div>

View File

@@ -14,9 +14,9 @@
<%= edit_form_for(@wiki_page) do |f| %>
<%= f.input :title, error: false, input_html: { data: { autocomplete: "tag" } } %>
<%= f.input :other_names_string, as: :text, input_html: { size: "30x1" }, label: "Other names (#{link_to_wiki "help", "help:translated_tags"})".html_safe, hint: "Names used for this tag on other sites such as Pixiv. Separate with spaces." %>
<%= dtext_field "wiki_page", "body" %>
<%= f.input :body, as: :dtext %>
<%= f.submit "Submit" %>
<%= dtext_preview_button "wiki_page", "body" %>
<%= dtext_preview_button "wiki_page_body" %>
<% end %>
<%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %>