From e5f0dd7dd8a3629416c413381993fb791f314311 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Thu, 26 Sep 2019 12:20:14 -0400 Subject: Add feature: Add due timeline into Calendar view --- models/cards.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'models/cards.js') diff --git a/models/cards.js b/models/cards.js index d30baaf1..8356b5f9 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1579,18 +1579,38 @@ const findDueCards = days => { const now = new Date(), aday = 3600 * 24 * 1e3, then = day => new Date(now.setHours(0, 0, 0, 0) + day * aday); - seekDue(then(1), then(days), 'almostdue'); - seekDue(then(0), then(1), 'duenow'); - seekDue(then(-days), now, 'pastdue'); + if (!days) return; + if (!days.map) days = [days]; + days.map(day => { + let args = []; + if (day == 0) { + args = [then(0), then(1), 'duenow']; + } else if (day > 0) { + args = [then(1), then(day), 'almostdue']; + } else { + args = [then(day), now, 'pastdue']; + } + seekDue.apply(null, args); + }); }; const addCronJob = _.debounce( Meteor.bindEnvironment(function findDueCardsDebounced() { - const notifydays = - parseInt(process.env.NOTIFY_DUE_DAYS_BEFORE_AND_AFTER, 10) || 2; // default as 2 days before and after - if (!(notifydays > 0 && notifydays < 15)) { - // notifying due is disabled + const envValue = process.env.NOTIFY_DUE_DAYS_BEFORE_AND_AFTER; + if (!envValue) { return; } + const notifydays = envValue + .split(',') + .map(value => { + const iValue = parseInt(value, 10); + if (!(iValue > 0 && iValue < 15)) { + // notifying due is disabled + return false; + } else { + return iValue; + } + }) + .filter(Boolean); const notifyitvl = process.env.NOTIFY_DUE_AT_HOUR_OF_DAY; //passed in the itvl has to be a number standing for the hour of current time const defaultitvl = 8; // default every morning at 8am, if the passed env variable has parsing error use default const itvl = parseInt(notifyitvl, 10) || defaultitvl; -- cgit v1.2.3-1-g7c22 From 020b66383643f42c183b758fe1bcb73ac6f689bb Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Thu, 26 Sep 2019 12:24:40 -0400 Subject: Feature enhancement: Allow wekan master have more flexiblity on setting up due reminder --- models/cards.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'models/cards.js') diff --git a/models/cards.js b/models/cards.js index 8356b5f9..371ad185 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1583,14 +1583,14 @@ const findDueCards = days => { if (!days.map) days = [days]; days.map(day => { let args = []; - if (day == 0) { + if (day === 0) { args = [then(0), then(1), 'duenow']; } else if (day > 0) { args = [then(1), then(day), 'almostdue']; } else { args = [then(day), now, 'pastdue']; } - seekDue.apply(null, args); + seekDue(...args); }); }; const addCronJob = _.debounce( -- cgit v1.2.3-1-g7c22