|
69 | 69 | import Base from '../../js/base'; |
70 | 70 | import moment from 'moment'; |
71 | 71 |
|
| 72 | + // global let |
| 73 | + let end, start, until, duration; |
| 74 | +
|
72 | 75 | // export default |
73 | 76 | export default class FieldDateInput extends Base { |
74 | 77 | /** |
|
320 | 323 | }); |
321 | 324 |
|
322 | 325 | // duration |
323 | | - let duration = (this.value || {}).duration || 0; |
| 326 | + duration = (this.value || {}).duration || 0; |
324 | 327 |
|
325 | 328 | // set date |
326 | | - let start = (this.value || {}).start || null; |
327 | | - let until = (this.value || {}).until || null; |
| 329 | + start = (this.value || {}).start || null; |
| 330 | + until = (this.value || {}).until || null; |
328 | 331 |
|
329 | 332 | // set end |
330 | | - let end = start && new Date(start.getTime() + duration); |
| 333 | + end = start && new Date(start.getTime() + duration); |
331 | 334 |
|
332 | 335 | // set values |
333 | 336 | this.value.end = end; |
334 | 337 | this.value.start = start; |
335 | 338 | this.value.until = until; |
336 | 339 | |
337 | 340 | // add datetime picker |
338 | | - if (this.$('[ref="end"]')) $(this.$('[ref="end"]')).datetimepicker({ |
| 341 | + if (this.$('[ref="end"]') && !$(this.$('[ref="end"]')).data().DateTimePicker) $(this.$('[ref="end"]')).datetimepicker({ |
339 | 342 | format : this.getFormat(), |
340 | 343 | defaultDate : until, |
341 | 344 | }).on('dp.change', (e) => { |
|
353 | 356 | }); |
354 | 357 | |
355 | 358 | // add datetime picker |
356 | | - if (this.$('[ref="duration"]')) $(this.$('[ref="duration"]')).datetimepicker({ |
| 359 | + if (this.$('[ref="duration"]') && !$(this.$('[ref="duration"]')).data().DateTimePicker) $(this.$('[ref="duration"]')).datetimepicker({ |
357 | 360 | format : this.getFormat(), |
358 | 361 | defaultDate : end || start || new Date(), |
359 | 362 | }).on('dp.change', (e) => { |
|
370 | 373 | }); |
371 | 374 | |
372 | 375 | // add datetime picker |
373 | | - $(this.$('[ref="date"]')).datetimepicker({ |
| 376 | + if (!$(this.$('[ref="date"]')).data().DateTimePicker) $(this.$('[ref="date"]')).datetimepicker({ |
374 | 377 | format : this.getFormat(), |
375 | 378 | defaultDate : start || new Date(), |
376 | 379 | }).on('dp.change', (e) => { |
|
0 commit comments