Skip to content

Commit

Permalink
Added Summary field on Person
Browse files Browse the repository at this point in the history
  • Loading branch information
kreaweb.be committed Sep 23, 2024
1 parent 959e823 commit fbcd634
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 54 deletions.
6 changes: 6 additions & 0 deletions app/Livewire/Forms/People/ProfileForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ProfileForm extends Form

public $pob = null;

public $summary = null;

// -----------------------------------------------------------------------
#[Computed(persist: true, seconds: 3600, cache: true)]
public function genders(): Collection
Expand Down Expand Up @@ -68,6 +70,8 @@ public function rules(): array
new DobValid,
],
'pob' => ['nullable', 'string', 'max:255'],

'summary' => ['nullable', 'string', 'max:65535'],
];
}

Expand All @@ -90,6 +94,8 @@ public function validationAttributes(): array
'yob' => __('person.yob'),
'dob' => __('person.dob'),
'pob' => __('person.pob'),

'summary' => __('person.summary'),
];
}
}
6 changes: 5 additions & 1 deletion app/Livewire/People/Edit/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function mount(): void
$this->profileForm->yob = $this->person->yob ?? null;
$this->profileForm->dob = $this->person->dob ? Carbon::parse($this->person->dob)->format('Y-m-d') : null;
$this->profileForm->pob = $this->person->pob;

$this->profileForm->summary = $this->person->summary;
}

public function saveProfile()
Expand Down Expand Up @@ -69,7 +71,9 @@ public function isDirty(): bool

$this->profileForm->yob != $this->person->yob or
$this->profileForm->dob != ($this->person->dob ? Carbon::parse($this->person->dob)->format('Y-m-d') : null) or
$this->profileForm->pob != $this->person->pob;
$this->profileForm->pob != $this->person->pob or

$this->profileForm->summary != $this->person->summary;
}

// ------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Person extends Model implements HasMedia
'dob', 'yob', 'pob',
'dod', 'yod', 'pod',

'summary',

'street', 'number',
'postal_code', 'city',
'province', 'state',
Expand Down
2 changes: 2 additions & 0 deletions database/migrations/2024_03_03_300001_create_people_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function up(): void
$table->integer('yod')->nullable();
$table->string('pod')->nullable();

$table->text('summary')->nullable();

$table->string('street', 100)->nullable();
$table->string('number', 20)->nullable();
$table->string('postal_code', 20)->nullable();
Expand Down
1 change: 1 addition & 0 deletions lang/de/person.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'dod' => 'Sterbedatum',
'yod' => 'Sterbejahr',
'pod' => 'Sterbeort',
'summary' => 'Zusammenfassung',
'email' => 'E-Mail Adresse',
'password' => 'Passwort',
'address' => 'Adresse',
Expand Down
1 change: 1 addition & 0 deletions lang/en/person.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'dod' => 'Date of death',
'yod' => 'Year of death',
'pod' => 'Place of death',
'summary' => 'Summary',
'email' => 'Email',
'password' => 'Password',
'address' => 'Address',
Expand Down
1 change: 1 addition & 0 deletions lang/nl/person.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'dod' => 'Datum overlijden',
'yod' => 'Jaar overlijden',
'pod' => 'Plaats overlijden',
'summary' => 'Samenvatting',
'email' => 'E-mail',
'password' => 'Password',
'address' => 'Adres',
Expand Down
73 changes: 44 additions & 29 deletions resources/views/livewire/people/datasheet.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="min-w-max max-w-max grow dark:text-neutral-200">
<div class="w-full min-w-max max-w-192 grow dark:text-neutral-200">
<table class="table-auto">
<tbody>
{{-- names --}}
Expand All @@ -9,25 +9,25 @@
<td>&nbsp;</td>
<td colspan="3" class="border-b-2 border-gray-600 border-solid">{{ __('person.names') }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.firstname') }} :</td>
<td>{{ $person->firstname }}</td>
<td class="break-words max-w-96">{{ $person->firstname }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.surname') }} :</td>
<td>{{ $person->surname }}</td>
<td class="break-words max-w-96">{{ $person->surname }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.birthname') }} :</td>
<td>{{ $person->birthname }}</td>
<td class="break-words max-w-96">{{ $person->birthname }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.nickname') }} :</td>
<td>{{ $person->nickname }}</td>
<td class="break-words max-w-96">{{ $person->nickname }}</td>
</tr>

{{-- sex & gender --}}
Expand All @@ -36,18 +36,18 @@
<td class="border-b-2 border-gray-600 border-solid">{{ __('person.sex') }} & {{ __('person.gender') }}</td>
<td colspan="2" class="border-b-2 border-gray-600 border-solid">&nbsp;</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.sex') }} :</td>
<td>
{{ $person->sex == 'm' ? __('app.male') : __('app.female') }}
<x-ts-icon icon="{{ $person->sex == 'm' ? 'gender-male' : 'gender-female' }}" class="inline-block size-5" />
</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.gender') }} :</td>
<td>{{ $person->gender }}</td>
<td class="break-words max-w-96">{{ $person->gender }}</td>
</tr>

{{-- birth --}}
Expand All @@ -56,17 +56,17 @@
<td class="border-b-2 border-gray-600 border-solid">{{ __('person.birth') }}</td>
<td colspan="2" class="border-b-2 border-gray-600 border-solid">&nbsp;</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.dob') }} :</td>
<td>{{ $person->birth_formatted }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.pob') }} :</td>
<td>{{ $person->pob }}</td>
<td class="break-words max-w-96">{{ $person->pob }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.age') }} :</td>
<td>{{ $person->age }}</td>
Expand All @@ -79,20 +79,20 @@
<td class="border-b-2 border-gray-600 border-solid">{{ __('person.death') }}</td>
<td colspan="2" class="border-b-2 border-gray-600 border-solid">&nbsp;</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.dod') }} :</td>
<td>{{ $person->death_formatted }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.pod') }} :</td>
<td>{{ $person->pod }}</td>
<td class="break-words max-w-96">{{ $person->pod }}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td valign="top">{{ __('person.cemetery') }} :</td>
<td>{!! implode('<br/>', array_filter([$person->getMetadataValue('cemetery_location_name'), nl2br(e($person->getMetadataValue('cemetery_location_address')))])) !!}</td>
<td>{{ __('person.cemetery') }} :</td>
<td class="break-words max-w-96">{!! implode('<br/>', array_filter([$person->getMetadataValue('cemetery_location_name'), nl2br(e($person->getMetadataValue('cemetery_location_address')))])) !!}</td>
</tr>
@else
{{-- contact --}}
Expand All @@ -101,22 +101,37 @@
<td class="border-b-2 border-gray-600 border-solid">{{ __('person.contact') }}</td>
<td colspan="2" class="border-b-2 border-gray-600 border-solid">&nbsp;</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td valign="top">{{ __('person.address') }} :</td>
<td>{!! nl2br(e($person->address)) !!}</td>
<td>{{ __('person.address') }} :</td>
<td class="break-words max-w-96">{!! nl2br(e($person->address)) !!}</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td>{{ __('person.phone') }} :</td>
<td>{{ $person->phone }}</td>
<td class="break-words max-w-96">{{ $person->phone }}</td>
</tr>
@endif

<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td>&nbsp;</td>
<td class="border-b-2 border-gray-600 border-solid">{{ __('person.summary') }}</td>
<td colspan="2" class="border-b-2 border-gray-600 border-solid">&nbsp;</td>
</tr>

<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td colspan="2" class="break-words whitespace-pre-line max-w-96">{{ $person->summary }}</td>
</tr>

<tr>
<td colspan="4">&nbsp;</td>
</tr>

{{-- family --}}
<tr class="border-gray-600 border-solid border-y-2">
<td>{{ __('person.family') }}</td>
Expand Down Expand Up @@ -144,9 +159,9 @@
@endif
</td>
</tr>
<tr>
<tr class="align-top">
<td colspan="2">&nbsp;</td>
<td valign="top">{{ __('person.parents') }} :</td>
<td>{{ __('person.parents') }} :</td>
<td>
@if ($person->parents)
{{ $person->parents->person_1->name }} <x-ts-icon icon="{{ $person->parents->person_1->sex == 'm' ? 'gender-male' : 'gender-female' }}" class="inline-block size-5" /> {{ $person->parents->person_1->birth_year }}<br/>
Expand Down
6 changes: 6 additions & 0 deletions resources/views/livewire/people/edit/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<div class="col-span-6">
<x-ts-input wire:model="profileForm.pob" id="pob" label="{{ __('person.pob') }} :" wire:dirty.class="bg-warning-200 dark:text-black" autocomplete="pod" />
</div>
<x-hr.narrow class="col-span-6 !my-0" />

{{-- summary --}}
<div class="col-span-6">
<x-ts-textarea wire:model="profileForm.summary" id="summary" label="{{ __('person.summary') }} :" wire:dirty.class="bg-warning-200 dark:text-black" autocomplete="summary" maxlength="65535" count/>
</div>
</div>
</div>

Expand Down
53 changes: 29 additions & 24 deletions resources/views/livewire/people/profile.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="min-w-100 flex flex-col rounded bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700 text-neutral-800 dark:text-neutral-50">
<div class="min-w-100 max-w-192 flex flex-col rounded bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700 text-neutral-800 dark:text-neutral-50">
<div class="flex flex-col p-2 text-lg font-medium border-b-2 rounded-t h-14 min-h-min border-neutral-100 dark:border-neutral-600 dark:text-neutral-50">
<div class="flex flex-wrap items-start justify-center gap-2">
<div class="items-center justify-center flex-1 flex-grow max-w-full align-middle min-w-max">
Expand Down Expand Up @@ -68,36 +68,36 @@
<div class="p-2">
<table class="w-full">
<tbody>
<tr>
<tr class="align-top">
<td class="pr-2 border-t-2 border-r-2">{{ __('person.firstname') }}</td>
<td class="pl-2 border-t-2">{{ $person->firstname }}</td>
<td class="pl-2 break-words border-t-2 max-w-96">{{ $person->firstname }}</td>
</tr>
<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.surname') }}</td>
<td class="pl-2">{{ $person->surname }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->surname }}</td>
</tr>
<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.birthname') }}</td>
<td class="pl-2">{{ $person->birthname }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->birthname }}</td>
</tr>
<tr class="border-b-2">
<tr class="align-top border-b-2">
<td class="pr-2 border-r-2">{{ __('person.nickname') }}</td>
<td class="pl-2">{{ $person->nickname }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->nickname }}</td>
</tr>

<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.sex') }} ({{ __('person.biological') }})</td>
<td class="pl-2">
{{ $person->sex == 'm' ? __('app.male') : __('app.female') }}
<x-ts-icon icon="{{ $person->sex == 'm' ? 'gender-male' : 'gender-female' }}" class="inline-block size-5" />
</td>
</tr>
<tr class="border-b-2">
<tr class="align-top border-b-2">
<td class="pr-2 border-r-2">{{ __('person.gender') }}</td>
<td class="pl-2">{{ $person->gender ? $person->gender->name : '' }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->gender ? $person->gender->name : '' }}</td>
</tr>

<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.dob') }}</td>
<td class="pl-2">
{{ $person->birth_formatted }}
Expand All @@ -106,13 +106,13 @@
@endif
</td>
</tr>
<tr class="border-b-2">
<tr class="align-top border-b-2">
<td class="pr-2 border-r-2">{{ __('person.pob') }}</td>
<td class="pl-2">{{ $person->pob }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->pob }}</td>
</tr>

@if ($person->isDeceased())
<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.dod') }}</td>
<td class="pl-2">
{{ $person->death_formatted }}
Expand All @@ -121,13 +121,13 @@
@endif
</td>
</tr>
<tr class="border-b-2">
<tr class="align-top border-b-2">
<td class="pr-2 border-r-2">{{ __('person.pod') }}</td>
<td class="pl-2">{{ $person->pod }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->pod }}</td>
</tr>
<tr>
<tr class="align-top">
<td class="pr-2 border-r-2">{{ __('person.cemetery') }}</td>
<td class="pl-2">{{ $person->getMetadataValue('cemetery_location_name') }}</td>
<td class="pl-2 break-words max-w-96">{{ $person->getMetadataValue('cemetery_location_name') }}</td>
</tr>
<tr class="align-top">
<td class="pr-2 border-b-2 border-r-2">
Expand All @@ -139,7 +139,7 @@
</a>
@endif
</td>
<td class="pl-2 border-b-2">{!! nl2br(e($person->getMetadataValue('cemetery_location_address'))) !!}</td>
<td class="pl-2 break-words border-b-2 max-w-96">{!! nl2br(e($person->getMetadataValue('cemetery_location_address'))) !!}</td>
</tr>
@else
<tr class="align-top">
Expand All @@ -153,13 +153,18 @@
</a>
@endif
</td>
<td class="pl-2 border-b-2">{!! nl2br(e($person->address)) !!}</td>
<td class="pl-2 break-words border-b-2 max-w-96">{!! nl2br(e($person->address)) !!}</td>
</tr>
<tr>
<tr class="align-top">
<td class="pr-2 border-b-2 border-r-2">{{ __('person.phone') }}</td>
<td class="pl-2 border-b-2">{{ $person->phone }}</td>
<td class="pl-2 break-words border-b-2 max-w-96">{{ $person->phone }}</td>
</tr>
@endif

<tr class="align-top border-b-2">
<td class="pr-2 border-r-2">{{ __('person.summary') }}</td>
<td class="pl-2 break-words whitespace-pre-line max-w-96">{{ $person->summary }}</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit fbcd634

Please sign in to comment.