🆕 feat(project): add website field and validation for project proposals form

This commit is contained in:
fsociety
2024-10-24 17:40:51 +02:00
parent 5c4f9b6371
commit 6db38d08f5
4 changed files with 58 additions and 3 deletions

View File

@@ -15,4 +15,7 @@ class ProjectProposalForm extends Form
#[Validate('required|string|min:5')] #[Validate('required|string|min:5')]
public $description = ''; public $description = '';
#[Validate('required|url')]
public $website= '';
} }

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('project_proposals', function (Blueprint $table) {
$table->string('website')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('project_proposals', function (Blueprint $table) {
//
});
}
};

View File

@@ -31,7 +31,7 @@ on([
$this->currentPubkey = $pubkey; $this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first(); $this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
if ($this->currentPleb->association_status->value < 3) { if ($this->currentPleb->association_status->value < 3) {
return $this->js('alert("Du bist hierzu berechtigt.")'); return $this->js('alert("Du bist hierzu nicht berechtigt.")');
} }
$this->isAllowed = true; $this->isAllowed = true;
}, },
@@ -57,7 +57,8 @@ $save = function () {
<x-layouts.app title="Welcome"> <x-layouts.app title="Welcome">
@volt @volt
<div x-cloak x-show="isAllowed" class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto" x-data="nostrDefault(@this)"> <div x-cloak x-show="isAllowed" class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto"
x-data="nostrDefault(@this)">
<form class="space-y-8 divide-y divide-gray-700 pb-24"> <form class="space-y-8 divide-y divide-gray-700 pb-24">
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5"> <div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5"> <div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
@@ -82,6 +83,11 @@ $save = function () {
:placeholder="__('Name')"/> :placeholder="__('Name')"/>
</x-input.group> </x-input.group>
<x-input.group :for="md5('form.website')" :label="__('Webseite des Projekts')">
<x-input autocomplete="off" wire:model.debounce="form.website"
:placeholder="__('Website')"/>
</x-input.group>
<x-input.group :for="md5('form.name')" :label="__('Beabsichtigte Unterstützung in Sats')"> <x-input.group :for="md5('form.name')" :label="__('Beabsichtigte Unterstützung in Sats')">
<x-input type="number" autocomplete="off" wire:model.debounce="form.support_in_sats" <x-input type="number" autocomplete="off" wire:model.debounce="form.support_in_sats"
:placeholder="__('Beabsichtigte Unterstützung in Sats')"/> :placeholder="__('Beabsichtigte Unterstützung in Sats')"/>

View File

@@ -23,13 +23,32 @@ state([
'votes', 'votes',
]) ])
->get(), ->get(),
'isAllowed' => false,
'currentPubkey' => null,
'currentPleb' => null,
]);
on([
'nostrLoggedIn' => function ($pubkey) {
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
if ($this->currentPleb->association_status->value < 2) {
return $this->js('alert("Du bist hierzu nicht berechtigt.")');
}
$this->isAllowed = true;
},
'nostrLoggedOut' => function () {
$this->isAllowed = false;
$this->currentPubkey = null;
$this->currentPleb = null;
},
]); ]);
?> ?>
<x-layouts.app title="Projekt Unterstützungen"> <x-layouts.app title="Projekt Unterstützungen">
@volt @volt
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto"> <div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto" x-data="nostrDefault(@this)" x-cloak x-show="isAllowed">
<!-- Page header --> <!-- Page header -->
<div class="sm:flex sm:justify-between sm:items-center mb-5"> <div class="sm:flex sm:justify-between sm:items-center mb-5">