Added notes.

master
Manager Bot 3 years ago
parent e2da4b8220
commit 6132c9b409
  1. 1
      Web/lib/MJB/Web.pm
  2. 15
      Web/lib/MJB/Web/Controller/Admin.pm
  3. 81
      Web/templates/admin/person.html.ep

@ -211,6 +211,7 @@ sub startup ($self) {
$admin->post( '/admin' )->to('Admin#do_admin_become' )->name('do_admin_become' );
$admin->get ( '/admin/people' )->to('Admin#people' )->name('show_admin_people' );
$admin->get ( '/admin/person/:id' )->to('Admin#person' )->name('show_admin_person' );
$admin->post( '/admin/person/:id/note' )->to('Admin#do_person_note' )->name('do_admin_person_note' );
$admin->get ( '/admin/blogs' )->to('Admin#blogs' )->name('show_admin_blogs' );
$admin->get ( '/admin/domains' )->to('Admin#domains' )->name('show_admin_domains' );
$admin->post( '/admin/domain' )->to('Admin#do_domain' )->name('do_admin_domain' );

@ -43,6 +43,21 @@ sub people ( $c ) {
}
sub person ( $c ) {
my $profile = $c->stash->{profile} = $c->db->person( $c->param('id') );
my $notes = $c->stash->{notes} = [ $profile->person_note_people->all ];
}
sub do_person_note ( $c ) {
my $profile = $c->db->person( $c->param('id') );
my $content = $c->param('content');
$profile->create_related( 'person_note_people', {
source_id => $c->stash->{person}->id,
content => $content,
});
$c->flash( confirmation => "Added note to this account." );
$c->redirect_to( $c->url_for( 'show_admin_person', { id => $profile->id } ) );
}

@ -0,0 +1,81 @@
% layout 'standard', title => 'Admin Panel', sb_active => 'admin';
%= include 'admin/_nav', page => 'person'
%= include '_base/status_window';
% if ( @{$c->stash->{notes}} ) {
<div style="margin-top: 2em" class="alert alert-primary" role="alert">
<p>There are the following notes on this account:</p>
<ul>
% foreach my $note ( @{$c->stash->{notes}} ) {
<li><%= $note->content %> ~<%= $note->source->name %></li>
% }
</ul>
</div>
% }
<form class="row mt-3 gy-2 gx-3 align-items-center" method="POST" enctype="multipart/form-data" action="<%= $c->url_for( 'do_admin_person_note', { id => $profile->id } ) %>">
<div class="col-auto">
<label for="content" class="col-form-label">Account Note</label>
</div>
<div class="col-auto">
<input type="text" class="form-control" id="content" name="content" >
</div>
<div class="col-auto">
<button type="submit" class="btn btn-sm btn-primary">Add Note</button>
</div>
</form>
<table style="border: 1px solid #ccc" class="mt-3 table">
<tbody>
<tr>
<th class="text-nowrap">Name</th>
<th class="text-nowrap">Email Address</th>
<th class="text-nowrap">Created</th>
<th class="text-nowrap">Become User</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="<%= $c->url_for( 'show_admin_person', { id => $profile->id } ) %>"><%= $profile->name %></a></td>
<td><%= $profile->email %></td>
<td><%= $profile->created_at->strftime( "%F" ) %></td>
<td>
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_admin_become' ) %>">
<input type="hidden" name="uid" value="<%= $profile->id %>">
<input type="hidden" name="url" value="<%= $c->url_for %>">
<button type="submit" class="btn btn-sm btn-outline-danger">Login</button>
</form>
</td>
</tr>
</tbody>
</table>
<table style="border: 1px solid #ccc" class="mt-3 table">
<tbody>
<tr>
<th class="text-nowrap">Blog Domain</th>
<th class="text-nowrap">Created</th>
<th class="text-nowrap">Manage Blog</th>
</tr>
</thead>
<tbody>
% for my $blog ( $profile->blogs->all ) {
<tr>
<td><a target="_blank" href="https://<%= $blog->domain->name %>/"><%= $blog->domain->name %></a></td>
<td><%= $blog->created_at->strftime( "%F" ) %></td>
<td>
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_admin_become' ) %>">
<input type="hidden" name="uid" value="<%= $profile->id %>">
<input type="hidden" name="bid" value="<%= $blog->id %>">
<input type="hidden" name="url" value="<%= $c->url_for %>">
<button type="submit" class="btn btn-sm btn-outline-danger">Manage Blog</button>
</form>
</td>
</tr>
% }
</tbody>
</table>
Loading…
Cancel
Save