Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= form_with(model: tweet, id: dom_id(tweet)) do |form| %> | ||
|
||
<div class="modal-header"> | ||
<h5 class="modal-title">New Tweet</h5> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<% if tweet.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(tweet.errors.count, "error") %> prohibited this tweet from being saved:</h2> | ||
|
||
<ul> | ||
<% tweet.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :body %> | ||
<%= form.text_area :body %> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<div class="actions"> | ||
<%= form.submit class: "btn btn-sm btn-outline-success" %> | ||
<%= link_to "Cancel", tweet, class: "btn btn-sm btn-outline-danger" %> | ||
</div> | ||
</div> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%= link_to "#", class: 'btn btn-sm btn-outline-primary', data: { toggle: "modal", target: "#tweetModal" } do %> | ||
New Tweet | ||
<% end %> | ||
|
||
<div class="modal fade" id="tweetModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<%= render "tweets/modal_form", tweet: tweet %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- to prepend on create - disabled to avoid double vision when broadcasting --> | ||
<%#% stream_action dom_id_target, render_partial, send_local_variables %> | ||
<%# turbo_stream.prepend "tweets", partial: "tweets/tweet", locals: { tweet: @tweet } %> | ||
|
||
<!-- might be better to use JS method and never conflict with replace in failure condition --> | ||
<%# clear form on create - without js - but now disable above or have double vision %> | ||
<%# turbo_stream.replace "new-tweet", partial: "tweets/form", locals: { tweet: Tweet.new } %> | ||
|
||
<!-- with a modal it auto clears so we don't conflict with a replace after create --> | ||
<%# turbo_stream.replace "new_tweet", partial: "tweets/modal_form", locals: { tweet: @tweet } %> | ||
<%= turbo_stream.replace @tweet, partial: "tweets/modal_form", locals: { tweet: @tweet } %> | ||
<%# to send a message to the notice partial %> | ||
<%# turbo_stream.append "notice", partial: "shared/notice", locals: {notice: "Tweet was successfully created."} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters