From 9819c9f801128d07374b0703b482bdb83a672297 Mon Sep 17 00:00:00 2001 From: Jonathan Baird Date: Fri, 27 Mar 2020 11:35:03 -0600 Subject: add a notification drawer like trello --- client/components/activities/activities.js | 111 +++++++++++++++++++---------- 1 file changed, 72 insertions(+), 39 deletions(-) (limited to 'client/components/activities/activities.js') diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index b082273a..36214e19 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -41,7 +41,9 @@ BlazeComponent.extendComponent({ }); }); }, +}).register('activities'); +BlazeComponent.extendComponent({ loadNextPage() { if (this.loadNextPageLocked === false) { this.page.set(this.page.get() + 1); @@ -50,41 +52,37 @@ BlazeComponent.extendComponent({ }, checkItem() { - const checkItemId = this.currentData().checklistItemId; + const checkItemId = this.currentData().activity.checklistItemId; const checkItem = ChecklistItems.findOne({ _id: checkItemId }); - return checkItem.title; + return checkItem && checkItem.title; }, boardLabel() { + const data = this.currentData(); + if (data.mode !== 'board') { + return createBoardLink(data.activity.board(), data.activity.listName); + } return TAPi18n.__('this-board'); }, cardLabel() { + const data = this.currentData(); + if (data.mode !== 'card') { + return createCardLink(this.currentData().activity.card()); + } return TAPi18n.__('this-card'); }, cardLink() { - const card = this.currentData().card(); - return ( - card && - Blaze.toHTML( - HTML.A( - { - href: card.absoluteUrl(), - class: 'action-card', - }, - card.title, - ), - ) - ); + return createCardLink(this.currentData().activity.card()); }, lastLabel() { - const lastLabelId = this.currentData().labelId; + const lastLabelId = this.currentData().activity.labelId; if (!lastLabelId) return null; - const lastLabel = Boards.findOne(Session.get('currentBoard')).getLabelById( - lastLabelId, - ); + const lastLabel = Boards.findOne( + this.currentData().activity.boardId, + ).getLabelById(lastLabelId); if (lastLabel && (lastLabel.name === undefined || lastLabel.name === '')) { return lastLabel.color; } else { @@ -94,7 +92,7 @@ BlazeComponent.extendComponent({ lastCustomField() { const lastCustomField = CustomFields.findOne( - this.currentData().customFieldId, + this.currentData().activity.customFieldId, ); if (!lastCustomField) return null; return lastCustomField.name; @@ -102,10 +100,10 @@ BlazeComponent.extendComponent({ lastCustomFieldValue() { const lastCustomField = CustomFields.findOne( - this.currentData().customFieldId, + this.currentData().activity.customFieldId, ); if (!lastCustomField) return null; - const value = this.currentData().value; + const value = this.currentData().activity.value; if ( lastCustomField.settings.dropdownItems && lastCustomField.settings.dropdownItems.length > 0 @@ -122,11 +120,13 @@ BlazeComponent.extendComponent({ }, listLabel() { - return this.currentData().list().title; + const activity = this.currentData().activity; + const list = activity.list(); + return (list && list.title) || activity.title; }, sourceLink() { - const source = this.currentData().source; + const source = this.currentData().activity.source; if (source) { if (source.url) { return Blaze.toHTML( @@ -146,30 +146,31 @@ BlazeComponent.extendComponent({ memberLink() { return Blaze.toHTMLWithData(Template.memberName, { - user: this.currentData().member(), + user: this.currentData().activity.member(), }); }, attachmentLink() { - const attachment = this.currentData().attachment(); + const attachment = this.currentData().activity.attachment(); // trying to display url before file is stored generates js errors return ( - attachment && - attachment.url({ download: true }) && - Blaze.toHTML( - HTML.A( - { - href: attachment.url({ download: true }), - target: '_blank', - }, - attachment.name(), - ), - ) + (attachment && + attachment.url({ download: true }) && + Blaze.toHTML( + HTML.A( + { + href: attachment.url({ download: true }), + target: '_blank', + }, + attachment.name(), + ), + )) || + this.currentData().activity.attachmentName ); }, customField() { - const customField = this.currentData().customField(); + const customField = this.currentData().activity.customField(); if (!customField) return null; return customField.name; }, @@ -199,4 +200,36 @@ BlazeComponent.extendComponent({ }, ]; }, -}).register('activities'); +}).register('activity'); + +function createCardLink(card) { + return ( + card && + Blaze.toHTML( + HTML.A( + { + href: card.absoluteUrl(), + class: 'action-card', + }, + card.title, + ), + ) + ); +} + +function createBoardLink(board, list) { + let text = board.title; + if (list) text += `: ${list}`; + return ( + board && + Blaze.toHTML( + HTML.A( + { + href: board.absoluteUrl(), + class: 'action-board', + }, + text, + ), + ) + ); +} -- cgit v1.2.3-1-g7c22 From fe6616941505b82d503899e2e27d5a2e95f39db3 Mon Sep 17 00:00:00 2001 From: Jonathan Baird Date: Thu, 9 Apr 2020 12:46:24 -0600 Subject: fix bug that prevents editing or deleting comments --- client/components/activities/activities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client/components/activities/activities.js') diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index 36214e19..5d356f6e 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -180,7 +180,7 @@ BlazeComponent.extendComponent({ { // XXX We should use Popup.afterConfirmation here 'click .js-delete-comment'() { - const commentId = this.currentData().commentId; + const commentId = this.currentData().activity.commentId; CardComments.remove(commentId); }, 'submit .js-edit-comment'(evt) { @@ -188,7 +188,7 @@ BlazeComponent.extendComponent({ const commentText = this.currentComponent() .getValue() .trim(); - const commentId = Template.parentData().commentId; + const commentId = Template.parentData().activity.commentId; if (commentText) { CardComments.update(commentId, { $set: { -- cgit v1.2.3-1-g7c22