From 3ca4f4f32c1d7a41f72b1b8634d29c4a4307ccb4 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 10 Jan 2020 12:08:28 -0600 Subject: [PATCH] posts: convert post edit form to simple form. --- .../src/styles/common/simple_form.scss | 33 +++++--- app/views/posts/partials/show/_edit.html.erb | 82 ++++++------------- 2 files changed, 47 insertions(+), 68 deletions(-) diff --git a/app/javascript/src/styles/common/simple_form.scss b/app/javascript/src/styles/common/simple_form.scss index 3be79d184..9d39c3a05 100644 --- a/app/javascript/src/styles/common/simple_form.scss +++ b/app/javascript/src/styles/common/simple_form.scss @@ -3,15 +3,27 @@ form.simple_form { margin: 0 0 1em 0; + fieldset.inline-fieldset { + > label { + display: block; + font-weight: bold; + } + + div.input { + display: inline; + margin-right: 2em; + } + } + div.input.boolean { label { display: inline; + font-weight: normal; vertical-align: middle; - margin-left: 0.5em; + } - input { - margin-right: 0.25em; - } + input { + margin-right: 0.25em; } } @@ -45,17 +57,12 @@ form.simple_form { line-height: 1.5em; } - fieldset { - border: none; - display: inline; - margin: 0; - padding: 0; - - label { + &.radio_buttons { + span.radio label { font-weight: normal; - width: auto; - margin-right: 2em; display: inline; + margin: 0 2em 0 0.25em; + vertical-align: middle; } } } diff --git a/app/views/posts/partials/show/_edit.html.erb b/app/views/posts/partials/show/_edit.html.erb index 6c066f890..fa02138e2 100644 --- a/app/views/posts/partials/show/_edit.html.erb +++ b/app/views/posts/partials/show/_edit.html.erb @@ -6,69 +6,40 @@ <%= render "sources/info" %> -<%= form_for(post, :html => {:class => "simple_form", :id => "form"}) do |f| %> +<%= simple_form_for(post, html: { id: "form" }) do |f| %> <%= hidden_field_tag :tags_query, params[:q] %> <%= hidden_field_tag :pool_id, params[:pool_id] %> <%= hidden_field_tag :favgroup_id, params[:favgroup_id] %> - <%= f.hidden_field :old_tag_string, :value => post.tag_string %> - <%= f.hidden_field :old_parent_id, :value => post.parent_id %> - <%= f.hidden_field :old_source, :value => post.source %> - <%= f.hidden_field :old_rating, :value => post.rating %> + <%= f.input :old_tag_string, as: :hidden, input_html: { value: post.tag_string } %> + <%= f.input :old_parent_id, as: :hidden, input_html: { value: post.parent_id } %> + <%= f.input :old_source, as: :hidden, input_html: { value: post.source } %> + <%= f.input :old_rating, as: :hidden, input_html: { value: post.rating } %> -
- <% if post.is_rating_locked? %> - This post is rating locked. - <% else %> - <%= f.label :blank, "Rating" %> - -
- <%= f.radio_button :rating, :e %> - <%= f.label :rating_e, "Explicit" %> - - <%= f.radio_button :rating, :q %> - <%= f.label :rating_q, "Questionable" %> - - <%= f.radio_button :rating, :s %> - <%= f.label :rating_s, "Safe" %> -
- <% end %> -
- - <% unless post.is_note_locked? %> -
- <%= f.label :has_embedded_notes, "Embed notes" %> - <%= f.check_box :has_embedded_notes %> -
+ <% if post.is_rating_locked? %> + This post is rating locked. + <% else %> + <%= f.input :rating, collection: [["Explicit", "e"], ["Questionable", "q"], ["Safe", "s"]], as: :radio_buttons, boolean_style: :inline %> <% end %> +
+ + <%= f.input :has_embedded_notes, label: "Embed notes", as: :boolean, boolean_style: :inline, disabled: post.is_note_locked? %> +
+ <% if CurrentUser.is_builder? %> -
- <%= f.label :blank, "Lock" %> +
+ -
- <%= f.check_box :is_note_locked %> - <%= f.label :is_note_locked, "Notes" %> - - <%= f.check_box :is_rating_locked %> - <%= f.label :is_rating_locked, "Rating" %> - - <% if CurrentUser.is_admin? %> - <%= f.check_box :is_status_locked %> - <%= f.label :is_status_locked, "Status" %> - <% end %> -
-
+ <%= f.input :is_rating_locked, label: "Rating", as: :boolean, boolean_style: :inline %> + <%= f.input :is_note_locked, label: "Notes", as: :boolean, boolean_style: :inline %> + <% if CurrentUser.is_admin? %> + <%= f.input :is_status_locked, label: "Status", as: :boolean, boolean_style: :inline %> + <% end %> + <% end %> -
- <%= f.label :parent_id, "Parent" %> - <%= f.text_field :parent_id, size: 60 %> -
- -
- <%= f.label :source %> - <%= f.text_field :source, size: 60 %> -
+ <%= f.input :parent_id, label: "Parent", input_html: { size: 60 }, as: :string %> + <%= f.input :source, input_html: { size: 60 } %>
@@ -82,13 +53,14 @@
- <%= f.text_area :tag_string, :size => "60x5", :spellcheck => false, :"data-autocomplete" => "tag-edit", :"data-shortcut" => "e", :value => post.presenter.split_tag_list_text + " " %> + <%= f.input :tag_string, label: false, input_html: { size: "60x5", spellcheck: false, "data-autocomplete": "tag-edit", "data-shortcut": "e", value: post.presenter.split_tag_list_text + " " } %>
+ <%= render "related_tags/buttons" %>
- <%= submit_tag "Submit", :class => "ui-button ui-widget ui-corner-all" %> + <%= f.submit "Submit" %>
<%= render "related_tags/container" %>