Commit 411f6f9c authored by Johannes Bill's avatar Johannes Bill

option for custom fields finished

parent 56cb660e
"use strict";
var dateArray = require('./lib/dateArray');
var dateView = require('./lib/dateView');
var splitMidnight = require('./lib/timeUtils').splitMidnight;
function mapEvents(dataObj) {
if (dataObj.intervals) {
return splitMidnight(dataObj.intervals).map(function(evt) {
function mapEvents(intervals) {
if (intervals) {
return splitMidnight(intervals).map(function(evt) {
return {
startDate: evt[0],
endDate: evt[1]
......@@ -38,10 +40,26 @@ function getOHIndex(info, today, cb) {
sure: transform(resultSure),
maybe: transform(resultMaybe)
};
if (result.customIntervals && result.customIntervals.emergency) {
fResult.emergency = transform(result.customIntervals.emergency);
}
cb(null, fResult);
})
}
function mapCustomIntervals(customIvals) {
var res = {};
if (customIvals) {
for (let key in customIvals) {
res[key] = mapEvents(customIvals[key]);
}
}
return res;
}
function getFull(info, now, cb) {
var epocheSpan = dateView.getPropperEpochSpan(now);
dateArray(epocheSpan).getData(info, function (err, dataObj) {
......@@ -53,8 +71,10 @@ function getFull(info, now, cb) {
text: short.text,
status: short.status,
weekView: dateView.weekViewData(dataObj, now),
events: mapEvents(dataObj)
events: mapEvents(dataObj.intervals),
customEvents: mapCustomIntervals(dataObj.customIntervals)
};
cb(null, res);
})
}
......
......@@ -30,10 +30,11 @@ function wrapper(_epochSpan) {
function parseJSON(data) {
var rawCustom = data["custom"];
var custom = {};
for (var key in rawCustom) {
var field = rawCustom[key];
custom[field] = {
custom[key] = {
include: field.include || [],
exclude: field.exclude || []
}
......
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