Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.17k stars 896 forks source link

[3.6][Inconsistency] date_range_options not considered on date_range filters, but are considered on date_range fields #1419

Closed pleone closed 4 years ago

pleone commented 6 years ago

Bug report

What I did:

I set the parameters for my date_range filter:

'type' => 'date_range',
'name' => 'from_to',
'label'=> 'Date range',
'date_range_options' => [
     'format' => 'DD/MM/YYYY',
     'locale' => ['format' => 'DD/MM/YYYY']
]

What I expected to happen:

Change the calendar date format

What happened:

Date format didn't change, probably because in views/filters/date_range.blade.php the date format is hard coded lines 67-70 var dates = { 'from': start.format('YYYY-MM-DD'), 'to': end.format('YYYY-MM-DD') };

I'm not good in frontend/js development, so i won't probably be the best one to submit a pr :p

welcome[bot] commented 6 years ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

mamarmite commented 6 years ago

Did you try to overwrite it with the date_range_optionsin the field setup config ? This will overwrite the default values of the field. Note, you can setup the format in the locale option too.

Check in the Bootstrap DateRange doc too for more customization : http://www.daterangepicker.com/#options

pleone commented 6 years ago

Hi @mamarmite , i'm not sure to understand your tip. What are the field setup configs? I'm trying to use a filter, the date_range filter.

Usually using a field i'm able to customize the locale to the daterange, passing the options array, because at line 34 of fields/date_range.blade.php options are handled: data-bs-daterangepicker="{{ isset($field['date_range_options']) ? json_encode($field['date_range_options']) : '{}'}}"
but in the filter options seem to be not handled. Am I wrong?

mamarmite commented 6 years ago

@pleone no you aren't! I am. Sorry for this, I misread you this morning and jump right through the wrong problem :P

The filter should have an extends for all default param to be able to customize and localize it.

tabacitu commented 6 years ago

Hmmm... I agree with you @pleone - for consistency there should be a date_range_options attribute to the date_range filter. However, filters are objects, not the same as fields, so implementing this will be a little different. Let me think about it.

Cheers!

pxpm commented 4 years ago

Hello @pleone

Good news, this is beeing addressed in #2253

Filter will allow to override the datepicker options.

I am going to close this so we don't have the discussion on this issue split accross multiple places, if you think there is something more we could do let us know in the PR I linked before.

Wish you the best, Pedro