Skip to content

Commit

Permalink
Merge pull request #449 from code4romania/417-make-sure-the-time-pick…
Browse files Browse the repository at this point in the history
…er-is-consistent-regardless-of-the-operating-system-or-browser-in-use

Date format
  • Loading branch information
gheorghelupu17 authored Dec 27, 2024
2 parents 91a0c27 + 9e4e64f commit 8661397
Show file tree
Hide file tree
Showing 46 changed files with 237 additions and 101 deletions.
2 changes: 1 addition & 1 deletion app/Concerns/HasBirthdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function initializeHasBirthdate()

public function setBirthdateAttribute(?string $value = null): void
{
$date = $value ? Carbon::createFromFormat('d-m-Y', $value) : null;
$date = $value ? Carbon::createFromFormat('d.m.Y', $value) : null;

$this->attributes['birthdate'] = $date?->format('Y-m-d');
}
Expand Down
3 changes: 2 additions & 1 deletion app/Concerns/HasIntervalAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ trait HasIntervalAttribute
public function initializeHasIntervalAttribute(): void
{
$this->fillable = array_merge($this->fillable, ['start_date_interval', 'end_date_interval']);
$this->casts = array_merge($this->casts, ['start_date_interval' => 'date', 'end_date_interval' => 'date']);
}

public function getIntervalAttribute(): string
{
return $this->start_date_interval . ' - ' . $this->end_date_interval;
return $this->start_date_interval?->format('d.m.Y') . ' - ' . $this->end_date_interval?->format('d.m.Y');
}
}
2 changes: 2 additions & 0 deletions app/Concerns/LogsActivityOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function tapActivity(Activity $activity, string $eventName)
}

$activity->event = $activity->subject_type;

$this->loadMissing('beneficiary');
$activity->subject()->associate($this->beneficiary);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Filament\Admin\Resources\InstitutionResource;
use App\Filament\Admin\Resources\UserInstitutionResource\Pages\EditUserInstitution;
use App\Tables\Columns\DateTimeColumn;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
Expand Down Expand Up @@ -54,7 +55,7 @@ public function table(Table $table): Table
TextColumn::make('userStatus.status')
->label(__('institution.labels.account_status')),

TextColumn::make('last_login_at')
DateTimeColumn::make('last_login_at')
->label(__('institution.labels.last_login_at')),
])
->headerActions([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\ActivateUserAction;
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\DeactivateUserAction;
use App\Filament\Admin\Resources\UserInstitutionResource\Actions\ResendInvitationAction;
use App\Infolists\Components\DateTimeEntry;
use App\Infolists\Components\SectionHeader;
use Filament\Infolists\Components\Actions\Action;
use Filament\Infolists\Components\Section;
Expand Down Expand Up @@ -72,14 +73,17 @@ public function infolist(Infolist $infolist): Infolist
->columns()
->schema([
TextEntry::make('userStatus.status')
->formatStateUsing(fn ($state) => $state === '-' ? $state : $state->label()),
TextEntry::make('updated_at'),
->label(__('user.labels.status')),

DateTimeEntry::make('last_login_at')
->label(__('user.labels.last_login_at_date_time')),
]),
Section::make()
->maxWidth('3xl')
->columns()
->schema([
SectionHeader::make('edit_user')
->state(__('user.heading.specialist_details'))
->action(
Action::make('edit')
->label(__('general.action.edit'))
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Organizations/Pages/ReportsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use App\Actions\ExportReport;
use App\Enums\ReportType;
use App\Forms\Components\DatePicker;
use App\Forms\Components\ReportTable;
use Filament\Forms;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Activity;
use App\Models\Beneficiary;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use App\Tables\Columns\DateColumn;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
Expand Down Expand Up @@ -66,9 +67,8 @@ public function table(Table $table): Table
)
->heading(__('beneficiary.section.history.headings.table'))
->columns([
TextColumn::make('created_at')
->label(__('beneficiary.section.history.labels.date'))
->date(),
DateColumn::make('created_at')
->label(__('beneficiary.section.history.labels.date')),

TextColumn::make('time')
->label(__('beneficiary.section.history.labels.time'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ protected function getFormSchema(): array
->options(MeetingStatus::options()),

DatePicker::make('date')
->label(__('intervention_plan.labels.date'))
->format('Y-m-d'),
->label(__('intervention_plan.labels.date')),

TimePicker::make('time')
->label(__('intervention_plan.labels.time'))
Expand Down Expand Up @@ -172,7 +171,7 @@ public function infolist(Infolist $infolist): Infolist

TextEntry::make('date')
->label(__('intervention_plan.labels.date'))
->formatStateUsing(fn (InterventionMeeting $record, Carbon | string $state) => (\is_string($state) ? $state : $state->format('Y-m-d')) . ' ' . $record->time?->format('H:i')),
->formatStateUsing(fn (InterventionMeeting $record, Carbon | string $state) => (\is_string($state) ? $state : $state->format('d.m.Y')) . ' ' . $record->time?->format('H:i')),
TextEntry::make('duration')
->label(__('intervention_plan.labels.duration')),
TextEntry::make('specialist.name_role')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ protected function getHeaderActions(): array
public function beforeFill(): void
{
$this->prefillFormData = [
'date' => now()->format('Y-m-d'),
'admittance_date' => $this->getRecord()->created_at->format('Y-m-d'),
'exit_date' => now()->format('Y-m-d'),
'date' => now()->format('d.m.Y'),
'admittance_date' => $this->getRecord()->created_at->format('d.m.Y'),
'exit_date' => now()->format('d.m.Y'),
'specialist_id' => $this->getRecord()
->specialistsTeam
->load('role')
Expand Down Expand Up @@ -106,17 +106,4 @@ protected function getSubmitFormAction(): Action
->submit('create')
->keyBindings(['mod+s']);
}

public function getCloseFilePreFillData(): array
{
return [
'date' => now()->format('Y-m-d'),
'admittance_date' => $this->getRecord()->created_at->format('Y-m-d'),
'exit_date' => now()->format('Y-m-d'),
'user_id' => $this->getRecord()
->managerTeam
->first()
?->user_id,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity;
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\DateEntry;
use App\Models\Beneficiary;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Actions\DeleteAction;
Expand Down Expand Up @@ -75,16 +76,16 @@ public function infolist(Infolist $infolist): Infolist
->url(self::getResource()::getUrl('edit_close_file_details', ['record' => $this->getRecord()])),
])
->schema([
TextEntry::make('date')
DateEntry::make('date')
->label(__('beneficiary.section.close_file.labels.date')),

TextEntry::make('number')
->label(__('beneficiary.section.close_file.labels.number')),

TextEntry::make('admittance_date')
DateEntry::make('admittance_date')
->label(__('beneficiary.section.close_file.labels.admittance_date')),

TextEntry::make('exit_date')
DateEntry::make('exit_date')
->label(__('beneficiary.section.close_file.labels.exit_date')),

TextEntry::make('caseManager.name_role')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity;
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\DateEntry;
use App\Infolists\Components\Location;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Infolists\Components\Group;
Expand Down Expand Up @@ -307,23 +308,25 @@ public function getDetailedEvaluationSchema(): array
TextEntry::make('relationship')
->label(__('beneficiary.section.detailed_evaluation.labels.relationship')),

TextEntry::make('date')
DateEntry::make('date')
->label(__('beneficiary.section.detailed_evaluation.labels.contact_date')),
]),
//

RepeatableEntry::make('meetings')
->columns()
->label(__('beneficiary.section.detailed_evaluation.labels.meetings'))
->schema([
TextEntry::make('specialist')
->label(__('beneficiary.section.detailed_evaluation.labels.specialist'))
->placeholder(__('beneficiary.placeholder.full_name')),
TextEntry::make('date')
->label(__('beneficiary.section.detailed_evaluation.labels.date'))
->placeholder(__('beneficiary.placeholder.date')),

DateEntry::make('date')
->label(__('beneficiary.section.detailed_evaluation.labels.date')),

TextEntry::make('location')
->label(__('beneficiary.section.detailed_evaluation.labels.location'))
->placeholder(__('beneficiary.placeholder.meet_location')),

TextEntry::make('observations')
->label(__('beneficiary.section.detailed_evaluation.labels.observations'))
->placeholder(__('beneficiary.placeholder.relevant_details')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static function getBeneficiaryIdentityFormSchema(?Beneficiary $parentBene
return;
}

if (filled($birthdate = (new Cnp($state))->getBirthDateFromCNP('d-m-Y'))) {
if (filled($birthdate = (new Cnp($state))->getBirthDateFromCNP('d.m.Y'))) {
$set('birthdate', $birthdate);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function getChildrenIdentityFormSchema(): array
}

try {
$age = Carbon::createFromFormat('d-m-Y', $state)->diffInYears(now());
$age = Carbon::createFromFormat('d.m.Y', $state)->diffInYears(now());
} catch (\Exception $e) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Forms\Components\DatePicker;
use App\Forms\Components\Select;
use App\Infolists\Components\DateEntry;
use App\Models\User;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Forms\Components\Section;
Expand Down Expand Up @@ -88,7 +89,7 @@ public static function getInfoListSchema(): array
->columns()
->relationship('evaluateDetails')
->schema([
TextEntry::make('registered_date')
DateEntry::make('registered_date')
->label(__('beneficiary.section.initial_evaluation.labels.registered_date')),

TextEntry::make('file_number')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource\Widgets\IntervetnionPlanWidget;
use App\Filament\Organizations\Resources\BeneficiaryResource\Widgets\RelatedCases;
use App\Filament\Organizations\Resources\MonitoringResource\Widgets\MonitoringWidget;
use App\Infolists\Components\DateEntry;
use App\Infolists\Components\EnumEntry;
use App\Infolists\Components\Location;
use App\Models\Activity;
Expand Down Expand Up @@ -179,9 +180,8 @@ protected function identitySectionSection(): Section
->label(__('field.age'))
->formatStateUsing(fn ($state) => $state === '-' ? $state : trans_choice('general.age', $state)),

TextEntry::make('birthdate')
->label(__('field.birthdate'))
->formatStateUsing(fn ($state) => $state !== '-' ? $state->format('m-d-Y') : $state),
DateEntry::make('birthdate')
->label(__('field.birthdate')),

EnumEntry::make('gender')
->label(__('field.gender')),
Expand Down Expand Up @@ -306,12 +306,13 @@ private function initialEvaluation(): Section
->columns()
->visible(fn (Beneficiary $record) => $record->violence?->violence_types)
->schema([
TextEntry::make('evaluateDetails.registered_date')
->label(__('beneficiary.section.initial_evaluation.labels.registered_date'))
->date('Y-m-d'),
DateEntry::make('evaluateDetails.registered_date')
->label(__('beneficiary.section.initial_evaluation.labels.registered_date')),

TextEntry::make('violence.violence_types')
->label(__('beneficiary.section.initial_evaluation.labels.violence_type'))
->color(Color::Gray),

TextEntry::make('riskFactors.risk_level')
->hiddenLabel()
->badge()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Enums\AddressType;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\DateEntry;
use App\Infolists\Components\EnumEntry;
use App\Infolists\Components\Location;
use App\Infolists\Components\Notice;
Expand Down Expand Up @@ -131,9 +132,8 @@ protected static function identitySchema(): array
->label(__('field.gender'))
->placeholder(__('placeholder.select_one')),

TextEntry::make('birthdate')
->label(__('field.birthdate'))
->formatStateUsing(fn ($state) => $state !== '-' ? $state->format('d-m-Y') : $state),
DateEntry::make('birthdate')
->label(__('field.birthdate')),

TextEntry::make('birthplace')
->label(__('field.birthplace'))
Expand Down Expand Up @@ -286,9 +286,8 @@ public static function childrenSchema(): array
TextEntry::make('gender')
->label(__('field.gender')),

TextEntry::make('birthdate')
->label(__('field.birthdate'))
->formatStateUsing(fn ($state) => $state !== '-' ? $state->format('d-m-Y') : $state),
DateEntry::make('birthdate')
->label(__('field.birthdate')),

TextEntry::make('current_address')
->label(__('field.current_address')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use App\Enums\CaseStatus;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Models\Beneficiary;
use App\Tables\Columns\DateColumn;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

Expand All @@ -32,9 +34,10 @@ public function table(Table $table): Table
->url(BeneficiaryResource::getUrl('view_close_file', ['record' => $this->record])),
])
->columns([
Tables\Columns\TextColumn::make('date')
DateColumn::make('date')
->label(__('beneficiary.section.close_file.labels.close_date')),
Tables\Columns\TextColumn::make('close_method')

TextColumn::make('close_method')
->label(__('beneficiary.section.close_file.labels.close_method')),
])
->emptyStateHeading(__('beneficiary.section.close_file.headings.widget_empty_state'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Filament\Organizations\Resources\DocumentResource;
use App\Models\Document;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use App\Tables\Columns\DateColumn;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Enums\ActionSize;
Expand Down Expand Up @@ -76,7 +77,7 @@ public function table(Table $table): Table
->heading(__('beneficiary.section.documents.title.table'))
->actionsColumnLabel(__('general.action.actions'))
->columns([
TextColumn::make('date')
DateColumn::make('date')
->label(__('beneficiary.section.documents.labels.date'))
->sortable(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function afterFill(): void
?->load(['children', 'specialistsTeam']);
$this->children = $this->getChildren();
foreach ($this->children as &$child) {
$child['birthdate'] = $child['birthdate'] ? Carbon::parse($child['birthdate'])->format('d-m-Y') : null;
$child['birthdate'] = $child['birthdate'] ? Carbon::parse($child['birthdate'])->format('d.m.Y') : null;
}

$this->specialistTeam = $this->getSpecialists();
Expand Down
Loading

0 comments on commit 8661397

Please sign in to comment.