Update Curated Onboarding dashboard, improve application filtering and make it easier to distinguish response state

This commit is contained in:
Daniel Supernault 2024-02-24 03:45:09 -07:00
parent 84aeec3b4e
commit 2b5d723582
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
6 changed files with 90 additions and 15 deletions

View file

@ -22,27 +22,43 @@ class AdminCuratedRegisterController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'filter' => 'sometimes|in:open,all,awaiting,approved,rejected' 'filter' => 'sometimes|in:open,all,awaiting,approved,rejected,responses',
'sort' => 'sometimes|in:asc,desc'
]); ]);
$filter = $request->input('filter', 'open'); $filter = $request->input('filter', 'open');
$sort = $request->input('sort', 'asc');
$records = CuratedRegister::when($filter, function($q, $filter) { $records = CuratedRegister::when($filter, function($q, $filter) {
if($filter === 'open') { if($filter === 'open') {
return $q->where('is_rejected', false) return $q->where('is_rejected', false)
->where(function($query) {
return $query->where('user_has_responded', true)->orWhere('is_awaiting_more_info', false);
})
->whereNotNull('email_verified_at') ->whereNotNull('email_verified_at')
->whereIsClosed(false); ->whereIsClosed(false);
} else if($filter === 'all') { } else if($filter === 'all') {
return $q; return $q;
} else if($filter === 'responses') {
return $q->whereIsClosed(false)
->whereNotNull('email_verified_at')
->where('user_has_responded', true)
->where('is_awaiting_more_info', true);
} elseif ($filter === 'awaiting') { } elseif ($filter === 'awaiting') {
return $q->whereIsClosed(false) return $q->whereIsClosed(false)
->whereNull('is_rejected') ->where('is_rejected', false)
->whereNull('is_approved'); ->where('is_approved', false)
->where('user_has_responded', false)
->where('is_awaiting_more_info', true);
} elseif ($filter === 'approved') { } elseif ($filter === 'approved') {
return $q->whereIsClosed(true)->whereIsApproved(true); return $q->whereIsClosed(true)->whereIsApproved(true);
} elseif ($filter === 'rejected') { } elseif ($filter === 'rejected') {
return $q->whereIsClosed(true)->whereIsRejected(true); return $q->whereIsClosed(true)->whereIsRejected(true);
} }
}) })
->paginate(10); ->when($sort, function($query, $sort) {
return $query->orderBy('id', $sort);
})
->paginate(10)
->withQueryString();
return view('admin.curated-register.index', compact('records', 'filter')); return view('admin.curated-register.index', compact('records', 'filter'));
} }
@ -160,6 +176,7 @@ class AdminCuratedRegisterController extends Controller
$activity->message = $request->input('message'); $activity->message = $request->input('message');
$activity->save(); $activity->save();
$record->is_awaiting_more_info = true; $record->is_awaiting_more_info = true;
$record->user_has_responded = false;
$record->save(); $record->save();
Mail::to($record->email)->send(new CuratedRegisterRequestDetailsFromUser($record, $activity)); Mail::to($record->email)->send(new CuratedRegisterRequestDetailsFromUser($record, $activity));
return $request->all(); return $request->all();

View file

@ -105,6 +105,7 @@ class CuratedRegisterController extends Controller
'action_required' => true, 'action_required' => true,
]); ]);
CuratedRegister::findOrFail($crid)->update(['user_has_responded' => true]);
$request->session()->pull('cur-reg-con'); $request->session()->pull('cur-reg-con');
$request->session()->pull('cur-reg-con-attempt'); $request->session()->pull('cur-reg-con-attempt');

View file

@ -9,25 +9,43 @@ class CuratedRegister extends Model
{ {
use HasFactory; use HasFactory;
protected $fillable = [
'user_has_responded'
];
protected $casts = [ protected $casts = [
'autofollow_account_ids' => 'array', 'autofollow_account_ids' => 'array',
'admin_notes' => 'array', 'admin_notes' => 'array',
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
'admin_notified_at' => 'datetime', 'admin_notified_at' => 'datetime',
'action_taken_at' => 'datetime', 'action_taken_at' => 'datetime',
'user_has_responded' => 'boolean',
'is_awaiting_more_info' => 'boolean',
'is_accepted' => 'boolean',
'is_rejected' => 'boolean',
'is_closed' => 'boolean',
]; ];
public function adminStatusLabel() public function adminStatusLabel()
{ {
if($this->user_has_responded) {
return '<span class="border border-warning px-3 py-1 rounded text-white font-weight-bold">Awaiting Admin Response</span>';
}
if(!$this->email_verified_at) { if(!$this->email_verified_at) {
return '<span class="border border-danger px-3 py-1 rounded text-white font-weight-bold">Unverified email</span>'; return '<span class="border border-danger px-3 py-1 rounded text-white font-weight-bold">Unverified email</span>';
} }
if($this->is_accepted) { return 'Approved'; } if($this->is_approved) {
if($this->is_rejected) { return 'Rejected'; } return '<span class="badge badge-success bg-success text-dark">Approved</span>';
if($this->is_awaiting_more_info ) { }
return '<span class="border border-info px-3 py-1 rounded text-white font-weight-bold">Awaiting Details</span>'; if($this->is_rejected) {
return '<span class="badge badge-danger bg-danger text-white">Rejected</span>';
}
if($this->is_awaiting_more_info ) {
return '<span class="border border-info px-3 py-1 rounded text-white font-weight-bold">Awaiting User Response</span>';
}
if($this->is_closed ) {
return '<span class="border border-muted px-3 py-1 rounded text-white font-weight-bold" style="opacity:0.5">Closed</span>';
} }
if($this->is_closed ) { return 'Closed'; }
return '<span class="border border-success px-3 py-1 rounded text-white font-weight-bold">Open</span>'; return '<span class="border border-success px-3 py-1 rounded text-white font-weight-bold">Open</span>';
} }

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\CuratedRegister;
use App\Models\CuratedRegisterActivity;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('curated_registers', function (Blueprint $table) {
$table->boolean('user_has_responded')->default(false)->index()->after('is_awaiting_more_info');
});
CuratedRegisterActivity::whereFromUser(true)->get()->each(function($cra) {
$cr = CuratedRegister::find($cra->register_id);
$cr->user_has_responded = true;
$cr->save();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('curated_registers', function (Blueprint $table) {
$table->dropColumn('user_has_responded');
});
}
};

View file

@ -26,7 +26,7 @@
<tr> <tr>
<th scope="col">ID</th> <th scope="col">ID</th>
<th scope="col">Username</th> <th scope="col">Username</th>
@if(in_array($filter, ['all', 'open'])) @if(in_array($filter, ['all', 'open', 'awaiting', 'responses']))
<th scope="col">Status</th> <th scope="col">Status</th>
@endif @endif
<th scope="col">Reason for Joining</th> <th scope="col">Reason for Joining</th>
@ -47,7 +47,7 @@
&commat;{{ $record->username }} &commat;{{ $record->username }}
</p> </p>
</td> </td>
@if(in_array($filter, ['all', 'open'])) @if(in_array($filter, ['all', 'open', 'awaiting', 'responses']))
<td class="align-middle"> <td class="align-middle">
{!! $record->adminStatusLabel() !!} {!! $record->adminStatusLabel() !!}
</td> </td>

View file

@ -18,16 +18,19 @@
<a class="nav-link {{request()->has('filter') ? '':'active'}}" href="/i/admin/curated-onboarding/home">Open Applications</a> <a class="nav-link {{request()->has('filter') ? '':'active'}}" href="/i/admin/curated-onboarding/home">Open Applications</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {{request()->has('filter') && request()->filter == 'all' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=all">All Applications</a> <a class="nav-link {{request()->has('filter') && request()->filter == 'responses' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=responses">User Response Replies</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {{request()->has('filter') && request()->filter == 'awaiting' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=awaiting">Awaiting Info</a> <a class="nav-link {{request()->has('filter') && request()->filter == 'awaiting' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=awaiting">Awaiting User Response</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {{request()->has('filter') && request()->filter == 'approved' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=approved">Approved Applications</a> <a class="nav-link {{request()->has('filter') && request()->filter == 'approved' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=approved&sort=desc">Approved Applications</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {{request()->has('filter') && request()->filter == 'rejected' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=rejected">Rejected Applications</a> <a class="nav-link {{request()->has('filter') && request()->filter == 'rejected' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=rejected&sort=desc">Rejected Applications</a>
</li>
<li class="nav-item">
<a class="nav-link {{request()->has('filter') && request()->filter == 'all' ? 'active':''}}" href="/i/admin/curated-onboarding/home?filter=all&sort=desc">All Applications</a>
</li> </li>
</ul> </ul>
</div> </div>