Przeglądaj źródła

Add feature: Add due timeline into Calendar view

Sam X. Chen 5 lat temu
rodzic
commit
62b72a03c4

+ 36 - 16
client/components/boards/boardBody.js

@@ -309,26 +309,46 @@ BlazeComponent.extendComponent({
       events(start, end, timezone, callback) {
       events(start, end, timezone, callback) {
         const currentBoard = Boards.findOne(Session.get('currentBoard'));
         const currentBoard = Boards.findOne(Session.get('currentBoard'));
         const events = [];
         const events = [];
+        const pushEvent = function(card, title, start, end, extraCls) {
+          start = start || card.startAt;
+          end = end || card.endAt;
+          title = title || card.title;
+          const className =
+            (extraCls ? `${extraCls} ` : '') +
+            (card.color ? `calendar-event-${card.color}` : '');
+          events.push({
+            id: card._id,
+            title,
+            start,
+            end: end || card.endAt,
+            allDay:
+              Math.abs(end.getTime() - start.getTime()) / 1000 === 24 * 3600,
+            url: FlowRouter.url('card', {
+              boardId: currentBoard._id,
+              slug: currentBoard.slug,
+              cardId: card._id,
+            }),
+            className,
+          });
+        };
         currentBoard
         currentBoard
           .cardsInInterval(start.toDate(), end.toDate())
           .cardsInInterval(start.toDate(), end.toDate())
           .forEach(function(card) {
           .forEach(function(card) {
-            events.push({
-              id: card._id,
-              title: card.title,
-              start: card.startAt,
-              end: card.endAt,
-              allDay:
-                Math.abs(card.endAt.getTime() - card.startAt.getTime()) /
-                  1000 ===
-                24 * 3600,
-              url: FlowRouter.url('card', {
-                boardId: currentBoard._id,
-                slug: currentBoard.slug,
-                cardId: card._id,
-              }),
-              className: card.color ? `calendar-event-${card.color}` : null,
-            });
+            pushEvent(card);
+          });
+        currentBoard
+          .cardsDueInBetween(start.toDate(), end.toDate())
+          .forEach(function(card) {
+            pushEvent(
+              card,
+              `${card.title} ${TAPi18n.__('card-due')}`,
+              card.dueAt,
+              new Date(card.dueAt.getTime() + 36e5),
+            );
           });
           });
+        events.sort(function(first, second) {
+          return first.id > second.id ? 1 : -1;
+        });
         callback(events);
         callback(events);
       },
       },
       eventResize(event, delta, revertFunc) {
       eventResize(event, delta, revertFunc) {

+ 9 - 1
client/lib/datepicker.js

@@ -21,7 +21,15 @@ DatePicker = BlazeComponent.extendComponent({
         function(evt) {
         function(evt) {
           this.find('#date').value = moment(evt.date).format('L');
           this.find('#date').value = moment(evt.date).format('L');
           this.error.set('');
           this.error.set('');
-          this.find('#time').focus();
+          const timeInput = this.find('#time');
+          timeInput.focus();
+          if (!timeInput.value) {
+            const currentHour = evt.date.getHours();
+            const defaultMoment = moment(
+              currentHour > 0 ? evt.date : '1970-01-01 08:00:00',
+            ); // default to 8:00 am local time
+            timeInput.value = defaultMoment.format('LT');
+          }
         }.bind(this),
         }.bind(this),
       );
       );
 
 

+ 3 - 3
i18n/en.i18n.json

@@ -731,12 +731,12 @@
   "almostdue": "current due time %s is approaching",
   "almostdue": "current due time %s is approaching",
   "pastdue": "current due time %s is past",
   "pastdue": "current due time %s is past",
   "duenow": "current due time %s is today",
   "duenow": "current due time %s is today",
-  "act-newDue": "__card__ has 1st due reminder [__board__]",
-  "act-withDue": "__card__ due reminders [__board__]",
+  "act-newDue": "__list__/__card__ has 1st due reminder [__board__]",
+  "act-withDue": "__list__/__card__ due reminders [__board__]",
   "act-almostdue": "was reminding the current due (__timeValue__) of __card__ is approaching",
   "act-almostdue": "was reminding the current due (__timeValue__) of __card__ is approaching",
   "act-pastdue": "was reminding the current due (__timeValue__) of __card__ is past",
   "act-pastdue": "was reminding the current due (__timeValue__) of __card__ is past",
   "act-duenow": "was reminding the current due (__timeValue__) of __card__ is now",
   "act-duenow": "was reminding the current due (__timeValue__) of __card__ is now",
-  "act-atUserComment": "You were mentioned in [__board__] __card__",
+  "act-atUserComment": "You were mentioned in [__board__] __list__/__card__",
   "delete-user-confirm-popup": "Are you sure you want to delete this account? There is no undo.",
   "delete-user-confirm-popup": "Are you sure you want to delete this account? There is no undo.",
   "accounts-allowUserDelete": "Allow users to self delete their account",
   "accounts-allowUserDelete": "Allow users to self delete their account",
   "hide-minicard-label-text": "Hide minicard label text",
   "hide-minicard-label-text": "Hide minicard label text",

+ 1 - 0
models/activities.js

@@ -289,6 +289,7 @@ if (Meteor.isServer) {
       activities: { $in: [description, 'all'] },
       activities: { $in: [description, 'all'] },
     }).fetch();
     }).fetch();
     if (integrations.length > 0) {
     if (integrations.length > 0) {
+      params.watchers = watchers;
       integrations.forEach(integration => {
       integrations.forEach(integration => {
         Meteor.call(
         Meteor.call(
           'outgoingWebhooks',
           'outgoingWebhooks',

+ 7 - 0
models/boards.js

@@ -699,6 +699,13 @@ Boards.helpers({
     return result;
     return result;
   },
   },
 
 
+  cardsDueInBetween(start, end) {
+    return Cards.find({
+      boardId: this._id,
+      dueAt: { $gte: start, $lte: end },
+    });
+  },
+
   cardsInInterval(start, end) {
   cardsInInterval(start, end) {
     return Cards.find({
     return Cards.find({
       boardId: this._id,
       boardId: this._id,

+ 6 - 3
server/notifications/email.js

@@ -13,11 +13,14 @@ Meteor.startup(() => {
     const lan = user.getLanguage();
     const lan = user.getLanguage();
     const subject = TAPi18n.__(title, params, lan); // the original function has a fault, i believe the title should be used according to original author
     const subject = TAPi18n.__(title, params, lan); // the original function has a fault, i believe the title should be used according to original author
     const existing = user.getEmailBuffer().length > 0;
     const existing = user.getEmailBuffer().length > 0;
-    const text = `${existing ? `<br/>\n${subject}<br/>\n` : ''}${
+    const htmlEnabled =
+      Meteor.settings.public &&
+      Meteor.settings.public.RICHER_CARD_COMMENT_EDITOR !== false;
+    const text = `${existing ? `\n${subject}\n` : ''}${
       params.user
       params.user
-    } ${TAPi18n.__(description, quoteParams, lan)}<br/>\n${params.url}`;
+    } ${TAPi18n.__(description, quoteParams, lan)}\n${params.url}`;
 
 
-    user.addEmailBuffer(text);
+    user.addEmailBuffer(htmlEnabled ? text.replace(/\n/g, '<br/>') : text);
 
 
     // unlike setTimeout(func, delay, args),
     // unlike setTimeout(func, delay, args),
     // Meteor.setTimeout(func, delay) does not accept args :-(
     // Meteor.setTimeout(func, delay) does not accept args :-(