Files
wekan/client/components/lists/listPermissions.js
T
Lauri Ojansivu 7595727917 Boards every signed-in user may edit, per-list permissions, board keys and shared labels.
A board can let every signed-in user edit it, when Admin Panel / Settings /
Visibility allows it: a non-member then comments, edits and moves cards like
a Normal member, and their first edit makes them one. Board-wide settings
stay members-only.

Lists can allow or refuse editing and commenting per role (list menu, board
admins): built-in roles, custom roles and, on an open board, everyone signed
in. The server applies it to card, checklist, attachment and comment writes
and to moves into the list; the REST API honours a list's refusal on every
per-list card route. A direct client write of the setting is refused and
shown in Admin Panel / Problems.

Every board has a key, unique in the instance, suggested from its title and
set for existing boards at startup; card numbers show as KEY-7 and searching
for KEY-7 finds the card.

Shared labels in Admin Panel / Labels, for every board or an organization's
or team's boards; a board uses them beside its own, and a rename or colour
change reaches every board that uses it.

New strings translated in all languages. Low confidence: chr, tlh, wal, ay,
ace, nah, gn, iu, zgh, rup, wo, se, ff, tig, vo, bm, kl, bua, nap, mai, to,
ks, qu, bo, fj, haw, om, ss, ts, ve-PP, lld, scn.

Thanks to Meeques, justinr1234, tiFabGrinch, ejlkemper and xet7 !

Fixes #4575,
Fixes #4527,
Fixes #2449,
Fixes #2450,
Fixes #2761,
Fixes #4698.
2026-10-14 09:28:45 +03:00

64 lines
2.4 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
import CustomBoardRoles from '/models/customBoardRoles';
// #4527: the List permissions popup (list menu, board admins). One row per
// role a member can have - the built-in ones, the custom ones, and on an open
// board everybody signed in - and for each, edit and comment: as the board
// says, allowed, or refused in this list.
const { BOARD_ROLES } = require('/models/lib/boardRoleCapabilities');
const { LIST_CAPABILITIES, SIGNED_IN, cleanExceptions } = require('/models/lib/listPermissions');
function choiceOf(list, role, cap) {
const entry = list && list.roleExceptions && list.roleExceptions[role];
if (!entry || typeof entry[cap] !== 'boolean') return '';
return entry[cap] ? 'allow' : 'deny';
}
Template.listPermissionsPopup.helpers({
roles() {
const list = Template.instance().data;
const board = list && ReactiveCache.getBoard(list.boardId);
const rows = BOARD_ROLES.filter(role => role !== 'board-admin')
.map(role => ({ key: role, label: TAPi18n.__(role) }));
CustomBoardRoles.find({}, { sort: { name: 1 } }).forEach(role => {
rows.push({ key: `custom:${role._id}`, label: role.name });
});
if (board && (board.permission === 'public' || board.permission === 'instance')) {
rows.push({ key: SIGNED_IN, label: TAPi18n.__('list-permission-signed-in') });
}
return rows;
},
capabilities() {
return LIST_CAPABILITIES;
},
capLabel(cap) {
return TAPi18n.__(cap === 'write' ? 'edit' : 'comment');
},
isChoice(role, cap, value) {
return choiceOf(Template.instance().data, role, cap) === value;
},
});
Template.listPermissionsPopup.events({
'click .js-save-list-permissions'(event, tpl) {
const list = tpl.data;
const exceptions = {};
tpl.findAll('select.js-list-permission').forEach(select => {
if (!select.value) return;
const role = select.getAttribute('data-role');
const cap = select.getAttribute('data-cap');
exceptions[role] = exceptions[role] || {};
exceptions[role][cap] = select.value === 'allow';
});
Meteor.call('lists.setRoleExceptions', list._id, cleanExceptions(exceptions), error => {
if (error) {
console.error('lists.setRoleExceptions', error);
return;
}
Popup.back();
});
},
});