wireui / wireui

TallStack UI components
https://v1.wireui.dev
MIT License
1.37k stars 166 forks source link

Using Datetime Picker with Carbon model #22

Closed trippo closed 2 years ago

trippo commented 2 years ago

Actually, the Datetime Picker component doesn't accept Carbon\Carbon type as livewire model, but it could be convenient on many occasions.

PH7-Jack commented 2 years ago

This is the error? Cannot assign string to property App\Http\Livewire\Testing::$datetime of type ?Carbon\Carbon

trippo commented 2 years ago

Typed property App\Http\Livewire\Admin\Actions\CreateShopEntry::$dateTest must be an instance of Carbon\Carbon or null, string used

PH7-Jack commented 2 years ago

I'll think of a solution to do this treatment in livewire middleware, convert the string into an instance of carbon This will be very useful

trippo commented 2 years ago

There is also another problem with dateTime component: If you use a carbon date inside an eloquent for livewire model, you obtain an alpine error: Livewire Entangle Error: Livewire property 'shopEntry.entered_at' cannot be found

But the value is setted on mount function like this: $this->shopEntry->entered_at = now()->roundMinute(10);

I tried to format carbon with toIso8601String or others formats without success

PH7-Jack commented 2 years ago

You have a validation rule to binding directly to model property?

https://laravel-livewire.com/docs/2.x/properties#binding-models

trippo commented 2 years ago

You are right... there is not error with rule

trippo commented 2 years ago

There is another problem: I'm on Rome(UTC+2) timezone and if I pass "2021-06-16 19:50:00" to DateTime picker i see on the frontend

16/06/2021 17:50

with these params

display-format="DD/MM/YYYY HH:mm"
parse-format="YYYY-MM-DD hh:mm:ss"

and with or without without-timezone

PH7-Jack commented 2 years ago

Can you give more information? I tried here and I couldn't reproduce

Your laravel timezone config is Europe/Rome?

Can you show me your component data using alpinejs tools? image

trippo commented 2 years ago

There is also another little ui problem with time picker.. If you have a modal with blur like

Schermata 2021-06-17 alle 09 37 54

and open a datetime picker

Schermata 2021-06-17 alle 09 38 20

it create a space at the bottom of the page

Schermata 2021-06-17 alle 09 38 31
trippo commented 2 years ago

Can you give more information? I tried here and I couldn't reproduce

Your laravel timezone config is Europe/Rome?

Can you show me your component data using alpinejs tools? image

image

trippo commented 2 years ago
Schermata 2021-06-17 alle 09 38 31

This problem there is also with select (not native) on a modal when you open the select

PH7-Jack commented 2 years ago

The modal bug has been fixed

PH7-Jack commented 2 years ago

There is another problem: I'm on Rome(UTC+2) timezone and if I pass "2021-06-16 19:50:00" to DateTime picker i see on the frontend

16/06/2021 17:50

with these params

display-format="DD/MM/YYYY HH:mm"
parse-format="YYYY-MM-DD hh:mm:ss"

and with or without without-timezone

If this still persists, create a new issue to this bug

trippo commented 2 years ago

Modal fixed. Leave open for Carbon

PH7-Jack commented 2 years ago

@trippo The livewire community helped me find a solution to this.

https://github.com/livewire/livewire/discussions/3370

public function updatingDate(&$date)
{
    $date = Carbon::parse($date);
}
trippo commented 2 years ago

Work like a charme