@@ -3,15 +3,14 @@ import { setInstance } from '../helpers/object.instances';
3
3
4
4
const { ibexa, document } = window ;
5
5
6
- const SECONDS_IN_DAY = 86400 ;
7
-
8
6
class DateTimeRangeSingle {
9
7
constructor ( config ) {
10
8
this . container = config . container ;
11
9
this . dateTimePickerInputWrapper = this . container . querySelector ( '.ibexa-date-time-range-single__date-time-picker-input-wrapper' ) ;
12
10
13
- const { periodSelector, endSelector } = this . container . dataset ;
11
+ const { periodSelector, startSelector , endSelector } = this . container . dataset ;
14
12
this . periodInput = document . querySelector ( periodSelector ) ;
13
+ this . startInput = document . querySelector ( startSelector ) ;
15
14
this . endInput = document . querySelector ( endSelector ) ;
16
15
17
16
const customDateConfig = config . dateConfig || { } ;
@@ -37,19 +36,22 @@ class DateTimeRangeSingle {
37
36
if ( dates . length === 2 ) {
38
37
const startDate = this . getUnixTimestampUTC ( dates [ 0 ] ) ;
39
38
const endDate = this . getUnixTimestampUTC ( dates [ 1 ] ) ;
40
- const days = Math . floor ( ( endDate - startDate ) / SECONDS_IN_DAY ) ;
41
39
42
- this . periodInput . value = `P0Y0M ${ days } D` ;
40
+ this . periodInput . value = '' ;
43
41
this . periodInput . dispatchEvent ( new Event ( 'change' ) ) ;
44
42
this . periodInput . dispatchEvent ( new Event ( 'input' ) ) ;
45
43
44
+ this . startInput . value = startDate ;
45
+ this . startInput . dispatchEvent ( new Event ( 'change' ) ) ;
46
+ this . startInput . dispatchEvent ( new Event ( 'input' ) ) ;
47
+
46
48
this . endInput . value = endDate ;
47
49
this . endInput . dispatchEvent ( new Event ( 'change' ) ) ;
48
50
this . endInput . dispatchEvent ( new Event ( 'input' ) ) ;
49
51
} else if ( dates . length === 0 ) {
50
- this . periodInput . value = '' ;
51
- this . periodInput . dispatchEvent ( new Event ( 'change' ) ) ;
52
- this . periodInput . dispatchEvent ( new Event ( 'input' ) ) ;
52
+ this . startInput . value = '' ;
53
+ this . startInput . dispatchEvent ( new Event ( 'change' ) ) ;
54
+ this . startInput . dispatchEvent ( new Event ( 'input' ) ) ;
53
55
54
56
this . endInput . value = '' ;
55
57
this . endInput . dispatchEvent ( new Event ( 'change' ) ) ;
0 commit comments