Return data on client (sync) and Promise on server (async) naturally, without wrapping in an extra Promise

This commit is contained in:
Harry Adel 2026-02-18 18:24:55 +02:00
parent 2b15a8ff09
commit f934aea2a5
21 changed files with 405 additions and 3760 deletions

View file

@ -13,54 +13,54 @@ import { ReactiveCache } from '/imports/reactiveCache';
Activities = new Mongo.Collection('activities');
Activities.helpers({
async board() {
return await ReactiveCache.getBoard(this.boardId);
board() {
return ReactiveCache.getBoard(this.boardId);
},
async oldBoard() {
return await ReactiveCache.getBoard(this.oldBoardId);
oldBoard() {
return ReactiveCache.getBoard(this.oldBoardId);
},
async user() {
return await ReactiveCache.getUser(this.userId);
user() {
return ReactiveCache.getUser(this.userId);
},
async member() {
return await ReactiveCache.getUser(this.memberId);
member() {
return ReactiveCache.getUser(this.memberId);
},
async list() {
return await ReactiveCache.getList(this.listId);
list() {
return ReactiveCache.getList(this.listId);
},
async swimlane() {
return await ReactiveCache.getSwimlane(this.swimlaneId);
swimlane() {
return ReactiveCache.getSwimlane(this.swimlaneId);
},
async oldSwimlane() {
return await ReactiveCache.getSwimlane(this.oldSwimlaneId);
oldSwimlane() {
return ReactiveCache.getSwimlane(this.oldSwimlaneId);
},
async oldList() {
return await ReactiveCache.getList(this.oldListId);
oldList() {
return ReactiveCache.getList(this.oldListId);
},
async card() {
return await ReactiveCache.getCard(this.cardId);
card() {
return ReactiveCache.getCard(this.cardId);
},
async comment() {
return await ReactiveCache.getCardComment(this.commentId);
comment() {
return ReactiveCache.getCardComment(this.commentId);
},
async attachment() {
return await ReactiveCache.getAttachment(this.attachmentId);
attachment() {
return ReactiveCache.getAttachment(this.attachmentId);
},
async checklist() {
return await ReactiveCache.getChecklist(this.checklistId);
checklist() {
return ReactiveCache.getChecklist(this.checklistId);
},
async checklistItem() {
return await ReactiveCache.getChecklistItem(this.checklistItemId);
checklistItem() {
return ReactiveCache.getChecklistItem(this.checklistItemId);
},
async subtasks() {
return await ReactiveCache.getCard(this.subtaskId);
subtasks() {
return ReactiveCache.getCard(this.subtaskId);
},
async customField() {
return await ReactiveCache.getCustomField(this.customFieldId);
customField() {
return ReactiveCache.getCustomField(this.customFieldId);
},
async label() {
label() {
// Label activity did not work yet, unable to edit labels when tried this.
return await ReactiveCache.getCard(this.labelId);
return ReactiveCache.getCard(this.labelId);
},
});

View file

@ -829,8 +829,8 @@ Boards.helpers({
},
async cards() {
const ret = await ReactiveCache.getCards(
cards() {
const ret = ReactiveCache.getCards(
{ boardId: this._id, archived: false },
{ sort: { title: 1 } },
);
@ -841,12 +841,12 @@ Boards.helpers({
return this.draggableLists();
},
async newestLists() {
newestLists() {
// sorted lists from newest to the oldest, by its creation date or its cards' last modification date
const user = await ReactiveCache.getCurrentUser();
const user = ReactiveCache.getCurrentUser();
const value = user._getListSortBy();
const sortKey = { starred: -1, [value[0]]: value[1] }; // [["starred",-1],value];
return await ReactiveCache.getLists(
return ReactiveCache.getLists(
{
boardId: this._id,
archived: false,
@ -855,8 +855,8 @@ Boards.helpers({
);
},
async draggableLists() {
return await ReactiveCache.getLists(
draggableLists() {
return ReactiveCache.getLists(
{
boardId: this._id,
},
@ -867,28 +867,28 @@ Boards.helpers({
/** returns the last list
* @returns Document the last list
*/
async getLastList() {
const ret = await ReactiveCache.getList({ boardId: this._id }, { sort: { sort: 'desc' } });
getLastList() {
const ret = ReactiveCache.getList({ boardId: this._id }, { sort: { sort: 'desc' } });
return ret;
},
async nullSortLists() {
return await ReactiveCache.getLists({
nullSortLists() {
return ReactiveCache.getLists({
boardId: this._id,
archived: false,
sort: { $eq: null },
});
},
async swimlanes() {
return await ReactiveCache.getSwimlanes(
swimlanes() {
return ReactiveCache.getSwimlanes(
{ boardId: this._id, archived: false },
{ sort: { sort: 1 } },
);
},
async nextSwimlane(swimlane) {
return await ReactiveCache.getSwimlane(
nextSwimlane(swimlane) {
return ReactiveCache.getSwimlane(
{
boardId: this._id,
archived: false,
@ -901,16 +901,16 @@ Boards.helpers({
);
},
async nullSortSwimlanes() {
return await ReactiveCache.getSwimlanes({
nullSortSwimlanes() {
return ReactiveCache.getSwimlanes({
boardId: this._id,
archived: false,
sort: { $eq: null },
});
},
async hasOvertimeCards() {
const card = await ReactiveCache.getCard({
hasOvertimeCards() {
const card = ReactiveCache.getCard({
isOvertime: true,
boardId: this._id,
archived: false,
@ -918,8 +918,8 @@ Boards.helpers({
return card !== undefined;
},
async hasSpentTimeCards() {
const card = await ReactiveCache.getCard({
hasSpentTimeCards() {
const card = ReactiveCache.getCard({
spentTime: { $gt: 0 },
boardId: this._id,
archived: false,
@ -927,20 +927,19 @@ Boards.helpers({
return card !== undefined;
},
async activities() {
activities() {
let linkedBoardId = [this._id];
const cards = await ReactiveCache.getCards({
ReactiveCache.getCards({
"type": "cardType-linkedBoard",
"boardId": this._id
});
for (const card of cards) {
}).forEach(card => {
linkedBoardId.push(card.linkedId);
}
const ret = await ReactiveCache.getActivities({ boardId: { $in: linkedBoardId } }, { sort: { createdAt: -1 } });
});
const ret = ReactiveCache.getActivities({ boardId: { $in: linkedBoardId } }, { sort: { createdAt: -1 } });
return ret;
},
async activeMembers(){
activeMembers(){
// Depend on the users collection for reactivity when users are loaded
const memberUserIds = _.pluck(this.members, 'userId');
// Use findOne with limit for reactivity trigger instead of count() which loads all users
@ -954,19 +953,14 @@ Boards.helpers({
return selected;
});
// Filter out members where user is not loaded
const filteredMembers = [];
for (const member of uniqueMembers) {
const user = await ReactiveCache.getUser(member.userId);
if (user !== undefined) {
filteredMembers.push(member);
}
}
const filteredMembers = uniqueMembers.filter(member => {
const user = ReactiveCache.getUser(member.userId);
return user !== undefined;
});
// Sort by role priority first (admin, normal, normal-assigned, no-comments, comment-only, comment-assigned, worker, read-only, read-assigned), then by fullname
// Build sort keys with async user lookup
const membersWithSortKey = [];
for (const member of filteredMembers) {
const user = await ReactiveCache.getUser(member.userId);
return _.sortBy(filteredMembers, member => {
const user = ReactiveCache.getUser(member.userId);
let rolePriority = 8; // Default for normal
if (member.isAdmin) rolePriority = 0;
@ -980,9 +974,8 @@ Boards.helpers({
else rolePriority = 1; // Normal
const fullname = user ? user.profile.fullname : '';
membersWithSortKey.push({ member, sortKey: rolePriority + '-' + fullname });
}
return _.sortBy(membersWithSortKey, 'sortKey').map(item => item.member);
return rolePriority + '-' + fullname;
});
},
activeOrgs() {
@ -1005,8 +998,8 @@ Boards.helpers({
return _.where(this.members, { isActive: true, isAdmin: true });
},
async memberUsers() {
return await ReactiveCache.getUsers({ _id: { $in: _.pluck(this.members, 'userId') } });
memberUsers() {
return ReactiveCache.getUsers({ _id: { $in: _.pluck(this.members, 'userId') } });
},
getLabel(name, color) {
@ -1126,8 +1119,8 @@ Boards.helpers({
return `board-color-${this.color}`;
},
async customFields() {
const ret = await ReactiveCache.getCustomFields(
customFields() {
const ret = ReactiveCache.getCustomFields(
{ boardIds: { $in: [this._id] } },
{ sort: { name: 1 } },
);
@ -1156,7 +1149,7 @@ Boards.helpers({
}
},
async searchBoards(term) {
searchBoards(term) {
check(term, Match.OneOf(String, null, undefined));
const query = { boardId: this._id };
@ -1171,11 +1164,11 @@ Boards.helpers({
query.$or = [{ title: regex }, { description: regex }];
}
const ret = await ReactiveCache.getCards(query, projection);
const ret = ReactiveCache.getCards(query, projection);
return ret;
},
async searchSwimlanes(term) {
searchSwimlanes(term) {
check(term, Match.OneOf(String, null, undefined));
const query = { boardId: this._id };
@ -1193,10 +1186,10 @@ Boards.helpers({
query.$or = [{ title: regex }, { description: regex }];
}
return await ReactiveCache.getSwimlanes(query, projection);
return ReactiveCache.getSwimlanes(query, projection);
},
async searchLists(term) {
searchLists(term) {
let ret = null;
if (term) {
check(term, Match.OneOf(String));
@ -1218,12 +1211,12 @@ Boards.helpers({
query.$or = [{ title: regex }, { description: regex }];
}
ret = await ReactiveCache.getLists(query, projection);
ret = ReactiveCache.getLists(query, projection);
}
return ret;
},
async searchCards(term, excludeLinked) {
searchCards(term, excludeLinked) {
let ret = null;
if (term) {
check(term, Match.OneOf(String));
@ -1249,7 +1242,7 @@ Boards.helpers({
{ description: regex },
{ customFields: { $elemMatch: { value: regex } } },
];
ret = await ReactiveCache.getCards(query, projection);
ret = ReactiveCache.getCards(query, projection);
}
return ret;
},
@ -1283,8 +1276,8 @@ Boards.helpers({
return this.subtasksDefaultBoardId;
},
async getDefaultSubtasksBoard() {
return await ReactiveCache.getBoard(this.getDefaultSubtasksBoardId());
getDefaultSubtasksBoard() {
return ReactiveCache.getBoard(this.getDefaultSubtasksBoardId());
},
//Date Settings option such as received date, start date and so on.
@ -1316,8 +1309,8 @@ Boards.helpers({
return this.dateSettingsDefaultBoardId;
},
async getDefaultDateSettingsBoard() {
return await ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId());
getDefaultDateSettingsBoard() {
return ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId());
},
getDefaultSubtasksListId() {
@ -1335,8 +1328,8 @@ Boards.helpers({
return this.subtasksDefaultListId;
},
async getDefaultSubtasksList() {
return await ReactiveCache.getList(this.getDefaultSubtasksListId());
getDefaultSubtasksList() {
return ReactiveCache.getList(this.getDefaultSubtasksListId());
},
getDefaultDateSettingsListId() {
@ -1354,15 +1347,15 @@ Boards.helpers({
return this.dateSettingsDefaultListId;
},
async getDefaultDateSettingsList() {
return await ReactiveCache.getList(this.getDefaultDateSettingsListId());
getDefaultDateSettingsList() {
return ReactiveCache.getList(this.getDefaultDateSettingsListId());
},
async getDefaultSwimline() {
let result = await ReactiveCache.getSwimlane({ boardId: this._id });
getDefaultSwimline() {
let result = ReactiveCache.getSwimlane({ boardId: this._id });
if (result === undefined) {
// Check if any swimlane exists for this board to avoid duplicates
const existingSwimlanes = await ReactiveCache.getSwimlanes({ boardId: this._id });
const existingSwimlanes = ReactiveCache.getSwimlanes({ boardId: this._id });
if (existingSwimlanes.length > 0) {
// Use the first existing swimlane
result = existingSwimlanes[0];
@ -1373,14 +1366,14 @@ Boards.helpers({
title: title,
boardId: this._id,
});
result = await ReactiveCache.getSwimlane({ boardId: this._id });
result = ReactiveCache.getSwimlane({ boardId: this._id });
}
}
return result;
},
async getNextCardNumber() {
const boardCards = await ReactiveCache.getCard(
getNextCardNumber() {
const boardCards = ReactiveCache.getCard(
{
boardId: this._id
},
@ -1399,16 +1392,16 @@ Boards.helpers({
return maxCardNr + 1;
},
async cardsDueInBetween(start, end) {
const ret = await ReactiveCache.getCards({
cardsDueInBetween(start, end) {
const ret = ReactiveCache.getCards({
boardId: this._id,
dueAt: { $gte: start, $lte: end },
});
return ret;
},
async cardsInInterval(start, end) {
const ret = await ReactiveCache.getCards({
cardsInInterval(start, end) {
const ret = ReactiveCache.getCards({
boardId: this._id,
$or: [
{
@ -1756,7 +1749,9 @@ Boards.uniqueTitle = async title => {
return title;
};
Boards.userSearch = async (
// Non-async: returns data on client, Promise on server.
// Server callers must await.
Boards.userSearch = (
userId,
selector = {},
projection = {},
@ -1770,36 +1765,44 @@ Boards.userSearch = async (
if (userId) {
selector.$or.push({ members: { $elemMatch: { userId, isActive: true } } });
}
const ret = await ReactiveCache.getBoards(selector, projection);
return ret;
return ReactiveCache.getBoards(selector, projection);
};
Boards.userBoards = async (
// Non-async: returns data on client (for Blaze templates), Promise on server.
// Server callers must await.
Boards.userBoards = (
userId,
archived = false,
selector = {},
projection = {},
) => {
const user = await ReactiveCache.getUser(userId);
if (!user) {
return [];
}
const _buildSelector = (user) => {
if (!user) return null;
if (typeof archived === 'boolean') {
selector.archived = archived;
}
if (!selector.type) {
selector.type = 'board';
}
selector.$or = [
{ permission: 'public' },
{ members: { $elemMatch: { userId, isActive: true } } },
{ orgs: { $elemMatch: { orgId: { $in: user.orgIds() }, isActive: true } } },
{ teams: { $elemMatch: { teamId: { $in: user.teamIds() }, isActive: true } } },
];
return selector;
};
if (typeof archived === 'boolean') {
selector.archived = archived;
if (Meteor.isServer) {
return (async () => {
const user = await ReactiveCache.getUser(userId);
if (!_buildSelector(user)) return [];
return await ReactiveCache.getBoards(selector, projection);
})();
}
if (!selector.type) {
selector.type = 'board';
}
selector.$or = [
{ permission: 'public' },
{ members: { $elemMatch: { userId, isActive: true } } },
{ orgs: { $elemMatch: { orgId: { $in: user.orgIds() }, isActive: true } } },
{ teams: { $elemMatch: { teamId: { $in: user.teamIds() }, isActive: true } } },
];
return await ReactiveCache.getBoards(selector, projection);
const user = ReactiveCache.getUser(userId);
if (!_buildSelector(user)) return [];
return ReactiveCache.getBoards(selector, projection);
};
Boards.userBoardIds = async (userId, archived = false, selector = {}) => {

View file

@ -101,21 +101,21 @@ CardComments.helpers({
CardComments.insert(this);
},
async user() {
return await ReactiveCache.getUser(this.userId);
user() {
return ReactiveCache.getUser(this.userId);
},
async reactions() {
const cardCommentReactions = await ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
reactions() {
const cardCommentReactions = ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
return !!cardCommentReactions ? cardCommentReactions.reactions : [];
},
async toggleReaction(reactionCodepoint) {
toggleReaction(reactionCodepoint) {
if (reactionCodepoint !== sanitizeText(reactionCodepoint)) {
return false;
} else {
const cardCommentReactions = await ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
const cardCommentReactions = ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
const reactions = !!cardCommentReactions ? cardCommentReactions.reactions : [];
const userId = Meteor.userId();
const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);

View file

@ -701,16 +701,16 @@ Cards.helpers({
return Cards.insert(linkCard);
},
async list() {
return await ReactiveCache.getList(this.listId);
list() {
return ReactiveCache.getList(this.listId);
},
async swimlane() {
return await ReactiveCache.getSwimlane(this.swimlaneId);
swimlane() {
return ReactiveCache.getSwimlane(this.swimlaneId);
},
async board() {
const ret = await ReactiveCache.getBoard(this.boardId);
board() {
const ret = ReactiveCache.getBoard(this.boardId);
return ret;
},
@ -725,8 +725,8 @@ Cards.helpers({
return this.__id;
},
async getList() {
const list = await this.list();
getList() {
const list = this.list();
if (!list) {
return {
_id: this.listId,
@ -738,8 +738,8 @@ Cards.helpers({
return list;
},
async getSwimlane() {
const swimlane = await this.swimlane();
getSwimlane() {
const swimlane = this.swimlane();
if (!swimlane) {
return {
_id: this.swimlaneId,
@ -751,8 +751,8 @@ Cards.helpers({
return swimlane;
},
async getBoard() {
const board = await this.board();
getBoard() {
const board = this.board();
if (!board) {
return {
_id: this.boardId,
@ -764,9 +764,8 @@ Cards.helpers({
return board;
},
async labels() {
const board = await this.board();
const boardLabels = board.labels;
labels() {
const boardLabels = this.board().labels;
const cardLabels = _.filter(boardLabels, label => {
return _.contains(this.labelIds, label._id);
});
@ -782,7 +781,7 @@ Cards.helpers({
* @param swimlaneId a swimlane id
* top sorting of the card at the top if true, or from the bottom if false
*/
async getSort(listId, swimlaneId, top) {
getSort(listId, swimlaneId, top) {
if (!_.isBoolean(top)) {
top = true;
}
@ -798,7 +797,7 @@ Cards.helpers({
archived: false,
};
const sorting = top ? 1 : -1;
const card = await ReactiveCache.getCard(selector, { sort: { sort: sorting } }, true);
const card = ReactiveCache.getCard(selector, { sort: { sort: sorting } }, true);
let ret = null
if (card) {
ret = card.sort;
@ -810,8 +809,8 @@ Cards.helpers({
* @param listId a list id
* @param swimlaneId a swimlane id
*/
async getMinSort(listId, swimlaneId) {
const ret = await this.getSort(listId, swimlaneId, true);
getMinSort(listId, swimlaneId) {
const ret = this.getSort(listId, swimlaneId, true);
return ret;
},
@ -819,40 +818,40 @@ Cards.helpers({
* @param listId a list id
* @param swimlaneId a swimlane id
*/
async getMaxSort(listId, swimlaneId) {
const ret = await this.getSort(listId, swimlaneId, false);
getMaxSort(listId, swimlaneId) {
const ret = this.getSort(listId, swimlaneId, false);
return ret;
},
async user() {
return await ReactiveCache.getUser(this.userId);
user() {
return ReactiveCache.getUser(this.userId);
},
async isAssigned(memberId) {
return _.contains(await this.getMembers(), memberId);
isAssigned(memberId) {
return _.contains(this.getMembers(), memberId);
},
async isAssignee(assigneeId) {
return _.contains(await this.getAssignees(), assigneeId);
isAssignee(assigneeId) {
return _.contains(this.getAssignees(), assigneeId);
},
async activities() {
activities() {
let ret;
if (this.isLinkedBoard()) {
ret = await ReactiveCache.getActivities(
ret = ReactiveCache.getActivities(
{ boardId: this.linkedId },
{ sort: { createdAt: -1 } },
);
} else {
ret = await ReactiveCache.getActivities({ cardId: this.getRealId() }, { sort: { createdAt: -1 } });
ret = ReactiveCache.getActivities({ cardId: this.getRealId() }, { sort: { createdAt: -1 } });
}
return ret;
},
async comments() {
comments() {
let ret
if (this.isLinkedBoard()) {
ret = await ReactiveCache.getCardComments(
ret = ReactiveCache.getCardComments(
{ boardId: this.linkedId },
{ sort: { createdAt: -1 } },
);
@ -866,18 +865,18 @@ Cards.helpers({
return ret;
},
async attachments() {
const ret = (await ReactiveCache.getAttachments(
attachments() {
const ret = ReactiveCache.getAttachments(
{ 'meta.cardId': this.getRealId() },
{ sort: { uploadedAt: -1 } },
true,
)).each();
).each();
return ret;
},
async cover() {
cover() {
if (!this.coverId) return false;
const cover = await ReactiveCache.getAttachment(this.coverId);
const cover = ReactiveCache.getAttachment(this.coverId);
// if we return a cover before it is fully stored, we will get errors when we try to display it
// todo XXX we could return a default "upload pending" image in the meantime?
return cover && cover.link() && cover;
@ -983,9 +982,9 @@ Cards.helpers({
},
// customFields with definitions
async customFieldsWD() {
customFieldsWD() {
// get all definitions
const definitions = await ReactiveCache.getCustomFields({
const definitions = ReactiveCache.getCustomFields({
boardIds: { $in: [this.boardId] },
});
if (!definitions) {

View file

@ -163,7 +163,10 @@ async function publishChekListCompleted(userId, doc) {
const boardId = card.boardId;
const checklistId = doc.checklistId;
const checkList = await ReactiveCache.getChecklist(checklistId);
if (checkList.isFinished()) {
const checklistItems = await ReactiveCache.getChecklistItems({ checklistId });
const isChecklistFinished = checkList.hideAllChecklistItems ||
(checklistItems.length > 0 && checklistItems.length === checklistItems.filter(i => i.isFinished).length);
if (isChecklistFinished) {
const act = {
userId,
activityType: 'completeChecklist',
@ -187,7 +190,7 @@ async function publishChekListUncompleted(userId, doc) {
// Currently in checklist all are set as uncompleted/not checked,
// IFTTT Rule does not move card to other list.
// If following line is negated/changed to:
// if(!checkList.isFinished()){
// if(!isChecklistFinished){
// then unchecking of any checkbox will move card to other list,
// even when all checkboxes are not yet unchecked.
// What is correct code for only moving when all in list is unchecked?
@ -196,7 +199,10 @@ async function publishChekListUncompleted(userId, doc) {
// find . | xargs grep 'count' -sl | grep -v .meteor | grep -v node_modules | grep -v .build
// Maybe something related here?
// wekan/client/components/rules/triggers/checklistTriggers.js
if (checkList.isFinished()) {
const uncheckItems = await ReactiveCache.getChecklistItems({ checklistId });
const isChecklistFinished = checkList.hideAllChecklistItems ||
(uncheckItems.length > 0 && uncheckItems.length === uncheckItems.filter(i => i.isFinished).length);
if (isChecklistFinished) {
const act = {
userId,
activityType: 'uncompleteChecklist',

View file

@ -161,9 +161,8 @@ Checklists.helpers({
await item.uncheck();
}
},
async itemIndex(itemId) {
const checklist = await ReactiveCache.getChecklist({ _id: this._id });
const items = checklist.items;
itemIndex(itemId) {
const items = ReactiveCache.getChecklist({ _id: this._id }).items;
return _.pluck(items, '_id').indexOf(itemId);
},

View file

@ -55,8 +55,8 @@ InvitationCodes.attachSchema(
);
InvitationCodes.helpers({
async author() {
return await ReactiveCache.getUser(this.authorId);
author() {
return ReactiveCache.getUser(this.authorId);
},
});

View file

@ -259,37 +259,37 @@ Lists.helpers({
}
},
async cards(swimlaneId) {
cards(swimlaneId) {
const selector = {
listId: this._id,
archived: false,
};
if (swimlaneId) selector.swimlaneId = swimlaneId;
const ret = await ReactiveCache.getCards(Filter.mongoSelector(selector), { sort: ['sort'] });
const ret = ReactiveCache.getCards(Filter.mongoSelector(selector), { sort: ['sort'] });
return ret;
},
async cardsUnfiltered(swimlaneId) {
cardsUnfiltered(swimlaneId) {
const selector = {
listId: this._id,
archived: false,
};
if (swimlaneId) selector.swimlaneId = swimlaneId;
const ret = await ReactiveCache.getCards(selector, { sort: ['sort'] });
const ret = ReactiveCache.getCards(selector, { sort: ['sort'] });
return ret;
},
async allCards() {
const ret = await ReactiveCache.getCards({ listId: this._id });
allCards() {
const ret = ReactiveCache.getCards({ listId: this._id });
return ret;
},
async board() {
return await ReactiveCache.getBoard(this.boardId);
board() {
return ReactiveCache.getBoard(this.boardId);
},
async getWipLimit(option) {
const list = await ReactiveCache.getList(this._id);
getWipLimit(option) {
const list = ReactiveCache.getList(this._id);
if (!list.wipLimit) {
// Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set
return 0;
@ -313,9 +313,9 @@ Lists.helpers({
return this.starred === true;
},
async isCollapsed() {
isCollapsed() {
if (Meteor.isClient) {
const user = await ReactiveCache.getCurrentUser();
const user = ReactiveCache.getCurrentUser();
// Logged-in users: prefer profile/cookie-backed state
if (user && user.getCollapsedListFromStorage) {
const stored = user.getCollapsedListFromStorage(this.boardId, this._id);
@ -334,13 +334,13 @@ Lists.helpers({
return this.collapsed === true;
},
async absoluteUrl() {
const card = await ReactiveCache.getCard({ listId: this._id });
return card && (await card.absoluteUrl());
absoluteUrl() {
const card = ReactiveCache.getCard({ listId: this._id });
return card && card.absoluteUrl();
},
async originRelativeUrl() {
const card = await ReactiveCache.getCard({ listId: this._id });
return card && (await card.originRelativeUrl());
originRelativeUrl() {
const card = ReactiveCache.getCard({ listId: this._id });
return card && card.originRelativeUrl();
},
async remove() {
return await Lists.removeAsync({ _id: this._id });
@ -492,7 +492,7 @@ Meteor.methods({
// my lists
const lists = await ReactiveCache.getLists(
{
boardId: { $in: Boards.userBoardIds(this.userId) },
boardId: { $in: await Boards.userBoardIds(this.userId) },
archived: false,
},
{

View file

@ -54,20 +54,20 @@ Rules.helpers({
async rename(description) {
return await Rules.updateAsync(this._id, { $set: { description } });
},
async getAction() {
return await ReactiveCache.getAction(this.actionId);
getAction() {
return ReactiveCache.getAction(this.actionId);
},
async getTrigger() {
return await ReactiveCache.getTrigger(this.triggerId);
getTrigger() {
return ReactiveCache.getTrigger(this.triggerId);
},
async board() {
return await ReactiveCache.getBoard(this.boardId);
board() {
return ReactiveCache.getBoard(this.boardId);
},
async trigger() {
return await ReactiveCache.getTrigger(this.triggerId);
trigger() {
return ReactiveCache.getTrigger(this.triggerId);
},
async action() {
return await ReactiveCache.getAction(this.actionId);
action() {
return ReactiveCache.getAction(this.actionId);
},
});

View file

@ -215,8 +215,8 @@ Swimlanes.helpers({
(await this.board()).getDefaultSwimline();
},
async cards() {
const ret = await ReactiveCache.getCards(
cards() {
const ret = ReactiveCache.getCards(
Filter.mongoSelector({
swimlaneId: this._id,
archived: false,
@ -226,12 +226,12 @@ Swimlanes.helpers({
return ret;
},
async lists() {
return await this.draggableLists();
lists() {
return this.draggableLists();
},
async newestLists() {
newestLists() {
// Revert to shared lists across swimlanes: filter by board only
return await ReactiveCache.getLists(
return ReactiveCache.getLists(
{
boardId: this.boardId,
archived: false,
@ -239,9 +239,9 @@ Swimlanes.helpers({
{ sort: { modifiedAt: -1 } },
);
},
async draggableLists() {
draggableLists() {
// Revert to shared lists across swimlanes: filter by board only
return await ReactiveCache.getLists(
return ReactiveCache.getLists(
{
boardId: this.boardId,
//archived: false,
@ -250,9 +250,9 @@ Swimlanes.helpers({
);
},
async myLists() {
myLists() {
// Return per-swimlane lists: provide lists specific to this swimlane
return await ReactiveCache.getLists(
return ReactiveCache.getLists(
{
boardId: this.boardId,
swimlaneId: this._id,
@ -262,14 +262,14 @@ Swimlanes.helpers({
);
},
async allCards() {
const ret = await ReactiveCache.getCards({ swimlaneId: this._id });
allCards() {
const ret = ReactiveCache.getCards({ swimlaneId: this._id });
return ret;
},
async isCollapsed() {
isCollapsed() {
if (Meteor.isClient) {
const user = await ReactiveCache.getCurrentUser();
const user = ReactiveCache.getCurrentUser();
if (user && user.getCollapsedSwimlaneFromStorage) {
const stored = user.getCollapsedSwimlaneFromStorage(this.boardId, this._id);
if (typeof stored === 'boolean') {
@ -286,8 +286,8 @@ Swimlanes.helpers({
return this.collapsed === true;
},
async board() {
return await ReactiveCache.getBoard(this.boardId);
board() {
return ReactiveCache.getBoard(this.boardId);
},
colorClass() {
@ -303,18 +303,18 @@ Swimlanes.helpers({
return this.type === 'template-container';
},
async isListTemplatesSwimlane() {
const user = await ReactiveCache.getCurrentUser();
isListTemplatesSwimlane() {
const user = ReactiveCache.getCurrentUser();
return (user.profile || {}).listTemplatesSwimlaneId === this._id;
},
async isCardTemplatesSwimlane() {
const user = await ReactiveCache.getCurrentUser();
isCardTemplatesSwimlane() {
const user = ReactiveCache.getCurrentUser();
return (user.profile || {}).cardTemplatesSwimlaneId === this._id;
},
async isBoardTemplatesSwimlane() {
const user = await ReactiveCache.getCurrentUser();
isBoardTemplatesSwimlane() {
const user = ReactiveCache.getCurrentUser();
return (user.profile || {}).boardTemplatesSwimlaneId === this._id;
},

View file

@ -181,7 +181,7 @@ export class TrelloCreator {
}
// You must call parseActions before calling this one.
createBoardAndLabels(trelloBoard) {
async createBoardAndLabels(trelloBoard) {
let color = 'blue';
if (this.getColor(trelloBoard.prefs.background) !== undefined) {
color = this.getColor(trelloBoard.prefs.background);
@ -207,7 +207,7 @@ export class TrelloCreator {
permission: this.getPermission(trelloBoard.prefs.permissionLevel),
slug: getSlug(trelloBoard.name) || 'board',
stars: 0,
title: Boards.uniqueTitle(trelloBoard.name),
title: await Boards.uniqueTitle(trelloBoard.name),
};
// now add other members
if (trelloBoard.memberships) {
@ -779,7 +779,7 @@ export class TrelloCreator {
await currentBoard.archive();
}
this.parseActions(board.actions);
const boardId = this.createBoardAndLabels(board);
const boardId = await this.createBoardAndLabels(board);
this.createLists(board.lists, boardId);
this.createSwimlanes(boardId);
this.createCards(board.cards, boardId);

View file

@ -36,20 +36,20 @@ Triggers.helpers({
return this.desc;
},
async getRule() {
return await ReactiveCache.getRule({ triggerId: this._id });
getRule() {
return ReactiveCache.getRule({ triggerId: this._id });
},
async fromList() {
return await ReactiveCache.getList(this.fromId);
fromList() {
return ReactiveCache.getList(this.fromId);
},
async toList() {
return await ReactiveCache.getList(this.toId);
toList() {
return ReactiveCache.getList(this.toId);
},
async findList(title) {
return await ReactiveCache.getList({
findList(title) {
return ReactiveCache.getList({
title,
});
},

View file

@ -902,10 +902,10 @@ if (Meteor.isClient) {
return board && board.hasWorker(this._id);
},
async isBoardAdmin(boardId) {
isBoardAdmin(boardId) {
let board;
if (boardId) {
board = await ReactiveCache.getBoard(boardId);
board = ReactiveCache.getBoard(boardId);
} else {
board = Utils.getCurrentBoard();
}

View file

@ -280,7 +280,7 @@ export class WekanCreator {
}
// You must call parseActions before calling this one.
createBoardAndLabels(boardToImport) {
async createBoardAndLabels(boardToImport) {
const boardToCreate = {
archived: boardToImport.archived,
color: boardToImport.color,
@ -304,7 +304,7 @@ export class WekanCreator {
permission: boardToImport.permission,
slug: getSlug(boardToImport.title) || 'board',
stars: 0,
title: Boards.uniqueTitle(boardToImport.title),
title: await Boards.uniqueTitle(boardToImport.title),
};
// now add other members
if (boardToImport.members) {
@ -982,7 +982,7 @@ export class WekanCreator {
await currentBoard.archive();
}
this.parseActivities(board);
const boardId = this.createBoardAndLabels(board);
const boardId = await this.createBoardAndLabels(board);
this.createLists(board.lists, boardId);
this.createSwimlanes(board.swimlanes, boardId);
this.createCustomFields(board.customFields, boardId);