summaryrefslogtreecommitdiffstats
path: root/client/components/activities/activities.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/activities/activities.js')
-rw-r--r--client/components/activities/activities.js111
1 files changed, 72 insertions, 39 deletions
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,
+ ),
+ )
+ );
+}