Skip to content

Commit 8bba8a3

Browse files
author
Chris Dickenson
committed
Added new messages to log pages
#5 #4
1 parent a822663 commit 8bba8a3

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

app/Extend/Parser.php

+21-2
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ class Parser
3232
private $format_dump;
3333
private $chunk_dump;
3434
// final array
35-
public $log_data;
35+
private $log_data;
3636
private $log_text;
3737
// useful data for saving the log
3838
private $user_weight;
3939
private $log_date;
4040
// formatted data
4141
private $log;
42-
private $new_prs = [];
4342
private $log_exercises = [];
4443
private $log_items = [];
4544
private $exercises = [];
45+
// for flash messages
46+
private $new_prs = [];
47+
private $new_exercises = [];
48+
private $warnings = [];
4649

4750
public function __construct($log_text, $log_date, $user_weight)
4851
{
@@ -403,6 +406,11 @@ public function formatLogData ($is_new)
403406
$prs = Exercise_record::exercisePrs($this->user->user_id, $this->log_date, $exercise_name);
404407

405408
$max_estimate_rm = Exercise_record::getlastest1rm($this->user->user_id, $exercise_name)->value('pr_1rm');
409+
if (count($item['data']) == 0)
410+
{
411+
$this->warnings['blank_exercise'] = true;
412+
}
413+
// add set data to exercise
406414
for ($j = 0, $count_j = count($item['data']); $j < $count_j; $j++)
407415
{
408416
$set = $item['data'][$j];
@@ -442,6 +450,7 @@ public function formatLogData ($is_new)
442450
$this->exercises[$i]['time'] = $this->log_items[$i][$j]->is_time;
443451
$this->exercises[$i]['endurance'] = $this->log_items[$i][$j]->is_endurance;
444452
$this->exercises[$i]['distance'] = $this->log_items[$i][$j]->is_distance;
453+
$this->new_exercises[] = [$exercise_name, $this->exercises[$i]['time'], $this->exercises[$i]['endurance'], $this->exercises[$i]['distance']];
445454
}
446455
$this->log_items[$i][$j]->logitem_1rm = $this->generate_rm ($this->log_items[$i][$j]->logitem_abs_weight, $set['R']);
447456
// get estimate 1rm
@@ -469,6 +478,16 @@ public function formatLogData ($is_new)
469478
{
470479
Session::flash('new_prs', $this->new_prs);
471480
}
481+
//return your new exercises :)
482+
if (count($this->new_exercises) > 0)
483+
{
484+
Session::flash('new_exercises', $this->new_exercises);
485+
}
486+
//return warnings
487+
if (count($this->warnings) > 0)
488+
{
489+
Session::flash('warnings', $this->warnings);
490+
}
472491
}
473492

474493
private function insertLogItemWeightTime ($set, $i, $j)

resources/views/log/view.blade.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,33 @@
6161
@if ($type == 'W')
6262
<p>You have set a new <strong>{{ $exercise }} {{ $rep }}RM</strong> of <strong>{{ $weight }}</strong> kg</p>
6363
@elseif ($type == 'D')
64-
<p>You have set a new <strong>{{ $exercise }} {{ $rep }}RM</strong> of <strong>{{ $weight/1000 }}</strong>km</p>
64+
<p>You have set a new <strong>{{ $exercise }} {{ $rep }}RM</strong> of <strong>{{ Format::format_distance($weight) }}</strong></p>
6565
@else
66-
<p>You have set a new <strong>{{ $exercise }} {{ $rep }}RM</strong> of <strong>{{ $weight }}</strong>s</p>
66+
<p>You have set a new <strong>{{ $exercise }} {{ $rep }}RM</strong> of <strong>{{ Format::format_time($weight) }}</strong></p>
6767
@endif
6868
@endforeach
6969
@endforeach
7070
@endforeach
7171
@endforeach
7272
</div>
7373
@endif
74+
@if (Session::has('new_exercises'))
75+
<div class="alert alert-info">
76+
@foreach (session('new_exercises') as $new_exercise)
77+
<p>You have logged {{ $new_exercise[0] }} for the first time</p>
78+
<p class="small">We have set it to be a {{ ($new_exercise[2]) ? 'endurance' : (($new_exercise[3]) ? 'distance' : (($new_exercise[1]) ? 'time' : 'weight')) }} exercise by default from now on</p>
79+
@endforeach
80+
</div>
81+
@endif
82+
@if (Session::has('warnings'))
83+
<div class="alert alert-danger">
84+
@foreach (session('warnings') as $warning => $bool)
85+
@if ($warning == 'blank_exercise')
86+
<p>One or more of the exercises you added did not have any workout data</p>
87+
@endif
88+
@endforeach
89+
</div>
90+
@endif
7491
<div class="container-fluid">
7592
<div class="row">
7693
<div class="col-md-3 col-md-push-9">

0 commit comments

Comments
 (0)