summaryrefslogtreecommitdiffstats
path: root/client/components/activities/activities.js
diff options
context:
space:
mode:
authorRomulus Tsai 蔡仲明 <urakagi@gmail.com>2020-05-08 09:35:11 +0800
committerRomulus Tsai 蔡仲明 <urakagi@gmail.com>2020-05-08 09:35:11 +0800
commitcfcc73724fcd394150d1b815d0a7a4c466e216b5 (patch)
treea9648255f14cd8b0e1ad8eee1f8d42337a0668bc /client/components/activities/activities.js
parenta3658993128bdddd5d40f792c19281dc5eac51f5 (diff)
parent533bc045d06269dba2f42cdfe61817a1b3407974 (diff)
downloadwekan-cfcc73724fcd394150d1b815d0a7a4c466e216b5.tar.gz
wekan-cfcc73724fcd394150d1b815d0a7a4c466e216b5.tar.bz2
wekan-cfcc73724fcd394150d1b815d0a7a4c466e216b5.zip
Merge branch 'master' of https://github.com/wekan/wekan
Diffstat (limited to 'client/components/activities/activities.js')
-rw-r--r--client/components/activities/activities.js115
1 files changed, 74 insertions, 41 deletions
diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js
index b082273a..5d356f6e 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;
},
@@ -179,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) {
@@ -187,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: {
@@ -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,
+ ),
+ )
+ );
+}