mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Four Kanban and Scrum practices other tools have, kept on the card (card.flow, models/lib/cardFlow.js), offline and with no AI: - Blocked: ticked with a reason; who marked it and since when are the server's. A red Blocked badge on the minicard, the reason its tooltip. - Class of service: Standard, Fixed date, Expedite, Intangible. Expedite has a WIP limit of one open card per board; a second is refused. - MoSCoW priority: Must, Should, Could, Won't have. - WSJF score: business value, time criticality and risk reduction divided by job size, each on the 1-20 scale; shown once every part is set. Each is a row of Board Settings / Card in the Card section, off on the card and the minicard until a board turns it on, and an Admin Panel / Features / Card field that hides it on every board. Written only by the setCardFlow method, which checks the card edit right, an assigned-only member's own cards and the values; a client write of flow is denied. Translated in every language. Thanks to xet7 !
54 lines
2.3 KiB
JavaScript
54 lines
2.3 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { check, Match } from 'meteor/check';
|
|
import Boards from '/models/boards';
|
|
import Cards from '/models/cards';
|
|
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
|
|
|
|
const { flowModifier, expediteOverLimit } = require('/models/lib/cardFlow');
|
|
const { isAssignedOnlyMember } = require('/models/lib/boardCardScope');
|
|
|
|
// The card's Kanban and Scrum flow fields (models/lib/cardFlow.js): blocked
|
|
// and why, class of service, MoSCoW, WSJF. The same permission as every other
|
|
// card edit (canEditCardOrLinkedCard, on the source of a linked card); an
|
|
// assigned-only member changes only a card assigned to them; Expedite keeps
|
|
// its WIP limit of one open card per board. Who blocked a card and when is
|
|
// the server's, never the client's.
|
|
export async function setCardFlowFor(userId, cardId, patch) {
|
|
check(cardId, String);
|
|
check(patch, Match.ObjectIncluding({}));
|
|
if (!userId) throw new Meteor.Error('not-authorized');
|
|
let card = await Cards.findOneAsync(cardId);
|
|
if (!card) throw new Meteor.Error('not-found');
|
|
if (card.type === 'cardType-linkedCard' && card.linkedId) {
|
|
card = await Cards.findOneAsync(card.linkedId);
|
|
if (!card) throw new Meteor.Error('not-found');
|
|
}
|
|
const board = await Boards.findOneAsync(card.boardId);
|
|
if (!board || !(await canEditCardOrLinkedCard(userId, card, board))) throw new Meteor.Error('not-authorized');
|
|
if (isAssignedOnlyMember(board, userId) && !(card.assignees || []).includes(userId)
|
|
&& !(card.members || []).includes(userId)) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
let modifier;
|
|
try {
|
|
modifier = flowModifier(patch, { userId, now: new Date() });
|
|
} catch (e) {
|
|
throw new Meteor.Error(e.code || 'invalid-flow-patch');
|
|
}
|
|
if (patch.classOfService === 'expedite' && card.flow?.classOfService !== 'expedite') {
|
|
const others = await Cards.find(
|
|
{ boardId: card.boardId, archived: { $ne: true }, 'flow.classOfService': 'expedite' },
|
|
{ fields: { _id: 1, archived: 1, dueComplete: 1, flow: 1 } },
|
|
).fetchAsync();
|
|
if (expediteOverLimit(card._id, others)) throw new Meteor.Error('expedite-limit');
|
|
}
|
|
await Cards.updateAsync({ _id: card._id }, modifier);
|
|
return true;
|
|
}
|
|
|
|
Meteor.methods({
|
|
async setCardFlow(cardId, patch) {
|
|
return await setCardFlowFor(this.userId, cardId, patch);
|
|
},
|
|
});
|