Commit 4ba200a5 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

period initial date fixes

parent 5ca02579
......@@ -552,15 +552,13 @@ var STWkit;
self.durationHours.value = moment.duration(self.to.diff(self.from)).asHours() + '';
}
}
self.updateSlider();
self.updateFromStartDate();
};
self.startDateInput.onchange = function (evt) {
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
};
self.startTimeInput.onchange = function (evt) {
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
};
UIkit.ready(function () {
if (!self.ready) {
......@@ -575,10 +573,13 @@ var STWkit;
sliderOpt['min'] = self.minDate.format("X");
sliderOpt['max'] = self.maxDate.format("X");
self.slider.update(sliderOpt);
var initDate = self.getInitDate();
self.startDateInput.value = initDate.format(self.dateFormat);
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.durationHours.value = '0';
var startDatePicker = UIkit.datepicker(self.startDateInput, { minDate: self.minDate.format(self.dateFormat), maxDate: self.maxDate.format(self.dateFormat), format: self.dateFormat });
var startTimePicker = UIkit.timepicker(self.startTimeInput, {});
self.ready = true;
self.clear();
self.defaults();
}
});
......@@ -652,7 +653,6 @@ var STWkit;
sliderOpt['to'] = self.to.format("X");
if (self.slider) {
self.slider.update(sliderOpt);
self.validate();
}
};
PeriodCard.prototype.adjustDateToRange = function () {
......@@ -674,9 +674,12 @@ var STWkit;
PeriodCard.prototype.defaults = function () {
var self = this;
self.durationHours.value = '48';
if (document.body.contains(self.forwardButton))
self.forwardButton.click();
else {
self.forward = true;
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
}
};
PeriodCard.prototype.populateCard = function (geojson) {
var self = this;
......@@ -722,6 +725,7 @@ var STWkit;
}
self.adjustDateToRange();
self.updateSlider();
if (self.ready)
self.validate();
};
PeriodCard.prototype.getInitDate = function () {
......@@ -742,10 +746,6 @@ var STWkit;
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.durationHours.value = '0';
self.updateFromStartDate();
if (document.body.contains(self.forwardButton))
self.forwardButton.click();
AccordionCard.enableNext(self.nextButton, false);
(self.oncallback && self.oncallback());
};
return PeriodCard;
}(AccordionCard));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -606,17 +606,15 @@ module STWkit {
self.durationHours.value = moment.duration(self.to.diff(self.from)).asHours() + '';
}
}
self.updateSlider();
self.updateFromStartDate();
};
self.startDateInput.onchange = function (evt) {
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
};
self.startTimeInput.onchange = function (evt) {
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
};
......@@ -635,10 +633,14 @@ module STWkit {
sliderOpt['min'] = self.minDate.format("X");
sliderOpt['max'] = self.maxDate.format("X");
self.slider.update(sliderOpt);
var initDate = self.getInitDate();
self.startDateInput.value = initDate.format(self.dateFormat);
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.durationHours.value = '0';
var startDatePicker = UIkit.datepicker(<any>self.startDateInput, { minDate: self.minDate.format(self.dateFormat), maxDate: self.maxDate.format(self.dateFormat), format: self.dateFormat });
var startTimePicker = UIkit.timepicker(<any>self.startTimeInput, {});
self.ready = true;
self.clear();
self.defaults();
}
});
......@@ -714,7 +716,6 @@ module STWkit {
sliderOpt['to'] = self.to.format("X");
if (self.slider) {
self.slider.update(sliderOpt);
self.validate();
}
}
......@@ -736,9 +737,14 @@ module STWkit {
public defaults() {
var self = this;
self.durationHours.value = '48';
if (document.body.contains(self.forwardButton))
self.forwardButton.click();
else {
self.forward = true;
self.adjustDateToRange();
self.updateSlider();
self.updateFromStartDate();
}
}
public populateCard(geojson) {
......@@ -784,7 +790,7 @@ module STWkit {
self.adjustDateToRange();
self.updateSlider();
self.validate();
if (self.ready) self.validate();
}
private getInitDate() {
......@@ -806,10 +812,6 @@ module STWkit {
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.durationHours.value = '0';
self.updateFromStartDate();
if (document.body.contains(self.forwardButton)) self.forwardButton.click();
AccordionCard.enableNext(self.nextButton, false);
(self.oncallback && self.oncallback());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment