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

obsdate can now affect start date on period

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