2023-01-14 13:29:57 +01:00
import { ReactiveCache } from '/imports/reactiveCache' ;
2021-07-10 10:55:54 +02:00
import escapeForRegex from 'escape-string-regexp' ;
import { TAPi18n } from '/imports/i18n' ;
2026-01-14 00:13:21 +02:00
import { CustomFields } from './customFields' ;
2021-04-03 01:19:02 +02:00
import {
ALLOWED _BOARD _COLORS ,
ALLOWED _COLORS ,
TYPE _BOARD ,
TYPE _TEMPLATE _BOARD ,
TYPE _TEMPLATE _CONTAINER ,
2021-04-03 18:52:47 +02:00
} from '/config/const' ;
2021-12-21 02:39:16 +02:00
import Users from "./users" ;
2026-01-14 00:13:21 +02:00
import { FlowRouter } from 'meteor/ostrio:flow-router-extra' ;
2025-12-29 16:29:01 +02:00
import TableVisibilityModeSettings from "./tableVisibilityModeSettings" ;
2021-04-03 01:19:02 +02:00
2022-04-18 21:25:47 +03:00
// const escapeForRegex = require('escape-string-regexp');
2020-09-16 14:52:00 -05:00
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
Boards = new Mongo . Collection ( 'boards' ) ;
2018-10-26 07:27:24 +02:00
/ * *
* This is a Board .
* /
2019-06-26 17:47:27 -05:00
Boards . attachSchema (
new SimpleSchema ( {
title : {
/ * *
* The title of the board
* /
type : String ,
} ,
slug : {
/ * *
* The title slugified .
* /
type : String ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
// In some cases (Chinese and Japanese for instance) the `getSlug` function
// return an empty string. This is causes bugs in our application so we set
// a default slug in this case.
2020-07-19 19:57:23 +02:00
// Improvment would be to change client URL after slug is changed
const title = this . field ( 'title' ) ;
if ( title . isSet && ! this . isSet ) {
2019-06-26 17:47:27 -05:00
let slug = 'board' ;
2020-07-19 19:57:23 +02:00
slug = getSlug ( title . value ) || slug ;
2019-06-26 17:47:27 -05:00
return slug ;
2016-04-22 00:59:05 +02:00
}
2019-06-26 17:47:27 -05:00
} ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
archived : {
/ * *
* Is the board archived ?
* /
type : Boolean ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert && ! this . isSet ) {
return false ;
}
} ,
2016-04-22 00:59:05 +02:00
} ,
2021-02-01 21:50:53 +01:00
archivedAt : {
/ * *
* Latest archiving time of the board
* /
type : Date ,
optional : true ,
} ,
2019-06-26 17:47:27 -05:00
createdAt : {
/ * *
* Creation time of the board
* /
type : Date ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert ) {
return new Date ( ) ;
2019-09-05 12:29:45 -05:00
} else if ( this . isUpsert ) {
return { $setOnInsert : new Date ( ) } ;
2019-06-26 17:47:27 -05:00
} else {
this . unset ( ) ;
}
} ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
// XXX Inconsistent field naming
modifiedAt : {
/ * *
* Last modification time of the board
* /
type : Date ,
optional : true ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert || this . isUpsert || this . isUpdate ) {
return new Date ( ) ;
} else {
this . unset ( ) ;
}
} ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
// De-normalized number of users that have starred this board
stars : {
/ * *
* How many stars the board has
* /
type : Number ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert ) {
return 0 ;
}
} ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
// De-normalized label system
labels : {
/ * *
* List of labels attached to a board
* /
type : [ Object ] ,
2021-06-08 05:07:32 +03:00
optional : true ,
/ * C o m m e n t e d o u t , s o d o e s n o t c r e a t e l a b e l s t o n e w b o a r d s .
2019-06-26 17:47:27 -05:00
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert && ! this . isSet ) {
const colors = Boards . simpleSchema ( ) . _schema [ 'labels.$.color' ]
. allowedValues ;
const defaultLabelsColors = _ . clone ( colors ) . splice ( 0 , 6 ) ;
2019-06-28 12:52:09 -05:00
return defaultLabelsColors . map ( color => ( {
2019-06-26 17:47:27 -05:00
color ,
_id : Random . id ( 6 ) ,
name : '' ,
} ) ) ;
}
} ,
2021-06-08 05:07:32 +03:00
* /
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
'labels.$._id' : {
/ * *
* Unique id of a label
* /
// We don't specify that this field must be unique in the board because that
// will cause performance penalties and is not necessary since this field is
// always set on the server.
// XXX Actually if we create a new label, the `_id` is set on the client
// without being overwritten by the server, could it be a problem?
type : String ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
'labels.$.name' : {
/ * *
* Name of a label
* /
type : String ,
optional : true ,
2016-04-22 00:59:05 +02:00
} ,
2019-06-26 17:47:27 -05:00
'labels.$.color' : {
/ * *
* color of a label .
*
* Can be amongst ` green ` , ` yellow ` , ` orange ` , ` red ` , ` purple ` ,
* ` blue ` , ` sky ` , ` lime ` , ` pink ` , ` black ` ,
* ` silver ` , ` peachpuff ` , ` crimson ` , ` plum ` , ` darkgreen ` ,
* ` slateblue ` , ` magenta ` , ` gold ` , ` navy ` , ` gray ` ,
* ` saddlebrown ` , ` paleturquoise ` , ` mistyrose ` , ` indigo `
* /
type : String ,
2021-04-03 01:19:02 +02:00
allowedValues : ALLOWED _COLORS ,
2019-06-26 17:47:27 -05:00
} ,
// XXX We might want to maintain more informations under the member sub-
// documents like de-normalized meta-data (the date the member joined the
// board, the number of contributions, etc.).
members : {
/ * *
* List of members of a board
* /
type : [ Object ] ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert && ! this . isSet ) {
return [
{
userId : this . userId ,
isAdmin : true ,
isActive : true ,
isNoComments : false ,
isCommentOnly : false ,
2020-01-05 21:28:14 +02:00
isWorker : false ,
2019-06-26 17:47:27 -05:00
} ,
] ;
}
} ,
} ,
'members.$.userId' : {
/ * *
* The uniq ID of the member
* /
type : String ,
} ,
'members.$.isAdmin' : {
/ * *
* Is the member an admin of the board ?
* /
type : Boolean ,
} ,
'members.$.isActive' : {
/ * *
* Is the member active ?
* /
type : Boolean ,
} ,
'members.$.isNoComments' : {
/ * *
* Is the member not allowed to make comments
* /
type : Boolean ,
optional : true ,
} ,
'members.$.isCommentOnly' : {
/ * *
* Is the member only allowed to comment on the board
* /
type : Boolean ,
optional : true ,
} ,
2020-01-05 21:28:14 +02:00
'members.$.isWorker' : {
/ * *
* Is the member only allowed to move card , assign himself to card and comment
* /
type : Boolean ,
optional : true ,
} ,
2025-12-22 21:45:09 +02:00
'members.$.isNormalAssignedOnly' : {
/ * *
* Is the member only allowed to see assigned cards ( Normal permission )
* /
type : Boolean ,
optional : true ,
} ,
'members.$.isCommentAssignedOnly' : {
/ * *
* Is the member only allowed to comment on assigned cards
* /
type : Boolean ,
optional : true ,
} ,
'members.$.isReadOnly' : {
/ * *
* Is the member only allowed to read the board ( no comments , no editing )
* /
type : Boolean ,
optional : true ,
} ,
'members.$.isReadAssignedOnly' : {
/ * *
* Is the member only allowed to read assigned cards ( no comments , no editing )
* /
type : Boolean ,
optional : true ,
} ,
2019-06-26 17:47:27 -05:00
permission : {
/ * *
* visibility of the board
* /
type : String ,
allowedValues : [ 'public' , 'private' ] ,
} ,
2021-07-05 11:27:38 +02:00
orgs : {
/ * *
* the list of organizations that a board belongs to
* /
type : [ Object ] ,
optional : true ,
} ,
'orgs.$.orgId' : {
/ * *
* The uniq ID of the organization
* /
type : String ,
} ,
'orgs.$.orgDisplayName' : {
/ * *
* The display name of the organization
* /
type : String ,
} ,
'orgs.$.isActive' : {
/ * *
* Is the organization active ?
* /
type : Boolean ,
} ,
teams : {
/ * *
* the list of teams that a board belongs to
* /
type : [ Object ] ,
optional : true ,
} ,
'teams.$.teamId' : {
/ * *
* The uniq ID of the team
* /
type : String ,
} ,
'teams.$.teamDisplayName' : {
/ * *
* The display name of the team
* /
type : String ,
} ,
'teams.$.isActive' : {
/ * *
* Is the team active ?
* /
type : Boolean ,
} ,
2019-06-26 17:47:27 -05:00
color : {
/ * *
* The color of the board .
* /
type : String ,
2021-04-03 01:19:02 +02:00
allowedValues : ALLOWED _BOARD _COLORS ,
2019-06-26 17:47:27 -05:00
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert && ! this . isSet ) {
2021-04-03 01:19:02 +02:00
return ALLOWED _BOARD _COLORS [ 0 ] ;
2019-06-26 17:47:27 -05:00
}
} ,
} ,
2023-05-27 03:10:41 -04:00
backgroundImageURL : {
/ * *
* The background image URL of the board .
* /
type : String ,
optional : true ,
} ,
2022-04-15 13:19:37 -03:00
allowsCardCounterList : {
/ * *
* Show card counter per list
* /
type : Boolean ,
defaultValue : false ,
} ,
allowsBoardMemberList : {
/ * *
* Show board member list
* /
type : Boolean ,
defaultValue : false ,
} ,
2019-06-26 17:47:27 -05:00
description : {
/ * *
* The description of the board
* /
type : String ,
optional : true ,
} ,
subtasksDefaultBoardId : {
/ * *
* The default board ID assigned to subtasks .
* /
type : String ,
optional : true ,
defaultValue : null ,
} ,
2025-10-12 03:48:21 +03:00
migrationVersion : {
/ * *
* The migration version of the board structure .
* New boards are created with the latest version and don ' t need migration .
* /
type : Number ,
// eslint-disable-next-line consistent-return
autoValue ( ) {
if ( this . isInsert && ! this . isSet ) {
return 1 ; // Latest migration version for new boards
}
} ,
} ,
2020-02-04 02:28:45 -08:00
2019-06-26 17:47:27 -05:00
subtasksDefaultListId : {
/ * *
* The default List ID assigned to subtasks .
* /
type : String ,
optional : true ,
defaultValue : null ,
} ,
2020-02-04 02:28:45 -08:00
dateSettingsDefaultBoardId : {
type : String ,
optional : true ,
defaultValue : null ,
} ,
dateSettingsDefaultListId : {
type : String ,
optional : true ,
defaultValue : null ,
} ,
2019-06-26 17:47:27 -05:00
allowsSubtasks : {
/ * *
* Does the board allows subtasks ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2020-02-04 02:28:45 -08:00
2020-02-05 01:17:15 +02:00
allowsAttachments : {
/ * *
* Does the board allows attachments ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsChecklists : {
/ * *
* Does the board allows checklists ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsComments : {
/ * *
* Does the board allows comments ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2020-02-12 02:08:29 +02:00
allowsDescriptionTitle : {
/ * *
* Does the board allows description title ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsDescriptionText : {
/ * *
* Does the board allows description text ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2022-04-05 17:00:39 -03:00
allowsDescriptionTextOnMinicard : {
/ * *
2022-04-05 17:06:26 -03:00
* Does the board allows description text on minicard ?
2022-04-05 17:00:39 -03:00
* /
type : Boolean ,
defaultValue : false ,
} ,
2020-02-12 02:08:29 +02:00
2023-05-31 11:52:20 -03:00
allowsCoverAttachmentOnMinicard : {
/ * *
* Does the board allows cover attachment on minicard ?
* /
type : Boolean ,
2025-10-10 18:52:30 +03:00
defaultValue : true ,
2023-05-31 11:52:20 -03:00
} ,
2023-05-31 14:49:02 -03:00
allowsBadgeAttachmentOnMinicard : {
/ * *
* Does the board allows badge attachment on minicard ?
* /
type : Boolean ,
defaultValue : false ,
} ,
allowsCardSortingByNumberOnMinicard : {
/ * *
* Does the board allows card sorting by number on minicard ?
* /
type : Boolean ,
defaultValue : false ,
} ,
2021-08-02 21:41:30 +02:00
allowsCardNumber : {
/ * *
* Does the board allows card numbers ?
* /
type : Boolean ,
defaultValue : false ,
} ,
2020-02-07 13:58:43 +02:00
allowsActivities : {
/ * *
* Does the board allows comments ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2020-02-05 01:17:15 +02:00
allowsLabels : {
/ * *
* Does the board allows labels ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2021-04-01 23:40:07 +02:00
allowsCreator : {
/ * *
* Does the board allow creator ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2023-12-01 13:31:16 +02:00
allowsCreatorOnMinicard : {
/ * *
* Does the board allow creator ?
* /
type : Boolean ,
defaultValue : false ,
} ,
2020-02-05 01:17:15 +02:00
allowsAssignee : {
/ * *
* Does the board allows assignee ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsMembers : {
/ * *
* Does the board allows members ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsRequestedBy : {
/ * *
* Does the board allows requested by ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2021-04-12 23:34:02 +02:00
allowsCardSortingByNumber : {
/ * *
* Does the board allows card sorting by number ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2022-02-02 23:34:38 +01:00
allowsShowLists : {
/ * *
* Does the board allows show lists on the card ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2025-10-11 11:31:57 +03:00
2020-02-05 01:17:15 +02:00
allowsAssignedBy : {
/ * *
* Does the board allows requested by ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2025-10-11 11:31:57 +03:00
allowsShowListsOnMinicard : {
/ * *
* Does the board allow showing list names on all minicards ?
* /
type : Boolean ,
defaultValue : false ,
} ,
2020-02-05 01:17:15 +02:00
2025-12-29 21:42:19 +02:00
allowsChecklistAtMinicard : {
/ * *
* Does the board allow showing checklists on all minicards ?
* /
type : Boolean ,
defaultValue : false ,
} ,
2020-02-04 02:28:45 -08:00
allowsReceivedDate : {
/ * *
* Does the board allows received date ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsStartDate : {
/ * *
* Does the board allows start date ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsEndDate : {
/ * *
* Does the board allows end date ?
* /
type : Boolean ,
defaultValue : true ,
} ,
allowsDueDate : {
/ * *
* Does the board allows due date ?
* /
type : Boolean ,
defaultValue : true ,
} ,
2019-06-26 17:47:27 -05:00
presentParentTask : {
/ * *
* Controls how to present the parent task :
*
* - ` prefix-with-full-path ` : add a prefix with the full path
* - ` prefix-with-parent ` : add a prefisx with the parent name
* - ` subtext-with-full-path ` : add a subtext with the full path
* - ` subtext-with-parent ` : add a subtext with the parent name
* - ` no-parent ` : does not show the parent at all
* /
type : String ,
allowedValues : [
'prefix-with-full-path' ,
'prefix-with-parent' ,
'subtext-with-full-path' ,
'subtext-with-parent' ,
'no-parent' ,
] ,
optional : true ,
defaultValue : 'no-parent' ,
} ,
2021-09-12 11:22:15 +02:00
receivedAt : {
/ * *
* Date the card was received
* /
type : Date ,
optional : true ,
} ,
2019-06-26 17:47:27 -05:00
startAt : {
/ * *
* Starting date of the board .
* /
type : Date ,
optional : true ,
} ,
dueAt : {
/ * *
* Due date of the board .
* /
type : Date ,
optional : true ,
} ,
endAt : {
/ * *
* End date of the board .
* /
type : Date ,
optional : true ,
} ,
spentTime : {
/ * *
* Time spent in the board .
* /
type : Number ,
decimal : true ,
optional : true ,
} ,
isOvertime : {
/ * *
* Is the board overtimed ?
* /
type : Boolean ,
defaultValue : false ,
optional : true ,
} ,
type : {
/ * *
* The type of board
2021-04-02 21:40:52 +02:00
* possible values : board , template - board , template - container
2019-06-26 17:47:27 -05:00
* /
type : String ,
2021-04-03 01:19:02 +02:00
defaultValue : TYPE _BOARD ,
allowedValues : [ TYPE _BOARD , TYPE _TEMPLATE _BOARD , TYPE _TEMPLATE _CONTAINER ] ,
2019-06-26 17:47:27 -05:00
} ,
2020-04-19 10:48:44 +03:00
sort : {
/ * *
* Sort value
* /
type : Number ,
decimal : true ,
defaultValue : - 1 ,
} ,
2023-03-17 21:26:40 +01:00
showActivities : {
type : Boolean ,
defaultValue : false ,
} ,
2019-06-28 12:52:09 -05:00
} ) ,
2019-06-26 17:47:27 -05:00
) ;
2015-09-08 20:19:42 +02:00
Boards . helpers ( {
2019-02-25 22:48:25 +01:00
copy ( ) {
const oldId = this . _id ;
2024-05-15 22:17:54 +02:00
const oldWatchers = this . watchers ? this . watchers . slice ( ) : [ ] ;
2019-02-25 22:48:25 +01:00
delete this . _id ;
2021-01-22 12:49:48 +02:00
delete this . slug ;
2021-01-28 18:21:56 +02:00
this . title = this . copyTitle ( ) ;
2019-02-25 22:48:25 +01:00
const _id = Boards . insert ( this ) ;
2024-05-15 22:17:54 +02:00
// Temporary remove watchers to disable notifications
Boards . update ( _id , {
$set : {
watchers : [ ]
} ,
} ) ;
2019-02-25 22:48:25 +01:00
// Copy all swimlanes in board
2023-02-22 22:21:42 +01:00
ReactiveCache . getSwimlanes ( {
2019-02-25 22:48:25 +01:00
boardId : oldId ,
archived : false ,
2019-06-28 12:52:09 -05:00
} ) . forEach ( swimlane => {
2019-02-25 22:48:25 +01:00
swimlane . type = 'swimlane' ;
2019-02-27 21:32:28 +01:00
swimlane . copy ( _id ) ;
2019-02-25 22:48:25 +01:00
} ) ;
2021-01-20 18:04:55 +02:00
// copy custom field definitions
const cfMap = { } ;
2023-02-22 23:02:31 +01:00
ReactiveCache . getCustomFields ( { boardIds : oldId } ) . forEach ( cf => {
2021-01-20 18:04:55 +02:00
const id = cf . _id ;
delete cf . _id ;
cf . boardIds = [ _id ] ;
cfMap [ id ] = CustomFields . insert ( cf ) ;
} ) ;
2023-02-14 18:52:36 +01:00
ReactiveCache . getCards ( { boardId : _id } ) . forEach ( card => {
2021-01-20 18:04:55 +02:00
Cards . update ( card . _id , {
$set : {
customFields : card . customFields . map ( cf => {
cf . _id = cfMap [ cf . _id ] ;
return cf ;
} ) ,
} ,
} ) ;
} ) ;
2021-01-22 01:26:08 +02:00
// copy rules, actions, and triggers
const actionsMap = { } ;
2023-02-25 19:45:15 +01:00
ReactiveCache . getActions ( { boardId : oldId } ) . forEach ( action => {
2021-01-22 01:26:08 +02:00
const id = action . _id ;
delete action . _id ;
action . boardId = _id ;
actionsMap [ id ] = Actions . insert ( action ) ;
} ) ;
const triggersMap = { } ;
2023-02-25 19:57:54 +01:00
ReactiveCache . getTriggers ( { boardId : oldId } ) . forEach ( trigger => {
2021-01-22 01:26:08 +02:00
const id = trigger . _id ;
delete trigger . _id ;
trigger . boardId = _id ;
triggersMap [ id ] = Triggers . insert ( trigger ) ;
} ) ;
2023-02-25 19:42:28 +01:00
ReactiveCache . getRules ( { boardId : oldId } ) . forEach ( rule => {
2021-01-22 01:26:08 +02:00
delete rule . _id ;
rule . boardId = _id ;
rule . actionId = actionsMap [ rule . actionId ] ;
rule . triggerId = triggersMap [ rule . triggerId ] ;
Rules . insert ( rule ) ;
} ) ;
2024-05-15 22:17:54 +02:00
// Re-set Watchers to reenable notification
Boards . update ( _id , {
$set : { watchers : oldWatchers }
} ) ;
2021-12-26 15:24:16 +02:00
return _id ;
2019-02-25 22:48:25 +01:00
} ,
2021-01-22 14:24:39 +02:00
/ * *
* Return a unique title based on the current title
*
* @ returns { string | null }
* /
copyTitle ( ) {
2021-01-28 18:21:56 +02:00
return Boards . uniqueTitle ( this . title ) ;
2019-02-25 22:48:25 +01:00
} ,
2021-01-22 14:24:39 +02:00
2015-12-13 20:02:34 +01:00
/ * *
2015-12-16 21:54:35 +01:00
* Is supplied user authorized to view this board ?
2015-12-13 20:02:34 +01:00
* /
2015-12-16 21:54:35 +01:00
isVisibleBy ( user ) {
2017-04-27 20:49:24 +03:00
if ( this . isPublic ( ) ) {
2015-12-13 20:02:34 +01:00
// public boards are visible to everyone
return true ;
} else {
// otherwise you have to be logged-in and active member
2015-12-17 23:57:28 +01:00
return user && this . isActiveMember ( user . _id ) ;
2015-12-13 20:02:34 +01:00
}
} ,
/ * *
* Is the user one of the active members of the board ?
*
* @ param userId
* @ returns { boolean } the member that matches , or undefined / false
* /
isActiveMember ( userId ) {
2017-04-27 20:49:24 +03:00
if ( userId ) {
2019-06-26 17:47:27 -05:00
return this . members . find (
2019-06-28 12:52:09 -05:00
member => member . userId === userId && member . isActive ,
2019-06-26 17:47:27 -05:00
) ;
2015-12-13 20:02:34 +01:00
} else {
return false ;
}
} ,
2015-09-08 20:19:42 +02:00
isPublic ( ) {
return this . permission === 'public' ;
} ,
2025-10-20 00:22:26 +03:00
hasSharedListsConverted ( ) {
return this . hasSharedListsConverted === true ;
2025-10-19 23:40:02 +03:00
} ,
2025-10-20 00:22:26 +03:00
2018-03-20 00:13:42 -03:00
cards ( ) {
2023-02-14 18:52:36 +01:00
const ret = ReactiveCache . getCards (
2019-06-26 17:47:27 -05:00
{ boardId : this . _id , archived : false } ,
2019-06-28 12:52:09 -05:00
{ sort : { title : 1 } } ,
2019-06-26 17:47:27 -05:00
) ;
2023-02-14 18:52:36 +01:00
return ret ;
2018-03-20 00:13:42 -03:00
} ,
2015-09-08 20:19:42 +02:00
lists ( ) {
New feature: Now there is popup selection of Lists/Swimlanes/Calendar/Roles.
New feature, not set visible yet, because switching to it does not
work properly yet: Collapsible Swimlanes #2804
Fix: Public board now loads correctly. When you select one of Lists/Swimlanes/Calendar view and
reload webbrowser page, it can change view. Closes #2311
Fix: List sorting commented out. Closes #2800
Fix: Errors hasHiddenMinicardText, hasShowDragHandles, showSort, hasSortBy, profile,
FirefoxAndroid/IE11/Vivaldi/Chromium browsers not working by using
cookies instead of database.
More details at https://github.com/wekan/wekan/issues/2643#issuecomment-554907955
Note: Cookie changes are not always immediate, if there is no effect,
you may need to reload webbrowser page.
Closes #2643 .
Thanks to xet7 !
2019-11-18 22:23:49 +02:00
return this . draggableLists ( ) ;
2019-10-29 19:05:44 +02:00
} ,
newestLists ( ) {
// sorted lists from newest to the oldest, by its creation date or its cards' last modification date
2023-01-16 23:00:10 +01:00
const value = ReactiveCache . getCurrentUser ( ) . _getListSortBy ( ) ;
2019-10-29 19:05:44 +02:00
const sortKey = { starred : - 1 , [ value [ 0 ] ] : value [ 1 ] } ; // [["starred",-1],value];
2023-02-19 17:43:22 +01:00
return ReactiveCache . getLists (
2019-10-29 19:05:44 +02:00
{
boardId : this . _id ,
archived : false ,
} ,
{ sort : sortKey } ,
) ;
} ,
2021-11-15 17:31:42 +01:00
2019-10-29 19:05:44 +02:00
draggableLists ( ) {
2025-10-10 21:14:44 +03:00
return ReactiveCache . getLists (
{
boardId : this . _id ,
} ,
{ sort : { sort : 1 } }
) ;
2015-09-08 20:19:42 +02:00
} ,
2021-11-15 17:31:42 +01:00
/ * * r e t u r n s t h e l a s t l i s t
* @ returns Document the last list
* /
getLastList ( ) {
2023-02-04 17:06:40 +01:00
const ret = ReactiveCache . getList ( { boardId : this . _id } , { sort : { sort : 'desc' } } ) ;
2021-11-15 17:31:42 +01:00
return ret ;
} ,
2019-01-25 10:47:36 +01:00
nullSortLists ( ) {
2023-02-19 17:43:22 +01:00
return ReactiveCache . getLists ( {
2019-01-25 10:47:36 +01:00
boardId : this . _id ,
archived : false ,
sort : { $eq : null } ,
} ) ;
} ,
2018-01-19 12:22:03 -03:00
swimlanes ( ) {
2023-02-22 22:21:42 +01:00
return ReactiveCache . getSwimlanes (
2019-06-26 17:47:27 -05:00
{ boardId : this . _id , archived : false } ,
2019-06-28 12:52:09 -05:00
{ sort : { sort : 1 } } ,
2019-06-26 17:47:27 -05:00
) ;
2018-01-19 12:22:03 -03:00
} ,
2019-01-24 20:45:52 +01:00
nextSwimlane ( swimlane ) {
2023-02-04 12:32:18 +01:00
return ReactiveCache . getSwimlane (
2019-06-26 17:47:27 -05:00
{
boardId : this . _id ,
archived : false ,
sort : { $gte : swimlane . sort } ,
_id : { $ne : swimlane . _id } ,
} ,
{
sort : { sort : 1 } ,
2019-06-28 12:52:09 -05:00
} ,
2019-06-26 17:47:27 -05:00
) ;
2019-01-24 20:45:52 +01:00
} ,
2019-01-25 10:47:36 +01:00
nullSortSwimlanes ( ) {
2023-02-22 22:21:42 +01:00
return ReactiveCache . getSwimlanes ( {
2019-01-25 10:47:36 +01:00
boardId : this . _id ,
archived : false ,
sort : { $eq : null } ,
} ) ;
} ,
2019-06-26 17:47:27 -05:00
hasOvertimeCards ( ) {
2023-02-04 12:38:37 +01:00
const card = ReactiveCache . getCard ( {
2019-06-26 17:47:27 -05:00
isOvertime : true ,
boardId : this . _id ,
archived : false ,
} ) ;
2017-11-20 23:24:27 +07:00
return card !== undefined ;
} ,
2019-06-26 17:47:27 -05:00
hasSpentTimeCards ( ) {
2023-02-04 12:38:37 +01:00
const card = ReactiveCache . getCard ( {
2019-06-26 17:47:27 -05:00
spentTime : { $gt : 0 } ,
boardId : this . _id ,
archived : false ,
} ) ;
2017-11-20 23:24:27 +07:00
return card !== undefined ;
} ,
2015-09-08 20:19:42 +02:00
activities ( ) {
2022-03-05 22:03:41 +01:00
let linkedBoardId = [ this . _id ] ;
2023-02-14 18:52:36 +01:00
ReactiveCache . getCards ( {
2022-03-05 22:03:41 +01:00
"type" : "cardType-linkedBoard" ,
"boardId" : this . _id }
) . forEach ( card => {
linkedBoardId . push ( card . linkedId ) ;
} ) ;
2023-02-25 20:06:05 +01:00
const ret = ReactiveCache . getActivities ( { boardId : { $in : linkedBoardId } } , { sort : { createdAt : - 1 } } ) ;
return ret ;
2015-09-08 20:19:42 +02:00
} ,
2021-09-09 16:51:37 +02:00
activeMembers ( ) {
2026-01-20 02:28:32 +02:00
// Depend on the users collection for reactivity when users are loaded
const memberUserIds = _ . pluck ( this . members , 'userId' ) ;
const dummy = Meteor . users . find ( { _id : { $in : memberUserIds } } ) . count ( ) ;
const members = _ . filter ( this . members , m => m . isActive === true ) ;
// Group by userId to handle duplicates
const grouped = _ . groupBy ( members , 'userId' ) ;
const uniqueMembers = _ . values ( grouped ) . map ( group => {
// Prefer admin member if exists, otherwise take the first
const selected = _ . find ( group , m => m . isAdmin ) || group [ 0 ] ;
return selected ;
} ) ;
// Filter out members where user is not loaded
const filteredMembers = uniqueMembers . filter ( member => {
const user = ReactiveCache . getUser ( member . userId ) ;
return user !== undefined ;
} ) ;
// Sort by role priority first (admin, normal, normal-assigned, no-comments, comment-only, comment-assigned, worker, read-only, read-assigned), then by fullname
return _ . sortBy ( filteredMembers , member => {
const user = ReactiveCache . getUser ( member . userId ) ;
let rolePriority = 8 ; // Default for normal
if ( member . isAdmin ) rolePriority = 0 ;
else if ( member . isReadAssignedOnly ) rolePriority = 8 ;
else if ( member . isReadOnly ) rolePriority = 7 ;
else if ( member . isWorker ) rolePriority = 6 ;
else if ( member . isCommentAssignedOnly ) rolePriority = 5 ;
else if ( member . isCommentOnly ) rolePriority = 4 ;
else if ( member . isNoComments ) rolePriority = 3 ;
else if ( member . isNormalAssignedOnly ) rolePriority = 2 ;
else rolePriority = 1 ; // Normal
const fullname = user ? user . profile . fullname : '' ;
return rolePriority + '-' + fullname ;
} ) ;
2015-09-08 20:19:42 +02:00
} ,
2021-07-05 11:27:38 +02:00
activeOrgs ( ) {
return _ . where ( this . orgs , { isActive : true } ) ;
} ,
// hasNotAnyOrg(){
// return this.orgs === undefined || this.orgs.length <= 0;
// },
2021-07-05 13:43:03 +03:00
activeTeams ( ) {
2021-07-05 11:27:38 +02:00
return _ . where ( this . teams , { isActive : true } ) ;
} ,
// hasNotAnyTeam(){
// return this.teams === undefined || this.teams.length <= 0;
// },
2015-12-07 11:15:57 +08:00
activeAdmins ( ) {
2017-04-27 20:49:24 +03:00
return _ . where ( this . members , { isActive : true , isAdmin : true } ) ;
2015-12-07 11:15:57 +08:00
} ,
memberUsers ( ) {
2023-02-22 22:53:48 +01:00
return ReactiveCache . getUsers ( { _id : { $in : _ . pluck ( this . members , 'userId' ) } } ) ;
2015-12-07 11:15:57 +08:00
} ,
2015-10-14 10:54:42 +02:00
getLabel ( name , color ) {
2015-10-14 23:40:00 +02:00
return _ . findWhere ( this . labels , { name , color } ) ;
2015-10-14 10:54:42 +02:00
} ,
2019-06-26 17:47:27 -05:00
getLabelById ( labelId ) {
2018-08-16 16:54:29 +02:00
return _ . findWhere ( this . labels , { _id : labelId } ) ;
} ,
2015-09-08 20:19:42 +02:00
labelIndex ( labelId ) {
2015-10-23 16:56:55 +02:00
return _ . pluck ( this . labels , '_id' ) . indexOf ( labelId ) ;
2015-09-08 20:19:42 +02:00
} ,
memberIndex ( memberId ) {
2015-10-23 16:56:55 +02:00
return _ . pluck ( this . members , 'userId' ) . indexOf ( memberId ) ;
2015-09-08 20:19:42 +02:00
} ,
2015-12-08 16:03:31 +08:00
hasMember ( memberId ) {
2017-04-27 20:49:24 +03:00
return ! ! _ . findWhere ( this . members , { userId : memberId , isActive : true } ) ;
2015-12-08 16:03:31 +08:00
} ,
hasAdmin ( memberId ) {
2019-06-26 17:47:27 -05:00
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : true ,
} ) ;
2015-12-08 16:03:31 +08:00
} ,
2018-09-04 20:09:36 +03:00
hasNoComments ( memberId ) {
2019-06-26 17:47:27 -05:00
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isNoComments : true ,
2020-01-05 21:28:14 +02:00
isWorker : false ,
2019-06-26 17:47:27 -05:00
} ) ;
2018-09-04 20:09:36 +03:00
} ,
2017-03-18 14:59:28 -04:00
hasCommentOnly ( memberId ) {
2019-06-26 17:47:27 -05:00
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isCommentOnly : true ,
2020-01-05 21:28:14 +02:00
isWorker : false ,
} ) ;
} ,
hasWorker ( memberId ) {
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isCommentOnly : false ,
isWorker : true ,
2019-06-26 17:47:27 -05:00
} ) ;
2017-03-18 14:59:28 -04:00
} ,
2025-12-22 21:45:09 +02:00
hasNormalAssignedOnly ( memberId ) {
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isNormalAssignedOnly : true ,
isCommentAssignedOnly : false ,
} ) ;
} ,
hasCommentAssignedOnly ( memberId ) {
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isNormalAssignedOnly : false ,
isCommentAssignedOnly : true ,
} ) ;
} ,
hasReadOnly ( memberId ) {
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isReadOnly : true ,
} ) ;
} ,
hasReadAssignedOnly ( memberId ) {
return ! ! _ . findWhere ( this . members , {
userId : memberId ,
isActive : true ,
isAdmin : false ,
isReadAssignedOnly : true ,
} ) ;
} ,
2021-10-21 00:14:17 +02:00
hasAnyAllowsDate ( ) {
const ret = this . allowsReceivedDate || this . allowsStartDate || this . allowsDueDate || this . allowsEndDate ;
return ret ;
} ,
hasAnyAllowsUser ( ) {
const ret = this . allowsCreator || this . allowsMembers || this . allowsAssignee || this . allowsRequestedBy || this . allowsAssignedBy ;
return ret ;
} ,
2015-09-08 20:19:42 +02:00
absoluteUrl ( ) {
2026-01-18 15:21:33 +02:00
return FlowRouter . url ( 'board' , { id : this . _id , slug : this . slug || 'board' } ) ;
2015-09-08 20:19:42 +02:00
} ,
2021-03-05 15:05:53 +03:00
originRelativeUrl ( ) {
2026-01-18 15:21:33 +02:00
return FlowRouter . path ( 'board' , { id : this . _id , slug : this . slug || 'board' } ) ;
2021-03-05 15:05:53 +03:00
} ,
2015-09-08 20:19:42 +02:00
colorClass ( ) {
return ` board-color- ${ this . color } ` ;
} ,
2015-10-19 20:14:29 +02:00
2017-08-27 22:31:24 +02:00
customFields ( ) {
2023-02-22 23:02:31 +01:00
const ret = ReactiveCache . getCustomFields (
2019-06-26 17:47:27 -05:00
{ boardIds : { $in : [ this . _id ] } } ,
2019-06-28 12:52:09 -05:00
{ sort : { name : 1 } } ,
2019-06-26 17:47:27 -05:00
) ;
2023-02-22 23:02:31 +01:00
return ret ;
2017-08-27 22:31:24 +02:00
} ,
2015-10-19 20:14:29 +02:00
// XXX currently mutations return no value so we have an issue when using addLabel in import
// XXX waiting on https://github.com/mquandalle/meteor-collection-mutations/issues/1 to remove...
pushLabel ( name , color ) {
const _id = Random . id ( 6 ) ;
2017-04-27 20:49:24 +03:00
Boards . direct . update ( this . _id , { $push : { labels : { _id , name , color } } } ) ;
2015-10-19 20:14:29 +02:00
return _id ;
} ,
2018-02-23 01:09:25 +01:00
2021-10-25 12:32:03 +02:00
/ * * s e t s t h e n e w l a b e l o r d e r
* @ param newLabelOrderOnlyIds new order array of _id , e . g . Array ( 4 ) [ "FvtD34" , "PAEgDP" , "LjRBxH" , "YJ8sZz" ]
* /
setNewLabelOrder ( newLabelOrderOnlyIds ) {
if ( this . labels . length == newLabelOrderOnlyIds . length ) {
if ( this . labels . every ( _label => newLabelOrderOnlyIds . indexOf ( _label . _id ) >= 0 ) ) {
const newLabels = _ . sortBy ( this . labels , _label => newLabelOrderOnlyIds . indexOf ( _label . _id ) ) ;
if ( this . labels . length == newLabels . length ) {
Boards . direct . update ( this . _id , { $set : { labels : newLabels } } ) ;
}
}
}
} ,
2019-02-25 22:48:25 +01:00
searchBoards ( term ) {
check ( term , Match . OneOf ( String , null , undefined ) ) ;
const query = { boardId : this . _id } ;
query . type = 'cardType-linkedBoard' ;
query . archived = false ;
const projection = { limit : 10 , sort : { createdAt : - 1 } } ;
if ( term ) {
const regex = new RegExp ( term , 'i' ) ;
2019-06-26 17:47:27 -05:00
query . $or = [ { title : regex } , { description : regex } ] ;
2019-02-25 22:48:25 +01:00
}
2023-02-14 18:52:36 +01:00
const ret = ReactiveCache . getCards ( query , projection ) ;
return ret ;
2019-02-25 22:48:25 +01:00
} ,
2019-02-23 23:07:54 +01:00
searchSwimlanes ( term ) {
check ( term , Match . OneOf ( String , null , undefined ) ) ;
const query = { boardId : this . _id } ;
if ( this . isTemplatesBoard ( ) ) {
query . type = 'template-swimlane' ;
query . archived = false ;
} else {
2019-06-26 17:47:27 -05:00
query . type = { $nin : [ 'template-swimlane' ] } ;
2019-02-23 23:07:54 +01:00
}
const projection = { limit : 10 , sort : { createdAt : - 1 } } ;
if ( term ) {
const regex = new RegExp ( term , 'i' ) ;
2019-06-26 17:47:27 -05:00
query . $or = [ { title : regex } , { description : regex } ] ;
2019-02-23 23:07:54 +01:00
}
2023-02-22 22:21:42 +01:00
return ReactiveCache . getSwimlanes ( query , projection ) ;
2019-02-23 23:07:54 +01:00
} ,
2019-02-23 20:41:36 +01:00
searchLists ( term ) {
2021-10-21 23:07:33 +02:00
let ret = null ;
if ( term ) {
check ( term , Match . OneOf ( String ) ) ;
term = term . trim ( ) ;
2019-02-23 20:41:36 +01:00
}
if ( term ) {
2021-10-21 23:07:33 +02:00
const query = { boardId : this . _id } ;
if ( this . isTemplatesBoard ( ) ) {
query . type = 'template-list' ;
query . archived = false ;
} else {
query . type = { $nin : [ 'template-list' ] } ;
}
const projection = { sort : { createdAt : - 1 } } ;
2019-02-23 20:41:36 +01:00
2021-10-21 23:07:33 +02:00
if ( term ) {
const regex = new RegExp ( term , 'i' ) ;
2019-02-23 20:41:36 +01:00
2021-10-21 23:07:33 +02:00
query . $or = [ { title : regex } , { description : regex } ] ;
}
2023-02-19 17:43:22 +01:00
ret = ReactiveCache . getLists ( query , projection ) ;
2021-10-21 23:07:33 +02:00
}
return ret ;
2019-02-23 20:41:36 +01:00
} ,
2018-05-02 14:20:55 -03:00
searchCards ( term , excludeLinked ) {
2021-10-21 23:07:33 +02:00
let ret = null ;
if ( term ) {
check ( term , Match . OneOf ( String ) ) ;
term = term . trim ( ) ;
2019-02-23 15:32:44 +01:00
}
2018-02-23 01:09:25 +01:00
if ( term ) {
2021-10-21 23:07:33 +02:00
const query = { boardId : this . _id } ;
if ( excludeLinked ) {
query . linkedId = null ;
}
if ( this . isTemplatesBoard ( ) ) {
query . type = 'template-card' ;
query . archived = false ;
} else {
query . type = { $nin : [ 'template-card' ] } ;
}
const projection = { sort : { createdAt : - 1 } } ;
2018-02-23 01:38:12 +01:00
const regex = new RegExp ( term , 'i' ) ;
2018-02-23 01:09:25 +01:00
2020-04-03 16:23:48 +01:00
query . $or = [
{ title : regex } ,
{ description : regex } ,
{ customFields : { $elemMatch : { value : regex } } } ,
] ;
2023-02-14 18:52:36 +01:00
ret = ReactiveCache . getCards ( query , projection ) ;
2018-02-23 01:09:25 +01:00
}
2021-10-21 23:07:33 +02:00
return ret ;
2018-02-23 01:09:25 +01:00
} ,
2018-06-23 23:22:38 +03:00
// A board alwasy has another board where it deposits subtasks of thasks
// that belong to itself.
getDefaultSubtasksBoardId ( ) {
2019-06-26 17:47:27 -05:00
if (
this . subtasksDefaultBoardId === null ||
this . subtasksDefaultBoardId === undefined
) {
2018-06-23 23:22:38 +03:00
this . subtasksDefaultBoardId = Boards . insert ( {
title : ` ^ ${ this . title } ^ ` ,
permission : this . permission ,
members : this . members ,
color : this . color ,
2025-10-13 20:34:23 +03:00
description : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default-subtasks-board' , {
2019-06-26 17:47:27 -05:00
board : this . title ,
2025-10-13 20:34:23 +03:00
} ) : ` Default subtasks board for ${ this . title } ` ,
2018-06-23 23:22:38 +03:00
} ) ;
Swimlanes . insert ( {
2025-10-13 20:34:23 +03:00
title : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default' ) : 'Default' ,
2018-06-23 23:22:38 +03:00
boardId : this . subtasksDefaultBoardId ,
} ) ;
2019-06-26 17:47:27 -05:00
Boards . update ( this . _id , {
$set : {
subtasksDefaultBoardId : this . subtasksDefaultBoardId ,
} ,
} ) ;
2018-06-23 23:22:38 +03:00
}
return this . subtasksDefaultBoardId ;
} ,
getDefaultSubtasksBoard ( ) {
2023-01-14 13:29:57 +01:00
return ReactiveCache . getBoard ( this . getDefaultSubtasksBoardId ( ) ) ;
2018-06-23 23:22:38 +03:00
} ,
2020-02-05 01:17:15 +02:00
//Date Settings option such as received date, start date and so on.
2020-02-04 02:28:45 -08:00
getDefaultDateSettingsBoardId ( ) {
if (
this . dateSettingsDefaultBoardId === null ||
this . dateSettingsDefaultBoardId === undefined
) {
this . dateSettingsDefaultBoardId = Boards . insert ( {
title : ` ^ ${ this . title } ^ ` ,
permission : this . permission ,
members : this . members ,
color : this . color ,
2025-10-13 20:34:23 +03:00
description : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default-dates-board' , {
2020-02-04 02:28:45 -08:00
board : this . title ,
2025-10-13 20:34:23 +03:00
} ) : ` Default dates board for ${ this . title } ` ,
2020-02-04 02:28:45 -08:00
} ) ;
Swimlanes . insert ( {
2025-10-13 20:34:23 +03:00
title : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default' ) : 'Default' ,
2020-02-04 02:28:45 -08:00
boardId : this . dateSettingsDefaultBoardId ,
} ) ;
Boards . update ( this . _id , {
$set : {
dateSettingsDefaultBoardId : this . dateSettingsDefaultBoardId ,
} ,
} ) ;
}
return this . dateSettingsDefaultBoardId ;
} ,
getDefaultDateSettingsBoard ( ) {
2023-01-14 13:29:57 +01:00
return ReactiveCache . getBoard ( this . getDefaultDateSettingsBoardId ( ) ) ;
2020-02-04 02:28:45 -08:00
} ,
2018-06-23 23:22:38 +03:00
getDefaultSubtasksListId ( ) {
2019-06-26 17:47:27 -05:00
if (
this . subtasksDefaultListId === null ||
this . subtasksDefaultListId === undefined
) {
2018-06-23 23:22:38 +03:00
this . subtasksDefaultListId = Lists . insert ( {
2025-10-13 20:34:23 +03:00
title : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'queue' ) : 'Queue' ,
2018-06-23 23:22:38 +03:00
boardId : this . _id ,
2025-10-10 21:14:44 +03:00
swimlaneId : this . getDefaultSwimline ( ) . _id , // Set default swimlane for subtasks list
2018-06-23 23:22:38 +03:00
} ) ;
2019-03-17 16:23:59 +01:00
this . setSubtasksDefaultListId ( this . subtasksDefaultListId ) ;
2018-06-23 23:22:38 +03:00
}
return this . subtasksDefaultListId ;
} ,
getDefaultSubtasksList ( ) {
2023-01-14 19:33:36 +01:00
return ReactiveCache . getList ( this . getDefaultSubtasksListId ( ) ) ;
2018-06-23 23:22:38 +03:00
} ,
2018-06-25 22:01:02 +03:00
2020-02-04 02:28:45 -08:00
getDefaultDateSettingsListId ( ) {
if (
this . dateSettingsDefaultListId === null ||
this . dateSettingsDefaultListId === undefined
) {
this . dateSettingsDefaultListId = Lists . insert ( {
2025-10-13 20:34:23 +03:00
title : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'queue' ) : 'Queue' ,
2020-02-04 02:28:45 -08:00
boardId : this . _id ,
2025-10-10 21:14:44 +03:00
swimlaneId : this . getDefaultSwimline ( ) . _id , // Set default swimlane for date settings list
2020-02-04 02:28:45 -08:00
} ) ;
this . setDateSettingsDefaultListId ( this . dateSettingsDefaultListId ) ;
}
return this . dateSettingsDefaultListId ;
} ,
getDefaultDateSettingsList ( ) {
2023-01-14 19:33:36 +01:00
return ReactiveCache . getList ( this . getDefaultDateSettingsListId ( ) ) ;
2020-02-04 02:28:45 -08:00
} ,
2018-06-25 22:01:02 +03:00
getDefaultSwimline ( ) {
2023-02-04 12:32:18 +01:00
let result = ReactiveCache . getSwimlane ( { boardId : this . _id } ) ;
2018-06-25 22:01:02 +03:00
if ( result === undefined ) {
2025-10-21 15:14:01 +03:00
// Check if any swimlane exists for this board to avoid duplicates
const existingSwimlanes = ReactiveCache . getSwimlanes ( { boardId : this . _id } ) ;
if ( existingSwimlanes . length > 0 ) {
// Use the first existing swimlane
result = existingSwimlanes [ 0 ] ;
} else {
// Use fallback title if i18n is not available (e.g., during migration)
const title = TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default' ) : 'Default' ;
Swimlanes . insert ( {
title : title ,
boardId : this . _id ,
} ) ;
result = ReactiveCache . getSwimlane ( { boardId : this . _id } ) ;
}
2018-06-25 22:01:02 +03:00
}
return result ;
} ,
2018-06-26 22:11:51 +03:00
2021-08-02 21:41:30 +02:00
getNextCardNumber ( ) {
2023-02-14 18:52:36 +01:00
const boardCards = ReactiveCache . getCard (
2021-08-03 14:02:22 +02:00
{
boardId : this . _id
} ,
{
sort : { cardNumber : - 1 } ,
limit : 1
}
2023-02-14 18:52:36 +01:00
, true ) ;
2021-08-03 14:02:22 +02:00
// If no card is assigned to the board, return 1
2023-02-14 18:52:36 +01:00
if ( ! boardCards ) {
2021-08-03 14:02:22 +02:00
return 1 ;
}
2023-02-14 18:52:36 +01:00
const maxCardNr = ! ! boardCards . cardNumber ? boardCards . cardNumber : 0 ;
2021-08-03 14:02:22 +02:00
return maxCardNr + 1 ;
2021-08-02 21:41:30 +02:00
} ,
2019-09-26 10:53:40 -04:00
cardsDueInBetween ( start , end ) {
2023-02-14 18:52:36 +01:00
const ret = ReactiveCache . getCards ( {
2019-09-26 10:53:40 -04:00
boardId : this . _id ,
dueAt : { $gte : start , $lte : end } ,
} ) ;
2023-02-14 18:52:36 +01:00
return ret ;
2019-09-26 10:53:40 -04:00
} ,
2018-06-26 22:11:51 +03:00
cardsInInterval ( start , end ) {
2023-02-14 18:52:36 +01:00
const ret = ReactiveCache . getCards ( {
2018-08-09 12:23:34 +03:00
boardId : this . _id ,
2018-06-26 22:11:51 +03:00
$or : [
{
startAt : {
$lte : start ,
2019-06-26 17:47:27 -05:00
} ,
endAt : {
2018-06-26 22:11:51 +03:00
$gte : start ,
} ,
2019-06-26 17:47:27 -05:00
} ,
{
2018-06-26 22:11:51 +03:00
startAt : {
$lte : end ,
2019-06-26 17:47:27 -05:00
} ,
endAt : {
2018-06-26 22:11:51 +03:00
$gte : end ,
} ,
2019-06-26 17:47:27 -05:00
} ,
{
2018-06-26 22:11:51 +03:00
startAt : {
$gte : start ,
2019-06-26 17:47:27 -05:00
} ,
endAt : {
2018-06-26 22:11:51 +03:00
$lte : end ,
} ,
} ,
] ,
} ) ;
2023-02-14 18:52:36 +01:00
return ret ;
2018-06-26 22:11:51 +03:00
} ,
2019-02-22 22:59:19 +01:00
isTemplateBoard ( ) {
return this . type === 'template-board' ;
} ,
2019-02-22 23:48:23 +01:00
isTemplatesBoard ( ) {
return this . type === 'template-container' ;
} ,
2015-09-08 20:19:42 +02:00
} ) ;
Boards . mutations ( {
archive ( ) {
2021-02-01 21:50:53 +01:00
return { $set : { archived : true , archivedAt : new Date ( ) } } ;
2015-09-08 20:19:42 +02:00
} ,
restore ( ) {
2017-04-27 20:49:24 +03:00
return { $set : { archived : false } } ;
2015-09-08 20:19:42 +02:00
} ,
rename ( title ) {
2017-04-27 20:49:24 +03:00
return { $set : { title } } ;
2015-09-08 20:19:42 +02:00
} ,
2017-02-01 20:01:38 +02:00
setDescription ( description ) {
2017-04-27 20:49:24 +03:00
return { $set : { description } } ;
2015-12-07 11:22:30 +08:00
} ,
2015-09-08 20:19:42 +02:00
setColor ( color ) {
2017-04-27 20:49:24 +03:00
return { $set : { color } } ;
2015-09-08 20:19:42 +02:00
} ,
2023-05-27 03:10:41 -04:00
setBackgroundImageURL ( backgroundImageURL ) {
2023-01-16 23:00:10 +01:00
const currentUser = ReactiveCache . getCurrentUser ( ) ;
if ( currentUser . isBoardAdmin ( ) ) {
2023-05-27 03:10:41 -04:00
return { $set : { backgroundImageURL } } ;
2023-01-16 23:00:10 +01:00
} else if ( currentUser . isAdmin ( ) ) {
2023-05-27 03:10:41 -04:00
return { $set : { backgroundImageURL } } ;
} else {
return false ;
}
} ,
2015-09-08 20:19:42 +02:00
setVisibility ( visibility ) {
2023-06-09 18:03:28 +03:00
return { $set : { permission : visibility } } ;
2015-09-08 20:19:42 +02:00
} ,
addLabel ( name , color ) {
2015-10-16 17:49:25 +02:00
// If label with the same name and color already exists we don't want to
// create another one because they would be indistinguishable in the UI
// (they would still have different `_id` but that is not exposed to the
// user).
if ( ! this . getLabel ( name , color ) ) {
const _id = Random . id ( 6 ) ;
2017-04-27 20:49:24 +03:00
return { $push : { labels : { _id , name , color } } } ;
2015-10-14 23:40:00 +02:00
}
2016-02-13 03:12:01 +01:00
return { } ;
2015-09-08 20:19:42 +02:00
} ,
editLabel ( labelId , name , color ) {
2015-10-16 17:49:25 +02:00
if ( ! this . getLabel ( name , color ) ) {
const labelIndex = this . labelIndex ( labelId ) ;
return {
$set : {
[ ` labels. ${ labelIndex } .name ` ] : name ,
[ ` labels. ${ labelIndex } .color ` ] : color ,
} ,
} ;
2015-10-14 23:40:00 +02:00
}
2016-02-13 03:12:01 +01:00
return { } ;
2015-09-08 20:19:42 +02:00
} ,
removeLabel ( labelId ) {
2017-04-27 20:49:24 +03:00
return { $pull : { labels : { _id : labelId } } } ;
2015-09-08 20:19:42 +02:00
} ,
2017-10-13 08:15:19 +02:00
changeOwnership ( fromId , toId ) {
const memberIndex = this . memberIndex ( fromId ) ;
return {
$set : {
[ ` members. ${ memberIndex } .userId ` ] : toId ,
} ,
} ;
} ,
2015-09-08 20:19:42 +02:00
addMember ( memberId ) {
const memberIndex = this . memberIndex ( memberId ) ;
2015-12-08 16:03:31 +08:00
if ( memberIndex >= 0 ) {
2015-09-08 20:19:42 +02:00
return {
$set : {
[ ` members. ${ memberIndex } .isActive ` ] : true ,
} ,
} ;
}
2015-12-08 16:03:31 +08:00
return {
$push : {
members : {
userId : memberId ,
isAdmin : false ,
isActive : true ,
2018-09-04 20:09:36 +03:00
isNoComments : false ,
2017-03-29 14:28:04 -04:00
isCommentOnly : false ,
2020-01-05 21:28:14 +02:00
isWorker : false ,
2025-12-22 21:45:09 +02:00
isNormalAssignedOnly : false ,
isCommentAssignedOnly : false ,
isReadOnly : false ,
isReadAssignedOnly : false ,
2015-12-08 16:03:31 +08:00
} ,
} ,
} ;
2015-09-08 20:19:42 +02:00
} ,
removeMember ( memberId ) {
const memberIndex = this . memberIndex ( memberId ) ;
2015-12-07 11:15:57 +08:00
// we do not allow the only one admin to be removed
2019-06-26 17:47:27 -05:00
const allowRemove =
! this . members [ memberIndex ] . isAdmin || this . activeAdmins ( ) . length > 1 ;
2015-12-08 16:03:31 +08:00
if ( ! allowRemove ) {
2015-12-07 11:15:57 +08:00
return {
$set : {
[ ` members. ${ memberIndex } .isActive ` ] : true ,
} ,
} ;
}
2015-12-08 16:03:31 +08:00
return {
$set : {
[ ` members. ${ memberIndex } .isActive ` ] : false ,
[ ` members. ${ memberIndex } .isAdmin ` ] : false ,
} ,
} ;
2015-09-08 20:19:42 +02:00
} ,
2019-06-26 17:47:27 -05:00
setMemberPermission (
memberId ,
isAdmin ,
isNoComments ,
isCommentOnly ,
2020-01-05 21:28:14 +02:00
isWorker ,
2025-12-22 21:45:09 +02:00
isNormalAssignedOnly = false ,
isCommentAssignedOnly = false ,
isReadOnly = false ,
isReadAssignedOnly = false ,
2019-06-28 12:52:09 -05:00
currentUserId = Meteor . userId ( ) ,
2019-06-26 17:47:27 -05:00
) {
2015-09-08 20:19:42 +02:00
const memberIndex = this . memberIndex ( memberId ) ;
2015-12-07 11:15:57 +08:00
// do not allow change permission of self
2018-09-30 02:37:16 +03:00
if ( memberId === currentUserId ) {
2015-12-07 11:15:57 +08:00
isAdmin = this . members [ memberIndex ] . isAdmin ;
}
2015-09-08 20:19:42 +02:00
return {
$set : {
[ ` members. ${ memberIndex } .isAdmin ` ] : isAdmin ,
2018-09-04 20:09:36 +03:00
[ ` members. ${ memberIndex } .isNoComments ` ] : isNoComments ,
2017-03-18 14:59:28 -04:00
[ ` members. ${ memberIndex } .isCommentOnly ` ] : isCommentOnly ,
2020-01-05 21:28:14 +02:00
[ ` members. ${ memberIndex } .isWorker ` ] : isWorker ,
2025-12-22 21:45:09 +02:00
[ ` members. ${ memberIndex } .isNormalAssignedOnly ` ] : isNormalAssignedOnly ,
[ ` members. ${ memberIndex } .isCommentAssignedOnly ` ] : isCommentAssignedOnly ,
[ ` members. ${ memberIndex } .isReadOnly ` ] : isReadOnly ,
[ ` members. ${ memberIndex } .isReadAssignedOnly ` ] : isReadAssignedOnly ,
2015-09-08 20:19:42 +02:00
} ,
} ;
} ,
2018-06-25 23:12:20 +03:00
setAllowsSubtasks ( allowsSubtasks ) {
return { $set : { allowsSubtasks } } ;
} ,
2021-04-01 23:40:07 +02:00
setAllowsCreator ( allowsCreator ) {
return { $set : { allowsCreator } } ;
} ,
2023-12-01 13:31:16 +02:00
setAllowsCreatorOnMinicard ( allowsCreatorOnMinicard ) {
return { $set : { allowsCreatorOnMinicard } } ;
} ,
2020-02-05 01:17:15 +02:00
setAllowsMembers ( allowsMembers ) {
return { $set : { allowsMembers } } ;
} ,
setAllowsChecklists ( allowsChecklists ) {
return { $set : { allowsChecklists } } ;
} ,
2020-02-07 02:34:57 +02:00
setAllowsAssignee ( allowsAssignee ) {
return { $set : { allowsAssignee } } ;
2020-02-05 01:17:15 +02:00
} ,
setAllowsAssignedBy ( allowsAssignedBy ) {
return { $set : { allowsAssignedBy } } ;
} ,
2025-10-11 11:31:57 +03:00
setAllowsShowListsOnMinicard ( allowsShowListsOnMinicard ) {
return { $set : { allowsShowListsOnMinicard } } ;
} ,
2025-12-29 21:42:19 +02:00
setAllowsChecklistAtMinicard ( allowsChecklistAtMinicard ) {
return { $set : { allowsChecklistAtMinicard } } ;
} ,
2020-02-05 01:17:15 +02:00
setAllowsRequestedBy ( allowsRequestedBy ) {
return { $set : { allowsRequestedBy } } ;
} ,
2021-04-12 23:34:02 +02:00
setAllowsCardSortingByNumber ( allowsCardSortingByNumber ) {
return { $set : { allowsCardSortingByNumber } } ;
2022-02-02 23:34:38 +01:00
} ,
setAllowsShowLists ( allowsShowLists ) {
return { $set : { allowsShowLists } } ;
2020-02-05 01:17:15 +02:00
} ,
2025-10-11 11:31:57 +03:00
2020-02-05 01:17:15 +02:00
setAllowsAttachments ( allowsAttachments ) {
return { $set : { allowsAttachments } } ;
} ,
setAllowsLabels ( allowsLabels ) {
return { $set : { allowsLabels } } ;
} ,
2020-02-07 02:34:57 +02:00
setAllowsComments ( allowsComments ) {
return { $set : { allowsComments } } ;
} ,
2020-02-12 02:08:29 +02:00
setAllowsDescriptionTitle ( allowsDescriptionTitle ) {
return { $set : { allowsDescriptionTitle } } ;
} ,
2021-08-02 21:41:30 +02:00
setAllowsCardNumber ( allowsCardNumber ) {
return { $set : { allowsCardNumber } } ;
} ,
2020-02-12 02:08:29 +02:00
setAllowsDescriptionText ( allowsDescriptionText ) {
return { $set : { allowsDescriptionText } } ;
} ,
2022-04-05 17:00:39 -03:00
setallowsDescriptionTextOnMinicard ( allowsDescriptionTextOnMinicard ) {
return { $set : { allowsDescriptionTextOnMinicard } } ;
} ,
2023-05-31 11:52:20 -03:00
setallowsCoverAttachmentOnMinicard ( allowsCoverAttachmentOnMinicard ) {
return { $set : { allowsCoverAttachmentOnMinicard } } ;
} ,
2023-05-31 14:49:02 -03:00
setallowsBadgeAttachmentOnMinicard ( allowsBadgeAttachmentOnMinicard ) {
return { $set : { allowsBadgeAttachmentOnMinicard } } ;
} ,
setallowsCardSortingByNumberOnMinicard ( allowsCardSortingByNumberOnMinicard ) {
return { $set : { allowsCardSortingByNumberOnMinicard } } ;
} ,
2020-02-07 13:58:43 +02:00
setAllowsActivities ( allowsActivities ) {
return { $set : { allowsActivities } } ;
} ,
2020-02-04 02:28:45 -08:00
setAllowsReceivedDate ( allowsReceivedDate ) {
return { $set : { allowsReceivedDate } } ;
} ,
2022-04-15 13:19:37 -03:00
setAllowsCardCounterList ( allowsCardCounterList ) {
return { $set : { allowsCardCounterList } } ;
} ,
setAllowsBoardMemberList ( allowsBoardMemberList ) {
return { $set : { allowsBoardMemberList } } ;
} ,
2020-02-04 02:28:45 -08:00
setAllowsStartDate ( allowsStartDate ) {
return { $set : { allowsStartDate } } ;
} ,
setAllowsEndDate ( allowsEndDate ) {
return { $set : { allowsEndDate } } ;
} ,
setAllowsDueDate ( allowsDueDate ) {
return { $set : { allowsDueDate } } ;
} ,
2018-06-25 23:12:20 +03:00
setSubtasksDefaultBoardId ( subtasksDefaultBoardId ) {
return { $set : { subtasksDefaultBoardId } } ;
} ,
setSubtasksDefaultListId ( subtasksDefaultListId ) {
return { $set : { subtasksDefaultListId } } ;
} ,
2018-06-26 02:13:31 +03:00
setPresentParentTask ( presentParentTask ) {
return { $set : { presentParentTask } } ;
} ,
2020-04-19 12:38:56 +03:00
move ( sortIndex ) {
return { $set : { sort : sortIndex } } ;
} ,
2023-03-17 21:26:40 +01:00
toggleShowActivities ( ) {
return { $set : { showActivities : ! this . showActivities } } ;
} ,
2015-09-08 20:19:42 +02:00
} ) ;
2019-04-23 18:00:09 +02:00
function boardRemover ( userId , doc ) {
2019-06-26 17:47:27 -05:00
[ Cards , Lists , Swimlanes , Integrations , Rules , Activities ] . forEach (
2019-06-28 12:52:09 -05:00
element => {
2019-06-26 17:47:27 -05:00
element . remove ( { boardId : doc . _id } ) ;
2019-06-28 12:52:09 -05:00
} ,
2019-06-26 17:47:27 -05:00
) ;
2019-04-23 18:00:09 +02:00
}
2021-01-28 18:21:56 +02:00
Boards . uniqueTitle = title => {
2021-01-29 13:15:53 +02:00
const m = title . match (
new RegExp ( '^(?<title>.*?)\\s*(\\[(?<num>\\d+)]\\s*$|\\s*$)' ) ,
) ;
2021-01-28 18:21:56 +02:00
const base = escapeForRegex ( m . groups . title ) ;
2022-03-08 22:25:07 +01:00
const baseTitle = m . groups . title ;
2023-02-25 20:19:18 +01:00
boards = ReactiveCache . getBoards ( { title : new RegExp ( ` ^ ${ base } \\ s*( \\ [(?<num> \\ d+)] \\ s* $ | \\ s* $ ) ` ) } ) ;
if ( boards . length > 0 ) {
2022-03-08 22:25:07 +01:00
let num = 0 ;
2023-02-25 20:19:18 +01:00
ReactiveCache . getBoards ( { title : new RegExp ( ` ^ ${ base } \\ s* \\ [ \\ d+] \\ s* $ ` ) } ) . forEach (
2022-03-08 22:25:07 +01:00
board => {
const m = board . title . match (
new RegExp ( '^(?<title>.*?)\\s*\\[(?<num>\\d+)]\\s*$' ) ,
) ;
if ( m ) {
const n = parseInt ( m . groups . num , 10 ) ;
num = num < n ? n : num ;
}
} ,
) ;
return ` ${ baseTitle } [ ${ num + 1 } ] ` ;
}
return title ;
2021-01-28 18:21:56 +02:00
} ;
2021-01-13 16:52:56 +02:00
Boards . userSearch = (
userId ,
selector = { } ,
projection = { } ,
2021-01-26 18:39:09 +02:00
// includeArchived = false,
2021-01-13 16:52:56 +02:00
) => {
2021-01-26 18:39:09 +02:00
// if (!includeArchived) {
// selector.archived = false;
// }
selector . $or = [ { permission : 'public' } ] ;
2021-01-13 01:14:49 +02:00
2021-01-26 18:39:09 +02:00
if ( userId ) {
selector . $or . push ( { members : { $elemMatch : { userId , isActive : true } } } ) ;
}
2023-02-25 20:19:18 +01:00
const ret = ReactiveCache . getBoards ( selector , projection ) ;
return ret ;
2021-01-13 01:14:49 +02:00
} ;
2021-04-17 10:27:16 +02:00
Boards . userBoards = (
userId ,
archived = false ,
selector = { } ,
projection = { } ,
) => {
2023-01-15 01:11:16 +01:00
const user = ReactiveCache . getUser ( userId ) ;
2021-12-21 02:39:16 +02:00
if ( ! user ) {
return [ ] ;
}
2021-01-26 18:39:09 +02:00
if ( typeof archived === 'boolean' ) {
selector . archived = archived ;
2021-01-11 18:18:26 +02:00
}
2021-04-02 02:15:12 +02:00
if ( ! selector . type ) {
selector . type = 'board' ;
}
2021-01-11 18:18:26 +02:00
2021-12-21 02:39:16 +02:00
selector . $or = [
{ permission : 'public' } ,
{ members : { $elemMatch : { userId , isActive : true } } } ,
2021-12-22 00:33:13 +02:00
{ orgs : { $elemMatch : { orgId : { $in : user . orgIds ( ) } , isActive : true } } } ,
{ teams : { $elemMatch : { teamId : { $in : user . teamIds ( ) } , isActive : true } } } ,
2021-12-21 02:39:16 +02:00
] ;
2023-02-25 20:19:18 +01:00
return ReactiveCache . getBoards ( selector , projection ) ;
2021-01-11 18:18:26 +02:00
} ;
2021-01-26 18:39:09 +02:00
Boards . userBoardIds = ( userId , archived = false , selector = { } ) => {
2021-04-17 10:27:16 +02:00
return Boards . userBoards ( userId , archived , selector , {
fields : { _id : 1 } ,
} ) . map ( board => {
2021-01-11 18:18:26 +02:00
return board . _id ;
} ) ;
} ;
2021-02-02 17:56:18 +02:00
Boards . colorMap = ( ) => {
const colors = { } ;
for ( const color of Boards . labelColors ( ) ) {
colors [ TAPi18n . _ _ ( ` color- ${ color } ` ) ] = color ;
}
return colors ;
} ;
Boards . labelColors = ( ) => {
2021-04-03 18:52:47 +02:00
return ALLOWED _COLORS ;
2021-02-02 17:56:18 +02:00
} ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
if ( Meteor . isServer ) {
Boards . allow ( {
2025-12-29 16:29:01 +02:00
insert ( userId , doc ) {
// Check if user is logged in
if ( ! userId ) return false ;
// If allowPrivateOnly is enabled, only allow private boards
const allowPrivateOnly = TableVisibilityModeSettings . findOne ( 'tableVisibilityMode-allowPrivateOnly' ) ? . booleanValue ;
if ( allowPrivateOnly && doc . permission === 'public' ) {
return false ;
}
return true ;
} ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
update : allowIsBoardAdmin ,
remove : allowIsBoardAdmin ,
2015-09-03 23:12:46 +02:00
fetch : [ 'members' ] ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ) ;
2020-07-10 18:56:26 +03:00
// All logged in users are allowed to reorder boards by dragging at All Boards page and Public Boards page.
Boards . allow ( {
update ( userId , board , fieldNames ) {
2025-11-02 10:13:45 +02:00
return canUpdateBoardSort ( userId , board , fieldNames ) ;
2020-07-10 18:56:26 +03:00
} ,
2025-11-02 10:13:45 +02:00
// Need members to verify membership in policy
fetch : [ 'members' ] ,
2020-07-10 18:56:26 +03:00
} ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// The number of users that have starred this board is managed by trusted code
// and the user is not allowed to update it
Boards . deny ( {
2015-09-03 23:12:46 +02:00
update ( userId , board , fieldNames ) {
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
return _ . contains ( fieldNames , 'stars' ) ;
} ,
2015-09-03 23:12:46 +02:00
fetch : [ ] ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ) ;
// We can't remove a member if it is the last administrator
Boards . deny ( {
2015-09-03 23:12:46 +02:00
update ( userId , doc , fieldNames , modifier ) {
2019-06-26 17:47:27 -05:00
if ( ! _ . contains ( fieldNames , 'members' ) ) return false ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// We only care in case of a $pull operation, ie remove a member
2019-06-26 17:47:27 -05:00
if ( ! _ . isObject ( modifier . $pull && modifier . $pull . members ) ) return false ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// If there is more than one admin, it's ok to remove anyone
2019-06-26 17:47:27 -05:00
const nbAdmins = _ . where ( doc . members , { isActive : true , isAdmin : true } )
. length ;
if ( nbAdmins > 1 ) return false ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
2015-07-13 23:47:21 -07:00
// If all the previous conditions were verified, we can't remove
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// a user if it's an admin
2015-09-03 23:12:46 +02:00
const removedMemberId = modifier . $pull . members . userId ;
2019-06-26 17:47:27 -05:00
return Boolean (
_ . findWhere ( doc . members , {
userId : removedMemberId ,
isAdmin : true ,
2019-06-28 12:52:09 -05:00
} ) ,
2019-06-26 17:47:27 -05:00
) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ,
2015-09-03 23:12:46 +02:00
fetch : [ 'members' ] ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ) ;
2015-12-07 11:15:57 +08:00
2025-12-29 16:29:01 +02:00
// Deny changing permission to public if allowPrivateOnly is enabled
Boards . deny ( {
update ( userId , doc , fieldNames , modifier ) {
if ( ! _ . contains ( fieldNames , 'permission' ) ) return false ;
const allowPrivateOnly = TableVisibilityModeSettings . findOne ( 'tableVisibilityMode-allowPrivateOnly' ) ? . booleanValue ;
if ( allowPrivateOnly && modifier . $set && modifier . $set . permission === 'public' ) {
return true ;
}
return false ;
} ,
fetch : [ ] ,
} ) ;
2015-12-07 11:15:57 +08:00
Meteor . methods ( {
2023-05-27 03:10:41 -04:00
getBackgroundImageURL ( boardId ) {
check ( boardId , String ) ;
2023-02-04 16:57:56 +01:00
return ReactiveCache . getBoard ( boardId , { } , { backgroundImageUrl : 1 } ) ;
2023-05-27 03:10:41 -04:00
} ,
2015-12-07 11:15:57 +08:00
quitBoard ( boardId ) {
check ( boardId , String ) ;
2023-01-14 13:29:57 +01:00
const board = ReactiveCache . getBoard ( boardId ) ;
2015-12-07 11:15:57 +08:00
if ( board ) {
const userId = Meteor . userId ( ) ;
const index = board . memberIndex ( userId ) ;
2017-04-27 20:49:24 +03:00
if ( index >= 0 ) {
2015-12-07 11:15:57 +08:00
board . removeMember ( userId ) ;
return true ;
} else throw new Meteor . Error ( 'error-board-notAMember' ) ;
} else throw new Meteor . Error ( 'error-board-doesNotExist' ) ;
} ,
2019-07-18 13:06:25 -05:00
acceptInvite ( boardId ) {
check ( boardId , String ) ;
2023-01-14 13:29:57 +01:00
const board = ReactiveCache . getBoard ( boardId ) ;
2019-07-18 13:06:25 -05:00
if ( ! board ) {
throw new Meteor . Error ( 'error-board-doesNotExist' ) ;
}
Meteor . users . update ( Meteor . userId ( ) , {
$pull : {
'profile.invitedBoards' : boardId ,
} ,
} ) ;
2026-01-20 02:28:32 +02:00
// Ensure the user is active on the board
Boards . update ( {
_id : boardId ,
'members.userId' : Meteor . userId ( )
} , {
$set : {
'members.$.isActive' : true ,
modifiedAt : new Date ( )
}
} ) ;
2019-07-18 13:06:25 -05:00
} ,
2021-01-21 01:48:24 +02:00
myLabelNames ( ) {
let names = [ ] ;
2021-04-02 02:15:12 +02:00
Boards . userBoards ( Meteor . userId ( ) ) . forEach ( board => {
2021-06-29 13:38:57 +03:00
// Only return labels when they exist.
if ( board . labels !== undefined ) {
names = names . concat (
board . labels
. filter ( label => ! ! label . name )
. map ( label => {
return label . name ;
} ) ,
) ;
} else {
return [ ] ;
}
2021-04-02 02:15:12 +02:00
} ) ;
2021-01-21 01:48:24 +02:00
return _ . uniq ( names ) . sort ( ) ;
} ,
myBoardNames ( ) {
return _ . uniq (
Boards . userBoards ( Meteor . userId ( ) ) . map ( board => {
return board . title ;
} ) ,
) . sort ( ) ;
} ,
2023-03-17 21:26:40 +01:00
setAllBoardsHideActivities ( ) {
2025-06-23 19:37:41 +00:00
if ( ( ReactiveCache . getCurrentUser ( ) || { } ) . isAdmin ) {
2023-03-17 21:26:40 +01:00
Boards . update (
{
showActivities : true
} ,
{
$set : {
showActivities : false ,
} ,
} ,
{
multi : true ,
} ,
) ;
return true ;
} else {
return false ;
}
} ,
2015-12-07 11:15:57 +08:00
} ) ;
2019-05-10 20:50:53 +03:00
Meteor . methods ( {
archiveBoard ( boardId ) {
check ( boardId , String ) ;
2023-01-14 13:29:57 +01:00
const board = ReactiveCache . getBoard ( boardId ) ;
2019-05-10 20:50:53 +03:00
if ( board ) {
const userId = Meteor . userId ( ) ;
const index = board . memberIndex ( userId ) ;
if ( index >= 0 ) {
board . archive ( ) ;
return true ;
} else throw new Meteor . Error ( 'error-board-notAMember' ) ;
} else throw new Meteor . Error ( 'error-board-doesNotExist' ) ;
} ,
2021-07-05 11:27:38 +02:00
setBoardOrgs ( boardOrgsArray , currBoardId ) {
check ( boardOrgsArray , Array ) ;
check ( currBoardId , String ) ;
2026-01-18 19:08:28 +02:00
const userId = Meteor . userId ( ) ;
if ( ! userId ) {
throw new Meteor . Error ( 'not-authorized' , 'You must be logged in to perform this action.' ) ;
}
const board = ReactiveCache . getBoard ( currBoardId ) ;
if ( ! board ) {
throw new Meteor . Error ( 'board-not-found' , 'Board not found.' ) ;
}
if ( ! allowIsBoardAdmin ( userId , board ) ) {
throw new Meteor . Error ( 'not-authorized' , 'You must be a board admin to perform this action.' ) ;
}
// Validate boardOrgsArray
for ( const org of boardOrgsArray ) {
check ( org . orgId , String ) ;
check ( org . orgDisplayName , String ) ;
check ( org . isActive , Boolean ) ;
}
2021-07-05 11:27:38 +02:00
Boards . update ( currBoardId , {
$set : {
orgs : boardOrgsArray ,
} ,
} ) ;
} ,
2021-09-09 16:51:37 +02:00
setBoardTeams ( boardTeamsArray , membersArray , currBoardId ) {
2021-07-05 11:27:38 +02:00
check ( boardTeamsArray , Array ) ;
2021-09-09 16:51:37 +02:00
check ( membersArray , Array ) ;
2021-07-05 11:27:38 +02:00
check ( currBoardId , String ) ;
2026-01-18 19:08:28 +02:00
const userId = Meteor . userId ( ) ;
if ( ! userId ) {
throw new Meteor . Error ( 'not-authorized' , 'You must be logged in to perform this action.' ) ;
}
const board = ReactiveCache . getBoard ( currBoardId ) ;
if ( ! board ) {
throw new Meteor . Error ( 'board-not-found' , 'Board not found.' ) ;
}
if ( ! allowIsBoardAdmin ( userId , board ) ) {
throw new Meteor . Error ( 'not-authorized' , 'You must be a board admin to perform this action.' ) ;
}
// Validate boardTeamsArray
for ( const team of boardTeamsArray ) {
check ( team . teamId , String ) ;
check ( team . teamDisplayName , String ) ;
check ( team . isActive , Boolean ) ;
}
// Validate membersArray
for ( const member of membersArray ) {
check ( member . userId , String ) ;
check ( member . isAdmin , Boolean ) ;
check ( member . isActive , Boolean ) ;
if ( member . isNoComments !== undefined ) check ( member . isNoComments , Boolean ) ;
if ( member . isCommentOnly !== undefined ) check ( member . isCommentOnly , Boolean ) ;
if ( member . isWorker !== undefined ) check ( member . isWorker , Boolean ) ;
if ( member . isNormalAssignedOnly !== undefined ) check ( member . isNormalAssignedOnly , Boolean ) ;
if ( member . isCommentAssignedOnly !== undefined ) check ( member . isCommentAssignedOnly , Boolean ) ;
if ( member . isReadOnly !== undefined ) check ( member . isReadOnly , Boolean ) ;
if ( member . isReadAssignedOnly !== undefined ) check ( member . isReadAssignedOnly , Boolean ) ;
}
2021-07-05 11:27:38 +02:00
Boards . update ( currBoardId , {
$set : {
2021-09-09 16:51:37 +02:00
members : membersArray ,
2021-07-05 11:27:38 +02:00
teams : boardTeamsArray ,
} ,
} ) ;
} ,
2019-05-10 20:50:53 +03:00
} ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
}
2020-04-19 15:53:13 +03:00
// Insert new board at last position in sort order.
Boards . before . insert ( ( userId , doc ) => {
2023-02-04 16:57:56 +01:00
const lastBoard = ReactiveCache . getBoard (
2020-04-22 21:00:31 +03:00
{ sort : { $exists : true } } ,
{ sort : { sort : - 1 } } ,
) ;
2020-04-19 15:53:13 +03:00
if ( lastBoard && typeof lastBoard . sort !== 'undefined' ) {
doc . sort = lastBoard . sort + 1 ;
}
} ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
if ( Meteor . isServer ) {
// Let MongoDB ensure that a member is not included twice in the same board
2015-09-03 23:12:46 +02:00
Meteor . startup ( ( ) => {
2021-10-09 15:56:16 +03:00
Boards . _collection . createIndex ( { modifiedAt : - 1 } ) ;
Boards . _collection . createIndex (
2019-06-26 17:47:27 -05:00
{
_id : 1 ,
'members.userId' : 1 ,
} ,
2019-06-28 12:52:09 -05:00
{ unique : true } ,
2019-06-26 17:47:27 -05:00
) ;
2021-10-09 15:56:16 +03:00
Boards . _collection . createIndex ( { 'members.userId' : 1 } ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ) ;
// Genesis: the first activity of the newly created board
2015-09-03 23:12:46 +02:00
Boards . after . insert ( ( userId , doc ) => {
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
Activities . insert ( {
2015-09-03 23:12:46 +02:00
userId ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
type : 'board' ,
activityTypeId : doc . _id ,
activityType : 'createBoard' ,
boardId : doc . _id ,
} ) ;
} ) ;
2015-10-14 23:40:00 +02:00
// If the user remove one label from a board, we cant to remove reference of
// this label in any card of this board.
2015-09-03 23:12:46 +02:00
Boards . after . update ( ( userId , doc , fieldNames , modifier ) => {
2019-06-26 17:47:27 -05:00
if (
! _ . contains ( fieldNames , 'labels' ) ||
2015-09-03 23:12:46 +02:00
! modifier . $pull ||
! modifier . $pull . labels ||
2019-06-26 17:47:27 -05:00
! modifier . $pull . labels . _id
) {
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
return ;
2016-02-13 03:12:01 +01:00
}
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
2015-09-03 23:12:46 +02:00
const removedLabelId = modifier . $pull . labels . _id ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
Cards . update (
{ boardId : doc . _id } ,
{
$pull : {
2015-10-20 19:06:20 +02:00
labelIds : removedLabelId ,
2015-09-03 23:12:46 +02:00
} ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ,
2019-06-28 12:52:09 -05:00
{ multi : true } ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
) ;
} ) ;
2016-08-16 19:00:04 +02:00
const foreachRemovedMember = ( doc , modifier , callback ) => {
2019-06-28 12:52:09 -05:00
Object . keys ( modifier ) . forEach ( set => {
2016-08-16 19:00:04 +02:00
if ( modifier [ set ] !== false ) {
return ;
}
const parts = set . split ( '.' ) ;
2019-06-26 17:47:27 -05:00
if (
parts . length === 3 &&
parts [ 0 ] === 'members' &&
parts [ 2 ] === 'isActive'
) {
2016-08-16 19:00:04 +02:00
callback ( doc . members [ parts [ 1 ] ] . userId ) ;
}
} ) ;
} ;
2016-08-16 17:29:01 +02:00
// Remove a member from all objects of the board before leaving the board
Boards . before . update ( ( userId , doc , fieldNames , modifier ) => {
if ( ! _ . contains ( fieldNames , 'members' ) ) {
return ;
}
if ( modifier . $set ) {
const boardId = doc . _id ;
2019-06-28 12:52:09 -05:00
foreachRemovedMember ( doc , modifier . $set , memberId => {
2016-08-16 17:29:01 +02:00
Cards . update (
{ boardId } ,
{
$pull : {
members : memberId ,
watchers : memberId ,
} ,
} ,
2019-06-28 12:52:09 -05:00
{ multi : true } ,
2016-08-16 17:29:01 +02:00
) ;
Lists . update (
{ boardId } ,
{
$pull : {
watchers : memberId ,
} ,
} ,
2019-06-28 12:52:09 -05:00
{ multi : true } ,
2016-08-16 17:29:01 +02:00
) ;
const board = Boards . _transform ( doc ) ;
board . setWatcher ( memberId , false ) ;
2016-08-16 17:45:53 +02:00
// Remove board from users starred list
if ( ! board . isPublic ( ) ) {
2019-06-26 17:47:27 -05:00
Users . update ( memberId , {
$pull : {
'profile.starredBoards' : boardId ,
} ,
} ) ;
2016-08-16 17:45:53 +02:00
}
2016-08-16 17:29:01 +02:00
} ) ;
}
} ) ;
2019-04-23 18:00:09 +02:00
Boards . before . remove ( ( userId , doc ) => {
boardRemover ( userId , doc ) ;
// Add removeBoard activity to keep it
Activities . insert ( {
userId ,
type : 'board' ,
activityTypeId : doc . _id ,
activityType : 'removeBoard' ,
boardId : doc . _id ,
} ) ;
} ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// Add a new activity if we add or remove a member to the board
2015-09-03 23:12:46 +02:00
Boards . after . update ( ( userId , doc , fieldNames , modifier ) => {
2023-11-14 09:49:10 +01:00
if ( fieldNames . includes ( 'title' ) ) {
Activities . insert ( {
userId ,
type : 'board' ,
activityType : 'changedBoardTitle' ,
boardId : doc . _id ,
// this preserves the name so that the activity can be useful after the
// list is deleted
title : doc . title ,
} ) ;
}
2016-02-13 03:12:01 +01:00
if ( ! _ . contains ( fieldNames , 'members' ) ) {
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
return ;
2016-02-13 03:12:01 +01:00
}
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
// Say hello to the new member
if ( modifier . $push && modifier . $push . members ) {
2016-08-16 19:00:04 +02:00
const memberId = modifier . $push . members . userId ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
Activities . insert ( {
2015-09-03 23:12:46 +02:00
userId ,
memberId ,
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
type : 'member' ,
activityType : 'addBoardMember' ,
boardId : doc . _id ,
} ) ;
}
// Say goodbye to the former member
2016-08-16 19:00:04 +02:00
if ( modifier . $set ) {
2019-06-28 12:52:09 -05:00
foreachRemovedMember ( doc , modifier . $set , memberId => {
2016-08-16 19:00:04 +02:00
Activities . insert ( {
userId ,
memberId ,
type : 'member' ,
activityType : 'removeBoardMember' ,
boardId : doc . _id ,
} ) ;
Renaissance
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(@@>Z| |ZZZ<'(@@>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
II888888888888PZ;;';;. ;. .;. .;. .. Y8888888I88888888888b,
,II888888888PZ;;' `8888888I8888888888888b,
II888888888' 888888I8888888888888888
,II888888888 ,888888I8888888888888888
,d88888888888 d888888I8888888888ZZZZZZ
,ad888888888888I 8888888I8888ZZZZZZZZZZZZ
888888888888888' 888888IZZZZZZZZZZZZZZZZZ
8888888888P'8P' Y888ZZZZZZZZZZZZZZZZZZZZ
888888888, " ,ZZZZZZZZZZZZZZZZZZZZZZZ
8888888888, ,ZZZZZZZZZZZZZZZZZZZZZZZZZZ
888888888888a, _ ,ZZZZZZZZZZZZZZZZZZZZ88888888
888888888888888ba,_d' ,ZZZZZZZZZZZZZZZZZ8888888888888
8888888888888888888888bbbaaa,,,______,ZZZZZZZZZZZZZZZ88888888888888888
88888888888888888888888888888888888ZZZZZZZZZZZZZZZ88888888888888888888
8888888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888
888888888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888888888
8888888888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888
88888888888888888888888888888ZZZZZZZZZZZZZZ888888888888888888888888888
8888888888888888888888888888ZZZZZZZZZZZZZZ88888888888888888 Normand 8
88888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888 Veilleux 8
8888888888888888888888888ZZZZZZZZZZZZZZ8888888888888888888888888888888
2015-05-12 19:20:58 +02:00
} ) ;
}
} ) ;
}
2017-04-27 20:49:24 +03:00
//BOARDS REST API
if ( Meteor . isServer ) {
2018-10-26 07:27:24 +02:00
/ * *
* @ operation get _boards _from _user
* @ summary Get all boards attached to a user
*
* @ param { string } userId the ID of the user to retrieve the data
* @ return _type [ { _id : string ,
2025-06-23 19:37:41 +00:00
* title : string } ]
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'GET' , '/api/users/:userId/boards' , function ( req , res ) {
2017-10-15 07:39:48 +02:00
try {
Authentication . checkLoggedIn ( req . userId ) ;
const paramUserId = req . params . userId ;
// A normal user should be able to see their own boards,
// admins can access boards of any user
2019-06-26 17:47:27 -05:00
Authentication . checkAdminOrCondition (
req . userId ,
2019-06-28 12:52:09 -05:00
req . userId === paramUserId ,
2019-06-26 17:47:27 -05:00
) ;
2017-10-15 07:39:48 +02:00
2023-02-25 20:19:18 +01:00
const data = ReactiveCache . getBoards (
2019-06-26 17:47:27 -05:00
{
archived : false ,
'members.userId' : paramUserId ,
} ,
{
2020-04-19 12:30:21 +03:00
sort : { sort : 1 /* boards default sorting */ } ,
2019-06-28 12:52:09 -05:00
} ,
2019-06-26 17:47:27 -05:00
) . map ( function ( board ) {
2017-10-15 07:39:48 +02:00
return {
_id : board . _id ,
title : board . title ,
} ;
} ) ;
2017-05-15 18:20:51 +02:00
2019-06-26 17:47:27 -05:00
JsonRoutes . sendResult ( res , { code : 200 , data } ) ;
} catch ( error ) {
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
2017-05-13 22:56:26 +02:00
} ) ;
2017-05-15 18:20:51 +02:00
2018-10-26 07:27:24 +02:00
/ * *
* @ operation get _public _boards
* @ summary Get all public boards
*
* @ return _type [ { _id : string ,
title : string } ]
2019-02-24 00:13:35 +01:00
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'GET' , '/api/boards' , function ( req , res ) {
2017-10-15 07:39:48 +02:00
try {
2021-09-25 18:09:18 +03:00
Authentication . checkUserId ( req . userId ) ;
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
2023-02-25 20:19:18 +01:00
data : ReactiveCache . getBoards (
2020-04-19 12:30:21 +03:00
{ permission : 'public' } ,
{
sort : { sort : 1 /* boards default sorting */ } ,
} ,
) . map ( function ( doc ) {
2017-10-15 07:39:48 +02:00
return {
_id : doc . _id ,
title : doc . title ,
} ;
} ) ,
} ) ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
2017-04-27 20:49:24 +03:00
} ) ;
2021-02-11 00:48:25 +01:00
/ * *
* @ operation get _boards _count
* @ summary Get public and private boards count
*
* @ return _type { private : integer , public : integer }
* /
JsonRoutes . add ( 'GET' , '/api/boards_count' , function ( req , res ) {
try {
Authentication . checkUserId ( req . userId ) ;
JsonRoutes . sendResult ( res , {
code : 200 ,
data : {
2023-02-25 20:19:18 +01:00
private : ReactiveCache . getBoards ( { permission : 'private' } ) . length ,
public : ReactiveCache . getBoards ( { permission : 'public' } ) . length ,
2021-02-11 00:48:25 +01:00
} ,
} ) ;
} catch ( error ) {
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
} ) ;
2018-10-26 07:27:24 +02:00
/ * *
* @ operation get _board
* @ summary Get the board with that particular ID
*
* @ param { string } boardId the ID of the board to retrieve the data
* @ return _type Boards
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'GET' , '/api/boards/:boardId' , function ( req , res ) {
2017-10-15 07:39:48 +02:00
try {
2023-01-13 21:50:39 +02:00
const paramBoardId = req . params . boardId ;
Authentication . checkBoardAccess ( req . userId , paramBoardId ) ;
2017-05-15 19:43:53 +02:00
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
2023-02-04 16:57:56 +01:00
data : ReactiveCache . getBoard ( paramBoardId ) ,
2017-10-15 07:39:48 +02:00
} ) ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
2017-04-27 20:49:24 +03:00
} ) ;
2018-10-26 07:27:24 +02:00
/ * *
* @ operation new _board
* @ summary Create a board
*
* @ description This allows to create a board .
*
* The color has to be chosen between ` belize ` , ` nephritis ` , ` pomegranate ` ,
2019-07-01 17:23:41 -04:00
* ` pumpkin ` , ` wisteria ` , ` moderatepink ` , ` strongcyan ` ,
2019-07-06 04:59:17 -04:00
* ` limegreen ` , ` midnight ` , ` dark ` , ` relax ` , ` corteza ` :
2018-10-26 07:27:24 +02:00
*
* < img src = "https://wekan.github.io/board-colors.png" width = "40%" alt = "Wekan logo" / >
*
* @ param { string } title the new title of the board
* @ param { string } owner "ABCDE12345" <= User ID in Wekan .
* ( Not username or email )
* @ param { boolean } [ isAdmin ] is the owner an admin of the board ( default true )
* @ param { boolean } [ isActive ] is the board active ( default true )
* @ param { boolean } [ isNoComments ] disable comments ( default false )
* @ param { boolean } [ isCommentOnly ] only enable comments ( default false )
2020-01-05 21:28:14 +02:00
* @ param { boolean } [ isWorker ] only move cards , assign himself to card and comment ( default false )
2018-10-26 07:27:24 +02:00
* @ param { string } [ permission ] "private" board <= = Set to "public" if you
* want public Wekan board
* @ param { string } [ color ] the color of the board
*
* @ return _type { _id : string ,
defaultSwimlaneId : string }
2019-02-24 00:13:35 +01:00
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'POST' , '/api/boards' , function ( req , res ) {
2017-10-15 07:39:48 +02:00
try {
2023-01-13 22:14:39 +02:00
Authentication . checkLoggedIn ( req . userId ) ;
2025-12-29 16:29:01 +02:00
const allowPrivateOnly = TableVisibilityModeSettings . findOne ( 'tableVisibilityMode-allowPrivateOnly' ) ? . booleanValue ;
const permission = allowPrivateOnly ? 'private' : ( req . body . permission || 'private' ) ;
2017-10-15 07:39:48 +02:00
const id = Boards . insert ( {
title : req . body . title ,
members : [
{
userId : req . body . owner ,
2018-09-06 11:56:38 +03:00
isAdmin : req . body . isAdmin || true ,
isActive : req . body . isActive || true ,
isNoComments : req . body . isNoComments || false ,
isCommentOnly : req . body . isCommentOnly || false ,
2020-01-05 21:28:14 +02:00
isWorker : req . body . isWorker || false ,
2017-10-15 07:39:48 +02:00
} ,
] ,
2025-12-29 16:29:01 +02:00
permission ,
2018-09-06 11:56:38 +03:00
color : req . body . color || 'belize' ,
2025-10-12 03:48:21 +03:00
migrationVersion : 1 , // Latest version - no migration needed
2017-10-15 07:39:48 +02:00
} ) ;
2018-09-06 00:17:45 +02:00
const swimlaneId = Swimlanes . insert ( {
2025-10-13 20:34:23 +03:00
title : TAPi18n && TAPi18n . i18n ? TAPi18n . _ _ ( 'default' ) : 'Default' ,
2018-09-06 00:17:45 +02:00
boardId : id ,
} ) ;
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : {
_id : id ,
2018-09-06 00:17:45 +02:00
defaultSwimlaneId : swimlaneId ,
2017-04-27 20:49:24 +03:00
} ,
2017-10-15 07:39:48 +02:00
} ) ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
2017-04-27 20:49:24 +03:00
} ) ;
2018-10-26 07:27:24 +02:00
/ * *
* @ operation delete _board
* @ summary Delete a board
*
* @ param { string } boardId the ID of the board
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'DELETE' , '/api/boards/:boardId' , function ( req , res ) {
2017-10-15 07:39:48 +02:00
try {
Authentication . checkUserId ( req . userId ) ;
2018-06-26 11:10:16 +02:00
const id = req . params . boardId ;
2017-10-15 07:39:48 +02:00
Boards . remove ( { _id : id } ) ;
JsonRoutes . sendResult ( res , {
code : 200 ,
2019-06-26 17:47:27 -05:00
data : {
2017-10-15 07:39:48 +02:00
_id : id ,
} ,
} ) ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2017-10-15 07:39:48 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
2017-04-27 20:49:24 +03:00
} ) ;
2018-05-07 13:32:33 +02:00
2024-02-16 10:50:52 +01:00
/ * *
* @ operation update _board _title
* @ summary Update the title of a board
*
* @ param { string } boardId the ID of the board to update
* @ param { string } title the new title for the board
* /
JsonRoutes . add ( 'PUT' , '/api/boards/:boardId/title' , function ( req , res ) {
try {
const boardId = req . params . boardId ;
2026-01-18 19:55:48 +02:00
Authentication . checkBoardWriteAccess ( req . userId , boardId ) ;
2024-02-16 10:50:52 +01:00
const title = req . body . title ;
Boards . direct . update ( { _id : boardId } , { $set : { title } } ) ;
JsonRoutes . sendResult ( res , {
code : 200 ,
data : {
_id : boardId ,
title ,
} ,
} ) ;
} catch ( error ) {
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
} ) ;
2025-06-23 19:37:41 +00:00
2018-10-26 07:27:24 +02:00
/ * *
* @ operation add _board _label
* @ summary Add a label to a board
*
* @ description If the board doesn ' t have the name / color label , this function
* adds the label to the board .
*
* @ param { string } boardId the board
* @ param { string } color the color of the new label
* @ param { string } name the name of the new label
*
* @ return _type string
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'PUT' , '/api/boards/:boardId/labels' , function ( req , res ) {
2018-06-26 11:10:16 +02:00
const id = req . params . boardId ;
2025-12-29 16:47:11 +02:00
Authentication . checkBoardWriteAccess ( req . userId , id ) ;
2018-05-07 13:32:33 +02:00
try {
if ( req . body . hasOwnProperty ( 'label' ) ) {
2023-02-04 16:57:56 +01:00
const board = ReactiveCache . getBoard ( id ) ;
2018-05-07 13:32:33 +02:00
const color = req . body . label . color ;
const name = req . body . label . name ;
const labelId = Random . id ( 6 ) ;
if ( ! board . getLabel ( name , color ) ) {
2019-06-26 17:47:27 -05:00
Boards . direct . update (
{ _id : id } ,
2019-06-28 12:52:09 -05:00
{ $push : { labels : { _id : labelId , name , color } } } ,
2019-06-26 17:47:27 -05:00
) ;
2018-05-07 13:32:33 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : labelId ,
} ) ;
} else {
JsonRoutes . sendResult ( res , {
code : 200 ,
} ) ;
}
}
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2018-05-07 13:32:33 +02:00
JsonRoutes . sendResult ( res , {
data : error ,
} ) ;
}
} ) ;
2018-09-30 02:37:16 +03:00
2024-03-10 08:42:04 +02:00
/ * *
* @ operation copy _board
* @ summary Copy a board to a new one
*
* @ description If your are board admin or wekan admin , this copies the
* given board to a new one .
*
* @ param { string } boardId the board
* @ param { string } title the title of the new board ( default to old one )
*
* @ return _type string
* /
JsonRoutes . add ( 'POST' , '/api/boards/:boardId/copy' , function ( req , res ) {
const id = req . params . boardId ;
const board = ReactiveCache . getBoard ( id ) ;
const adminAccess = board . members . some ( e => e . userId === req . userId && e . isAdmin ) ;
Authentication . checkAdminOrCondition ( req . userId , adminAccess ) ;
try {
board [ 'title' ] = req . body . title || Boards . uniqueTitle ( board . title ) ;
ret = board . copy ( ) ;
JsonRoutes . sendResult ( res , {
code : 200 ,
data : ret ,
} ) ;
} catch ( error ) {
JsonRoutes . sendResult ( res , {
data : error ,
} ) ;
}
} ) ;
2018-10-26 07:27:24 +02:00
/ * *
* @ operation set _board _member _permission
* @ tag Users
* @ summary Change the permission of a member of a board
*
* @ param { string } boardId the ID of the board that we are changing
* @ param { string } memberId the ID of the user to change permissions
* @ param { boolean } isAdmin admin capability
* @ param { boolean } isNoComments NoComments capability
* @ param { boolean } isCommentOnly CommentsOnly capability
2020-01-05 21:28:14 +02:00
* @ param { boolean } isWorker Worker capability
2025-12-22 21:45:09 +02:00
* @ param { boolean } isNormalAssignedOnly NormalAssignedOnly capability
* @ param { boolean } isCommentAssignedOnly CommentAssignedOnly capability
* @ param { boolean } isReadOnly ReadOnly capability
* @ param { boolean } isReadAssignedOnly ReadAssignedOnly capability
2018-10-26 07:27:24 +02:00
* /
2019-06-26 17:47:27 -05:00
JsonRoutes . add ( 'POST' , '/api/boards/:boardId/members/:memberId' , function (
req ,
2019-06-28 12:52:09 -05:00
res ,
2019-06-26 17:47:27 -05:00
) {
2018-09-30 02:37:16 +03:00
try {
2021-09-25 18:09:18 +03:00
Authentication . checkUserId ( req . userId ) ;
2018-09-30 02:37:16 +03:00
const boardId = req . params . boardId ;
const memberId = req . params . memberId ;
2025-12-22 21:45:09 +02:00
const { isAdmin , isNoComments , isCommentOnly , isWorker , isNormalAssignedOnly , isCommentAssignedOnly , isReadOnly , isReadAssignedOnly } = req . body ;
2023-02-04 16:57:56 +01:00
const board = ReactiveCache . getBoard ( boardId ) ;
2019-06-26 17:47:27 -05:00
function isTrue ( data ) {
2019-01-25 14:10:10 +01:00
try {
return data . toLowerCase ( ) === 'true' ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2019-01-25 14:10:10 +01:00
return data ;
}
2018-09-30 02:37:16 +03:00
}
2019-06-26 17:47:27 -05:00
const query = board . setMemberPermission (
memberId ,
isTrue ( isAdmin ) ,
isTrue ( isNoComments ) ,
isTrue ( isCommentOnly ) ,
2020-01-05 21:28:14 +02:00
isTrue ( isWorker ) ,
2025-12-22 21:45:09 +02:00
isTrue ( isNormalAssignedOnly ) ,
isTrue ( isCommentAssignedOnly ) ,
isTrue ( isReadOnly ) ,
isTrue ( isReadAssignedOnly ) ,
2019-06-28 12:52:09 -05:00
req . userId ,
2019-06-26 17:47:27 -05:00
) ;
2018-09-30 02:37:16 +03:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : query ,
} ) ;
2019-06-26 17:47:27 -05:00
} catch ( error ) {
2018-09-30 02:37:16 +03:00
JsonRoutes . sendResult ( res , {
code : 200 ,
data : error ,
} ) ;
}
} ) ;
2020-11-30 20:41:54 +02:00
//ATTACHMENTS REST API
/ * *
* @ operation get _board _attachments
* @ summary Get the list of attachments of a board
*
* @ param { string } boardId the board ID
* @ return _type [ { attachmentId : string ,
* attachmentName : string ,
* attachmentType : string ,
2023-07-05 11:05:37 +02:00
* url : string ,
* urlDownload : string ,
* boardId : string ,
* swimlaneId : string ,
2020-11-30 20:41:54 +02:00
* listId : string ,
2023-07-05 11:05:37 +02:00
* cardId : string
* } ]
2020-11-30 20:41:54 +02:00
* /
JsonRoutes . add ( 'GET' , '/api/boards/:boardId/attachments' , function ( req , res ) {
const paramBoardId = req . params . boardId ;
2023-01-13 21:50:39 +02:00
Authentication . checkBoardAccess ( req . userId , paramBoardId ) ;
2020-11-30 20:41:54 +02:00
JsonRoutes . sendResult ( res , {
code : 200 ,
2023-03-12 18:33:38 +01:00
data : ReactiveCache
. getAttachments ( { 'meta.boardId' : paramBoardId } , { } , true )
2023-07-05 11:05:37 +02:00
. each ( )
. map ( function ( attachment ) {
2020-11-30 20:41:54 +02:00
return {
2023-07-05 11:05:37 +02:00
attachmentId : attachment . _id ,
attachmentName : attachment . name ,
attachmentType : attachment . type ,
2023-07-05 12:51:49 +02:00
url : attachment . link ( ) ,
urlDownload : ` ${ attachment . link ( ) } ?download=true&token= ` ,
2023-07-05 11:05:37 +02:00
boardId : attachment . meta . boardId ,
swimlaneId : attachment . meta . swimlaneId ,
listId : attachment . meta . listId ,
cardId : attachment . meta . cardId
2020-11-30 20:41:54 +02:00
} ;
} ) ,
} ) ;
} ) ;
2017-04-27 20:49:24 +03:00
}
2019-06-26 17:47:27 -05:00
export default Boards ;