diff --git a/app/assets/stylesheets/classified_listings.scss b/app/assets/stylesheets/classified_listings.scss
index d1918d4c3..8683320d3 100644
--- a/app/assets/stylesheets/classified_listings.scss
+++ b/app/assets/stylesheets/classified_listings.scss
@@ -165,7 +165,6 @@
a {
color: $medium-gray;
color: var(--theme-secondary-color, $medium-gray);
- font-style: italic;
}
}
}
diff --git a/app/controllers/classified_listings_controller.rb b/app/controllers/classified_listings_controller.rb
index 7034b20f3..befb92fb2 100644
--- a/app/controllers/classified_listings_controller.rb
+++ b/app/controllers/classified_listings_controller.rb
@@ -35,8 +35,7 @@ class ClassifiedListingsController < ApplicationController
@classified_listing.published = true
@classified_listing.organization_id = current_user.organization_id if @classified_listing.post_as_organization.to_i == 1
if @classified_listing.save
- CacheBuster.new.bust("/listings")
- CacheBuster.new.bust("/listings?i=i")
+ clear_listings_cache
available_credits.limit(number_of_credits_needed).update_all(spent: true)
redirect_to "/listings"
else
@@ -63,9 +62,12 @@ class ClassifiedListingsController < ApplicationController
@classified_listing.save
@classified_listing.remove_from_index!
elsif params[:classified_listing][:body_markdown].present? && @classified_listing.bumped_at > 24.hours.ago
- @classified_listing.body_markdown = params[:classified_listing][:body_markdown]
+ @classified_listing.title = params[:classified_listing][:title] if params[:classified_listing][:title]
+ @classified_listing.body_markdown = params[:classified_listing][:body_markdown] if params[:classified_listing][:body_markdown]
+ @classified_listing.tag_list = params[:classified_listing][:tag_list] if params[:classified_listing][:tag_list]
@classified_listing.save
end
+ clear_listings_cache
redirect_to "/listings"
end
@@ -81,4 +83,9 @@ class ClassifiedListingsController < ApplicationController
accessible = %i[title body_markdown category tag_list contact_via_connect post_as_organization action]
params.require(:classified_listing).permit(accessible)
end
+
+ def clear_listings_cache
+ CacheBuster.new.bust("/listings")
+ CacheBuster.new.bust("/listings?i=i")
+ end
end
diff --git a/app/javascript/listings/listings.jsx b/app/javascript/listings/listings.jsx
index 3347481ee..849c61366 100644
--- a/app/javascript/listings/listings.jsx
+++ b/app/javascript/listings/listings.jsx
@@ -165,6 +165,7 @@ export class Listings extends Component {
const allListings = listings.map(listing => (
diff --git a/app/javascript/listings/singleListing.jsx b/app/javascript/listings/singleListing.jsx
index 6c299cb2b..ad23b91b5 100644
--- a/app/javascript/listings/singleListing.jsx
+++ b/app/javascript/listings/singleListing.jsx
@@ -1,7 +1,7 @@
import { h, Component } from 'preact';
import PropTypes from 'prop-types';
-export const SingleListing = ({listing, onAddTag, currentUserId}) => {
+export const SingleListing = ({listing, onAddTag, currentUserId, onChangeCategory}) => {
const tagLinks = listing.tag_list.map(tag => (
onAddTag(e, tag)} data-no-instant>{tag}
));
@@ -13,7 +13,10 @@ export const SingleListing = ({listing, onAddTag, currentUserId}) => {
{ tagLinks }
@@ -23,5 +26,6 @@ export const SingleListing = ({listing, onAddTag, currentUserId}) => {
SingleListing.propTypes = {
listing: PropTypes.object.isRequired,
onAddTag: PropTypes.func.isRequired,
+ onChangeCategory: PropTypes.func.isRequired,
currentUserId: PropTypes.number,
};
diff --git a/app/views/classified_listings/edit.html.erb b/app/views/classified_listings/edit.html.erb
index 23dc0dda8..3dcab7e70 100644
--- a/app/views/classified_listings/edit.html.erb
+++ b/app/views/classified_listings/edit.html.erb
@@ -20,7 +20,18 @@
Markdown: You can only modify within the first 24 hours of listing/bumping
- <%= f.text_area :body_markdown%>
+
+ <%= f.label "title", "Title" %>
+ <%= f.text_field "title", maxlength: 128, placeholder: "128 characters max, plain text" %>
+
+
+ <%= f.label "body_markdown", "Body Markdown" %>
+ <%= f.text_area "body_markdown", maxlength: 400, placeholder: "400 characters max, 12 line break max, no images allowed" %>
+
+
+ <%= f.label "tag_list", "Tags" %>
+ <%= f.text_field "tag_list", value: @classified_listing.cached_tag_list, placeholder: "8 tags max, comma separated, no spaces or special characters" %>
+
<%= f.submit "Update Body Markdown" %>
<% end %>
\ No newline at end of file
diff --git a/spec/requests/listings_spec.rb b/spec/requests/listings_spec.rb
index 4a5464cc7..9db87bc03 100644
--- a/spec/requests/listings_spec.rb
+++ b/spec/requests/listings_spec.rb
@@ -113,5 +113,20 @@ RSpec.describe "/listings", type: :request do
}
expect(ClassifiedListing.last.body_markdown).not_to eq("hello new markdown")
end
+ it "updates other fields" do
+ put "/listings/#{classified_listing.id}", params: {
+ classified_listing: { body_markdown: "hello new markdown", title: "New title!", tag_list: "new, tags, hey" }
+ }
+ expect(ClassifiedListing.last.title).to eq("New title!")
+ expect(ClassifiedListing.last.cached_tag_list).to include("hey")
+ end
+ it "does not update other fields" do
+ classified_listing.update_column(:bumped_at, 50.hours.ago)
+ put "/listings/#{classified_listing.id}", params: {
+ classified_listing: { body_markdown: "hello new markdown", title: "New title!", tag_list: "new, tags, hey" }
+ }
+ expect(ClassifiedListing.last.title).not_to eq("New title!")
+ expect(ClassifiedListing.last.cached_tag_list).not_to include("hey")
+ end
end
end