Skip to content

Commit 1869a82

Browse files
author
edencoder
committed
fix date input restarting
1 parent 18c96a9 commit 1869a82

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

bundles/form/views/field/date/input.riot

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
import Base from '../../js/base';
7070
import moment from 'moment';
7171
72+
// global let
73+
let end, start, until, duration;
74+
7275
// export default
7376
export default class FieldDateInput extends Base {
7477
/**
@@ -320,22 +323,22 @@
320323
});
321324
322325
// duration
323-
let duration = (this.value || {}).duration || 0;
326+
duration = (this.value || {}).duration || 0;
324327
325328
// 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;
328331
329332
// set end
330-
let end = start && new Date(start.getTime() + duration);
333+
end = start && new Date(start.getTime() + duration);
331334
332335
// set values
333336
this.value.end = end;
334337
this.value.start = start;
335338
this.value.until = until;
336339
337340
// 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({
339342
format : this.getFormat(),
340343
defaultDate : until,
341344
}).on('dp.change', (e) => {
@@ -353,7 +356,7 @@
353356
});
354357
355358
// 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({
357360
format : this.getFormat(),
358361
defaultDate : end || start || new Date(),
359362
}).on('dp.change', (e) => {
@@ -370,7 +373,7 @@
370373
});
371374
372375
// add datetime picker
373-
$(this.$('[ref="date"]')).datetimepicker({
376+
if (!$(this.$('[ref="date"]')).data().DateTimePicker) $(this.$('[ref="date"]')).datetimepicker({
374377
format : this.getFormat(),
375378
defaultDate : start || new Date(),
376379
}).on('dp.change', (e) => {

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
},
2222
"dependencies": {
2323
"country-codes-list": "^1.6.8",
24-
"font-awesome-filetypes": "^2.0.1",
24+
"font-awesome-filetypes": "^2.1.0",
2525
"geo-tz": "^6.0.1",
2626
"geocomplete": "^1.7.0",
2727
"is-url": "^1.2.4",
28-
"libphonenumber-js": "^1.9.2",
29-
"moment-timezone": "^0.5.32",
28+
"libphonenumber-js": "^1.9.11",
29+
"moment-timezone": "^0.5.33",
3030
"node-fetch": "^2.6.1",
3131
"query": "github:protobi/query"
3232
}

0 commit comments

Comments
 (0)