Skip to content
Merged
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
16 changes: 16 additions & 0 deletions src/Http/Controllers/Tools/MoonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function store(ProbeReport $request)
$universe_moon = UniverseMoonReport::firstOrNew(['moon_id' => $component->moonID]);
$universe_moon->user_id = auth()->user()->getAuthIdentifier();
$universe_moon->updated_at = now();
$universe_moon->notes = $request->notes;
$universe_moon->save();

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

return redirect()->back();
}

/**
* @param int $moon
* @return \Illuminate\Http\JsonResponse
*/
public function edit(int $moon)
{
$moon = UniverseMoonReport::with('content')->where('moon_id', $moon)->first();
if($moon == null) return response()->json([], 400);

return response()->json([
'report' => $moon->formatReport(),
'notes' => $moon->notes,
]);
}
}
4 changes: 4 additions & 0 deletions src/Http/Routes/Tools/Moons.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
->name('seatcore::tools.moons.show')
->uses('MoonsController@show');

Route::get('/{id}/edit')
->name('seatcore::tools.moons.edit')
->uses('MoonsController@edit');

Route::post('/')
->name('seatcore::tools.moons.store')
->uses('MoonsController@store')
Expand Down
1 change: 1 addition & 0 deletions src/Http/Validation/ProbeReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function rules()
{
return [
'moon-report' => 'required',
'notes' => 'present|string',
];
}
}
23 changes: 23 additions & 0 deletions src/Models/UniverseMoonReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,29 @@ public function scopeExceptional($query)
});
}

/**
* Converts the moon back into a report string.
*
* @return string
*/
public function formatReport(): string
{
// header + moon name
$report = sprintf("Moon Moon Product\tQuantity\tOre TypeID\tSolarSystemID\tPlanetID\tMoonID\n%s\n", $this->moon->name);

foreach ($this->content as $content){
$report .= sprintf("\t%s\t%F\t%d\t%d\t%d\t%d\n",
$content->typeName,
$content->pivot->rate,
$content->typeID,
$this->moon->system_id,
$this->moon->planet_id,
$this->moon_id);
}

return $report;
}

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of SeAT
*
* Copyright (C) 2015 to present Leon Jacobs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('universe_moon_reports', function (Blueprint $table) {
$table->string('notes')->default('');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('universe_moon_reports', function (Blueprint $table) {
$table->dropColumn('notes');
});
}
};
4 changes: 4 additions & 0 deletions src/resources/lang/de/moons.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
'uncommon' => 'Ungewöhnlich',
'rare' => 'Selten',
'exceptional' => 'Außergewöhnlich',

'notes' => 'Notizen',
'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.',
'notes_placeholder' => 'Gib hier Notizen ein',
];
3 changes: 3 additions & 0 deletions src/resources/lang/en/moons.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@
'filter_by_constellation' => 'Filter by constellation',
'filter_by_system' => 'Filter by system',
'import' => 'Import',
'notes' => 'Notes',
'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.',
'notes_placeholder' => 'Enter your notes here',
];
1 change: 1 addition & 0 deletions src/resources/views/tools/moons/buttons/action.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="btn-group btn-group-sm">
@include('web::tools.moons.buttons.show')
@include('web::tools.moons.buttons.edit')
@include('web::tools.moons.buttons.delete')
</div>
3 changes: 3 additions & 0 deletions src/resources/views/tools/moons/buttons/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<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) }}">
<i class="fas fa-pen"></i> {{ trans_choice('web::seat.edit', 1) }}
</button>
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h4>{{ $moon->moon->name }}</h4>
<h4 class="d-flex">
<span class="mr-auto">{{ $moon->moon->name }}</span>
@include('web::tools.moons.buttons.edit',['row'=>$moon])
</h4>
<p class="lead">
{{ trans('web::moons.yield_explanation',['volume'=>number_format(Seat\Eveapi\Models\Industry\CorporationIndustryMiningExtraction::BASE_DRILLING_VOLUME, 2),'yield'=>(setting('reprocessing_yield') ?: 0.80) * 100]) }}
</p>
Expand All @@ -16,6 +19,11 @@
<dt>{{ trans_choice('web::moons.moon', 1) }}</dt>
<dd>{{ $moon->moon->name }}</dd>

@if(strip_tags($moon->notes) !== "")
<dt>{{ trans('web::moons.notes') }}</dt>
<dd>{!! $moon->notes !!}</dd>
@endif

<dt>{{trans_choice('web::moons.region', 1)}}</dt>
<dd>{{ $moon->moon->region->name }}</dd>

Expand Down
60 changes: 59 additions & 1 deletion src/resources/views/tools/moons/modals/import/import.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@
{{ csrf_field() }}
<div class="form-group">
<label for="moon-report" class="control-label">{{ trans('web::moons.report') }}</label>
<textarea class="form-control" name="moon-report" id="moon-report"></textarea>
<textarea class="form-control" name="moon-report" id="moon-report" rows="5"></textarea>
<p class="form-text text-muted mb-0">
{!! trans('web::moons.probe_report_instruction') !!}
</p>
</div>
<div class="form-group">
<label for="notes" class="control-label">{{ trans('web::moons.notes') }}</label>
<input type="hidden" id="notes" name="notes" value="" />
<div id="moon-notes" style="max-height: 7em"></div>
<p class="form-text text-muted mb-0">
{!! trans('web::moons.notes_instruction') !!}
</p>
</div>
</form>
</div>
<div class="modal-footer">
Expand All @@ -26,3 +34,53 @@
</div>
</div>
</div>

@push('head')
<link href="{{ asset('web/css/quill.snow.css') }}" rel="stylesheet" />
@endpush

@push('javascript')
<script src="{{ asset('web/js/quill.min.js') }}"></script>

<script>
Quill.prototype.getHtml = function () {
var html = this.container.querySelector('.ql-editor').innerHTML;
html = html.replace(/<p>(<br>|<br\/>|<br\s\/>|\s+|)<\/p>\r\n/gmi, "");
return html;
};

var editor = new Quill('#moon-notes', {
modules: {
toolbar: [
[{'header': ['1', '2', '3', '4', '5', '6', false]}, {'color': []}],
['bold', 'italic', 'underline', 'strike'],
[{'list': 'ordered'}, {'list': 'bullet'}],
[{'align': []}, {'indent': '-1'}, {'indent': '+1'}],
['link'],
['clean']
]
},
placeholder: '{{ trans('web::moons.notes_placeholder') }}',
theme: 'snow'
});

$('#moon-report-form').on('submit', function () {
const input = $('input[name="notes"]');
input.val(editor.getHtml());
});


$('#moon-import').on('show.bs.modal', function (e) {
$('#components-detail').modal('hide')

$.ajax($(e.relatedTarget).data('url'))
.done(function (data) {
$('#moon-report').val(data.report)
editor.setContents(editor.clipboard.convert(data.notes), 'silent');
}).fail(function () {
$('#moon-report').val('')
editor.setContents(editor.clipboard.convert(''), 'silent');
})
})
</script>
@endpush