Commit 3e138d7a authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

fixed firest card

parent 20c24ca6
......@@ -83,6 +83,7 @@ var OSLocation = (function (_super) {
e.stopPropagation();
return false;
};
self.datetimeFormat = 'YYYY-MM-DD HH:mm';
self.dateFormat = 'YYYY-MM-DD';
self.timeFormat = 'HH:mm';
var obsdateLabelGrid = L.DomUtil.create('div', 'uk-grid', form);
......@@ -107,10 +108,16 @@ var OSLocation = (function (_super) {
self.depthInput.onchange = function () {
validate();
};
self.hasPosition = false;
function validate() {
var value = parseInt(self.depthInput.value);
if (value < 0)
self.depthInput.value = "0";
var date = moment.utc(self.obsDateInput.value + ' ' + self.obsTimeInput.value, self.datetimeFormat);
if (!date.isValid())
return;
if (!self.hasPosition)
return;
self.status = true;
OilSpillCard.enableNext(self.nextButton, true);
(self.oncallback && self.oncallback());
......@@ -160,6 +167,7 @@ var OSLocation = (function (_super) {
"buttons": false,
"tabs": false,
"callback": function (latlngs, geojson) {
self.hasPosition = false;
if (latlngs.length > 0) {
var toggleevt = document.createEvent("CustomEvent");
toggleevt.initCustomEvent('container:toggleVisibility', false, false, {
......@@ -170,6 +178,7 @@ var OSLocation = (function (_super) {
map.removeControl(self.exitControl);
self.exitControl = null;
self.control.showTable();
self.hasPosition = true;
validate();
}
}
......@@ -283,6 +292,7 @@ var OSLocation = (function (_super) {
var initDate = moment.utc();
self.obsDateInput.value = initDate.format(self.dateFormat);
self.obsTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.depthInput.value = '0';
self.control.clear();
self.control.hideTable();
if (self.nextButton)
......
This diff is collapsed.
......@@ -90,7 +90,10 @@ class OSLocation extends OilSpillCard {
public obsTimeInput : HTMLInputElement;
public depthInput : HTMLInputElement;
public dateFormat : string;
public timeFormat : string;
public timeFormat : string;
public datetimeFormat : string;
public hasPosition : boolean;
constructor(id, parentDiv, lang, langData, map) {
......@@ -103,6 +106,7 @@ class OSLocation extends OilSpillCard {
e.stopPropagation();
return false;
};
self.datetimeFormat = 'YYYY-MM-DD HH:mm';
self.dateFormat = 'YYYY-MM-DD';
self.timeFormat = 'HH:mm';
var obsdateLabelGrid = <HTMLDivElement>L.DomUtil.create('div', 'uk-grid', form);
......@@ -129,20 +133,23 @@ class OSLocation extends OilSpillCard {
validate();
};
self.hasPosition = false;
function validate() {
var value = parseInt(self.depthInput.value);
if (value < 0) self.depthInput.value = "0";
var date = moment.utc(self.obsDateInput.value+' '+ self.obsTimeInput.value, self.datetimeFormat);
if (!date.isValid()) return;
if (!self.hasPosition) return;
self.status = true;
OilSpillCard.enableNext(self.nextButton, true);
(self.oncallback && self.oncallback());
};
UIkit.ready( function(){
var startDatePicker = UIkit.datepicker(<any>self.obsDateInput, { format: self.dateFormat });
var startTimePicker = UIkit.timepicker(<any> self.obsTimeInput, { });
var startDatePicker = UIkit.datepicker(<any>self.obsDateInput, { format: self.dateFormat });
var startTimePicker = UIkit.timepicker(<any> self.obsTimeInput, { });
self.defaults();
self.defaults();
});
var positionLabelGrid = <HTMLDivElement>L.DomUtil.create('div', 'uk-grid uk-margin-top', form);
......@@ -185,6 +192,7 @@ class OSLocation extends OilSpillCard {
"buttons" : false,
"tabs" : false,
"callback": function(latlngs, geojson) {
self.hasPosition = false;
if (latlngs.length > 0) {
var toggleevt = document.createEvent("CustomEvent");
toggleevt.initCustomEvent('container:toggleVisibility', false, false, {
......@@ -194,8 +202,9 @@ class OSLocation extends OilSpillCard {
if (self.exitControl) map.removeControl(self.exitControl);
self.exitControl = null;
self.control.showTable();
self.hasPosition = true;
validate();
}
}
}
});
var content = self.control.onAdd(map);
......@@ -314,11 +323,10 @@ class OSLocation extends OilSpillCard {
public clear() {
var self = this;
super.clear();
var initDate = moment.utc();
self.obsDateInput.value = initDate.format(self.dateFormat);
self.obsTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
self.depthInput.value = '0';
self.control.clear();
self.control.hideTable();
if (self.nextButton) OilSpillCard.enableNext(self.nextButton, false);
......
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