Merge branch 'master' into lib-change

This commit is contained in:
Romulus Tsai 蔡仲明 2020-05-08 10:13:11 +08:00
commit c3458855bd
425 changed files with 15176 additions and 28903 deletions

View file

@ -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,31 +146,32 @@ 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();
const link = attachment.link('original', '/');
// trying to display url before file is stored generates js errors
return (
attachment &&
link &&
Blaze.toHTML(
HTML.A(
{
href: link,
target: '_blank',
},
attachment.get('name'),
),
)
(attachment &&
link &&
Blaze.toHTML(
HTML.A(
{
href: link,
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;
},
@ -180,7 +181,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 +189,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: {
@ -200,4 +201,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,
),
)
);
}