mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The card color, the parent card path and prefix, the linked card indicator, the rule card buttons, the description badge and the unread comments marker were drawn with no Board Settings / Card row, so a board could not turn them off. Each has a row now, with a card and a minicard side. Where something was drawn before it stays on; the description badge on the card, the card buttons on the minicard and the unread marker on the card are new and off until chosen. The minicard's card buttons read the board's rules from one board-level subscription, taken only while that side is on, and run a rule without opening the card. Not given rows, by decision: the archived banner and the upload progress are status, not options; week-of-year is the user's own Member Settings preference; card aging has its own board setting. The new labels are in English, pending Transifex. Thanks to xet7 !
77 lines
2.5 KiB
JavaScript
77 lines
2.5 KiB
JavaScript
import Rules from '/models/rules';
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { Tracker } from 'meteor/tracker';
|
|
import { Utils } from '/client/lib/utils';
|
|
|
|
// Lists the board's "card button" rules and runs one on the current card when
|
|
// clicked. Expects the card data context (cardId + boardId) inherited from the
|
|
// card detail template. The button metadata is denormalised onto the rule (see
|
|
// server/rulesButton.js), so this reads from the published `rules` collection
|
|
// alone — the schemaless `triggers` collection does not reach the client over
|
|
// the board subscription in this Meteor 3 setup.
|
|
Template.cardButtons.onCreated(function () {
|
|
this.autorun(() => {
|
|
const boardId = this.data && this.data.boardId;
|
|
if (boardId) this.subscribe('boardRules', boardId);
|
|
});
|
|
});
|
|
|
|
function buttonRulesForBoard(boardId) {
|
|
if (!boardId) return [];
|
|
return Rules.find({ boardId, buttonType: 'card' })
|
|
.fetch()
|
|
.map(rule => ({
|
|
_id: rule._id,
|
|
ruleId: rule._id,
|
|
label: rule.buttonLabel || rule.title,
|
|
}));
|
|
}
|
|
|
|
Template.cardButtons.helpers({
|
|
hasCardButtons() {
|
|
return buttonRulesForBoard(this.boardId).length > 0;
|
|
},
|
|
cardButtonRules() {
|
|
return buttonRulesForBoard(this.boardId);
|
|
},
|
|
});
|
|
|
|
Template.cardButtons.events({
|
|
'click .js-run-card-button'(event, tpl) {
|
|
event.preventDefault();
|
|
const ruleId = event.currentTarget.getAttribute('data-rule-id');
|
|
const cardId = tpl.data && tpl.data._id;
|
|
Meteor.call('rules.runButton', ruleId, cardId);
|
|
},
|
|
});
|
|
|
|
// Card buttons, Show on Minicard: the same rule buttons under each minicard.
|
|
// They read the rules from the ONE board-level subscription below, never one
|
|
// per minicard; a click runs the rule and does not open the card.
|
|
Template.minicardCardButtons.helpers({
|
|
hasCardButtons() {
|
|
return buttonRulesForBoard(this.boardId).length > 0;
|
|
},
|
|
cardButtonRules() {
|
|
return buttonRulesForBoard(this.boardId);
|
|
},
|
|
});
|
|
|
|
Template.minicardCardButtons.events({
|
|
'click .js-run-minicard-card-button'(event, tpl) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
const ruleId = event.currentTarget.getAttribute('data-rule-id');
|
|
const cardId = tpl.data && tpl.data._id;
|
|
Meteor.call('rules.runButton', ruleId, cardId);
|
|
},
|
|
});
|
|
|
|
Meteor.startup(() => {
|
|
Tracker.autorun(() => {
|
|
const board = Utils.getCurrentBoard();
|
|
// Stopped by the autorun itself when the board or the setting changes.
|
|
if (board && board.allowsCardButtonsOnMinicard === true) Meteor.subscribe('boardRules', board._id);
|
|
});
|
|
});
|