Initial commit
This commit is contained in:
19
app/views/notes/_form.html.erb
Normal file
19
app/views/notes/_form.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<%= bootstrap_form_with model: [releasable, note] do |form| %>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add Note to <%= releasable.name %></h5>
|
||||
<%= button_tag type: "button", class: "close", data: { dismiss: "modal" }, aria: { label: "Close" } do %>
|
||||
<span aria-hidden="true">×</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<%= form.text_area :content, hide_label: true, placeholder: true, rows: 6 %>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<%= form.submit class: "btn btn-primary", data: { disable_with: t("shared.disable_with") } %>
|
||||
<%= form.button "Close", class: "btn btn-secondary", type: "button", data: { dismiss: "modal" } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
3
app/views/notes/_new_note_modal.html.erb
Normal file
3
app/views/notes/_new_note_modal.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="modal" id="<%= dom_id(note, dom_id(releasable)) %>" tabindex="-1" role="dialog">
|
||||
<%= render "form", releasable: releasable, note: note %>
|
||||
</div>
|
||||
29
app/views/notes/_notes_modal.html.erb
Normal file
29
app/views/notes/_notes_modal.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="modal" id="<%= dom_id(releasable, "notes") %>" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Notes for <%= releasable.name %></h5>
|
||||
<%= button_tag type: "button", class: "close", data: { dismiss: "modal" }, aria: { label: "Close" } do %>
|
||||
<span aria-hidden="true">×</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="list-group overflow-auto" style="height: 50vh">
|
||||
<% notes.each do |note| %>
|
||||
<div class="list-group-item">
|
||||
<p class="mb-1"><%= note.content %></p>
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small><%= mail_to note.email %></small>
|
||||
<small><%= time_ago_in_words note.created_at %> ago</small>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<%= button_tag "Close", class: "btn btn-secondary", type: "button", data: { dismiss: "modal" } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
8
app/views/notes/create.js.erb
Normal file
8
app/views/notes/create.js.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
var $modal = $("#<%= dom_id Note.new, dom_id(@releasable) %>")
|
||||
|
||||
<% if @note.valid? %>
|
||||
$modal.modal("toggle");
|
||||
$("tr#<%= dom_id @releasable %>").replaceWith("<%= j render(@releasable) %>");
|
||||
<% else %>
|
||||
$modal.html("<%= j render(partial: "form", locals: { releasable: @releasable, note: @note }) %>")
|
||||
<% end %>
|
||||
11
app/views/notes/index.js.erb
Normal file
11
app/views/notes/index.js.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
var modalSelector = "#<%= dom_id @releasable, "notes" %>"
|
||||
var modal = "<%= j render("notes_modal", releasable: @releasable, notes: @notes) %>"
|
||||
|
||||
// If the modal already exists, replace it. Otherwise, create it
|
||||
if ($(modalSelector).length > 0) {
|
||||
$(modalSelector).replaceWith(modal)
|
||||
} else {
|
||||
$('body').append(modal)
|
||||
}
|
||||
|
||||
$(modalSelector).modal("toggle")
|
||||
11
app/views/notes/new.js.erb
Normal file
11
app/views/notes/new.js.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
var modalSelector = "#<%= dom_id @note, dom_id(@releasable) %>"
|
||||
var modal = "<%= j render("new_note_modal", releasable: @releasable, note: @note) %>"
|
||||
|
||||
// If the modal already exists, replace it. Otherwise, create it
|
||||
if ($(modalSelector).length > 0) {
|
||||
$(modalSelector).replaceWith(modal)
|
||||
} else {
|
||||
$('body').append(modal)
|
||||
}
|
||||
|
||||
$(modalSelector).modal("toggle")
|
||||
Reference in New Issue
Block a user