sudara/alonetone

View on GitHub
app/views/assets/_comment.html.erb

Summary

Maintainability
Test Coverage
 <div class="comment_asset" data-controller="comment">
  <div class="comment_form" data-comment-target="div">
    <%= form_with scope: :comment, url: user_track_comments_path(asset.user, asset),
      data: { action: 'comment#startSpinner turbo:submit-end->comment#displayResult' } do |f| %>

    <div class="comment_as" data-comment-target="personalization">
        <!-- will be replaced by js payload to allow caching -->
    </div>

    <%= f.text_area :body, rows:4, class: 'double_trouble', data: { 'comment-target': 'textarea' } , id: "comment_body_#{asset.unique_id}"  %>

    <span class="private private_warning hidden" data-comment-target="banner">
      Only <span class="only_user_name"><%= asset.user.name%></span> and <span class="only_alonetone_mods">alonetone mods</span> will see this
    </span>

    <div class="private_check_box">
      <%= f.check_box :private, class: 'private', id: nil, data: { 'comment-target': 'actualCheckbox'} %>
        <label for="comment[private]" data-comment-target='markAsPrivate' data-action='click->comment#toggle'><span class="public">Make private</span></label>
    </div>

    <%= f.hidden_field :commentable_type, value: 'Asset' %>
    <%= f.hidden_field :commentable_id, value: asset.id %>

    <div class="submit_wrapper submit_wrapper_comment">
        <div class="ajax_waiting" data-comment-target="response"></div>
        <div class="small_spinner" data-comment-target='spinner' style="display:none;"></div>
        <%= f.submit "post comment".html_safe, class: 'comment_submit', id: " "%>
      </div>
    <% end %>
  </div>
  </div>