Commit dca1cf1a authored by Johannes Bill's avatar Johannes Bill

fixed error handling, added filtering of invalid default fields

parent 41a62a15
......@@ -34,7 +34,7 @@ function getOHIndex(info, today, cb) {
function getFull(info, now, cb) {
var epocheSpan = dateView.getPropperEpochSpan(now);
dateArray(epocheSpan).getData(info, function (err, dataObj) {
if (err) return cb(null, err);
if (err) return cb(err);
var short = dateView.asString(dataObj, now);
var res = {
threeMonth: dateView.threeMonth(dataObj, now),
......@@ -50,7 +50,7 @@ function getFull(info, now, cb) {
function getShort(info, now, cb) {
var epocheSpan = dateView.getPropperEpochSpan(now);
dateArray(epocheSpan).getData(info, function (err, dataObj) {
if (err) return cb(null, err);
if (err) return cb(err);
var obj = dateView.asString(dataObj, now);
cb(null, obj);
})
......
......@@ -154,7 +154,7 @@ function wrapper(_epochSpan) {
}
var split = date.split(".");
if(split.length < 2) {
if(!split || split.length < 2) {
return null;
}
......
......@@ -27,15 +27,29 @@ function pretify(data) {
return ret;
}
function filterField(field) {
if (!field) return false;
var mandFields = ['opening_from', 'opening_to'];
if (field.option == 'default') {
var hasMandFields = true;
for (let mandField of mandFields) {
if (! field[mandField]) hasMandFields = false;
}
return hasMandFields;
}
else {
return true;
}
}
var ret = {};
for (let key of Object.keys(data)) {
let fields = data[key];
if (fields) {
var newFields = fields.map(function (field) {
return pretifyField(field);
}).filter(function (field) {
return !!field;
});
}).filter(filterField);
ret[key] = newFields;
}
}
......
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