mirror of
https://github.com/wekan/wekan.git
synced 2026-11-08 03:22:32 -05:00
Board/card 'button' rules now denormalise their button type/label onto the schema-backed rules document (via a board-admin-gated rules.createRule method) and the header/card read them from there, because the schemaless triggers collection's documents do not reach the client over the board subscription; the boardRules publication and the rules-list editor read from it too. Also warn (instead of silently creating an empty board) when a pasted WeKan export has no swimlanes/lists/cards (a broken older export). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
import Rules from '/models/rules';
|
|
|
|
// Renders the board's "board button" rules in the board header and runs one
|
|
// (board-level, no card) when clicked. The button metadata (type + label) is
|
|
// denormalised onto the rule document (see server/rulesButton.js), so the board
|
|
// view reads it from the published `rules` collection alone — the schemaless
|
|
// `triggers` collection's documents do not reach the client over the board
|
|
// subscription in this Meteor 3 setup.
|
|
Template.boardButtons.onCreated(function () {
|
|
this.autorun(() => {
|
|
const boardId = Session.get('currentBoard');
|
|
if (boardId) this.subscribe('boardRules', boardId);
|
|
});
|
|
});
|
|
|
|
Template.boardButtons.helpers({
|
|
boardButtonRules() {
|
|
const boardId = Session.get('currentBoard');
|
|
if (!boardId) return [];
|
|
// Read Minimongo directly (not the memoizing ReactiveCache, which can latch a
|
|
// transient empty result during subscription churn). A stable `_id` lets
|
|
// Blaze reuse the node across re-renders.
|
|
return Rules.find({ boardId, buttonType: 'board' })
|
|
.fetch()
|
|
.map(rule => ({
|
|
_id: rule._id,
|
|
ruleId: rule._id,
|
|
label: rule.buttonLabel || rule.title,
|
|
}));
|
|
},
|
|
});
|
|
|
|
Template.boardButtons.events({
|
|
'click .js-run-board-button'(event) {
|
|
event.preventDefault();
|
|
const ruleId = event.currentTarget.getAttribute('data-rule-id');
|
|
Meteor.call('rules.runButton', ruleId);
|
|
},
|
|
});
|