diff --git a/app/assets/javascripts/closet_lists/form.js b/app/assets/javascripts/closet_lists/form.js new file mode 100644 index 00000000..39e80cf5 --- /dev/null +++ b/app/assets/javascripts/closet_lists/form.js @@ -0,0 +1,7 @@ +document.addEventListener("change", ({ target }) => { + if (target.matches('select[name="closet_list[visibility]"]')) { + target + .closest("form") + .setAttribute("data-list-visibility", target.value); + } +}); diff --git a/app/assets/stylesheets/closet_lists/_form.sass b/app/assets/stylesheets/closet_lists/_form.sass index 2ec70c54..a65f6a86 100644 --- a/app/assets/stylesheets/closet_lists/_form.sass +++ b/app/assets/stylesheets/closet_lists/_form.sass @@ -1,4 +1,5 @@ @import "../partials/secondary_nav" +@import "../partials/clean/mixins" body.closet_lists-new, body.closet_lists-create, body.closet_lists-edit, body.closet_lists-update +secondary-nav @@ -30,3 +31,15 @@ body.closet_lists-new, body.closet_lists-create, body.closet_lists-edit, body.cl font: size: 85% + .trade-warning + +warning + margin-bottom: 1em + padding: .75em .5em + text-align: center + + p:last-of-type + margin-bottom: 0 + + // Only show the trade warning when the list is marked as Trading! + form:not([data-list-visibility="2"]) .trade-warning + display: none diff --git a/app/views/closet_lists/_form.html.haml b/app/views/closet_lists/_form.html.haml index 77c7cc40..6e0e231b 100644 --- a/app/views/closet_lists/_form.html.haml +++ b/app/views/closet_lists/_form.html.haml @@ -1,7 +1,8 @@ - secondary_nav do = link_to t('.your_items_link'), user_closet_hangers_path(current_user), :class => 'button' -= form_for [@closet_list.user, @closet_list] do |f| += form_for [@closet_list.user, @closet_list], + html: {data: {"list-visibility" => @closet_list.visibility}} do |f| %ul.fields %li = f.label :name @@ -18,5 +19,16 @@ %span.hint= t '.description.hint' = f.text_area :description %span.hint= t '.description.markup_hint_html' + %li.trade-warning + :markdown + Please use these lists *only* for real NC trades, negotiated on + Neopets.com! We need to keep users safe, so we'll delete *any* list + that seems suspicious. + + If you're doing something more creative, please do so in another + setting, where traders can better manage reputation and trust. Thank + you! = f.submit t('.submit') +- content_for :javascripts do + = javascript_include_tag "closet_lists/form"