Skip to content

Commit 20aab32

Browse files
Moon Reporter Feature: Moon Notes (#710)
* feature: moon notes when adding moon * feat: allow editing moon reports * styleci * add german translations I actually speak german :). I just usually don't translate seat stuff because I play EVE in English, so I don't know the game terms in German
1 parent 0f60349 commit 20aab32

File tree

11 files changed

+174
-2
lines changed

11 files changed

+174
-2
lines changed

src/Http/Controllers/Tools/MoonsController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public function store(ProbeReport $request)
125125
$universe_moon = UniverseMoonReport::firstOrNew(['moon_id' => $component->moonID]);
126126
$universe_moon->user_id = auth()->user()->getAuthIdentifier();
127127
$universe_moon->updated_at = now();
128+
$universe_moon->notes = $request->notes;
128129
$universe_moon->save();
129130

130131
// search for any existing and outdated report regarding current moon
@@ -158,4 +159,19 @@ public function destroy(UniverseMoonReport $report)
158159

159160
return redirect()->back();
160161
}
162+
163+
/**
164+
* @param int $moon
165+
* @return \Illuminate\Http\JsonResponse
166+
*/
167+
public function edit(int $moon)
168+
{
169+
$moon = UniverseMoonReport::with('content')->where('moon_id', $moon)->first();
170+
if($moon == null) return response()->json([], 400);
171+
172+
return response()->json([
173+
'report' => $moon->formatReport(),
174+
'notes' => $moon->notes,
175+
]);
176+
}
161177
}

src/Http/Routes/Tools/Moons.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
->name('seatcore::tools.moons.show')
3535
->uses('MoonsController@show');
3636

37+
Route::get('/{id}/edit')
38+
->name('seatcore::tools.moons.edit')
39+
->uses('MoonsController@edit');
40+
3741
Route::post('/')
3842
->name('seatcore::tools.moons.store')
3943
->uses('MoonsController@store')

src/Http/Validation/ProbeReport.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function rules()
4646
{
4747
return [
4848
'moon-report' => 'required',
49+
'notes' => 'present|string',
4950
];
5051
}
5152
}

src/Models/UniverseMoonReport.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ public function scopeExceptional($query)
147147
});
148148
}
149149

150+
/**
151+
* Converts the moon back into a report string.
152+
*
153+
* @return string
154+
*/
155+
public function formatReport(): string
156+
{
157+
// header + moon name
158+
$report = sprintf("Moon Moon Product\tQuantity\tOre TypeID\tSolarSystemID\tPlanetID\tMoonID\n%s\n", $this->moon->name);
159+
160+
foreach ($this->content as $content){
161+
$report .= sprintf("\t%s\t%F\t%d\t%d\t%d\t%d\n",
162+
$content->typeName,
163+
$content->pivot->rate,
164+
$content->typeID,
165+
$this->moon->system_id,
166+
$this->moon->planet_id,
167+
$this->moon_id);
168+
}
169+
170+
return $report;
171+
}
172+
150173
/**
151174
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
152175
*/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of SeAT
5+
*
6+
* Copyright (C) 2015 to present Leon Jacobs
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License along
19+
* with this program; if not, write to the Free Software Foundation, Inc.,
20+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*/
22+
23+
use Illuminate\Database\Migrations\Migration;
24+
use Illuminate\Database\Schema\Blueprint;
25+
use Illuminate\Support\Facades\Schema;
26+
27+
return new class extends Migration {
28+
/**
29+
* Run the migrations.
30+
*
31+
* @return void
32+
*/
33+
public function up()
34+
{
35+
Schema::table('universe_moon_reports', function (Blueprint $table) {
36+
$table->string('notes')->default('');
37+
});
38+
}
39+
40+
/**
41+
* Reverse the migrations.
42+
*
43+
* @return void
44+
*/
45+
public function down()
46+
{
47+
Schema::table('universe_moon_reports', function (Blueprint $table) {
48+
$table->dropColumn('notes');
49+
});
50+
}
51+
};

src/resources/lang/de/moons.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@
3333
'uncommon' => 'Ungewöhnlich',
3434
'rare' => 'Selten',
3535
'exceptional' => 'Außergewöhnlich',
36+
37+
'notes' => 'Notizen',
38+
'notes_instruction' => 'Du kannst hier Notizen zu den Mond(en) eingeben. Falls du Daten für mehrere Monde gleichzeitig eingibst, wird die Notiz zu allen neuen Monden hinzugefügt.',
39+
'notes_placeholder' => 'Gib hier Notizen ein',
3640
];

src/resources/lang/en/moons.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@
5555
'filter_by_constellation' => 'Filter by constellation',
5656
'filter_by_system' => 'Filter by system',
5757
'import' => 'Import',
58+
'notes' => 'Notes',
59+
'notes_instruction' => 'You can enter some notes about the moon(s) here. When adding multiple moons, the note will be added to all of them.',
60+
'notes_placeholder' => 'Enter your notes here',
5861
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div class="btn-group btn-group-sm">
22
@include('web::tools.moons.buttons.show')
3+
@include('web::tools.moons.buttons.edit')
34
@include('web::tools.moons.buttons.delete')
45
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<button type="button" class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#moon-import" data-url="{{ route('seatcore::tools.moons.edit', $row->moon_id) }}">
2+
<i class="fas fa-pen"></i> {{ trans_choice('web::seat.edit', 1) }}
3+
</button>

src/resources/views/tools/moons/modals/components/content.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<h4>{{ $moon->moon->name }}</h4>
1+
<h4 class="d-flex">
2+
<span class="mr-auto">{{ $moon->moon->name }}</span>
3+
@include('web::tools.moons.buttons.edit',['row'=>$moon])
4+
</h4>
25
<p class="lead">
36
{{ trans('web::moons.yield_explanation',['volume'=>number_format(Seat\Eveapi\Models\Industry\CorporationIndustryMiningExtraction::BASE_DRILLING_VOLUME, 2),'yield'=>(setting('reprocessing_yield') ?: 0.80) * 100]) }}
47
</p>
@@ -16,6 +19,11 @@
1619
<dt>{{ trans_choice('web::moons.moon', 1) }}</dt>
1720
<dd>{{ $moon->moon->name }}</dd>
1821

22+
@if(strip_tags($moon->notes) !== "")
23+
<dt>{{ trans('web::moons.notes') }}</dt>
24+
<dd>{!! $moon->notes !!}</dd>
25+
@endif
26+
1927
<dt>{{trans_choice('web::moons.region', 1)}}</dt>
2028
<dd>{{ $moon->moon->region->name }}</dd>
2129

0 commit comments

Comments
 (0)