Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions app/Http/Livewire/ToggleStudentAppAcceptedStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Http\Livewire;

use App\User;
use App\Student;
use Livewire\Component;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class ToggleStudentAppAcceptedStatus extends Component
{
use AuthorizesRequests;

/** @var User */
public $user;

public Student $student;

public $visible;

public $stats;

public function mount()
{
$this->user = auth()->user();
$this->syncStatsVisibility();
}

public function updatedVisible($value)
{
$this->authorize('update', [$this->student, $this->user]);

$this->stats->removeData('accepted_status_history_visibility');
$this->stats->insertData(['accepted_status_history_visibility' => $value ? '1' : '0']);
$this->emit('alert', $value
? "Now Displaying Last Accepted Status!"
: "Last Accepted Status is Hidden Now.",
'success'
);

$this->syncStatsVisibility();
}

private function syncStatsVisibility()
{
$this->stats = $this->student->fresh()->stats;
$this->visible = !isset($this->stats->accepted_status_history_visibility) || $this->stats->accepted_status_history_visibility === '1' ? true : false;
}
}
1 change: 1 addition & 0 deletions app/Student.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function updateAcceptedStats(Profile $profile, $accepted = true)
if ($accepted) {
if (!isset($stats->accepted_by[$accepted_key])) {
$stats->insertData([
'accepted_status_history_visibility' => '1',
'accepted_by' => [
$accepted_key => [
'profile' => $profile->id,
Expand Down
31 changes: 25 additions & 6 deletions public/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"/js/app.js.map": "/js/app.js.map?id=271c8f103c569b8f5613b8778d48ee75",
"/js/manifest.js": "/js/manifest.js?id=dc9ead3d7857b522d7de22d75063453c",
"/js/manifest.js.map": "/js/manifest.js.map?id=389e00e7d7680b68d4e1d128ce27ff48",
"/css/app.css": "/css/app.css?id=0fd161f323dd5c77642c3240bbb47d16",
"/css/app.css.map": "/css/app.css.map?id=3ba6add83b449d9a830b1160dc25d43d",
"/css/app.css": "/css/app.css?id=b94039e3f74ab92a4c88352f22bb0334",
"/css/app.css.map": "/css/app.css.map?id=7d5ab92385140497a5e682d0633c052d",
"/js/vendor.js": "/js/vendor.js?id=77012e19e850a379f73e3ac0c76bc9b1",
"/js/vendor.js.map": "/js/vendor.js.map?id=f3f5514d1186aa088c887b6ebe999fe0"
}
39 changes: 27 additions & 12 deletions resources/assets/sass/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,30 @@ div.content.showContent {
/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
/* Base container */
.switch {
/* Default (original) values */
--switch-size: 26px;
--switch-gap: 4px;
--switch-translation: 26px;

position: relative;
display: inline-block;
width: calc(var(--switch-size) * 2 + (var(--switch-gap) * 2));
height: calc(var(--switch-size) + (var(--switch-gap) * 2));
}

/* SMALL VERSION OVERRIDE */
.switch.small-switch {
--switch-size: 12px; /* Smaller knob */
--switch-gap: 3px; /* Tighter padding */
--switch-translation: 12px; /* Smaller slide distance */
}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
top: 0; left: 0; right: 0; bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
Expand All @@ -379,10 +395,10 @@ div.content.showContent {
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
height: var(--switch-size);
width: var(--switch-size);
left: var(--switch-gap);
bottom: var(--switch-gap);
background-color: white;
-webkit-transition: .4s;
transition: .4s;
Expand All @@ -397,9 +413,8 @@ input:focus + .slider {
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
/* Automatically uses the correct distance based on the class */
transform: translateX(var(--switch-translation));
}

/* Rounded sliders */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="col col-12 mb-4">
<span>Display previous accepted history</span>
<label class="switch small-switch pull-left">

<input type="hidden" name="student[accepted_by][visible]" value="{{ $visible ? '1' : '0' }}">

<input type="checkbox"
id="accepted-by-visible"
name="student[accepted_by][visible]"
data-toggle="show"
data-toggle-target="#accepted_status_history"
@if($visible)
checked
@endif
wire:model="visible">

<span class="slider round"></span>
</label>
</div>
28 changes: 20 additions & 8 deletions resources/views/students/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<div class="mr-2"><a class="btn btn-primary btn-sm" href="#student_feedback"><i class="fas fa-comment"></i> Feedback</a></div>
@endcan
</div>
@can('update', $student)
<div class="mt-2 row">
<livewire:toggle-student-app-accepted-status :student="$student">
</div>
@endcan
</div>
<div class="col-md-4 stats alert alert-success">
<dl class="row mb-0">
Expand Down Expand Up @@ -96,14 +101,21 @@
@endif

@if($student->stats->accepted_by && !empty($student->stats->accepted_by))
<dt class="col-sm-4" title="Accepted to research with these labs" data-toggle="tooltip">
accepted by
</dt>
<dd class="col-sm-8">
@foreach($student->stats->accepted_by as $accepted_record)
<div>{{ $accepted_record['profile_name'] ?? 'n/a' }}</div>
@endforeach
</dd>
<dt class="col-sm-4" title="Accepted to research with these labs" data-toggle="tooltip">
accepted by
</dt>
<div class="row-cols-md-1"
id="accepted_status_history"
@if(!(!isset($student->stats->accepted_status_history_visibility) || $student->stats->accepted_status_history_visibility === '1'))
style="display:none;"
@endif
>
<dd class="col-sm-8">
@foreach($student->stats->accepted_by as $accepted_record)
<div>{{ $accepted_record['profile_name'] ?? 'n/a' }}</div>
@endforeach
</dd>
</div>
@endif
@endif
</dl>
Expand Down
Loading