From 20f2479b33bc548c4736cdc1ceffde6e3af3a31d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 22:52:41 -0400 Subject: Added quote editing --- app/views/admin/quotes/_form.html.haml | 27 +++++++++++++++++++++++++++ app/views/admin/quotes/edit.html.haml | 3 +++ app/views/admin/quotes/index.html.haml | 1 + app/views/admin/quotes/pending.html.haml | 1 + app/views/layouts/quotes.html.haml | 4 +++- app/views/quotes/_quote.html.haml | 2 ++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/quotes/_form.html.haml create mode 100644 app/views/admin/quotes/edit.html.haml (limited to 'app/views') diff --git a/app/views/admin/quotes/_form.html.haml b/app/views/admin/quotes/_form.html.haml new file mode 100644 index 0000000..920835b --- /dev/null +++ b/app/views/admin/quotes/_form.html.haml @@ -0,0 +1,27 @@ +%fieldset#content + %h2 Quote ##{f.object.id} + .halfbody-field + = f.label :content + = f.text_area :content + %h3 Notes + .halfbody-field + = f.label :notes + = f.text_area :notes +%fieldset#details + - if f.object.errors.any? + #errors.details-module + %h3 Error! + %ul + - f.object.errors.full_messages.each do |error| + %li= error + - unless f.object.new_record? + #entry-preview-link.details-module= link_to "View quote", quote_url(f.object.id), target: "entry-preview" + .details-module + .tags-field + = f.label :tag_list, "Tags" + = f.text_field :tag_list, type: :tags, value: f.object.tag_list.join(",") + .details-module + .published-field + = f.label :state + = f.select :state, Quote.state.options + .details-module= f.submit diff --git a/app/views/admin/quotes/edit.html.haml b/app/views/admin/quotes/edit.html.haml new file mode 100644 index 0000000..47ff2d1 --- /dev/null +++ b/app/views/admin/quotes/edit.html.haml @@ -0,0 +1,3 @@ +- title "Editing Quote \##{@quote.id}" += form_for @quote, url: admin_quote_url(@quote.id), html: { id: "entry-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/quotes/index.html.haml b/app/views/admin/quotes/index.html.haml index afe2c20..c1a4866 100644 --- a/app/views/admin/quotes/index.html.haml +++ b/app/views/admin/quotes/index.html.haml @@ -16,5 +16,6 @@ %td %ul.admin-actions %li= link_to "View", quote + %li= link_to "Edit", edit_admin_quote_url(quote) %li= link_to "Delete", admin_quote_url(quote), method: :delete, data: { confirm: "Are you sure?" } = will_paginate @quotes diff --git a/app/views/admin/quotes/pending.html.haml b/app/views/admin/quotes/pending.html.haml index 14d6cf8..ef52099 100644 --- a/app/views/admin/quotes/pending.html.haml +++ b/app/views/admin/quotes/pending.html.haml @@ -15,6 +15,7 @@ %td= quote.created_at.strftime("%B %d, %Y, %l:%M%P") %td %ul.admin-actions + %li= link_to "Edit", edit_admin_quote_url(quote) %li= link_to "Accept", accept_admin_quote_url(quote), method: :post, data: { confirm: "Are you sure you want to accept this quote?" } %li= link_to "Reject", admin_quote_url(quote), method: :delete, data: { confirm: "Are you sure you want to reject this quote?" } = will_paginate @quotes diff --git a/app/views/layouts/quotes.html.haml b/app/views/layouts/quotes.html.haml index f42eee0..98a7a86 100644 --- a/app/views/layouts/quotes.html.haml +++ b/app/views/layouts/quotes.html.haml @@ -11,7 +11,7 @@ %body #wrap %header#banner - %h1#banner-title= link_to "The Four Island Quotes DB", root_path + %h1#banner-title= link_to "The Four Island Quotes DB", quotes_url #banner-abbr FIQDB .cleardiv %nav#top-bar @@ -25,6 +25,8 @@ %li= link_to_unless_current "Tags", tags_quotes_url %li= link_to_unless_current "Stats", stats_quotes_url %li= link_to_unless_current "Feed", latest_quotes_url(:atom) + - if user_signed_in? + %li= link_to_unless_current "Admin", admin_url .cleardiv #page-body - if flash[:notice] diff --git a/app/views/quotes/_quote.html.haml b/app/views/quotes/_quote.html.haml index 2a9fb37..46b0266 100644 --- a/app/views/quotes/_quote.html.haml +++ b/app/views/quotes/_quote.html.haml @@ -5,6 +5,8 @@ %span.quote-rating{ :id => "quote-rating-#{quote.id}" }= "+#{quote.upvotes}/-#{quote.downvotes}" %span.vote-link{ :id => "quote-downvote-link-#{quote.id}" }= link_to_unless (quote.new_record? or quote.already_downvoted?(request.remote_ip)), "Down", downvote_quote_path(quote.id), :remote => true, :rel => "nofollow", :class => "quote-downvote-link", method: :post %datetime= quote.published_date + - if user_signed_in? and !quote.new_record? + = link_to "Edit", edit_admin_quote_path(quote), :class => "quote-edit-link" %blockquote.quote-body= raw quote_format(h(quote.content)) - if !quote.new_record? and quote.has_extra? .quote-footer -- cgit 1.4.1