Skip to content

Commit

Permalink
✨ add ui for reporting (#2881)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Aug 29, 2024
1 parent 20883ba commit 24361d3
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 3 deletions.
20 changes: 19 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,5 +777,23 @@
"settings.find-users": "User finden",
"stationboard.friends-none": "Du hast keine Freunde.",
"stationboard.friends-set": "Hier kannst du Freunde verwalten:",
"stationboard.friend-filter": "Tippen, um nach Freunden zu filtern"
"stationboard.friend-filter": "Tippen, um nach Freunden zu filtern",
"report-something": "Etwas melden",
"report.reason": "Grund",
"report.description": "Beschreibung",
"report.subjectType": "Was möchtest du melden?",
"report.subjectId": "ID des Objekts",
"report.submit": "Absenden",
"report.success": "Deine Meldung wurde erfolgreich übermittelt. Wir schauen uns das an.",
"report.error": "Beim Übermitteln deiner Meldung ist ein Fehler aufgetreten.",
"report-reason.inappropriate": "Unangemessen",
"report-reason.implausible": "Unplausibel",
"report-reason.spam": "Spam",
"report-reason.illegal": "Illegal",
"report-reason.other": "Sonstiges",
"report-subject.Event": "Veranstaltung",
"report-subject.User": "User",
"report-subject.Status": "Status",
"report-subject.Trip": "Fahrt",
"status.report": "Status melden"
}
20 changes: 19 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,5 +777,23 @@
"settings.find-users": "Find users",
"stationboard.friends-none": "You don't have any friends.",
"stationboard.friends-set": "You can manage your friends here:",
"stationboard.friend-filter": "Filter for friends"
"stationboard.friend-filter": "Filter for friends",
"report-something": "Report something",
"report.reason": "Reason",
"report.description": "Description",
"report.subjectType": "Type of subject",
"report.subjectId": "ID of subject",
"report.submit": "Submit",
"report.success": "Your report has been submitted successfully. We will take care of it as soon as possible.",
"report.error": "An error occurred while submitting your report.",
"report-reason.inappropriate": "Inappropriate",
"report-reason.implausible": "Implausible",
"report-reason.spam": "Spam",
"report-reason.illegal": "Illegal",
"report-reason.other": "Other",
"report-subject.Event": "Event",
"report-subject.User": "User",
"report-subject.Status": "Status",
"report-subject.Trip": "Trip",
"status.report": "Report status"
}
9 changes: 9 additions & 0 deletions resources/views/includes/status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ class="like {{ auth()->user() && $status->likes->where('user_id', auth()->user()
</li>
<x-mute-button :user="$status->user" :dropdown="true"/>
<x-block-button :user="$status->user" :dropdown="true"/>
<li>
<a href="{{ route('report', ['subjectType' => 'status', 'subjectId' => $status->id]) }}"
class="dropdown-item">
<div class="dropdown-icon-suspense">
<i class="fas fa-flag" aria-hidden="true"></i>
</div>
{{__('status.report')}}
</a>
</li>
@endif
@admin
<li>
Expand Down
100 changes: 100 additions & 0 deletions resources/views/report.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@php
use App\Enum\Report\ReportableSubject;
use App\Enum\Report\ReportReason;
@endphp

@extends('layouts.app')

@section('title', __('report-something'))

@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-7">
<h1>{{__('report-something')}}</h1>

<form id="report">

<div class="row">
<div class="col-md-6">
<div class="form-floating mb-2 {{request()->has('subjectType') ? 'd-none' : ''}}">
<select name="subjectType" class="form-select" required id="subjectType">
<option value=""
{{!request()->has('subjectType') ? 'selected' : ''}} disabled></option>
@foreach(ReportableSubject::cases() as $reportableSubject)
<option value="{{$reportableSubject->value}}"
{{request()->get('subjectType') === $reportableSubject->value ? 'selected' : ''}}
>
{{__('report-subject.' . $reportableSubject->value)}}
</option>
@endforeach
</select>
<label for="subjectType">{{__('report.subjectType')}}</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating mb-2 {{request()->has('subjectId') ? 'd-none' : ''}}">
<input type="number" name="subjectId" id="subjectId" class="form-control" required
value="{{request()->get('subjectId')}}"
/>
<label for="subjectId">{{__('report.subjectId')}}</label>
</div>
</div>
</div>

<div class="form-floating mb-2">
<select name="reason" class="form-select" id="reason" required>
<option value="" selected disabled></option>
@foreach(ReportReason::cases() as $reason)
<option value="{{$reason->value}}">
{{__('report-reason.' . $reason->value)}}
</option>
@endforeach
</select>
<label for="title">{{__('report.reason')}}</label>
</div>

<div class="form-floating mb-2">
<textarea name="description" id="description" class="form-control" required
style="min-height: 100px;"></textarea>
<label for="description">{{__('report.description')}}</label>
</div>

<button class="btn btn-sm btn-outline-primary" type="submit">
{{__('report.submit')}}
</button>

</form>

<script>
// seeing this quick and dirty code?
// maybe you want to help us out and make it better?
// Create a Pull Request on GitHub!
// https://github.com/Traewelling/traewelling
document.getElementById('report').addEventListener('submit', function (event) {
event.preventDefault();
let formData = new FormData(this);
fetch('/api/v1/report', {
method: 'POST',
body: formData
})
.then(response => {
if (response.ok) {
notyf.success('{{__('report.success')}}');
document.getElementById('report').reset();
return response;
}
notyf.error('{{__('report.error')}}');
return response;
});
});
</script>

</div>
</div>
</div>
@endsection
5 changes: 4 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
->middleware(['can:create-manual-trip'])
->name('trip.create');

Route::view('/report', 'report')
->name('report');

Route::post('/ics/createToken', [IcsController::class, 'createIcsToken'])
->name('ics.createToken'); //TODO: Replace with API Endpoint
Route::post('/ics/revokeToken', [IcsController::class, 'revokeIcsToken'])
Expand All @@ -129,7 +132,7 @@
Route::get('/daily/{dateString}', [DailyStatsController::class, 'renderDailyStats'])
->name('stats.daily');
});

Route::prefix('open-data')->group(function() {
Route::get('/wikidata', [WikidataController::class, 'indexHelpPage'])
->name('open-data.wikidata');
Expand Down

0 comments on commit 24361d3

Please sign in to comment.