Files
wekan/server/tableViewCards.js
T
Lauri Ojansivu 68dcfd14fe Admin Panel / Settings / Features: an unticked feature is refused on the server, not only hidden.
An unticked feature hid its menus and nothing else: the Table, Chat, Email,
Version Control and Scrum views' methods and publications still answered,
setBoardView still stored a hidden view, and a client could still turn on a
list policy, a commitment point, a WIP limit per person or a split list.

models/lib/featureServerGates.js lists, for every catalog feature, its server
paths, its write gates, or why it is display only. requireFeature /
featureAllowed (server/lib/assistGate.js) refuse with feature-disabled and
record the attempt in Admin Panel / Problems as Disabled setting; the Scrum
methods are wrapped in one place, except the ones the card details, Board
Settings and data recovery use too; Boards / Lists deny rules refuse turning
a flow policy on; setCardFlow refuses Done here while split lists is off;
setBoardView refuses a hidden view. Board Settings / Scrum settings follows the
Scrum views tick, as it opens in the Sprints view.

tests/featureServerGates.test.cjs fails when a catalog feature is undecided,
or when a method or publication of a feature file does not ask the gate.

Thanks to xet7 !
2026-11-22 18:46:33 +02:00

41 lines
2.0 KiB
JavaScript

// #864: adding a card from the Table view - title, list and swimlane - with
// the same right as adding one on the board: a member who may write in that
// list (server/lib/listPermissionGate.js).
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Boards from '/models/boards';
import Cards from '/models/cards';
import Lists from '/models/lists';
import Swimlanes from '/models/swimlanes';
import { canWriteInList } from '/server/lib/listPermissionGate';
// Admin Panel / Settings / Features / Table view (models/lib/featureServerGates.js).
import { requireFeature } from '/server/lib/assistGate';
Meteor.methods({
async tableViewAddCard(input) {
check(input, { boardId: String, listId: String, swimlaneId: String, title: String });
if (!this.userId) throw new Meteor.Error('not-authorized');
await requireFeature(this.userId, 'views-table', 'ddp:tableViewAddCard');
const title = input.title.replace(/\s+/g, ' ').trim().slice(0, 1000);
if (!title) throw new Meteor.Error('table-view-empty-title');
const board = await Boards.findOneAsync(input.boardId);
if (!board || board.archived) throw new Meteor.Error('not-found');
const list = await Lists.findOneAsync({ _id: input.listId, boardId: board._id, archived: { $ne: true } });
const swimlane = await Swimlanes.findOneAsync({ _id: input.swimlaneId, boardId: board._id, archived: { $ne: true } });
if (!list || !swimlane) throw new Meteor.Error('not-found');
if (!(await canWriteInList(this.userId, board, list._id))) throw new Meteor.Error('not-authorized');
const last = await Cards.findOneAsync({ listId: list._id, swimlaneId: swimlane._id, archived: false },
{ sort: { sort: -1 }, fields: { sort: 1 } });
return Cards.insertAsync({
title,
listId: list._id,
boardId: board._id,
swimlaneId: swimlane._id,
sort: last && Number.isFinite(last.sort) ? last.sort + 1 : 0,
type: 'cardType-card',
cardNumber: await board.getNextCardNumber(),
userId: this.userId,
});
},
});