Skip to content

Commit

Permalink
Date format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Dec 23, 2024
1 parent 91a0c27 commit 1a265e1
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 52 deletions.
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
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 @@ -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 @@ -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 @@ -10,6 +10,7 @@
use App\Filament\Organizations\Resources\MonitoringResource;
use App\Models\Monitoring;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use App\Tables\Columns\DateColumn;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\CreateAction;
Expand Down Expand Up @@ -84,16 +85,19 @@ public function table(Table $table): Table
->columns([
TextColumn::make('id')
->label(__('monitoring.headings.id')),

TextColumn::make('number')
->label(__('monitoring.headings.file_number'))
->sortable(),
TextColumn::make('date')

DateColumn::make('date')
->label(__('monitoring.headings.date'))
->sortable(),
TextColumn::make('start_date')

TextColumn::make('interval')
->label(__('monitoring.headings.interval'))
->sortable()
->formatStateUsing(fn ($record) => $record->start_date . ' - ' . $record->end_date),
->sortable(),

TextColumn::make('specialistsTeam.name_role')
->label(__('monitoring.headings.team'))
->sortable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity;
use App\Filament\Organizations\Resources\MonitoringResource;
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\DateEntry;
use App\Infolists\Components\SectionHeader;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Actions;
Expand Down Expand Up @@ -78,16 +79,16 @@ public function infolist(Infolist $infolist): Infolist
])
->columns()
->schema([
TextEntry::make('date')
DateEntry::make('date')
->label(__('monitoring.labels.date')),

TextEntry::make('number')
->label(__('monitoring.labels.number')),

TextEntry::make('start_date')
DateEntry::make('start_date')
->label(__('monitoring.labels.start_date')),

TextEntry::make('end_date')
DateEntry::make('end_date')
->label(__('monitoring.labels.end_date')),

TextEntry::make('specialistsTeam.name_role')
Expand Down Expand Up @@ -132,9 +133,8 @@ public function infolist(Infolist $infolist): Infolist
TextEntry::make('age')
->label(__('monitoring.labels.age')),

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

TextEntry::make('aggressor_relationship')
->label(__('monitoring.labels.aggressor_relationship')),
Expand Down Expand Up @@ -174,7 +174,7 @@ public function infolist(Infolist $infolist): Infolist
->schema([
Grid::make()
->schema([
TextEntry::make('admittance_date')
DateEntry::make('admittance_date')
->label(__('monitoring.labels.admittance_date')),

TextEntry::make('admittance_disposition')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Models\Beneficiary;
use Filament\Tables;
use App\Tables\Columns\DateColumn;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

Expand All @@ -27,22 +29,23 @@ public function table(Table $table): Table
->paginated(false)
->heading(__('monitoring.headings.widget_table'))
->headerActions([
Tables\Actions\Action::make('view_monitoring')
Action::make('view_monitoring')
->label(__('general.action.view_details'))
->link()
->visible(fn () => $this->record->monitoring->count())
->url(BeneficiaryResource::getUrl('monitorings.index', ['parent' => $this->record])),
])
->columns([
Tables\Columns\TextColumn::make('date')
DateColumn::make('date')
->label(__('monitoring.labels.last_monitoring_date')),
Tables\Columns\TextColumn::make('count')

TextColumn::make('count')
->label(__('monitoring.labels.count'))
->default(fn () => $this->record->monitoring->count()),
])
->emptyStateHeading(__('monitoring.headings.widget_empty_state'))
->emptyStateActions([
Tables\Actions\Action::make('create_monitoring')
Action::make('create_monitoring')
->label(__('monitoring.actions.create_widget'))
->outlined()
->url(BeneficiaryResource::getUrl('monitorings.create', ['parent' => $this->record])),
Expand Down
Loading

0 comments on commit 1a265e1

Please sign in to comment.