Add a Broadcast Show View (#8769) [deploy]
* Add #show to the Broadcasts::Controller and to routes.rb - Adds a show method to the Broadcasts Controller - Adds a show route to routes.rb * Add a show view for Broadcasts - Adds show.html.erb to /internal/broadcasts - Repurposes code from index.html.erb for show view - Repurposes code from edit.html.erb for show view * Rewrite /internal/broadcasts index to use a table - Formats /internal/broadcasts with a table - Removes on-hover functionality from show.html.erb * Refactor Broadcast resources in routes.rb * Redirect to #show on create and update for Broadcasts * Add the Destroy Broadcast button to the Broadcast show view * Remove style preventing Broadcast preview * Add Broadcast styling back and add display: block to stylesheet * Add display: flex to .broadcast-wrapper in layout.scss * Remove superfluous slashes from opening tags
This commit is contained in:
parent
904f0dac78
commit
426d3191e8
7 changed files with 70 additions and 41 deletions
|
|
@ -52,6 +52,7 @@
|
|||
}
|
||||
|
||||
.broadcast-wrapper {
|
||||
display: flex;
|
||||
position: relative;
|
||||
z-index: auto;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ class Internal::BroadcastsController < Internal::ApplicationController
|
|||
end.order(title: :asc)
|
||||
end
|
||||
|
||||
def show
|
||||
@broadcast = Broadcast.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@broadcast = Broadcast.new
|
||||
end
|
||||
|
|
@ -22,7 +26,7 @@ class Internal::BroadcastsController < Internal::ApplicationController
|
|||
|
||||
if @broadcast.save
|
||||
flash[:success] = "Broadcast has been created!"
|
||||
redirect_to internal_broadcasts_path
|
||||
redirect_to internal_broadcast_path(@broadcast)
|
||||
else
|
||||
flash[:danger] = @broadcast.errors.full_messages.to_sentence
|
||||
render new_internal_broadcast_path
|
||||
|
|
@ -34,7 +38,7 @@ class Internal::BroadcastsController < Internal::ApplicationController
|
|||
|
||||
if @broadcast.update(broadcast_params)
|
||||
flash[:success] = "Broadcast has been updated!"
|
||||
redirect_to internal_broadcasts_path
|
||||
redirect_to internal_broadcast_path(@broadcast)
|
||||
else
|
||||
flash[:danger] = @broadcast.errors.full_messages.to_sentence
|
||||
render :edit
|
||||
|
|
|
|||
|
|
@ -17,17 +17,4 @@
|
|||
<%= label_tag :active, "Active:" %>
|
||||
<%= select_tag :active, options_for_select([false, true], selected: @broadcast.active) %>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<% if @broadcast.processed_html %>
|
||||
<div>
|
||||
</p><strong>Preview</strong></p>
|
||||
<div class="broadcast-wrapper visible <%= banner_class(@broadcast) %>">
|
||||
<div class="broadcast-data">
|
||||
<%= sanitize @broadcast.processed_html, attributes: %w[href style src] %>
|
||||
</div>
|
||||
</div>
|
||||
</p><em>Please note: announcement broadcasts will render directly below the nav bar once activated.</em></p>
|
||||
<div>
|
||||
<% end %>
|
||||
<hr>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,5 @@
|
|||
<%= render "form" %>
|
||||
<%= submit_tag "Update Broadcast", class: "btn btn-primary float-right" %>
|
||||
<% end %>
|
||||
<%= link_to "Destroy Broadcast", url_for(action: :destroy, id: @broadcast.id), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,30 +19,29 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row my-3">
|
||||
<div class="col">
|
||||
<div class="alert alert-warning"><strong>Note: You must ensure that your Broadcast is active in order for it to be sent to users!<strong></div>
|
||||
<div class="list-group-flush w-100">
|
||||
<% @broadcasts.each do |broadcast| %>
|
||||
<a class="list-group-item list-group-item-action flex-column align-items-start" href="/internal/broadcasts/<%= broadcast.id %>/edit">
|
||||
<h3 class="mb-2">Title: <%= broadcast.title %></h3>
|
||||
<h3>Broadcast Type: <%= broadcast.type_of %></h3>
|
||||
<h3>Content:</h3>
|
||||
<p>
|
||||
<%= broadcast.processed_html %>
|
||||
</p>
|
||||
<h3>Last Active On: <%= broadcast.active_status_updated_at&.strftime("%b %d, %Y %H:%M UTC") %></h3>
|
||||
<h3>Status:</h3>
|
||||
<h3>
|
||||
<span class="badge badge-<%= broadcast.active? ? "success" : "warning" %>">
|
||||
<div class="alert alert-warning"><strong>Note: You must ensure that your Broadcast is active in order for it to be sent to users!</strong></div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Title</th>
|
||||
<th scope="col">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @broadcasts.each do |broadcast| %>
|
||||
<tr>
|
||||
<td><%= link_to broadcast.title, internal_broadcast_path(broadcast.id) %></td>
|
||||
<td class="justify-content-center">
|
||||
<h5>
|
||||
<div class="badge badge-<%= broadcast.active? ? "success" : "warning" %>">
|
||||
<%= broadcast.active? ? "Active" : "Inactive" %>
|
||||
</span>
|
||||
<span class="sr-only">Broadcast Status</span>
|
||||
</h3>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</h5>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= csrf_meta_tags %>
|
||||
|
|
|
|||
39
app/views/internal/broadcasts/show.html.erb
Normal file
39
app/views/internal/broadcasts/show.html.erb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<div class="row my-3">
|
||||
<div class="col">
|
||||
<div class="list-group-flush w-100">
|
||||
<a class="list-group-item flex-column align-items-start">
|
||||
<h3 class="mb-2">Title: <%= @broadcast.title %></h3>
|
||||
<h3>Broadcast Type: <%= @broadcast.type_of %></h3>
|
||||
<h3>Content:</h3>
|
||||
<p>
|
||||
<%= @broadcast.processed_html %>
|
||||
</p>
|
||||
<h3>Last Active On: <%= @broadcast.active_status_updated_at&.strftime("%b %d, %Y %H:%M UTC") %></h3>
|
||||
<h3>Status:</h3>
|
||||
<h3>
|
||||
<span class="badge badge-<%= @broadcast.active? ? "success" : "warning" %>">
|
||||
<%= @broadcast.active? ? "Active" : "Inactive" %>
|
||||
</span>
|
||||
<span class="sr-only">Broadcast Status</span>
|
||||
</h3>
|
||||
</a>
|
||||
<hr>
|
||||
<% if @broadcast.processed_html %>
|
||||
<div>
|
||||
<p><strong>Preview</strong></p>
|
||||
<div class="broadcast-wrapper visible <%= banner_class(@broadcast) %>">
|
||||
<div class="broadcast-data">
|
||||
<%= sanitize @broadcast.processed_html, attributes: %w[href style src] %>
|
||||
</div>
|
||||
</div>
|
||||
<p><em>Please note: announcement broadcasts will render directly below the nav bar once activated.</em></p>
|
||||
<div>
|
||||
<% end %>
|
||||
<hr>
|
||||
<%= link_to "Destroy Broadcast", url_for(action: :destroy, id: @broadcast.id), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
|
||||
<%= link_to "Edit Broadcast", edit_internal_broadcast_path, class: "btn btn-primary float-right" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= csrf_meta_tags %>
|
||||
|
|
@ -46,7 +46,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :articles, only: %i[index show update]
|
||||
resources :broadcasts, only: %i[index new create edit update destroy]
|
||||
resources :broadcasts
|
||||
resources :buffer_updates, only: %i[create update]
|
||||
resources :listings, only: %i[index edit update destroy]
|
||||
resources :comments, only: [:index]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue