Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .rake_tasks~
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
about
action_mailbox:ingress:exim
action_mailbox:ingress:postfix
action_mailbox:ingress:qmail
action_mailbox:install
action_mailbox:install:migrations
action_text:install
action_text:install:migrations
active_storage:install
annotate_models
annotate_routes
app:template
app:update
assets:clean[keep]
assets:clobber
assets:environment
assets:precompile
cache_digests:dependencies
cache_digests:nested_dependencies
db:create
db:drop
db:encryption:init
db:environment:set
db:fixtures:load
db:migrate
db:migrate:down
db:migrate:redo
db:migrate:status
db:migrate:up
db:prepare
db:reset
db:rollback
db:schema:cache:clear
db:schema:cache:dump
db:schema:dump
db:schema:load
db:seed
db:seed:replant
db:setup
db:version
erd
grade
grade:all
grade:next
grade:reset_token
grade_runner:runner
importmap:install
log:clear
middleware
remove_annotation
remove_routes
restart
sample_data
secret
spec
spec:features
specs:readme
stats
stimulus:install
stimulus:install:importmap
stimulus:install:node
test
test:all
test:db
test:system
time:zones[country_or_offset]
tmp:clear
tmp:create
turbo:install
turbo:install:importmap
turbo:install:node
turbo:install:redis
yarn:install
zeitwerk:check
5 changes: 5 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def create
if @comment.save
format.html { redirect_back fallback_location: root_path, notice: "Comment was successfully created." }
format.json { render :show, status: :created, location: @comment }
format.js
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @comment.errors, status: :unprocessable_entity }
Expand All @@ -59,6 +60,10 @@ def destroy
respond_to do |format|
format.html { redirect_back fallback_location: root_url, notice: "Comment was successfully destroyed." }
format.json { head :no_content }

format.js do
render template: "comments/destroy"
end
end
end

Expand Down
7 changes: 5 additions & 2 deletions app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<li class="list-group-item">
<li id="<%= dom_id(comment) %>" class="list-group-item">
<div class="d-flex">
<div class="flex-shrink-0">
<%= image_tag comment.author.avatar_image, class: "rounded-circle mr-2", width: 36 %>
Expand All @@ -15,7 +15,10 @@
<i class="fas fa-edit fa-fw"></i>
<% end %>

<%= link_to comment, data: { turbo_method: :delete }, class: "btn btn-link btn-sm text-muted" do %>
<%= link_to comment,
method: :delete,
class: "btn btn-link btn-sm text-muted",
remote: true do %>
<i class="fas fa-trash fa-fw"></i>
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li class="list-group-item">
<%= form_with(model: comment) do |form| %>
<li id="<%= dom_id(comment.photo) %>_new_comment_form" class="list-group-item">
<%= form_with(model: comment, local: false) do |form| %>
<% if comment.errors.any? %>
<div id="error_explanation">
<ul class="list-unstyled">
Expand Down
9 changes: 9 additions & 0 deletions app/views/comments/create.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var added_comment = $("<%= j(render @comment) %>");

added_comment.hide();

$("#<%= dom_id(@comment.photo) %>_new_comment_form").before(added_comment);

added_comment.slideDown();

$("#<%= dom_id(@comment.photo) %>_new_comment_form #comment_body").val("");
5 changes: 5 additions & 0 deletions app/views/comments/destroy.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log("bye comment!")

$("#<%= dom_id(@comment) %>").fadeOut(5000, function() {
$(this).remove();
});