Add Country field to forms
This commit is contained in:
parent
17808c6eb1
commit
144af1bf71
|
@ -0,0 +1,256 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Contribution\Enums;
|
||||||
|
|
||||||
|
enum Country: string {
|
||||||
|
case AD = 'Andorra';
|
||||||
|
case AE = 'Vereinigte Arabische Emirate';
|
||||||
|
case AF = 'Afghanistan';
|
||||||
|
case AG = 'Antigua und Barbuda';
|
||||||
|
case AI = 'Anguilla';
|
||||||
|
case AL = 'Albanien';
|
||||||
|
case AM = 'Armenien';
|
||||||
|
case AN = 'Niederländische Antillen';
|
||||||
|
case AO = 'Angola';
|
||||||
|
case AQ = 'Antarktis';
|
||||||
|
case AR = 'Argentinien';
|
||||||
|
case AS = 'Amerikanisch-Samoa';
|
||||||
|
case AT = 'Österreich (Austria)';
|
||||||
|
case AU = 'Australien';
|
||||||
|
case AW = 'Aruba';
|
||||||
|
case AZ = 'Azerbaijan';
|
||||||
|
case BA = 'Bosnien-Herzegovina';
|
||||||
|
case BB = 'Barbados';
|
||||||
|
case BD = 'Bangladesh';
|
||||||
|
case BE = 'Belgien';
|
||||||
|
case BF = 'Burkina Faso';
|
||||||
|
case BG = 'Bulgarien';
|
||||||
|
case BH = 'Bahrain';
|
||||||
|
case BI = 'Burundi';
|
||||||
|
case BJ = 'Benin';
|
||||||
|
case BM = 'Bermudas';
|
||||||
|
case BN = 'Brunei Darussalam';
|
||||||
|
case BO = 'Bolivien';
|
||||||
|
case BR = 'Brasilien';
|
||||||
|
case BS = 'Bahamas';
|
||||||
|
case BT = 'Bhutan';
|
||||||
|
case BV = 'Bouvet Island';
|
||||||
|
case BW = 'Botswana';
|
||||||
|
case BY = 'Weißrußland (Belarus)';
|
||||||
|
case BZ = 'Belize';
|
||||||
|
case CA = 'Canada';
|
||||||
|
case CC = 'Cocos (Keeling) Islands';
|
||||||
|
case CD = 'Demokratische Republik Kongo';
|
||||||
|
case CF = 'Zentralafrikanische Republik';
|
||||||
|
case CG = 'Kongo';
|
||||||
|
case CH = 'Schweiz';
|
||||||
|
case CI = 'Elfenbeinküste (Cote D’Ivoire)';
|
||||||
|
case CK = 'Cook Islands';
|
||||||
|
case CL = 'Chile';
|
||||||
|
case CM = 'Kamerun';
|
||||||
|
case CN = 'China';
|
||||||
|
case CO = 'Kolumbien';
|
||||||
|
case CR = 'Costa Rica';
|
||||||
|
case CS = 'Tschechoslowakei (ehemalige)';
|
||||||
|
case CU = 'Kuba';
|
||||||
|
case CV = 'Kap Verde';
|
||||||
|
case CX = 'Christmas Island';
|
||||||
|
case CY = 'Zypern';
|
||||||
|
case CZ = 'Tschechische Republik';
|
||||||
|
case DE = 'Deutschland';
|
||||||
|
case DJ = 'Djibouti';
|
||||||
|
case DK = 'Dänemark';
|
||||||
|
case DM = 'Dominica';
|
||||||
|
case DO = 'Dominikanische Republik';
|
||||||
|
case DZ = 'Algerien';
|
||||||
|
case EC = 'Ecuador';
|
||||||
|
case EE = 'Estland';
|
||||||
|
case EG = 'Ägypten';
|
||||||
|
case EH = 'Westsahara';
|
||||||
|
case ER = 'Eritrea';
|
||||||
|
case ES = 'Spanien';
|
||||||
|
case ET = 'Äthiopien';
|
||||||
|
case FI = 'Finnland';
|
||||||
|
case FJ = 'Fiji';
|
||||||
|
case FK = 'Falkland-Inseln (Malvinas)';
|
||||||
|
case FM = 'Micronesien';
|
||||||
|
case FO = 'Faröer-Inseln';
|
||||||
|
case FR = 'Frankreich';
|
||||||
|
case FX = 'France, Metropolitan';
|
||||||
|
case GA = 'Gabon';
|
||||||
|
case GD = 'Grenada';
|
||||||
|
case GE = 'Georgien';
|
||||||
|
case GF = 'Französisch Guiana';
|
||||||
|
case GH = 'Ghana';
|
||||||
|
case GI = 'Gibraltar';
|
||||||
|
case GL = 'Grönland';
|
||||||
|
case GM = 'Gambia';
|
||||||
|
case GN = 'Guinea';
|
||||||
|
case GP = 'Guadeloupe';
|
||||||
|
case GQ = 'Äquatorialguinea';
|
||||||
|
case GR = 'Griechenland';
|
||||||
|
case GS = 'Südgeorgien und Südliche Sandwich-Inseln';
|
||||||
|
case GT = 'Guatemala';
|
||||||
|
case GU = 'Guam';
|
||||||
|
case GW = 'Guinea-Bissau';
|
||||||
|
case GY = 'Guyana';
|
||||||
|
case HK = 'Kong Hong';
|
||||||
|
case HM = 'Heard und Mc Donald Islands';
|
||||||
|
case HN = 'Honduras';
|
||||||
|
case HT = 'Haiti';
|
||||||
|
case HU = 'Ungarn';
|
||||||
|
case ID = 'Indonesien';
|
||||||
|
case IE = 'Irland';
|
||||||
|
case IL = 'Israel';
|
||||||
|
case IN = 'Indien';
|
||||||
|
case IO = 'British Indian Ocean Territory';
|
||||||
|
case IQ = 'Irak';
|
||||||
|
case IR = 'Iran (Islamische Republik)';
|
||||||
|
case IS = 'Island';
|
||||||
|
case IT = 'Italien';
|
||||||
|
case JM = 'Jamaica';
|
||||||
|
case JO = 'Jordanien';
|
||||||
|
case JP = 'Japan';
|
||||||
|
case KE = 'Kenya';
|
||||||
|
case KG = 'Kirgisien';
|
||||||
|
case KH = 'Königreich Kambodscha';
|
||||||
|
case KI = 'Kiribati';
|
||||||
|
case KM = 'Komoren';
|
||||||
|
case KN = 'Saint Kitts und Nevis';
|
||||||
|
case KP = 'Korea, Volksrepublik';
|
||||||
|
case KR = 'Korea';
|
||||||
|
case KW = 'Kuwait';
|
||||||
|
case KY = 'Kayman Islands';
|
||||||
|
case KZ = 'Kasachstan';
|
||||||
|
case LA = 'Laos';
|
||||||
|
case LB = 'Libanon';
|
||||||
|
case LC = 'Saint Lucia';
|
||||||
|
case LI = 'Liechtenstein';
|
||||||
|
case LK = 'Sri Lanka';
|
||||||
|
case LR = 'Liberia';
|
||||||
|
case LS = 'Lesotho';
|
||||||
|
case LT = 'Littauen';
|
||||||
|
case LU = 'Luxemburg';
|
||||||
|
case LV = 'Lettland';
|
||||||
|
case LY = 'Libyen';
|
||||||
|
case MA = 'Marokko';
|
||||||
|
case MC = 'Monaco';
|
||||||
|
case MD = 'Moldavien';
|
||||||
|
case MG = 'Madagaskar';
|
||||||
|
case MH = 'Marshall-Inseln';
|
||||||
|
case MK = 'Mazedonien, ehem. Jugoslawische Republik';
|
||||||
|
case ML = 'Mali';
|
||||||
|
case MM = 'Myanmar';
|
||||||
|
case MN = 'Mongolei';
|
||||||
|
case MO = 'Macao';
|
||||||
|
case MP = 'Nördliche Marianneninseln';
|
||||||
|
case MQ = 'Martinique';
|
||||||
|
case MR = 'Mauretanien';
|
||||||
|
case MS = 'Montserrat';
|
||||||
|
case MT = 'Malta';
|
||||||
|
case MU = 'Mauritius';
|
||||||
|
case MV = 'Malediven';
|
||||||
|
case MW = 'Malawi';
|
||||||
|
case MX = 'Mexico';
|
||||||
|
case MY = 'Malaysien';
|
||||||
|
case MZ = 'Mozambique';
|
||||||
|
case NA = 'Namibia';
|
||||||
|
case NC = 'Neu Kaledonien';
|
||||||
|
case NE = 'Niger';
|
||||||
|
case NF = 'Norfolk Island';
|
||||||
|
case NG = 'Nigeria';
|
||||||
|
case NI = 'Nicaragua';
|
||||||
|
case NL = 'Niederlande';
|
||||||
|
case NO = 'Norwegen';
|
||||||
|
case NP = 'Nepal';
|
||||||
|
case NR = 'Nauru';
|
||||||
|
case NU = 'Niue';
|
||||||
|
case NZ = 'Neuseeland';
|
||||||
|
case OM = 'Oman';
|
||||||
|
case PA = 'Panama';
|
||||||
|
case PE = 'Peru';
|
||||||
|
case PF = 'Französisch Polynesien';
|
||||||
|
case PG = 'Papua Neuguinea';
|
||||||
|
case PH = 'Philippinen';
|
||||||
|
case PK = 'Pakistan';
|
||||||
|
case PL = 'Polen';
|
||||||
|
case PM = 'St. Pierre und Miquelon';
|
||||||
|
case PN = 'Pitcairn';
|
||||||
|
case PR = 'Puerto Rico';
|
||||||
|
case PT = 'Portugal';
|
||||||
|
case PW = 'Palau';
|
||||||
|
case PY = 'Paraguay';
|
||||||
|
case QA = 'Katar';
|
||||||
|
case RE = 'Reunion';
|
||||||
|
case RO = 'Rumänien';
|
||||||
|
case RU = 'Russische Föderation';
|
||||||
|
case RW = 'Ruanda';
|
||||||
|
case SA = 'Saudi Arabien';
|
||||||
|
case SB = 'Salomonen';
|
||||||
|
case SC = 'Seychellen';
|
||||||
|
case SD = 'Sudan';
|
||||||
|
case SE = 'Schweden';
|
||||||
|
case SG = 'Singapur';
|
||||||
|
case SH = 'St. Helena';
|
||||||
|
case SI = 'Slovenien';
|
||||||
|
case SJ = 'Svalbard und Jan Mayen Islands';
|
||||||
|
case SK = 'Slowakei';
|
||||||
|
case SL = 'Sierra Leone';
|
||||||
|
case SM = 'San Marino';
|
||||||
|
case SN = 'Senegal';
|
||||||
|
case SO = 'Somalia';
|
||||||
|
case SR = 'Surinam';
|
||||||
|
case ST = 'Sao Tome und Principe';
|
||||||
|
case SV = 'El Salvador';
|
||||||
|
case SY = 'Syrien, Arabische Republik';
|
||||||
|
case SZ = 'Swaziland';
|
||||||
|
case TC = 'Turk und Caicos-Inseln';
|
||||||
|
case TD = 'Tschad';
|
||||||
|
case TF = 'Französisches Südl.Territorium';
|
||||||
|
case TG = 'Togo';
|
||||||
|
case TH = 'Thailand';
|
||||||
|
case TJ = 'Tadschikistan';
|
||||||
|
case TK = 'Tokelau';
|
||||||
|
case TM = 'Turkmenistan';
|
||||||
|
case TN = 'Tunesien';
|
||||||
|
case TO = 'Tonga';
|
||||||
|
case TP = 'Ost-Timor';
|
||||||
|
case TR = 'Türkei';
|
||||||
|
case TT = 'Trinidad und Tobago';
|
||||||
|
case TV = 'Tuvalu';
|
||||||
|
case TW = 'Taiwan';
|
||||||
|
case TZ = 'Tansania, United Republic of';
|
||||||
|
case UA = 'Ukraine';
|
||||||
|
case UG = 'Uganda';
|
||||||
|
case GB = 'Großbritannien';
|
||||||
|
case US = 'Vereinigte Staaten';
|
||||||
|
case UM = 'Vereinigte Staaten, Minor Outlying Islands';
|
||||||
|
case UY = 'Uruguay';
|
||||||
|
case UZ = 'Usbekistan';
|
||||||
|
case VA = 'Vatikanstaat';
|
||||||
|
case VC = 'Saint Vincent und Grenadines';
|
||||||
|
case VE = 'Venezuela';
|
||||||
|
case VG = 'Virgin Islands (Britisch)';
|
||||||
|
case VI = 'Virgin Islands (U.S.)';
|
||||||
|
case VN = 'Vietnam';
|
||||||
|
case VU = 'Vanuatu';
|
||||||
|
case WF = 'Wallis und Futuna Islands';
|
||||||
|
case WS = 'Samoa';
|
||||||
|
case YE = 'Jemen';
|
||||||
|
case YT = 'Mayotte';
|
||||||
|
case YU = 'Jugoslawien';
|
||||||
|
case ZA = 'Südafrika';
|
||||||
|
case ZM = 'Sambia';
|
||||||
|
case ZW = 'Zimbabw';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{name: string, id: string}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return collect(static::cases())
|
||||||
|
->map(fn ($case) => ['id' => $case->value, 'name' => $case->value])
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class FormStoreAction
|
||||||
'prevention_conditions' => 'array',
|
'prevention_conditions' => 'array',
|
||||||
'zip' => 'present|nullable|string',
|
'zip' => 'present|nullable|string',
|
||||||
'location' => 'present|nullable|string',
|
'location' => 'present|nullable|string',
|
||||||
|
'country' => 'nullable|string|max:255',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class FormUpdateAction
|
||||||
'prevention_conditions' => 'array',
|
'prevention_conditions' => 'array',
|
||||||
'location' => 'present|nullable|string',
|
'location' => 'present|nullable|string',
|
||||||
'zip' => 'present|nullable|string',
|
'zip' => 'present|nullable|string',
|
||||||
|
'country' => 'nullable|string|max:255',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Form\Models;
|
namespace App\Form\Models;
|
||||||
|
|
||||||
|
use App\Contribution\Enums\Country;
|
||||||
use App\Form\Actions\UpdateParticipantSearchIndexAction;
|
use App\Form\Actions\UpdateParticipantSearchIndexAction;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\Data\FieldCollection;
|
use App\Form\Data\FieldCollection;
|
||||||
|
@ -48,6 +49,7 @@ class Form extends Model implements HasMedia
|
||||||
'to' => 'datetime',
|
'to' => 'datetime',
|
||||||
'registration_from' => 'datetime',
|
'registration_from' => 'datetime',
|
||||||
'registration_until' => 'datetime',
|
'registration_until' => 'datetime',
|
||||||
|
'country' => Country::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +70,6 @@ class Form extends Model implements HasMedia
|
||||||
return $this->hasMany(Participant::class);
|
return $this->hasMany(Participant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function registerMediaCollections(): void
|
public function registerMediaCollections(): void
|
||||||
{
|
{
|
||||||
$this->addMediaCollection('headerImage')
|
$this->addMediaCollection('headerImage')
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Form\Resources;
|
namespace App\Form\Resources;
|
||||||
|
|
||||||
|
use App\Contribution\Enums\Country;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\Enums\NamiType;
|
use App\Form\Enums\NamiType;
|
||||||
use App\Form\Enums\SpecialType;
|
use App\Form\Enums\SpecialType;
|
||||||
|
@ -55,6 +56,7 @@ class FormResource extends JsonResource
|
||||||
'prevention_conditions' => $this->prevention_conditions,
|
'prevention_conditions' => $this->prevention_conditions,
|
||||||
'zip' => $this->zip,
|
'zip' => $this->zip,
|
||||||
'location' => $this->location,
|
'location' => $this->location,
|
||||||
|
'country' => $this->country,
|
||||||
'links' => [
|
'links' => [
|
||||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
||||||
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
||||||
|
@ -85,6 +87,7 @@ class FormResource extends JsonResource
|
||||||
'templates' => FormtemplateResource::collection(Formtemplate::get()),
|
'templates' => FormtemplateResource::collection(Formtemplate::get()),
|
||||||
'namiTypes' => NamiType::forSelect(),
|
'namiTypes' => NamiType::forSelect(),
|
||||||
'specialTypes' => SpecialType::forSelect(),
|
'specialTypes' => SpecialType::forSelect(),
|
||||||
|
'countries' => Country::forSelect(),
|
||||||
'default' => [
|
'default' => [
|
||||||
'description' => [],
|
'description' => [],
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
|
@ -106,6 +109,7 @@ class FormResource extends JsonResource
|
||||||
'prevention_conditions' => ['mode' => 'all', 'ifs' => []],
|
'prevention_conditions' => ['mode' => 'all', 'ifs' => []],
|
||||||
'zip' => '',
|
'zip' => '',
|
||||||
'location' => '',
|
'location' => '',
|
||||||
|
'country' => null,
|
||||||
],
|
],
|
||||||
'section_default' => [
|
'section_default' => [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?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('forms', function (Blueprint $table) {
|
||||||
|
$table->string('country')->nullable()->after('location');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('forms', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('country');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -20,14 +20,15 @@
|
||||||
<ui-popup v-if="single !== null && single.config !== null" :heading="`Veranstaltung ${single.id ? 'bearbeiten' : 'erstellen'}`" full @close="cancel">
|
<ui-popup v-if="single !== null && single.config !== null" :heading="`Veranstaltung ${single.id ? 'bearbeiten' : 'erstellen'}`" full @close="cancel">
|
||||||
<div class="flex flex-col mt-3">
|
<div class="flex flex-col mt-3">
|
||||||
<ui-tabs v-model="active" :entries="tabs" />
|
<ui-tabs v-model="active" :entries="tabs" />
|
||||||
<div v-show="active === 0" class="grid grid-cols-2 gap-3">
|
<div v-show="active === 0" class="grid grid-cols-4 gap-3">
|
||||||
<div class="flex space-x-3">
|
<div class="flex space-x-3 col-span-2">
|
||||||
<f-text id="name" v-model="single.name" class="grow" label="Name" required />
|
<f-text id="name" v-model="single.name" class="grow" label="Name" required />
|
||||||
<f-switch id="is_active" v-model="single.is_active" name="is_active" label="Aktiv" />
|
<f-switch id="is_active" v-model="single.is_active" name="is_active" label="Aktiv" />
|
||||||
<f-switch id="is_private" v-model="single.is_private" name="is_private" label="Privat" />
|
<f-switch id="is_private" v-model="single.is_private" name="is_private" label="Privat" />
|
||||||
</div>
|
</div>
|
||||||
<f-singlefile id="header_image"
|
<f-singlefile id="header_image"
|
||||||
v-model="single.header_image"
|
v-model="single.header_image"
|
||||||
|
class="col-span-2"
|
||||||
label="Bild"
|
label="Bild"
|
||||||
name="header_image"
|
name="header_image"
|
||||||
parent-name="form"
|
parent-name="form"
|
||||||
|
@ -35,14 +36,11 @@
|
||||||
collection="headerImage"
|
collection="headerImage"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<div class="grid gap-3 grid-cols-2">
|
|
||||||
<f-text id="from" v-model="single.from" type="date" label="Von" required />
|
<f-text id="from" v-model="single.from" type="date" label="Von" required />
|
||||||
<f-text id="to" v-model="single.to" type="date" label="Bis" required />
|
<f-text id="to" v-model="single.to" type="date" label="Bis" required />
|
||||||
</div>
|
|
||||||
<div class="grid gap-3 grid-cols-2">
|
|
||||||
<f-text id="zip" v-model="single.zip" label="PLZ" />
|
<f-text id="zip" v-model="single.zip" label="PLZ" />
|
||||||
<f-text id="location" v-model="single.location" label="Ort" />
|
<f-text id="location" v-model="single.location" label="Ort" />
|
||||||
</div>
|
<f-select id="country" v-model="single.country" class="col-span-2" name="country" label="Land" :options="meta.countries" />
|
||||||
<f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" required />
|
<f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" required />
|
||||||
<f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required />
|
<f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required />
|
||||||
<f-textarea id="excerpt"
|
<f-textarea id="excerpt"
|
||||||
|
@ -50,6 +48,7 @@
|
||||||
hint="Gebe hier eine kurze Beschreibung für die Veranstaltungs-Übersicht ein (Maximal 130 Zeichen)."
|
hint="Gebe hier eine kurze Beschreibung für die Veranstaltungs-Übersicht ein (Maximal 130 Zeichen)."
|
||||||
label="Auszug"
|
label="Auszug"
|
||||||
:rows="5"
|
:rows="5"
|
||||||
|
class="col-span-full"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\EndToEnd\Form;
|
namespace Tests\EndToEnd\Form;
|
||||||
|
|
||||||
|
use App\Contribution\Enums\Country;
|
||||||
use App\Fileshare\Data\FileshareResourceData;
|
use App\Fileshare\Data\FileshareResourceData;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\FormSettings;
|
use App\Form\FormSettings;
|
||||||
|
@ -11,12 +12,15 @@ use App\Form\Models\Participant;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
use Tests\RequestFactories\EditorRequestFactory;
|
||||||
|
use Tests\Lib\CreatesFormFields;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\EndToEndTestCase;
|
||||||
|
|
||||||
class FormIndexActionTest extends FormTestCase
|
uses(CreatesFormFields::class);
|
||||||
{
|
uses(DatabaseTransactions::class);
|
||||||
|
uses(EndToEndTestCase::class);
|
||||||
|
|
||||||
public function testItDisplaysForms(): void
|
it('testItDisplaysForms', function () {
|
||||||
{
|
|
||||||
Carbon::setTestNow(Carbon::parse('2023-03-03'));
|
Carbon::setTestNow(Carbon::parse('2023-03-03'));
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
$form = Form::factory()
|
$form = Form::factory()
|
||||||
|
@ -33,6 +37,7 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->has(Participant::factory()->count(5))
|
->has(Participant::factory()->count(5))
|
||||||
->zip('12345')
|
->zip('12345')
|
||||||
->location('SG')
|
->location('SG')
|
||||||
|
->country(Country::CH)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@ -50,6 +55,7 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
||||||
->assertInertiaPath('data.data.0.zip', '12345')
|
->assertInertiaPath('data.data.0.zip', '12345')
|
||||||
->assertInertiaPath('data.data.0.location', 'SG')
|
->assertInertiaPath('data.data.0.location', 'SG')
|
||||||
|
->assertInertiaPath('data.data.0.country', 'Schweiz')
|
||||||
->assertInertiaPath('data.data.0.participants_count', 5)
|
->assertInertiaPath('data.data.0.participants_count', 5)
|
||||||
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
||||||
->assertInertiaPath('data.data.0.is_active', true)
|
->assertInertiaPath('data.data.0.is_active', true)
|
||||||
|
@ -66,21 +72,25 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.meta.default.prevention_text.version', '1.0')
|
->assertInertiaPath('data.meta.default.prevention_text.version', '1.0')
|
||||||
->assertInertiaPath('data.meta.default.description', [])
|
->assertInertiaPath('data.meta.default.description', [])
|
||||||
->assertInertiaPath('data.meta.default.excerpt', '')
|
->assertInertiaPath('data.meta.default.excerpt', '')
|
||||||
|
->assertInertiaPath('data.meta.default.zip', '')
|
||||||
|
->assertInertiaPath('data.meta.default.location', '')
|
||||||
|
->assertInertiaPath('data.meta.default.country', null)
|
||||||
->assertInertiaPath('data.meta.default.is_active', true)
|
->assertInertiaPath('data.meta.default.is_active', true)
|
||||||
->assertInertiaPath('data.meta.default.is_private', false)
|
->assertInertiaPath('data.meta.default.is_private', false)
|
||||||
->assertInertiaPath('data.meta.default.mailattachments', [])
|
->assertInertiaPath('data.meta.default.mailattachments', [])
|
||||||
->assertInertiaPath('data.meta.default.export', ['root' => null, 'group_by' => null, 'to_group_field' => null])
|
->assertInertiaPath('data.meta.default.export', ['root' => null, 'group_by' => null, 'to_group_field' => null])
|
||||||
->assertInertiaPath('data.meta.default.config', null)
|
->assertInertiaPath('data.meta.default.config', null)
|
||||||
|
->assertInertiaPath('data.meta.countries.0.id', 'Andorra')
|
||||||
|
->assertInertiaPath('data.meta.countries.0.name', 'Andorra')
|
||||||
->assertInertiaPath('data.meta.base_url', url(''))
|
->assertInertiaPath('data.meta.base_url', url(''))
|
||||||
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||||
->assertInertiaPath('data.meta.specialTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
->assertInertiaPath('data.meta.specialTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||||
->assertInertiaPath('data.meta.section_default.name', '')
|
->assertInertiaPath('data.meta.section_default.name', '')
|
||||||
->assertInertiaPath('data.meta.default.zip', '')
|
->assertInertiaPath('data.meta.default.zip', '')
|
||||||
->assertInertiaPath('data.meta.default.location', '');
|
->assertInertiaPath('data.meta.default.location', '');
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testFormtemplatesHaveData(): void
|
it('testFormtemplatesHaveData', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')->fields([
|
Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')->fields([
|
||||||
$this->textField('vorname')
|
$this->textField('vorname')
|
||||||
|
@ -98,10 +108,9 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.fields.0.key', 'vorname')
|
->assertInertiaPath('data.meta.templates.0.config.sections.0.fields.0.key', 'vorname')
|
||||||
->assertInertiaPath('data.meta.templates.0.mail_top.blocks.0.data.text', 'lala')
|
->assertInertiaPath('data.meta.templates.0.mail_top.blocks.0.data.text', 'lala')
|
||||||
->assertInertiaPath('data.meta.templates.0.mail_bottom.blocks.0.data.text', 'lalb');
|
->assertInertiaPath('data.meta.templates.0.mail_bottom.blocks.0.data.text', 'lalb');
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItDisplaysExport(): void
|
it('testItDisplaysExport', function () {
|
||||||
{
|
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
Form::factory()
|
Form::factory()
|
||||||
->name('lala')
|
->name('lala')
|
||||||
|
@ -114,10 +123,9 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.data.0.export.root.connection_id', 2)
|
->assertInertiaPath('data.data.0.export.root.connection_id', 2)
|
||||||
->assertInertiaPath('data.data.0.export.root.resource', '/dir')
|
->assertInertiaPath('data.data.0.export.root.resource', '/dir')
|
||||||
->assertInertiaPath('data.data.0.export.to_group_field', 'abc');
|
->assertInertiaPath('data.data.0.export.to_group_field', 'abc');
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItHandlesFullTextSearch(): void
|
it('testItHandlesFullTextSearch', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||||
Form::factory()->to(now()->addYear())->name('Rover-Spek 2025')->create();
|
Form::factory()->to(now()->addYear())->name('Rover-Spek 2025')->create();
|
||||||
|
@ -127,10 +135,9 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaCount('data.data', 1);
|
->assertInertiaCount('data.data', 1);
|
||||||
$this->callFilter('form.index', [])
|
$this->callFilter('form.index', [])
|
||||||
->assertInertiaCount('data.data', 2);
|
->assertInertiaCount('data.data', 2);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItDisplaysParentLinkForFormWithNamiFields(): void
|
it('testItDisplaysParentLinkForFormWithNamiFields', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$form = Form::factory()->fields([$this->namiField('mitglieder')])->create();
|
$form = Form::factory()->fields([$this->namiField('mitglieder')])->create();
|
||||||
|
|
||||||
|
@ -139,29 +146,26 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.data.0.has_nami_field', true)
|
->assertInertiaPath('data.data.0.has_nami_field', true)
|
||||||
->assertInertiaPath('data.data.0.links.participant_root_index', route('form.participant.index', ['form' => $form, 'parent' => -1]))
|
->assertInertiaPath('data.data.0.links.participant_root_index', route('form.participant.index', ['form' => $form, 'parent' => -1]))
|
||||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form, 'parent' => null]));
|
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form, 'parent' => null]));
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItDisplaysRegisterUrl(): void
|
it('testItDisplaysRegisterUrl', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
FormSettings::fake(['registerUrl' => 'https://example.com/form/{slug}/register']);
|
FormSettings::fake(['registerUrl' => 'https://example.com/form/{slug}/register']);
|
||||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.frontend', 'https://example.com/form/zem-2024/register');
|
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.frontend', 'https://example.com/form/zem-2024/register');
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItDisplaysCopyUrl(): void
|
it('testItDisplaysCopyUrl', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$form = Form::factory()->create();
|
$form = Form::factory()->create();
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.copy', route('form.copy', $form));
|
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.copy', route('form.copy', $form));
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItDoesntReturnInactiveForms(): void
|
it('testItDoesntReturnInactiveForms', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
Form::factory()->isActive(false)->count(1)->create();
|
Form::factory()->isActive(false)->count(1)->create();
|
||||||
Form::factory()->isActive(true)->count(2)->create();
|
Form::factory()->isActive(true)->count(2)->create();
|
||||||
|
@ -170,10 +174,9 @@ class FormIndexActionTest extends FormTestCase
|
||||||
$this->callFilter('form.index', [])->assertInertiaCount('data.data', 2);
|
$this->callFilter('form.index', [])->assertInertiaCount('data.data', 2);
|
||||||
$this->callFilter('form.index', ['inactive' => true])->assertInertiaCount('data.data', 3);
|
$this->callFilter('form.index', ['inactive' => true])->assertInertiaCount('data.data', 3);
|
||||||
$this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2);
|
$this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItOrdersByStartDateDesc(): void
|
it('testItOrdersByStartDateDesc', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
||||||
$form2 = Form::factory()->from(now()->addDays(3))->to(now()->addYear())->create();
|
$form2 = Form::factory()->from(now()->addDays(3))->to(now()->addYear())->create();
|
||||||
|
@ -184,10 +187,9 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaPath('data.data.0.id', $form3->id)
|
->assertInertiaPath('data.data.0.id', $form3->id)
|
||||||
->assertInertiaPath('data.data.1.id', $form2->id)
|
->assertInertiaPath('data.data.1.id', $form2->id)
|
||||||
->assertInertiaPath('data.data.2.id', $form1->id);
|
->assertInertiaPath('data.data.2.id', $form1->id);
|
||||||
}
|
});
|
||||||
|
|
||||||
public function testItShowsPastEvents(): void
|
it('testItShowsPastEvents', function () {
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
||||||
Form::factory()->count(3)->to(now()->subDays(5))->create();
|
Form::factory()->count(3)->to(now()->subDays(5))->create();
|
||||||
|
@ -198,5 +200,4 @@ class FormIndexActionTest extends FormTestCase
|
||||||
->assertInertiaCount('data.data', 10);
|
->assertInertiaCount('data.data', 10);
|
||||||
$this->callFilter('form.index', [])
|
$this->callFilter('form.index', [])
|
||||||
->assertInertiaCount('data.data', 2);
|
->assertInertiaCount('data.data', 2);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Form;
|
namespace Tests\Feature\Form;
|
||||||
|
|
||||||
|
use App\Contribution\Enums\Country;
|
||||||
use App\Fileshare\Data\FileshareResourceData;
|
use App\Fileshare\Data\FileshareResourceData;
|
||||||
use App\Form\Data\ExportData;
|
use App\Form\Data\ExportData;
|
||||||
use App\Form\Enums\NamiType;
|
use App\Form\Enums\NamiType;
|
||||||
|
@ -34,6 +35,7 @@ it('testItStoresForm', function () {
|
||||||
->headerImage('htzz.jpg')
|
->headerImage('htzz.jpg')
|
||||||
->zip('12345')
|
->zip('12345')
|
||||||
->location('Solingen')
|
->location('Solingen')
|
||||||
|
->country('Schweiz')
|
||||||
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])])
|
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])])
|
||||||
->fake();
|
->fake();
|
||||||
|
|
||||||
|
@ -59,6 +61,7 @@ it('testItStoresForm', function () {
|
||||||
$this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name);
|
$this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name);
|
||||||
$this->assertEquals('Solingen', $form->location);
|
$this->assertEquals('Solingen', $form->location);
|
||||||
$this->assertEquals('12345', $form->zip);
|
$this->assertEquals('12345', $form->zip);
|
||||||
|
$this->assertEquals(Country::CH, $form->country);
|
||||||
Event::assertDispatched(Succeeded::class, fn(Succeeded $event) => $event->message === 'Veranstaltung gespeichert.');
|
Event::assertDispatched(Succeeded::class, fn(Succeeded $event) => $event->message === 'Veranstaltung gespeichert.');
|
||||||
$this->assertFrontendCacheCleared();
|
$this->assertFrontendCacheCleared();
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,16 +118,17 @@ it('testItUpdatesActiveState', function () {
|
||||||
$this->assertTrue($form->fresh()->is_active);
|
$this->assertTrue($form->fresh()->is_active);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates zip and location', function () {
|
it('updates meta info', function () {
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
$form = Form::factory()->create();
|
$form = Form::factory()->create();
|
||||||
$request = FormRequest::new()->zip('12345')->location('Musterstadt')->create();
|
$request = FormRequest::new()->zip('12345')->location('Musterstadt')->country('Schweiz')->create();
|
||||||
|
|
||||||
$this->patchJson(route('form.update', ['form' => $form]), $request)->assertOk();
|
$this->patchJson(route('form.update', ['form' => $form]), $request)->assertOk();
|
||||||
test()->assertDatabaseHas('forms', [
|
test()->assertDatabaseHas('forms', [
|
||||||
'id' => $form->id,
|
'id' => $form->id,
|
||||||
'zip' => '12345',
|
'zip' => '12345',
|
||||||
'location' => 'Musterstadt',
|
'location' => 'Musterstadt',
|
||||||
|
'country' => 'Schweiz',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue