Skip to content

Commit

Permalink
Add basic admin notes index
Browse files Browse the repository at this point in the history
Allow admins to view all notes in one place and navigate to any Note's
Notable record.
  • Loading branch information
garethrees committed Dec 20, 2023
1 parent 52f8fc2 commit 250aca2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class Admin::NotesController < AdminController
include Admin::TagHelper
include TranslatableParams

def index
@notes = Note.paginate(page: params[:page], per_page: 50)
end

def new
@note = scope.build
@note.build_all_translations
Expand Down
12 changes: 7 additions & 5 deletions app/views/admin/notes/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
<% end %>
</div>

<div class="row">
<p class="span12">
<%= link_to "New note", new_admin_note_path(notable_type: notable.class, notable_id: notable), class: "btn btn-info" %>
</p>
</div>
<% if notable %>
<div class="row">
<p class="span12">
<%= link_to "New note", new_admin_note_path(notable_type: notable.class, notable_id: notable), class: "btn btn-info" %>
</p>
</div>
<% end %>
18 changes: 18 additions & 0 deletions app/views/admin/notes/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="row">
<div class="span12">
<div class="page-header">
<h1><%= @title = 'Notes' %></h1>
</div>
</div>
</div>

<div class="row">
<div class="span12">
<p class="lead">Create notes either directly on a record or <%= link_to 'via a tag', admin_tags_path %>.</p>
</div>
</div>

<%= render partial: 'admin/notes/show',
locals: { notes: @notes, notable: nil } %>

<%= will_paginate(@notes) %>
1 change: 1 addition & 0 deletions app/views/admin_general/_admin_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<li><%= link_to 'Blog Posts', admin_blog_posts_path %></li>
<li><%= link_to 'Censor Rules', admin_censor_rules_path %></li>
<li><%= link_to 'Holidays', admin_holidays_path %></li>
<li><%= link_to 'Notes', admin_notes_path %></li>
<li><%= link_to 'Spam Addresses', admin_spam_addresses_path %></li>
</ul>
</li>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def matches?(request)

#### AdminNote controller
namespace :admin do
resources :notes, except: [:index, :show]
resources :notes, except: [:show]
end

direct :admin_note_parent do |note|
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Add basic admin notes index page (Gareth Rees)
* Add link from incoming message to admin page for attachments (Gareth Rees)
* Add XSLX spreadsheet analyser to automatically detect hidden data (Helen
Cross, Graeme Porteous)
Expand Down

0 comments on commit 250aca2

Please sign in to comment.