Files
RomhackPlaza/resources/views/submissions/form.blade.php
2026-06-08 16:25:52 +02:00

210 lines
10 KiB
PHP

<?php
/** @var \App\Models\Modification $modif */
/** @var \App\Models\Status $status */
?>
{{-- Pushed in header. --}}
@push('styles')
<meta name="fs-section" content="{{ $section }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="submission-has-errors" content="{{ $errors->any() ? '1' : '0' }}">
@endpush
@push('scripts')
@vite('resources/js/submissions.js')
@endpush
{{-- Server side errors summary --}}
@if($errors->any())
@foreach( $errors->all() as $error )
<x-form-error-text message="{{ $error }}" />
@endforeach
@endif
<div class="block">
<form action="{{ $isEdit ? route('submit.update', [ $section, $entry->id ] ) : route('submit.store', $section ) }}"
method="POST" x-data="Submission()" x-init="init()" @submit.prevent="submitForm($event)">
@include('submissions.fs-upload')
<!-- ABOUT THE ENTRY -->
<x-form-group-title label="{{ $words['about_the'] }}" icon="puzzle" />
@if( section_must_not_be( 'translations', $section ) )
<div class="form-group">
<x-form-field-title name="{{ $words['entry_title'] }}" required="true" />
<input class="form-input" type="text" name="entry_title" value="{{ old('entry_title', $entry->title ?? '' ) }}" required>
@error('entry_title')
<x-form-error-text message="{{ $message }}" />
@enderror
</div>
@else
<div class="form-group">
<x-form-field-title name="{{ $words['entry_title'] }}" helper="{{ $words['entry_title_helper'] }}" />
<input class="form-input" type="text" name="entry_title" value="{{ old('entry_title', $entry->title, '' ) }}">
@error('entry_title')
<x-form-error-text message="{{ $message }}" />
@enderror
</div>
@endif
@if( section_must_be( 'romhacks', $section ) )
<div class="form-group">
<x-form-field-title name="{{ $words['type_of_hack'] }}" required="true" />
<div class="form-type-of-checkboxes form-group level" id="modifications-group" x-ref="modificationsGroup">
@foreach( $modifications as $modif )
<label><input class="form-checkbox" type="checkbox" name="modifications[]" value="{{ $modif->id }}" {{ in_array($modif->id, $oldModifications) ? 'checked' : '' }}>{{ $modif->name }}</label>
@endforeach
</div>
<div class="form-error-text" x-show="errorKey === 'noModifications'" x-text="errorMessage"></div>
</div>
@endif
@if( section_must_be( ['romhacks', 'translations'], $section ) )
<div class="form-group grid-c3">
<div>
<x-form-field-title name="{{ $words['version'] }}" required="true" />
<input class="form-input" type="text" name="version" value="{{ old( 'version', $entry->version ?? '' ) }}" required>
</div>
<div>
<x-form-field-title name="{{ $words['release_date'] }}" helper="{{ $words['release_date_helper'] }}" required="true" />
{{-- TODO: Add max to the date --}}
<input type="date" class="form-input" name="release-date" value="{{ old('release-date') ?? $entry->release_date?->format('Y-m-d') ?? '' }}" required>
</div>
<div>
<x-form-field-title name="{{ $words['status'] }}" required="true" />
<div class="form-status-radio form-group level">
@foreach( $statuses as $status )
<label><input class="form-radio" type="radio" name="status" value="{{ $status->id }}" {{ old('status', $entry->status_id ) == $status->id ? 'checked' : '' }} required>{{ $status->name }}</label>
@endforeach
</div>
</div>
</div>
@endif
@if( section_must_be( 'translations', $section ) )
<x-form-field-title name="Languages" required="true" />
<x-languages-selector :selected="$oldLanguages" />
@error('languages')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('languages.*')
<x-form-error-text message="{{ $message }}" />
@enderror
@endif
<div class="form-group" x-ref="descriptionField">
<x-form-field-title name="{{ $words['description'] }}" required="true" />
<x-markdown-textarea name="description" value="{{ old('description', $entry->description ?? '') }}" />
<div class="form-error-text" x-show="errorKey === 'noDescription'" x-text="errorMessage"></div>
@error('description')
<x-form-error-text message="{{ $message }}" />
@enderror
</div>
<x-form-group-title label="{{ $words['about_game'] }}" icon="gamepad-2" />
<div x-ref="gameSelector">
<livewire:game-selector
:game-id="old('game_id', $entry->game_id ?? null )"
:new-game-title="old('new-game-title')"
:new-game-platform="old('new-game-platform')"
:new-game-genre="old('new-game-genre')"
/>
</div>
<div class="form-error-text" x-show="errorKey === 'noGame'" x-text="errorMessage"></div>
@error('game_id')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('new-game-title')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('new-game-platform')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('new-game-genre')
<x-form-error-text message="{{ $message }}" />
@enderror
<livewire:hashes-upload :old-hashes="old('hashes', $entry->hashes->toArray(), [])" />
@if( section_must_not_be( 'translations', $section ) )
<x-form-field-title name="Languages" required="true" />
<x-languages-selector :selected="$oldLanguages" />
@error('languages')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('languages.*')
<x-form-error-text message="{{ $message }}" />
@enderror
@endif
<x-form-group-title label="{{ $words['attachments'] }}" icon="paperclip" />
<x-main-image-field :old-path="old('main-image', $entry->main_image ?? '') ?? ''" />
<x-gallery-field :old-paths="old('gallery', $entry->gallery->pluck('image')->toArray() ?? [] )"/>
@error('gallery')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('gallery.*')
<x-form-error-text message="{{ $message }}" />
@enderror
<x-form-group-title label="{{ $words['authors'] }}" icon="users" />
<livewire:authors-selector :old-authors="old('authors', $entry->authors->map(fn($a) => ['id' => $a->id, 'name' => $a->name ])->toArray() ?? [])" :old-new-authors="old('new-authors', [])" />
@error('authors')
<x-form-error-text message="{{ $message }}" />
@enderror
@error('new-authors')
<x-form-error-text message="{{ $message }}" />
@enderror
<x-staff-credits-field :old-staff-credits="old('staff_credits', $entry->staff_credits ?? null)" />
<x-form-group-title label="{{ $words['related_links'] }}" icon="link" />
<div class="form-group grid-c2">
<div>
<x-form-field-title name="{{ $words['release_site'] }}" helper="{{ $words['release_site_helper'] }}" required="" />
<input class="form-input" type="url" name="release_site" value="{{ old( 'release_site', $entry->relevant_link ?? '' ) }}">
</div>
<div>
<x-form-field-title name="{{ $words['youtube_video'] }}" required="" />
<input class="form-input" type="url" name="youtube_video" value="{{ old( 'youtube_video', $entry->youtube_link ?? '' ) }}">
</div>
</div>
@if($isEdit)
<x-form-group-title label="Entry Management" icon="wrench" />
@can('moderate',$entry)
<div class="form-group grid-c2">
<div>
<x-form-field-title name="Staff comment" />
<textarea class="form-textarea" name="staff_comment" rows="3">{{ old('staff_comment', $entry->staff_comment ?? '' ) }}</textarea>
</div>
<div>
<x-form-field-title name="Owner" required="true" />
<livewire:xf-user-selector :initial-user-id="$entry->user_id" />
</div>
</div>
<div class="form-group grid-c2">
<div>
<x-form-field-title name="XenForo Comments Thread ID" />
<input type="text" name="comments_thread_id" class="form-input" value="{{ old('comments_thread_id', $entry->comments_thread_id) }}">
</div>
</div>
<div class="form-group">
<x-form-field-title name="Metadata" required="true" />
<div class="form-type-of-checkboxes form-group level" id="entry-metadata">
<label><input class="form-checkbox" type="checkbox" name="featured" value="1" {{ old('featured', $entry->featured ) ? 'checked' : '' }}>Featured entry</label>
</div>
</div>
@endcan
@cannot('moderate', $entry)
@endcannot
@endif
@csrf
<div class="submit">
<x-submit-entry-status :section="$section" :is-edit="$isEdit" :current-state="$entry->state ?? null" :entry="$entry" />
<button id="submit-button" type="submit" class="btn primary" style="padding:1%;">Submit</button>
</div>
</form>
</div>