-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5046529
commit 0fb2895
Showing
10 changed files
with
118 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function LGDatePicker(dataField, jsDateFormat, dateFormat, locale, dateFrom, dateTo) { | ||
return { | ||
dataField: dataField, | ||
dateFrom: dateFrom, | ||
dateTo: dateTo, | ||
element: null, | ||
|
||
init() { | ||
window.addEventListener(`LGdatePickerClear`, () => { | ||
if (this.$refs.datePicker && this.element) { | ||
this.element.clear() | ||
} | ||
}) | ||
|
||
if (this.$refs && this.$refs.datePicker) { | ||
this.element = flatpickr(this.$refs.datePicker, this.getOptions()); | ||
} | ||
}, | ||
|
||
getOptions() { | ||
return { | ||
mode: 'range', | ||
defaultHour: 0, | ||
defaultDate: [this.dateFrom, this.dateTo], | ||
dateFormat: dateFormat, | ||
locale: locale, | ||
onClose: function (selectedDates) { | ||
if (selectedDates.length === 2) { | ||
let elementFrom = document.querySelector(`input[name="filter.${dataField}.from"]`); | ||
let elementTo = document.querySelector(`input[name="filter.${dataField}.to"]`); | ||
|
||
elementFrom.value = dayjs(selectedDates[0], 'Y-MM-DD').format(jsDateFormat); | ||
elementTo.value = dayjs(selectedDates[1], 'Y-MM-DD').format(jsDateFormat); | ||
|
||
elementFrom.dispatchEvent(new Event('input')); | ||
elementTo.dispatchEvent(new Event('input')); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Here you can override default config for LaraGrid | ||
*/ | ||
return [ | ||
'locale' => 'en', | ||
'flatpickr' => [ | ||
/** | ||
* You can override default flatpickr locale here | ||
*/ | ||
'locale' => 'en', | ||
|
||
/** | ||
* Both options must use same format!!! | ||
* JS format is used for wire model input and url params | ||
* Date format is used for displaying date in table | ||
*/ | ||
'date_format' => 'Y-m-d', | ||
'js_date_format' => 'Y-MM-DD', | ||
/** | ||
* Both options must use same output format!!! | ||
* Example: If you want d.m.Y, you must also specify js_date_format DD.MM.YYYY. Otherwise, you will get wrong dates. | ||
* I don't know why, but it is like that. If you know why, please let me know, or create PR. | ||
* | ||
* JS format is used for wire model input and url params. | ||
* It must be in format that is supported by daysjs library (https://day.js.org/docs/en/display/format) | ||
* | ||
* Tested formats: | ||
* YYYY-MM-DD, DD-MM-YYYY, | ||
* DD.MM.YYYY, YYYY.MM.DD, | ||
* DD/MM/YYYY, YYYY/MM/DD, | ||
* | ||
* Date format is used for displaying date in table | ||
*/ | ||
'date_format' => 'Y-m-d', | ||
'js_date_format' => 'YYYY-MM-DD', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters