Skip to content

Commit

Permalink
Add basic view of news popups to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Sep 13, 2023
1 parent b17f29e commit 5bba776
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 49 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.admin-background {
background-size: 20px 20px;
background-image: radial-gradient(circle, #bebebe 1px, #ffffff00 1px);
}


#admin-news {
max-width: 1400px;
}
1 change: 1 addition & 0 deletions app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
.order(:created_at)
.reverse)
.page(params[:page]).per(10)
@news_popups = NewsPopup.all
end

def new
Expand Down
144 changes: 95 additions & 49 deletions app/views/announcements/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,55 +1,101 @@
<div class="row mt-3 p-2">
<div class="col-7">
<h4>
<%= t('basics.news') %>
</h4>
<div class="container" id="admin-news">

<%# News popups %>
<div class="row mt-3 p-2">
<div class="col-12">
<h4>
News Popups
</h4>
</div>
</div>
<div class="col-3">
<%= paginate @announcements, window: 2 %>

<div class="row p-2">
<div class="col-12">
<table class="table table-striped bg-white border border-primary-subtle shadow">
<thead>
<tr>
<th scope="col">Created at</th>
<th scope="col">Updated at</th>
<th scope="col">Name</th>
<th scope="col">Active</th>
</tr>
</thead>
<tbody>
<% @news_popups.each do |popup| %>
<tr>
<td><%= popup.created_at %></td>
<td><%= popup.updated_at %></td>
<td><%= link_to popup.name,
'/news_popups/' + popup.name + '.html',
target: :_blank %>
</td>
<td>
<div class="form-check form-switch">
<% is_checked = popup.active ? 'checked' : '' %>
<input class="form-check-input" type="checkbox" role="switch" <%= is_checked %>>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="col-2 text-end">
<%= link_to t('buttons.create_announcement'),
new_announcement_path,
class: 'btn btn-sm btn-secondary',
remote: true %>

<%# News %>
<div class="row mt-3 p-2">
<div class="col-7">
<h4>
<%= t('basics.news') %>
</h4>
</div>
<div class="col-3">
<%= paginate @announcements, window: 2 %>
</div>
<div class="col-2 text-end">
<%= link_to t('buttons.create_announcement'),
new_announcement_path,
class: 'btn btn-sm btn-secondary',
remote: true %>
</div>
</div>
</div>
<div class="row bg-mdb-color-lighten-2 mx-2 px-4 py-3">
<div class="col-2 text-light">
<strong>
<%= t('basics.date') %>
</strong>
</div>
<div class="col-2 text-light">
<strong>
<%= t('basics.author') %>
</strong>
</div>
<div class="col-5 text-light">
<strong>
<%= t('basics.text') %>
</strong>
<div class="row bg-mdb-color-lighten-2 mx-2 px-4 py-3">
<div class="col-2 text-light">
<strong>
<%= t('basics.date') %>
</strong>
</div>
<div class="col-2 text-light">
<strong>
<%= t('basics.author') %>
</strong>
</div>
<div class="col-5 text-light">
<strong>
<%= t('basics.text') %>
</strong>
</div>
<div class="col-1 text-light">
<strong>
<%= t('admin.announcement.main_page') %>
</strong>
</div>
<div class="col-2 text-light">
<strong>
<%= t('basics.action') %>
</strong>
</div>
</div>
<div class="col-1 text-light">
<strong>
<%= t('admin.announcement.main_page') %>
</strong>
<div id="row-new-announcement"
class="border-bottom mx-2 py-2"
style="display: none;">
</div>
<div class="col-2 text-light">
<strong>
<%= t('basics.action') %>
</strong>
</div>
</div>
<div id="row-new-announcement"
class="border-bottom mx-2 py-2"
style="display: none;" >
<% @announcements.each do |a| %>
<div class="row border-bottom mx-2 px-4 py-2 bg-white"
id="row-announcement-<%= a.id %>">
<%= render partial: 'announcements/row',
locals: { announcement: a } %>
</div>
<% end %>
<%= render partial: 'announcements/modal' %>
</div>
<% @announcements.each do |a| %>
<div class="row border-bottom mx-2 px-4 py-2"
id="row-announcement-<%= a.id %>">
<%= render partial: 'announcements/row',
locals: { announcement: a }%>
</div>
<% end %>
<%= render partial: 'announcements/modal' %>

0 comments on commit 5bba776

Please sign in to comment.