Files
wekan/client/lib/dependencyLayers.js
T
Lauri Ojansivu 7e1f9e89eb Docs: every feature topic in one folder under docs/Features, each with README.md as its main page.
- The General/ level is gone: its 109 files moved up into the folders of the
  same name, and its topic table is the "Shared topics" section of
  Features.md.
- Accessibility is one folder, docs/Features/Accessibility/, with the Admin
  Panel's accessibility page in it.
- Every folder's main page is README.md (110 X/X.md pages renamed with git mv,
  five merged with an existing README.md, 26 index pages added for folders
  that had none), so a folder opened on GitHub shows its page.
- The 73 "# Moved" forwarding pages are deleted, with the folders that held
  only them; every link that went to one goes to its final page.
- docs/Features/README.md has the website's "Features in WeKan" overview,
  each feature linking to its page here.

1,129 Markdown links in 262 files and 352 doc paths in code, tests, compose,
snap and release files follow. tests/docsFeaturesLayout.test.cjs fails when
General/ or a "# Moved" page comes back, a folder has no README.md, or a
relative link in the docs or README.md does not resolve.

Thanks to xet7 !
2026-11-24 20:02:06 +02:00

56 lines
2.5 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { ReactiveCache } from '/imports/reactiveCache';
import { currentUserWith } from '/client/lib/currentUserWith';
import { Utils } from '/client/lib/utils';
import { normalizeDependency } from '/models/metadata/dependencies';
const { canEditBoardDependencies, canEditCardDependency, normalizeMyDependencies } = require('/models/lib/dependencyAccess');
// #6732: the two dependency layers as THIS user sees them
// (docs/Features/Editor/RedStrings/Board-And-My-Dependencies.md). Both are off
// until the user turns them on in Member Settings, and turning one on changes
// only their own view.
export function dependencyVisibility() {
// #6745: read per minicard (newLineLayer), so only these two fields.
const user = currentUserWith(['profile.showBoardDependencies', 'profile.showMyDependencies']);
const profile = (user || {}).profile || {};
return { board: profile.showBoardDependencies === true, mine: profile.showMyDependencies === true };
}
export function canEditBoardDependenciesHere(board) {
return !!board && canEditBoardDependencies(board, Meteor.userId());
}
// Where a line drawn on the board goes: the Board Dependencies when they are
// shown and this user may edit them, otherwise My Dependencies when those are
// shown. With neither, nothing is drawn and no connect handle appears.
export function newLineLayer(board) {
const shown = dependencyVisibility();
if (shown.board && canEditBoardDependenciesHere(board)) return 'board';
if (shown.mine && Meteor.userId()) return 'mine';
return null;
}
// This user's own lines on one board.
export function myDependencyLines(boardId) {
const profile = (ReactiveCache.getCurrentUser() || {}).profile || {};
return normalizeMyDependencies(profile.myDependencies, normalizeDependency).filter(row => row.boardId === boardId);
}
// May this user edit this card's Board Dependencies? A linked card's live on
// the card it points at, as the server resolves them.
export function canEditCardDependenciesHere(card) {
const real = card && typeof card.getRealCard === 'function' ? card.getRealCard() : card;
const board = real && ReactiveCache.getBoard(real.boardId);
return !!(board && real && canEditCardDependency(board, Meteor.userId(), real));
}
// The open card's (card details).
Template.registerHelper('canEditBoardDependencies', () =>
canEditCardDependenciesHere(ReactiveCache.getCard(Utils.getCurrentCardId())));
Template.registerHelper('showAnyDependencies', () => {
const shown = dependencyVisibility();
return shown.board || shown.mine;
});