@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Pages;
|
||||
|
||||
use App\Filament\Resources\TlaSuggestions\TlaSuggestionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTlaSuggestion extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TlaSuggestionResource::class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Pages;
|
||||
|
||||
use App\Filament\Resources\TlaSuggestions\TlaSuggestionResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTlaSuggestion extends EditRecord
|
||||
{
|
||||
protected static string $resource = TlaSuggestionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Pages;
|
||||
|
||||
use App\Filament\Resources\TlaSuggestions\TlaSuggestionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTlaSuggestions extends ListRecords
|
||||
{
|
||||
protected static string $resource = TlaSuggestionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Pages;
|
||||
|
||||
use App\Filament\Resources\TlaSuggestions\TlaSuggestionResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTlaSuggestion extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TlaSuggestionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TlaSuggestionForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('acronym')
|
||||
->required(),
|
||||
TextInput::make('hint')
|
||||
->default(null),
|
||||
Select::make('language')
|
||||
->options(['hu' => 'Hu', 'en' => 'En'])
|
||||
->required(),
|
||||
Textarea::make('context')
|
||||
->default(null)
|
||||
->columnSpanFull(),
|
||||
TextInput::make('submitter')
|
||||
->default(null),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TlaSuggestionInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('acronym'),
|
||||
TextEntry::make('hint')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('language')
|
||||
->badge(),
|
||||
TextEntry::make('context')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('submitter')
|
||||
->placeholder('-'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TlaSuggestionsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('acronym')
|
||||
->searchable(),
|
||||
TextColumn::make('hint')
|
||||
->searchable(),
|
||||
TextColumn::make('language')
|
||||
->badge(),
|
||||
TextColumn::make('submitter')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TlaSuggestions;
|
||||
|
||||
use App\Filament\Resources\TlaSuggestions\Pages\CreateTlaSuggestion;
|
||||
use App\Filament\Resources\TlaSuggestions\Pages\EditTlaSuggestion;
|
||||
use App\Filament\Resources\TlaSuggestions\Pages\ListTlaSuggestions;
|
||||
use App\Filament\Resources\TlaSuggestions\Pages\ViewTlaSuggestion;
|
||||
use App\Filament\Resources\TlaSuggestions\Schemas\TlaSuggestionForm;
|
||||
use App\Filament\Resources\TlaSuggestions\Schemas\TlaSuggestionInfolist;
|
||||
use App\Filament\Resources\TlaSuggestions\Tables\TlaSuggestionsTable;
|
||||
use App\Models\TlaSuggestion;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TlaSuggestionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TlaSuggestion::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'TlaSuggestion';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TlaSuggestionForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return TlaSuggestionInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TlaSuggestionsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTlaSuggestions::route('/'),
|
||||
'create' => CreateTlaSuggestion::route('/create'),
|
||||
'view' => ViewTlaSuggestion::route('/{record}'),
|
||||
'edit' => EditTlaSuggestion::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class TlaResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'tla';
|
||||
protected static ?string $recordTitleAttribute = 'Tla';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -42,13 +42,23 @@ class TlaResource extends Resource
|
||||
Textarea::make('context')
|
||||
->default(null)
|
||||
->columnSpanFull(),
|
||||
TextInput::make('submitter')
|
||||
->default(null),
|
||||
TextInput::make('likes')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
TextInput::make('dislikes')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('tla')
|
||||
->recordTitleAttribute('Tla')
|
||||
->columns([
|
||||
TextColumn::make('acronym')
|
||||
->searchable(),
|
||||
@@ -59,6 +69,14 @@ class TlaResource extends Resource
|
||||
TextColumn::make('used')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('submitter')
|
||||
->searchable(),
|
||||
TextColumn::make('likes')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('dislikes')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -37,6 +37,7 @@ class TlaController extends Controller
|
||||
'date' => $session->get('date-'.$language),
|
||||
'tla' => $session->get('tla-'.$language) == $tla->acronym ? $tla->acronym : NULL,
|
||||
'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL,
|
||||
'submitter' => $tla->submitter,
|
||||
'correct' => $session->get('correct-'.$language),
|
||||
]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ class Tla extends Model
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'likes', 'dislikes'];
|
||||
protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'submitter', 'likes', 'dislikes'];
|
||||
|
||||
public static function GetCurrentTla( string $language ) : Tla {
|
||||
$tla = Tla::where('used', date("Y-m-d"))
|
||||
|
||||
@@ -12,7 +12,10 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tla_suggestion', function (Blueprint $table){
|
||||
$table->string('submitter')->default('Anonymus')->after('context');
|
||||
$table->string('submitter')->nullable()->after('context');
|
||||
});
|
||||
Schema::table('tla', function (Blueprint $table){
|
||||
$table->string('submitter')->nullable()->after('context');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@
|
||||
</template>
|
||||
|
||||
|
||||
<template #footer>
|
||||
|
||||
<template v-if="guesses.length < maxGuesses && !correct">
|
||||
<div class="flex-container" v-if="guess.length > 0">
|
||||
@@ -122,9 +121,11 @@
|
||||
<Review/>
|
||||
</template>
|
||||
<h3>Guesses left: {{ maxGuesses - guesses.length }}</h3>
|
||||
|
||||
</template>
|
||||
</UCard>
|
||||
</UCard>
|
||||
<br>
|
||||
<UButton to="/suggestion" color="neutral" variant="subtle">
|
||||
Suggest a TLA!
|
||||
</UButton>
|
||||
|
||||
<Modal v-model:open="victory">
|
||||
<h1>Congratulations!</h1>
|
||||
@@ -138,6 +139,7 @@
|
||||
<h3>The context of todays TLA:</h3>
|
||||
{{ context }}
|
||||
</Modal>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,35 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import Modal from '../components/Modal.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>TLA suggestion form</h1>
|
||||
<UCard class="w-140 align-center">
|
||||
|
||||
<UForm @submit="onSubmit" class="space-y-4" action="/api/suggestion" method="post">
|
||||
<UFormField class="form-field" label="Acronym" required>
|
||||
<UInput v-model="form.acronym" class="w-80" placeholder="Enter your TLA" name="tla"></UInput>
|
||||
</UFormField>
|
||||
<UFormField label="Motto" required>
|
||||
<UInput class="w-80" v-model="form.hint" placeholder="Enter the motto for your TLA" name="hint"></UInput>
|
||||
</UFormField>
|
||||
<UFormField label="Contex" required>
|
||||
<UTextarea class="w-80" v-model="form.context" name="context" rows=5 placeholder="Provide context for your TLA. This will be displayed upon completing the riddle of the day, either by guessing it correctly, or by running out of guesses."></UTextarea>
|
||||
</UFormField>
|
||||
<UFormField required>
|
||||
<URadioGroup orientation="horizontal" v-model="form.language" name="language" variant="table" size="xs" default-value="en" :items="['en', 'hu']" />
|
||||
</UFormField>
|
||||
<UFormField class="form-field" label="Submitter (your name)">
|
||||
<UInput v-model="form.submitter" class="w-80" placeholder="Anonymus" name="submitter"></UInput>
|
||||
</UFormField>
|
||||
<UButton type="submit">
|
||||
Submit suggestion
|
||||
</UButton>
|
||||
</UForm>
|
||||
<br>
|
||||
Disclaimer: I'm going through these manually, approving them or even changing the context or motto for them, if I feel it's necessary. I don't guarantee, that your suggestion will be approved and even if it is, it may not be next days TLA.
|
||||
</UCard>
|
||||
<UCard class="align-center">
|
||||
|
||||
<UForm @submit="onSubmit" class="space-y-4" action="/api/suggestion" method="post">
|
||||
<UFormField class="form-field" label="Acronym" required>
|
||||
<UInput v-model="form.acronym" class="w-80" placeholder="Enter your TLA" name="tla"></UInput>
|
||||
</UFormField>
|
||||
<UFormField label="Motto" required>
|
||||
<UInput class="w-80" v-model="form.hint" placeholder="Enter the motto for your TLA" name="hint"></UInput>
|
||||
</UFormField>
|
||||
<UFormField label="Contex" required>
|
||||
<UTextarea class="w-80" v-model="form.context" name="context" rows=5 placeholder="Provide context for your TLA. This will be displayed upon completing the riddle of the day, either by guessing it correctly, or by running out of guesses."></UTextarea>
|
||||
</UFormField>
|
||||
<UFormField required>
|
||||
<URadioGroup orientation="horizontal" v-model="form.language" name="language" variant="table" size="xs" default-value="en" :items="['en', 'hu']" />
|
||||
</UFormField>
|
||||
<UFormField class="form-field" label="Submitter (your name)">
|
||||
<UInput v-model="form.submitter" class="w-80" placeholder="Anonymus" name="submitter"></UInput>
|
||||
</UFormField>
|
||||
<UButton type="submit">
|
||||
Submit suggestion
|
||||
</UButton>
|
||||
</UForm>
|
||||
<br>
|
||||
Disclaimer: I'm going through these manually, approving them or even changing the context or motto for them, if I feel it's necessary. I don't guarantee, that your suggestion will be approved and even if it is, it may not be next days TLA.
|
||||
</UCard>
|
||||
|
||||
<Modal v-model:open="submited">
|
||||
<b>Your suggestion has been submitted!</b><br>
|
||||
If you wish, you can submit adnother TLA by exiting this alert. <br><br>
|
||||
<UButton to="/">Main page</UButton>
|
||||
<UButton to="/">Main page</UButton>
|
||||
</Modal>
|
||||
|
||||
</template>
|
||||
@@ -46,6 +51,7 @@
|
||||
<script lang="ts">
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -62,13 +68,17 @@ import axios from 'axios';
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
axios.post('/api/suggestion/en', this.form);
|
||||
this.form.acronym = '';
|
||||
this.form.hint = '';
|
||||
this.form.context = '';
|
||||
this.form.submitter = '';
|
||||
this.form.language = 'en';
|
||||
this.submited = true;
|
||||
axios.post('/api/suggestion/en', this.form).then( response => {
|
||||
if (response.status == 200)
|
||||
{
|
||||
this.form.acronym = '';
|
||||
this.form.hint = '';
|
||||
this.form.context = '';
|
||||
this.form.submitter = '';
|
||||
this.form.language = 'en';
|
||||
this.submited = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user