Commit 1b43a570 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

obsdate can now affect start date on period

parent 959af3ad
......@@ -186,11 +186,12 @@
var oiltypeoptions = {};
oiltypeoptions['type'] = type;
oiltypeoptions['initials'] = initials;
// oiltypeoptions['stateofoil'] = false;
// oiltypeoptions['stateofoil'] = false;
var oiltypeid = 'oiltypeCard';
this.cardMap[oiltypeid] = new STWkit.OilTypeCard(oiltypeid, 'Type of oil', this.accordionDiv, this.lang, map, oiltypeoptions);
this.cardMap[periodid].addChangeFnListener(this.cardMap[oiltypeid]);
this.cardMap[locationid].addChangeFnListener(this.cardMap[periodid]);
super.setup(map);
var chain = [];
......
......@@ -488,9 +488,7 @@ var STWkit;
self.backwardButton.textContent = 'Backward';
self.forwardButton.onclick = function () {
self.forward = true;
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
var initDate = self.getInitDate();
self.from = initDate;
initDate.add(parseInt(self.durationHours.value), 'hours');
self.to = initDate;
......@@ -502,8 +500,7 @@ var STWkit;
self.backwardButton.onclick = function () {
self.forward = false;
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
var initDate = self.getInitDate();
self.to = initDate;
initDate.subtract(parseInt(self.durationHours.value), 'hours');
self.from = initDate;
......@@ -602,6 +599,21 @@ var STWkit;
});
return _this;
}
PeriodCard.prototype.getInitDate = function () {
var self = this;
var initDate = moment.utc();
if (self.obsdate)
initDate = self.obsdate;
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
return initDate;
};
PeriodCard.prototype.changeFn = function (changeCard) {
var self = this;
if ((typeof changeCard.obsDateInput !== 'undefined') && (typeof changeCard.obsTimeInput !== 'undefined')) {
self.obsdate = moment.utc(changeCard.obsDateInput.value + ' ' + changeCard.obsTimeInput.value, self.datetimeFormat).valueOf();
}
};
PeriodCard.prototype.isDateValid = function (date) {
var self = this;
if (!date.isValid())
......@@ -714,9 +726,7 @@ var STWkit;
PeriodCard.prototype.clear = function () {
var self = this;
_super.prototype.clear.call(this);
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
var initDate = self.getInitDate();
self.startDateInput.value = initDate.format(self.dateFormat);
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.forward = true;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -470,6 +470,7 @@ module STWkit {
public domain: string;
public forcingmodel: string;
public ready: boolean;
public obsdate: any;
constructor(id, title, parentDiv, lang, map, domain, forcingmodel, options?) {
......@@ -539,9 +540,7 @@ module STWkit {
self.forwardButton.onclick = function () {
self.forward = true;
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
var initDate = self.getInitDate();
self.from = initDate;
initDate.add(parseInt(self.durationHours.value), 'hours');
self.to = initDate;
......@@ -554,8 +553,7 @@ module STWkit {
self.backwardButton.onclick = function () {
self.forward = false;
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate))
initDate = self.minDate;
var initDate = self.getInitDate();
self.to = initDate;
initDate.subtract(parseInt(self.durationHours.value), 'hours');
self.from = initDate;
......@@ -664,6 +662,22 @@ module STWkit {
}
});
}
private getInitDate() {
var self = this;
var initDate = moment.utc();
if (self.obsdate) initDate = self.obsdate;
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate)) initDate = self.minDate;
return initDate;
}
public changeFn(changeCard) {
var self = this;
if ((typeof changeCard.obsDateInput !== 'undefined') && (typeof changeCard.obsTimeInput !== 'undefined')) {
self.obsdate = moment.utc(changeCard.obsDateInput.value + ' ' + changeCard.obsTimeInput.value, self.datetimeFormat).valueOf();
}
}
private isDateValid(date) {
var self = this;
......@@ -776,8 +790,7 @@ module STWkit {
public clear() {
var self = this;
super.clear();
var initDate = moment.utc();
if (initDate.isBefore(self.minDate) || initDate.isAfter(self.maxDate)) initDate = self.minDate;
var initDate = self.getInitDate();
self.startDateInput.value = initDate.format(self.dateFormat);
self.startTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.forward = true;
......
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