boards.js 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305
  1. import { ReactiveCache } from '/imports/reactiveCache';
  2. import escapeForRegex from 'escape-string-regexp';
  3. import { TAPi18n } from '/imports/i18n';
  4. import {
  5. ALLOWED_BOARD_COLORS,
  6. ALLOWED_COLORS,
  7. TYPE_BOARD,
  8. TYPE_TEMPLATE_BOARD,
  9. TYPE_TEMPLATE_CONTAINER,
  10. } from '/config/const';
  11. import Users from "./users";
  12. // const escapeForRegex = require('escape-string-regexp');
  13. Boards = new Mongo.Collection('boards');
  14. /**
  15. * This is a Board.
  16. */
  17. Boards.attachSchema(
  18. new SimpleSchema({
  19. title: {
  20. /**
  21. * The title of the board
  22. */
  23. type: String,
  24. },
  25. slug: {
  26. /**
  27. * The title slugified.
  28. */
  29. type: String,
  30. // eslint-disable-next-line consistent-return
  31. autoValue() {
  32. // In some cases (Chinese and Japanese for instance) the `getSlug` function
  33. // return an empty string. This is causes bugs in our application so we set
  34. // a default slug in this case.
  35. // Improvment would be to change client URL after slug is changed
  36. const title = this.field('title');
  37. if (title.isSet && !this.isSet) {
  38. let slug = 'board';
  39. slug = getSlug(title.value) || slug;
  40. return slug;
  41. }
  42. },
  43. },
  44. archived: {
  45. /**
  46. * Is the board archived?
  47. */
  48. type: Boolean,
  49. // eslint-disable-next-line consistent-return
  50. autoValue() {
  51. if (this.isInsert && !this.isSet) {
  52. return false;
  53. }
  54. },
  55. },
  56. archivedAt: {
  57. /**
  58. * Latest archiving time of the board
  59. */
  60. type: Date,
  61. optional: true,
  62. },
  63. createdAt: {
  64. /**
  65. * Creation time of the board
  66. */
  67. type: Date,
  68. // eslint-disable-next-line consistent-return
  69. autoValue() {
  70. if (this.isInsert) {
  71. return new Date();
  72. } else if (this.isUpsert) {
  73. return { $setOnInsert: new Date() };
  74. } else {
  75. this.unset();
  76. }
  77. },
  78. },
  79. // XXX Inconsistent field naming
  80. modifiedAt: {
  81. /**
  82. * Last modification time of the board
  83. */
  84. type: Date,
  85. optional: true,
  86. // eslint-disable-next-line consistent-return
  87. autoValue() {
  88. if (this.isInsert || this.isUpsert || this.isUpdate) {
  89. return new Date();
  90. } else {
  91. this.unset();
  92. }
  93. },
  94. },
  95. // De-normalized number of users that have starred this board
  96. stars: {
  97. /**
  98. * How many stars the board has
  99. */
  100. type: Number,
  101. // eslint-disable-next-line consistent-return
  102. autoValue() {
  103. if (this.isInsert) {
  104. return 0;
  105. }
  106. },
  107. },
  108. // De-normalized label system
  109. labels: {
  110. /**
  111. * List of labels attached to a board
  112. */
  113. type: [Object],
  114. optional: true,
  115. /* Commented out, so does not create labels to new boards.
  116. // eslint-disable-next-line consistent-return
  117. autoValue() {
  118. if (this.isInsert && !this.isSet) {
  119. const colors = Boards.simpleSchema()._schema['labels.$.color']
  120. .allowedValues;
  121. const defaultLabelsColors = _.clone(colors).splice(0, 6);
  122. return defaultLabelsColors.map(color => ({
  123. color,
  124. _id: Random.id(6),
  125. name: '',
  126. }));
  127. }
  128. },
  129. */
  130. },
  131. 'labels.$._id': {
  132. /**
  133. * Unique id of a label
  134. */
  135. // We don't specify that this field must be unique in the board because that
  136. // will cause performance penalties and is not necessary since this field is
  137. // always set on the server.
  138. // XXX Actually if we create a new label, the `_id` is set on the client
  139. // without being overwritten by the server, could it be a problem?
  140. type: String,
  141. },
  142. 'labels.$.name': {
  143. /**
  144. * Name of a label
  145. */
  146. type: String,
  147. optional: true,
  148. },
  149. 'labels.$.color': {
  150. /**
  151. * color of a label.
  152. *
  153. * Can be amongst `green`, `yellow`, `orange`, `red`, `purple`,
  154. * `blue`, `sky`, `lime`, `pink`, `black`,
  155. * `silver`, `peachpuff`, `crimson`, `plum`, `darkgreen`,
  156. * `slateblue`, `magenta`, `gold`, `navy`, `gray`,
  157. * `saddlebrown`, `paleturquoise`, `mistyrose`, `indigo`
  158. */
  159. type: String,
  160. allowedValues: ALLOWED_COLORS,
  161. },
  162. // XXX We might want to maintain more informations under the member sub-
  163. // documents like de-normalized meta-data (the date the member joined the
  164. // board, the number of contributions, etc.).
  165. members: {
  166. /**
  167. * List of members of a board
  168. */
  169. type: [Object],
  170. // eslint-disable-next-line consistent-return
  171. autoValue() {
  172. if (this.isInsert && !this.isSet) {
  173. return [
  174. {
  175. userId: this.userId,
  176. isAdmin: true,
  177. isActive: true,
  178. isNoComments: false,
  179. isCommentOnly: false,
  180. isWorker: false,
  181. },
  182. ];
  183. }
  184. },
  185. },
  186. 'members.$.userId': {
  187. /**
  188. * The uniq ID of the member
  189. */
  190. type: String,
  191. },
  192. 'members.$.isAdmin': {
  193. /**
  194. * Is the member an admin of the board?
  195. */
  196. type: Boolean,
  197. },
  198. 'members.$.isActive': {
  199. /**
  200. * Is the member active?
  201. */
  202. type: Boolean,
  203. },
  204. 'members.$.isNoComments': {
  205. /**
  206. * Is the member not allowed to make comments
  207. */
  208. type: Boolean,
  209. optional: true,
  210. },
  211. 'members.$.isCommentOnly': {
  212. /**
  213. * Is the member only allowed to comment on the board
  214. */
  215. type: Boolean,
  216. optional: true,
  217. },
  218. 'members.$.isWorker': {
  219. /**
  220. * Is the member only allowed to move card, assign himself to card and comment
  221. */
  222. type: Boolean,
  223. optional: true,
  224. },
  225. permission: {
  226. /**
  227. * visibility of the board
  228. */
  229. type: String,
  230. allowedValues: ['public', 'private'],
  231. },
  232. orgs: {
  233. /**
  234. * the list of organizations that a board belongs to
  235. */
  236. type: [Object],
  237. optional: true,
  238. },
  239. 'orgs.$.orgId':{
  240. /**
  241. * The uniq ID of the organization
  242. */
  243. type: String,
  244. },
  245. 'orgs.$.orgDisplayName':{
  246. /**
  247. * The display name of the organization
  248. */
  249. type: String,
  250. },
  251. 'orgs.$.isActive': {
  252. /**
  253. * Is the organization active?
  254. */
  255. type: Boolean,
  256. },
  257. teams: {
  258. /**
  259. * the list of teams that a board belongs to
  260. */
  261. type: [Object],
  262. optional: true,
  263. },
  264. 'teams.$.teamId':{
  265. /**
  266. * The uniq ID of the team
  267. */
  268. type: String,
  269. },
  270. 'teams.$.teamDisplayName':{
  271. /**
  272. * The display name of the team
  273. */
  274. type: String,
  275. },
  276. 'teams.$.isActive': {
  277. /**
  278. * Is the team active?
  279. */
  280. type: Boolean,
  281. },
  282. color: {
  283. /**
  284. * The color of the board.
  285. */
  286. type: String,
  287. allowedValues: ALLOWED_BOARD_COLORS,
  288. // eslint-disable-next-line consistent-return
  289. autoValue() {
  290. if (this.isInsert && !this.isSet) {
  291. return ALLOWED_BOARD_COLORS[0];
  292. }
  293. },
  294. },
  295. backgroundImageURL: {
  296. /**
  297. * The background image URL of the board.
  298. */
  299. type: String,
  300. optional: true,
  301. },
  302. allowsCardCounterList: {
  303. /**
  304. * Show card counter per list
  305. */
  306. type: Boolean,
  307. defaultValue: false,
  308. },
  309. allowsBoardMemberList: {
  310. /**
  311. * Show board member list
  312. */
  313. type: Boolean,
  314. defaultValue: false,
  315. },
  316. description: {
  317. /**
  318. * The description of the board
  319. */
  320. type: String,
  321. optional: true,
  322. },
  323. subtasksDefaultBoardId: {
  324. /**
  325. * The default board ID assigned to subtasks.
  326. */
  327. type: String,
  328. optional: true,
  329. defaultValue: null,
  330. },
  331. subtasksDefaultListId: {
  332. /**
  333. * The default List ID assigned to subtasks.
  334. */
  335. type: String,
  336. optional: true,
  337. defaultValue: null,
  338. },
  339. dateSettingsDefaultBoardId: {
  340. type: String,
  341. optional: true,
  342. defaultValue: null,
  343. },
  344. dateSettingsDefaultListId: {
  345. type: String,
  346. optional: true,
  347. defaultValue: null,
  348. },
  349. allowsSubtasks: {
  350. /**
  351. * Does the board allows subtasks?
  352. */
  353. type: Boolean,
  354. defaultValue: true,
  355. },
  356. allowsAttachments: {
  357. /**
  358. * Does the board allows attachments?
  359. */
  360. type: Boolean,
  361. defaultValue: true,
  362. },
  363. allowsChecklists: {
  364. /**
  365. * Does the board allows checklists?
  366. */
  367. type: Boolean,
  368. defaultValue: true,
  369. },
  370. allowsComments: {
  371. /**
  372. * Does the board allows comments?
  373. */
  374. type: Boolean,
  375. defaultValue: true,
  376. },
  377. allowsDescriptionTitle: {
  378. /**
  379. * Does the board allows description title?
  380. */
  381. type: Boolean,
  382. defaultValue: true,
  383. },
  384. allowsDescriptionText: {
  385. /**
  386. * Does the board allows description text?
  387. */
  388. type: Boolean,
  389. defaultValue: true,
  390. },
  391. allowsDescriptionTextOnMinicard: {
  392. /**
  393. * Does the board allows description text on minicard?
  394. */
  395. type: Boolean,
  396. defaultValue: false,
  397. },
  398. allowsCoverAttachmentOnMinicard: {
  399. /**
  400. * Does the board allows cover attachment on minicard?
  401. */
  402. type: Boolean,
  403. defaultValue: false,
  404. },
  405. allowsBadgeAttachmentOnMinicard: {
  406. /**
  407. * Does the board allows badge attachment on minicard?
  408. */
  409. type: Boolean,
  410. defaultValue: false,
  411. },
  412. allowsCardSortingByNumberOnMinicard: {
  413. /**
  414. * Does the board allows card sorting by number on minicard?
  415. */
  416. type: Boolean,
  417. defaultValue: false,
  418. },
  419. allowsCardNumber: {
  420. /**
  421. * Does the board allows card numbers?
  422. */
  423. type: Boolean,
  424. defaultValue: false,
  425. },
  426. allowsActivities: {
  427. /**
  428. * Does the board allows comments?
  429. */
  430. type: Boolean,
  431. defaultValue: true,
  432. },
  433. allowsLabels: {
  434. /**
  435. * Does the board allows labels?
  436. */
  437. type: Boolean,
  438. defaultValue: true,
  439. },
  440. allowsCreator: {
  441. /**
  442. * Does the board allow creator?
  443. */
  444. type: Boolean,
  445. defaultValue: true,
  446. },
  447. allowsAssignee: {
  448. /**
  449. * Does the board allows assignee?
  450. */
  451. type: Boolean,
  452. defaultValue: true,
  453. },
  454. allowsMembers: {
  455. /**
  456. * Does the board allows members?
  457. */
  458. type: Boolean,
  459. defaultValue: true,
  460. },
  461. allowsRequestedBy: {
  462. /**
  463. * Does the board allows requested by?
  464. */
  465. type: Boolean,
  466. defaultValue: true,
  467. },
  468. allowsCardSortingByNumber: {
  469. /**
  470. * Does the board allows card sorting by number?
  471. */
  472. type: Boolean,
  473. defaultValue: true,
  474. },
  475. allowsShowLists: {
  476. /**
  477. * Does the board allows show lists on the card?
  478. */
  479. type: Boolean,
  480. defaultValue: true,
  481. },
  482. allowsAssignedBy: {
  483. /**
  484. * Does the board allows requested by?
  485. */
  486. type: Boolean,
  487. defaultValue: true,
  488. },
  489. allowsReceivedDate: {
  490. /**
  491. * Does the board allows received date?
  492. */
  493. type: Boolean,
  494. defaultValue: true,
  495. },
  496. allowsStartDate: {
  497. /**
  498. * Does the board allows start date?
  499. */
  500. type: Boolean,
  501. defaultValue: true,
  502. },
  503. allowsEndDate: {
  504. /**
  505. * Does the board allows end date?
  506. */
  507. type: Boolean,
  508. defaultValue: true,
  509. },
  510. allowsDueDate: {
  511. /**
  512. * Does the board allows due date?
  513. */
  514. type: Boolean,
  515. defaultValue: true,
  516. },
  517. presentParentTask: {
  518. /**
  519. * Controls how to present the parent task:
  520. *
  521. * - `prefix-with-full-path`: add a prefix with the full path
  522. * - `prefix-with-parent`: add a prefisx with the parent name
  523. * - `subtext-with-full-path`: add a subtext with the full path
  524. * - `subtext-with-parent`: add a subtext with the parent name
  525. * - `no-parent`: does not show the parent at all
  526. */
  527. type: String,
  528. allowedValues: [
  529. 'prefix-with-full-path',
  530. 'prefix-with-parent',
  531. 'subtext-with-full-path',
  532. 'subtext-with-parent',
  533. 'no-parent',
  534. ],
  535. optional: true,
  536. defaultValue: 'no-parent',
  537. },
  538. receivedAt: {
  539. /**
  540. * Date the card was received
  541. */
  542. type: Date,
  543. optional: true,
  544. },
  545. startAt: {
  546. /**
  547. * Starting date of the board.
  548. */
  549. type: Date,
  550. optional: true,
  551. },
  552. dueAt: {
  553. /**
  554. * Due date of the board.
  555. */
  556. type: Date,
  557. optional: true,
  558. },
  559. endAt: {
  560. /**
  561. * End date of the board.
  562. */
  563. type: Date,
  564. optional: true,
  565. },
  566. spentTime: {
  567. /**
  568. * Time spent in the board.
  569. */
  570. type: Number,
  571. decimal: true,
  572. optional: true,
  573. },
  574. isOvertime: {
  575. /**
  576. * Is the board overtimed?
  577. */
  578. type: Boolean,
  579. defaultValue: false,
  580. optional: true,
  581. },
  582. type: {
  583. /**
  584. * The type of board
  585. * possible values: board, template-board, template-container
  586. */
  587. type: String,
  588. defaultValue: TYPE_BOARD,
  589. allowedValues: [TYPE_BOARD, TYPE_TEMPLATE_BOARD, TYPE_TEMPLATE_CONTAINER],
  590. },
  591. sort: {
  592. /**
  593. * Sort value
  594. */
  595. type: Number,
  596. decimal: true,
  597. defaultValue: -1,
  598. },
  599. }),
  600. );
  601. Boards.helpers({
  602. copy() {
  603. const oldId = this._id;
  604. delete this._id;
  605. delete this.slug;
  606. this.title = this.copyTitle();
  607. const _id = Boards.insert(this);
  608. // Copy all swimlanes in board
  609. ReactiveCache.getSwimlanes({
  610. boardId: oldId,
  611. archived: false,
  612. }).forEach(swimlane => {
  613. swimlane.type = 'swimlane';
  614. swimlane.copy(_id);
  615. });
  616. // copy custom field definitions
  617. const cfMap = {};
  618. ReactiveCache.getCustomFields({ boardIds: oldId }).forEach(cf => {
  619. const id = cf._id;
  620. delete cf._id;
  621. cf.boardIds = [_id];
  622. cfMap[id] = CustomFields.insert(cf);
  623. });
  624. ReactiveCache.getCards({ boardId: _id }).forEach(card => {
  625. Cards.update(card._id, {
  626. $set: {
  627. customFields: card.customFields.map(cf => {
  628. cf._id = cfMap[cf._id];
  629. return cf;
  630. }),
  631. },
  632. });
  633. });
  634. // copy rules, actions, and triggers
  635. const actionsMap = {};
  636. ReactiveCache.getActions({ boardId: oldId }).forEach(action => {
  637. const id = action._id;
  638. delete action._id;
  639. action.boardId = _id;
  640. actionsMap[id] = Actions.insert(action);
  641. });
  642. const triggersMap = {};
  643. ReactiveCache.getTriggers({ boardId: oldId }).forEach(trigger => {
  644. const id = trigger._id;
  645. delete trigger._id;
  646. trigger.boardId = _id;
  647. triggersMap[id] = Triggers.insert(trigger);
  648. });
  649. ReactiveCache.getRules({ boardId: oldId }).forEach(rule => {
  650. delete rule._id;
  651. rule.boardId = _id;
  652. rule.actionId = actionsMap[rule.actionId];
  653. rule.triggerId = triggersMap[rule.triggerId];
  654. Rules.insert(rule);
  655. });
  656. return _id;
  657. },
  658. /**
  659. * Return a unique title based on the current title
  660. *
  661. * @returns {string|null}
  662. */
  663. copyTitle() {
  664. return Boards.uniqueTitle(this.title);
  665. },
  666. /**
  667. * Is supplied user authorized to view this board?
  668. */
  669. isVisibleBy(user) {
  670. if (this.isPublic()) {
  671. // public boards are visible to everyone
  672. return true;
  673. } else {
  674. // otherwise you have to be logged-in and active member
  675. return user && this.isActiveMember(user._id);
  676. }
  677. },
  678. /**
  679. * Is the user one of the active members of the board?
  680. *
  681. * @param userId
  682. * @returns {boolean} the member that matches, or undefined/false
  683. */
  684. isActiveMember(userId) {
  685. if (userId) {
  686. return this.members.find(
  687. member => member.userId === userId && member.isActive,
  688. );
  689. } else {
  690. return false;
  691. }
  692. },
  693. isPublic() {
  694. return this.permission === 'public';
  695. },
  696. cards() {
  697. const ret = ReactiveCache.getCards(
  698. { boardId: this._id, archived: false },
  699. { sort: { title: 1 } },
  700. );
  701. return ret;
  702. },
  703. lists() {
  704. return this.draggableLists();
  705. },
  706. newestLists() {
  707. // sorted lists from newest to the oldest, by its creation date or its cards' last modification date
  708. const value = ReactiveCache.getCurrentUser()._getListSortBy();
  709. const sortKey = { starred: -1, [value[0]]: value[1] }; // [["starred",-1],value];
  710. return ReactiveCache.getLists(
  711. {
  712. boardId: this._id,
  713. archived: false,
  714. },
  715. { sort: sortKey },
  716. );
  717. },
  718. draggableLists() {
  719. return ReactiveCache.getLists({ boardId: this._id }, { sort: { sort: 1 } });
  720. },
  721. /** returns the last list
  722. * @returns Document the last list
  723. */
  724. getLastList() {
  725. const ret = ReactiveCache.getList({ boardId: this._id }, { sort: { sort: 'desc' } });
  726. return ret;
  727. },
  728. nullSortLists() {
  729. return ReactiveCache.getLists({
  730. boardId: this._id,
  731. archived: false,
  732. sort: { $eq: null },
  733. });
  734. },
  735. swimlanes() {
  736. return ReactiveCache.getSwimlanes(
  737. { boardId: this._id, archived: false },
  738. { sort: { sort: 1 } },
  739. );
  740. },
  741. nextSwimlane(swimlane) {
  742. return ReactiveCache.getSwimlane(
  743. {
  744. boardId: this._id,
  745. archived: false,
  746. sort: { $gte: swimlane.sort },
  747. _id: { $ne: swimlane._id },
  748. },
  749. {
  750. sort: { sort: 1 },
  751. },
  752. );
  753. },
  754. nullSortSwimlanes() {
  755. return ReactiveCache.getSwimlanes({
  756. boardId: this._id,
  757. archived: false,
  758. sort: { $eq: null },
  759. });
  760. },
  761. hasOvertimeCards() {
  762. const card = ReactiveCache.getCard({
  763. isOvertime: true,
  764. boardId: this._id,
  765. archived: false,
  766. });
  767. return card !== undefined;
  768. },
  769. hasSpentTimeCards() {
  770. const card = ReactiveCache.getCard({
  771. spentTime: { $gt: 0 },
  772. boardId: this._id,
  773. archived: false,
  774. });
  775. return card !== undefined;
  776. },
  777. activities() {
  778. let linkedBoardId = [this._id];
  779. ReactiveCache.getCards({
  780. "type": "cardType-linkedBoard",
  781. "boardId": this._id}
  782. ).forEach(card => {
  783. linkedBoardId.push(card.linkedId);
  784. });
  785. const ret = ReactiveCache.getActivities({ boardId: { $in: linkedBoardId } }, { sort: { createdAt: -1 } });
  786. return ret;
  787. },
  788. activeMembers(){
  789. return _.where(this.members, { isActive: true });
  790. },
  791. activeMembers2(members, boardTeamUsers) {
  792. let allMembers = members;
  793. if(this.teams !== undefined && this.teams.length > 0){
  794. let index;
  795. if(boardTeamUsers && boardTeamUsers.count() > 0){
  796. boardTeamUsers.forEach((u) => {
  797. index = allMembers.findIndex(function(m){ return m.userId == u._id});
  798. if(index == -1){
  799. allMembers.push({
  800. "isActive": true,
  801. "isAdmin": u.isAdmin !== undefined ? u.isAdmin : false,
  802. "isCommentOnly" : false,
  803. "isNoComments" : false,
  804. "userId": u._id,
  805. });
  806. }
  807. });
  808. }
  809. }
  810. return allMembers;
  811. },
  812. activeOrgs() {
  813. return _.where(this.orgs, { isActive: true });
  814. },
  815. // hasNotAnyOrg(){
  816. // return this.orgs === undefined || this.orgs.length <= 0;
  817. // },
  818. activeTeams() {
  819. return _.where(this.teams, { isActive: true });
  820. },
  821. // hasNotAnyTeam(){
  822. // return this.teams === undefined || this.teams.length <= 0;
  823. // },
  824. activeAdmins() {
  825. return _.where(this.members, { isActive: true, isAdmin: true });
  826. },
  827. memberUsers() {
  828. return ReactiveCache.getUsers({ _id: { $in: _.pluck(this.members, 'userId') } });
  829. },
  830. getLabel(name, color) {
  831. return _.findWhere(this.labels, { name, color });
  832. },
  833. getLabelById(labelId) {
  834. return _.findWhere(this.labels, { _id: labelId });
  835. },
  836. labelIndex(labelId) {
  837. return _.pluck(this.labels, '_id').indexOf(labelId);
  838. },
  839. memberIndex(memberId) {
  840. return _.pluck(this.members, 'userId').indexOf(memberId);
  841. },
  842. hasMember(memberId) {
  843. return !!_.findWhere(this.members, { userId: memberId, isActive: true });
  844. },
  845. hasAdmin(memberId) {
  846. return !!_.findWhere(this.members, {
  847. userId: memberId,
  848. isActive: true,
  849. isAdmin: true,
  850. });
  851. },
  852. hasNoComments(memberId) {
  853. return !!_.findWhere(this.members, {
  854. userId: memberId,
  855. isActive: true,
  856. isAdmin: false,
  857. isNoComments: true,
  858. isWorker: false,
  859. });
  860. },
  861. hasCommentOnly(memberId) {
  862. return !!_.findWhere(this.members, {
  863. userId: memberId,
  864. isActive: true,
  865. isAdmin: false,
  866. isCommentOnly: true,
  867. isWorker: false,
  868. });
  869. },
  870. hasWorker(memberId) {
  871. return !!_.findWhere(this.members, {
  872. userId: memberId,
  873. isActive: true,
  874. isAdmin: false,
  875. isCommentOnly: false,
  876. isWorker: true,
  877. });
  878. },
  879. hasAnyAllowsDate() {
  880. const ret = this.allowsReceivedDate || this.allowsStartDate || this.allowsDueDate || this.allowsEndDate;
  881. return ret;
  882. },
  883. hasAnyAllowsUser() {
  884. const ret = this.allowsCreator || this.allowsMembers || this.allowsAssignee || this.allowsRequestedBy || this.allowsAssignedBy;
  885. return ret;
  886. },
  887. absoluteUrl() {
  888. return FlowRouter.url('board', { id: this._id, slug: this.slug });
  889. },
  890. originRelativeUrl() {
  891. return FlowRouter.path('board', { id: this._id, slug: this.slug });
  892. },
  893. colorClass() {
  894. return `board-color-${this.color}`;
  895. },
  896. customFields() {
  897. const ret = ReactiveCache.getCustomFields(
  898. { boardIds: { $in: [this._id] } },
  899. { sort: { name: 1 } },
  900. );
  901. return ret;
  902. },
  903. // XXX currently mutations return no value so we have an issue when using addLabel in import
  904. // XXX waiting on https://github.com/mquandalle/meteor-collection-mutations/issues/1 to remove...
  905. pushLabel(name, color) {
  906. const _id = Random.id(6);
  907. Boards.direct.update(this._id, { $push: { labels: { _id, name, color } } });
  908. return _id;
  909. },
  910. /** sets the new label order
  911. * @param newLabelOrderOnlyIds new order array of _id, e.g. Array(4) [ "FvtD34", "PAEgDP", "LjRBxH", "YJ8sZz" ]
  912. */
  913. setNewLabelOrder(newLabelOrderOnlyIds) {
  914. if (this.labels.length == newLabelOrderOnlyIds.length) {
  915. if (this.labels.every(_label => newLabelOrderOnlyIds.indexOf(_label._id) >= 0)) {
  916. const newLabels = _.sortBy(this.labels, _label => newLabelOrderOnlyIds.indexOf(_label._id));
  917. if (this.labels.length == newLabels.length) {
  918. Boards.direct.update(this._id, {$set: {labels: newLabels}});
  919. }
  920. }
  921. }
  922. },
  923. searchBoards(term) {
  924. check(term, Match.OneOf(String, null, undefined));
  925. const query = { boardId: this._id };
  926. query.type = 'cardType-linkedBoard';
  927. query.archived = false;
  928. const projection = { limit: 10, sort: { createdAt: -1 } };
  929. if (term) {
  930. const regex = new RegExp(term, 'i');
  931. query.$or = [{ title: regex }, { description: regex }];
  932. }
  933. const ret = ReactiveCache.getCards(query, projection);
  934. return ret;
  935. },
  936. searchSwimlanes(term) {
  937. check(term, Match.OneOf(String, null, undefined));
  938. const query = { boardId: this._id };
  939. if (this.isTemplatesBoard()) {
  940. query.type = 'template-swimlane';
  941. query.archived = false;
  942. } else {
  943. query.type = { $nin: ['template-swimlane'] };
  944. }
  945. const projection = { limit: 10, sort: { createdAt: -1 } };
  946. if (term) {
  947. const regex = new RegExp(term, 'i');
  948. query.$or = [{ title: regex }, { description: regex }];
  949. }
  950. return ReactiveCache.getSwimlanes(query, projection);
  951. },
  952. searchLists(term) {
  953. let ret = null;
  954. if (term) {
  955. check(term, Match.OneOf(String));
  956. term = term.trim();
  957. }
  958. if (term) {
  959. const query = { boardId: this._id };
  960. if (this.isTemplatesBoard()) {
  961. query.type = 'template-list';
  962. query.archived = false;
  963. } else {
  964. query.type = { $nin: ['template-list'] };
  965. }
  966. const projection = { sort: { createdAt: -1 } };
  967. if (term) {
  968. const regex = new RegExp(term, 'i');
  969. query.$or = [{ title: regex }, { description: regex }];
  970. }
  971. ret = ReactiveCache.getLists(query, projection);
  972. }
  973. return ret;
  974. },
  975. searchCards(term, excludeLinked) {
  976. let ret = null;
  977. if (term) {
  978. check(term, Match.OneOf(String));
  979. term = term.trim();
  980. }
  981. if (term) {
  982. const query = { boardId: this._id };
  983. if (excludeLinked) {
  984. query.linkedId = null;
  985. }
  986. if (this.isTemplatesBoard()) {
  987. query.type = 'template-card';
  988. query.archived = false;
  989. } else {
  990. query.type = { $nin: ['template-card'] };
  991. }
  992. const projection = { sort: { createdAt: -1 } };
  993. const regex = new RegExp(term, 'i');
  994. query.$or = [
  995. { title: regex },
  996. { description: regex },
  997. { customFields: { $elemMatch: { value: regex } } },
  998. ];
  999. ret = ReactiveCache.getCards(query, projection);
  1000. }
  1001. return ret;
  1002. },
  1003. // A board alwasy has another board where it deposits subtasks of thasks
  1004. // that belong to itself.
  1005. getDefaultSubtasksBoardId() {
  1006. if (
  1007. this.subtasksDefaultBoardId === null ||
  1008. this.subtasksDefaultBoardId === undefined
  1009. ) {
  1010. this.subtasksDefaultBoardId = Boards.insert({
  1011. title: `^${this.title}^`,
  1012. permission: this.permission,
  1013. members: this.members,
  1014. color: this.color,
  1015. description: TAPi18n.__('default-subtasks-board', {
  1016. board: this.title,
  1017. }),
  1018. });
  1019. Swimlanes.insert({
  1020. title: TAPi18n.__('default'),
  1021. boardId: this.subtasksDefaultBoardId,
  1022. });
  1023. Boards.update(this._id, {
  1024. $set: {
  1025. subtasksDefaultBoardId: this.subtasksDefaultBoardId,
  1026. },
  1027. });
  1028. }
  1029. return this.subtasksDefaultBoardId;
  1030. },
  1031. getDefaultSubtasksBoard() {
  1032. return ReactiveCache.getBoard(this.getDefaultSubtasksBoardId());
  1033. },
  1034. //Date Settings option such as received date, start date and so on.
  1035. getDefaultDateSettingsBoardId() {
  1036. if (
  1037. this.dateSettingsDefaultBoardId === null ||
  1038. this.dateSettingsDefaultBoardId === undefined
  1039. ) {
  1040. this.dateSettingsDefaultBoardId = Boards.insert({
  1041. title: `^${this.title}^`,
  1042. permission: this.permission,
  1043. members: this.members,
  1044. color: this.color,
  1045. description: TAPi18n.__('default-dates-board', {
  1046. board: this.title,
  1047. }),
  1048. });
  1049. Swimlanes.insert({
  1050. title: TAPi18n.__('default'),
  1051. boardId: this.dateSettingsDefaultBoardId,
  1052. });
  1053. Boards.update(this._id, {
  1054. $set: {
  1055. dateSettingsDefaultBoardId: this.dateSettingsDefaultBoardId,
  1056. },
  1057. });
  1058. }
  1059. return this.dateSettingsDefaultBoardId;
  1060. },
  1061. getDefaultDateSettingsBoard() {
  1062. return ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId());
  1063. },
  1064. getDefaultSubtasksListId() {
  1065. if (
  1066. this.subtasksDefaultListId === null ||
  1067. this.subtasksDefaultListId === undefined
  1068. ) {
  1069. this.subtasksDefaultListId = Lists.insert({
  1070. title: TAPi18n.__('queue'),
  1071. boardId: this._id,
  1072. });
  1073. this.setSubtasksDefaultListId(this.subtasksDefaultListId);
  1074. }
  1075. return this.subtasksDefaultListId;
  1076. },
  1077. getDefaultSubtasksList() {
  1078. return ReactiveCache.getList(this.getDefaultSubtasksListId());
  1079. },
  1080. getDefaultDateSettingsListId() {
  1081. if (
  1082. this.dateSettingsDefaultListId === null ||
  1083. this.dateSettingsDefaultListId === undefined
  1084. ) {
  1085. this.dateSettingsDefaultListId = Lists.insert({
  1086. title: TAPi18n.__('queue'),
  1087. boardId: this._id,
  1088. });
  1089. this.setDateSettingsDefaultListId(this.dateSettingsDefaultListId);
  1090. }
  1091. return this.dateSettingsDefaultListId;
  1092. },
  1093. getDefaultDateSettingsList() {
  1094. return ReactiveCache.getList(this.getDefaultDateSettingsListId());
  1095. },
  1096. getDefaultSwimline() {
  1097. let result = ReactiveCache.getSwimlane({ boardId: this._id });
  1098. if (result === undefined) {
  1099. Swimlanes.insert({
  1100. title: TAPi18n.__('default'),
  1101. boardId: this._id,
  1102. });
  1103. result = ReactiveCache.getSwimlane({ boardId: this._id });
  1104. }
  1105. return result;
  1106. },
  1107. getNextCardNumber() {
  1108. const boardCards = ReactiveCache.getCard(
  1109. {
  1110. boardId: this._id
  1111. },
  1112. {
  1113. sort: { cardNumber: -1 },
  1114. limit: 1
  1115. }
  1116. , true);
  1117. // If no card is assigned to the board, return 1
  1118. if (!boardCards) {
  1119. return 1;
  1120. }
  1121. const maxCardNr = !!boardCards.cardNumber ? boardCards.cardNumber : 0;
  1122. return maxCardNr + 1;
  1123. },
  1124. cardsDueInBetween(start, end) {
  1125. const ret = ReactiveCache.getCards({
  1126. boardId: this._id,
  1127. dueAt: { $gte: start, $lte: end },
  1128. });
  1129. return ret;
  1130. },
  1131. cardsInInterval(start, end) {
  1132. const ret = ReactiveCache.getCards({
  1133. boardId: this._id,
  1134. $or: [
  1135. {
  1136. startAt: {
  1137. $lte: start,
  1138. },
  1139. endAt: {
  1140. $gte: start,
  1141. },
  1142. },
  1143. {
  1144. startAt: {
  1145. $lte: end,
  1146. },
  1147. endAt: {
  1148. $gte: end,
  1149. },
  1150. },
  1151. {
  1152. startAt: {
  1153. $gte: start,
  1154. },
  1155. endAt: {
  1156. $lte: end,
  1157. },
  1158. },
  1159. ],
  1160. });
  1161. return ret;
  1162. },
  1163. isTemplateBoard() {
  1164. return this.type === 'template-board';
  1165. },
  1166. isTemplatesBoard() {
  1167. return this.type === 'template-container';
  1168. },
  1169. });
  1170. Boards.mutations({
  1171. archive() {
  1172. return { $set: { archived: true, archivedAt: new Date() } };
  1173. },
  1174. restore() {
  1175. return { $set: { archived: false } };
  1176. },
  1177. rename(title) {
  1178. return { $set: { title } };
  1179. },
  1180. setDescription(description) {
  1181. return { $set: { description } };
  1182. },
  1183. setColor(color) {
  1184. return { $set: { color } };
  1185. },
  1186. setBackgroundImageURL(backgroundImageURL) {
  1187. const currentUser = ReactiveCache.getCurrentUser();
  1188. if(currentUser.isBoardAdmin()) {
  1189. return { $set: { backgroundImageURL } };
  1190. } else if (currentUser.isAdmin()) {
  1191. return { $set: { backgroundImageURL } };
  1192. } else {
  1193. return false;
  1194. }
  1195. },
  1196. setVisibility(visibility) {
  1197. return { $set: { permission: visibility } };
  1198. },
  1199. addLabel(name, color) {
  1200. // If label with the same name and color already exists we don't want to
  1201. // create another one because they would be indistinguishable in the UI
  1202. // (they would still have different `_id` but that is not exposed to the
  1203. // user).
  1204. if (!this.getLabel(name, color)) {
  1205. const _id = Random.id(6);
  1206. return { $push: { labels: { _id, name, color } } };
  1207. }
  1208. return {};
  1209. },
  1210. editLabel(labelId, name, color) {
  1211. if (!this.getLabel(name, color)) {
  1212. const labelIndex = this.labelIndex(labelId);
  1213. return {
  1214. $set: {
  1215. [`labels.${labelIndex}.name`]: name,
  1216. [`labels.${labelIndex}.color`]: color,
  1217. },
  1218. };
  1219. }
  1220. return {};
  1221. },
  1222. removeLabel(labelId) {
  1223. return { $pull: { labels: { _id: labelId } } };
  1224. },
  1225. changeOwnership(fromId, toId) {
  1226. const memberIndex = this.memberIndex(fromId);
  1227. return {
  1228. $set: {
  1229. [`members.${memberIndex}.userId`]: toId,
  1230. },
  1231. };
  1232. },
  1233. addMember(memberId) {
  1234. const memberIndex = this.memberIndex(memberId);
  1235. if (memberIndex >= 0) {
  1236. return {
  1237. $set: {
  1238. [`members.${memberIndex}.isActive`]: true,
  1239. },
  1240. };
  1241. }
  1242. return {
  1243. $push: {
  1244. members: {
  1245. userId: memberId,
  1246. isAdmin: false,
  1247. isActive: true,
  1248. isNoComments: false,
  1249. isCommentOnly: false,
  1250. isWorker: false,
  1251. },
  1252. },
  1253. };
  1254. },
  1255. removeMember(memberId) {
  1256. const memberIndex = this.memberIndex(memberId);
  1257. // we do not allow the only one admin to be removed
  1258. const allowRemove =
  1259. !this.members[memberIndex].isAdmin || this.activeAdmins().length > 1;
  1260. if (!allowRemove) {
  1261. return {
  1262. $set: {
  1263. [`members.${memberIndex}.isActive`]: true,
  1264. },
  1265. };
  1266. }
  1267. return {
  1268. $set: {
  1269. [`members.${memberIndex}.isActive`]: false,
  1270. [`members.${memberIndex}.isAdmin`]: false,
  1271. },
  1272. };
  1273. },
  1274. setMemberPermission(
  1275. memberId,
  1276. isAdmin,
  1277. isNoComments,
  1278. isCommentOnly,
  1279. isWorker,
  1280. currentUserId = Meteor.userId(),
  1281. ) {
  1282. const memberIndex = this.memberIndex(memberId);
  1283. // do not allow change permission of self
  1284. if (memberId === currentUserId) {
  1285. isAdmin = this.members[memberIndex].isAdmin;
  1286. }
  1287. return {
  1288. $set: {
  1289. [`members.${memberIndex}.isAdmin`]: isAdmin,
  1290. [`members.${memberIndex}.isNoComments`]: isNoComments,
  1291. [`members.${memberIndex}.isCommentOnly`]: isCommentOnly,
  1292. [`members.${memberIndex}.isWorker`]: isWorker,
  1293. },
  1294. };
  1295. },
  1296. setAllowsSubtasks(allowsSubtasks) {
  1297. return { $set: { allowsSubtasks } };
  1298. },
  1299. setAllowsCreator(allowsCreator) {
  1300. return { $set: { allowsCreator } };
  1301. },
  1302. setAllowsMembers(allowsMembers) {
  1303. return { $set: { allowsMembers } };
  1304. },
  1305. setAllowsChecklists(allowsChecklists) {
  1306. return { $set: { allowsChecklists } };
  1307. },
  1308. setAllowsAssignee(allowsAssignee) {
  1309. return { $set: { allowsAssignee } };
  1310. },
  1311. setAllowsAssignedBy(allowsAssignedBy) {
  1312. return { $set: { allowsAssignedBy } };
  1313. },
  1314. setAllowsRequestedBy(allowsRequestedBy) {
  1315. return { $set: { allowsRequestedBy } };
  1316. },
  1317. setAllowsCardSortingByNumber(allowsCardSortingByNumber) {
  1318. return { $set: { allowsCardSortingByNumber } };
  1319. },
  1320. setAllowsShowLists(allowsShowLists) {
  1321. return { $set: { allowsShowLists } };
  1322. },
  1323. setAllowsAttachments(allowsAttachments) {
  1324. return { $set: { allowsAttachments } };
  1325. },
  1326. setAllowsLabels(allowsLabels) {
  1327. return { $set: { allowsLabels } };
  1328. },
  1329. setAllowsComments(allowsComments) {
  1330. return { $set: { allowsComments } };
  1331. },
  1332. setAllowsDescriptionTitle(allowsDescriptionTitle) {
  1333. return { $set: { allowsDescriptionTitle } };
  1334. },
  1335. setAllowsCardNumber(allowsCardNumber) {
  1336. return { $set: { allowsCardNumber } };
  1337. },
  1338. setAllowsDescriptionText(allowsDescriptionText) {
  1339. return { $set: { allowsDescriptionText } };
  1340. },
  1341. setallowsDescriptionTextOnMinicard(allowsDescriptionTextOnMinicard) {
  1342. return { $set: { allowsDescriptionTextOnMinicard } };
  1343. },
  1344. setallowsCoverAttachmentOnMinicard(allowsCoverAttachmentOnMinicard) {
  1345. return { $set: { allowsCoverAttachmentOnMinicard } };
  1346. },
  1347. setallowsBadgeAttachmentOnMinicard(allowsBadgeAttachmentOnMinicard) {
  1348. return { $set: { allowsBadgeAttachmentOnMinicard } };
  1349. },
  1350. setallowsCardSortingByNumberOnMinicard(allowsCardSortingByNumberOnMinicard) {
  1351. return { $set: { allowsCardSortingByNumberOnMinicard } };
  1352. },
  1353. setAllowsActivities(allowsActivities) {
  1354. return { $set: { allowsActivities } };
  1355. },
  1356. setAllowsReceivedDate(allowsReceivedDate) {
  1357. return { $set: { allowsReceivedDate } };
  1358. },
  1359. setAllowsCardCounterList(allowsCardCounterList) {
  1360. return { $set: { allowsCardCounterList } };
  1361. },
  1362. setAllowsBoardMemberList(allowsBoardMemberList) {
  1363. return { $set: { allowsBoardMemberList } };
  1364. },
  1365. setAllowsStartDate(allowsStartDate) {
  1366. return { $set: { allowsStartDate } };
  1367. },
  1368. setAllowsEndDate(allowsEndDate) {
  1369. return { $set: { allowsEndDate } };
  1370. },
  1371. setAllowsDueDate(allowsDueDate) {
  1372. return { $set: { allowsDueDate } };
  1373. },
  1374. setSubtasksDefaultBoardId(subtasksDefaultBoardId) {
  1375. return { $set: { subtasksDefaultBoardId } };
  1376. },
  1377. setSubtasksDefaultListId(subtasksDefaultListId) {
  1378. return { $set: { subtasksDefaultListId } };
  1379. },
  1380. setPresentParentTask(presentParentTask) {
  1381. return { $set: { presentParentTask } };
  1382. },
  1383. move(sortIndex) {
  1384. return { $set: { sort: sortIndex } };
  1385. },
  1386. });
  1387. function boardRemover(userId, doc) {
  1388. [Cards, Lists, Swimlanes, Integrations, Rules, Activities].forEach(
  1389. element => {
  1390. element.remove({ boardId: doc._id });
  1391. },
  1392. );
  1393. }
  1394. Boards.uniqueTitle = title => {
  1395. const m = title.match(
  1396. new RegExp('^(?<title>.*?)\\s*(\\[(?<num>\\d+)]\\s*$|\\s*$)'),
  1397. );
  1398. const base = escapeForRegex(m.groups.title);
  1399. const baseTitle = m.groups.title;
  1400. boards = ReactiveCache.getBoards({ title: new RegExp(`^${base}\\s*(\\[(?<num>\\d+)]\\s*$|\\s*$)`) });
  1401. if (boards.length > 0) {
  1402. let num = 0;
  1403. ReactiveCache.getBoards({ title: new RegExp(`^${base}\\s*\\[\\d+]\\s*$`) }).forEach(
  1404. board => {
  1405. const m = board.title.match(
  1406. new RegExp('^(?<title>.*?)\\s*\\[(?<num>\\d+)]\\s*$'),
  1407. );
  1408. if (m) {
  1409. const n = parseInt(m.groups.num, 10);
  1410. num = num < n ? n : num;
  1411. }
  1412. },
  1413. );
  1414. return `${baseTitle} [${num + 1}]`;
  1415. }
  1416. return title;
  1417. };
  1418. Boards.userSearch = (
  1419. userId,
  1420. selector = {},
  1421. projection = {},
  1422. // includeArchived = false,
  1423. ) => {
  1424. // if (!includeArchived) {
  1425. // selector.archived = false;
  1426. // }
  1427. selector.$or = [{ permission: 'public' }];
  1428. if (userId) {
  1429. selector.$or.push({ members: { $elemMatch: { userId, isActive: true } } });
  1430. }
  1431. const ret = ReactiveCache.getBoards(selector, projection);
  1432. return ret;
  1433. };
  1434. Boards.userBoards = (
  1435. userId,
  1436. archived = false,
  1437. selector = {},
  1438. projection = {},
  1439. ) => {
  1440. const user = ReactiveCache.getUser(userId);
  1441. if (!user) {
  1442. return [];
  1443. }
  1444. if (typeof archived === 'boolean') {
  1445. selector.archived = archived;
  1446. }
  1447. if (!selector.type) {
  1448. selector.type = 'board';
  1449. }
  1450. selector.$or = [
  1451. { permission: 'public' },
  1452. { members: { $elemMatch: { userId, isActive: true } } },
  1453. { orgs: { $elemMatch: { orgId: { $in: user.orgIds() }, isActive: true } } },
  1454. { teams: { $elemMatch: { teamId: { $in: user.teamIds() }, isActive: true } } },
  1455. ];
  1456. return ReactiveCache.getBoards(selector, projection);
  1457. };
  1458. Boards.userBoardIds = (userId, archived = false, selector = {}) => {
  1459. return Boards.userBoards(userId, archived, selector, {
  1460. fields: { _id: 1 },
  1461. }).map(board => {
  1462. return board._id;
  1463. });
  1464. };
  1465. Boards.colorMap = () => {
  1466. const colors = {};
  1467. for (const color of Boards.labelColors()) {
  1468. colors[TAPi18n.__(`color-${color}`)] = color;
  1469. }
  1470. return colors;
  1471. };
  1472. Boards.labelColors = () => {
  1473. return ALLOWED_COLORS;
  1474. };
  1475. if (Meteor.isServer) {
  1476. Boards.allow({
  1477. insert: Meteor.userId,
  1478. update: allowIsBoardAdmin,
  1479. remove: allowIsBoardAdmin,
  1480. fetch: ['members'],
  1481. });
  1482. // All logged in users are allowed to reorder boards by dragging at All Boards page and Public Boards page.
  1483. Boards.allow({
  1484. update(userId, board, fieldNames) {
  1485. return _.contains(fieldNames, 'sort');
  1486. },
  1487. fetch: [],
  1488. });
  1489. // The number of users that have starred this board is managed by trusted code
  1490. // and the user is not allowed to update it
  1491. Boards.deny({
  1492. update(userId, board, fieldNames) {
  1493. return _.contains(fieldNames, 'stars');
  1494. },
  1495. fetch: [],
  1496. });
  1497. // We can't remove a member if it is the last administrator
  1498. Boards.deny({
  1499. update(userId, doc, fieldNames, modifier) {
  1500. if (!_.contains(fieldNames, 'members')) return false;
  1501. // We only care in case of a $pull operation, ie remove a member
  1502. if (!_.isObject(modifier.$pull && modifier.$pull.members)) return false;
  1503. // If there is more than one admin, it's ok to remove anyone
  1504. const nbAdmins = _.where(doc.members, { isActive: true, isAdmin: true })
  1505. .length;
  1506. if (nbAdmins > 1) return false;
  1507. // If all the previous conditions were verified, we can't remove
  1508. // a user if it's an admin
  1509. const removedMemberId = modifier.$pull.members.userId;
  1510. return Boolean(
  1511. _.findWhere(doc.members, {
  1512. userId: removedMemberId,
  1513. isAdmin: true,
  1514. }),
  1515. );
  1516. },
  1517. fetch: ['members'],
  1518. });
  1519. Meteor.methods({
  1520. getBackgroundImageURL(boardId) {
  1521. check(boardId, String);
  1522. return ReactiveCache.getBoard(boardId, {}, { backgroundImageUrl: 1 });
  1523. },
  1524. quitBoard(boardId) {
  1525. check(boardId, String);
  1526. const board = ReactiveCache.getBoard(boardId);
  1527. if (board) {
  1528. const userId = Meteor.userId();
  1529. const index = board.memberIndex(userId);
  1530. if (index >= 0) {
  1531. board.removeMember(userId);
  1532. return true;
  1533. } else throw new Meteor.Error('error-board-notAMember');
  1534. } else throw new Meteor.Error('error-board-doesNotExist');
  1535. },
  1536. acceptInvite(boardId) {
  1537. check(boardId, String);
  1538. const board = ReactiveCache.getBoard(boardId);
  1539. if (!board) {
  1540. throw new Meteor.Error('error-board-doesNotExist');
  1541. }
  1542. Meteor.users.update(Meteor.userId(), {
  1543. $pull: {
  1544. 'profile.invitedBoards': boardId,
  1545. },
  1546. });
  1547. },
  1548. myLabelNames() {
  1549. let names = [];
  1550. Boards.userBoards(Meteor.userId()).forEach(board => {
  1551. // Only return labels when they exist.
  1552. if (board.labels !== undefined) {
  1553. names = names.concat(
  1554. board.labels
  1555. .filter(label => !!label.name)
  1556. .map(label => {
  1557. return label.name;
  1558. }),
  1559. );
  1560. } else {
  1561. return [];
  1562. }
  1563. });
  1564. return _.uniq(names).sort();
  1565. },
  1566. myBoardNames() {
  1567. return _.uniq(
  1568. Boards.userBoards(Meteor.userId()).map(board => {
  1569. return board.title;
  1570. }),
  1571. ).sort();
  1572. },
  1573. });
  1574. Meteor.methods({
  1575. archiveBoard(boardId) {
  1576. check(boardId, String);
  1577. const board = ReactiveCache.getBoard(boardId);
  1578. if (board) {
  1579. const userId = Meteor.userId();
  1580. const index = board.memberIndex(userId);
  1581. if (index >= 0) {
  1582. board.archive();
  1583. return true;
  1584. } else throw new Meteor.Error('error-board-notAMember');
  1585. } else throw new Meteor.Error('error-board-doesNotExist');
  1586. },
  1587. setBoardOrgs(boardOrgsArray, currBoardId){
  1588. check(boardOrgsArray, Array);
  1589. check(currBoardId, String);
  1590. Boards.update(currBoardId, {
  1591. $set: {
  1592. orgs: boardOrgsArray,
  1593. },
  1594. });
  1595. },
  1596. setBoardTeams(boardTeamsArray, membersArray, currBoardId){
  1597. check(boardTeamsArray, Array);
  1598. check(membersArray, Array);
  1599. check(currBoardId, String);
  1600. Boards.update(currBoardId, {
  1601. $set: {
  1602. members: membersArray,
  1603. teams: boardTeamsArray,
  1604. },
  1605. });
  1606. },
  1607. });
  1608. }
  1609. // Insert new board at last position in sort order.
  1610. Boards.before.insert((userId, doc) => {
  1611. const lastBoard = ReactiveCache.getBoard(
  1612. { sort: { $exists: true } },
  1613. { sort: { sort: -1 } },
  1614. );
  1615. if (lastBoard && typeof lastBoard.sort !== 'undefined') {
  1616. doc.sort = lastBoard.sort + 1;
  1617. }
  1618. });
  1619. if (Meteor.isServer) {
  1620. // Let MongoDB ensure that a member is not included twice in the same board
  1621. Meteor.startup(() => {
  1622. Boards._collection.createIndex({ modifiedAt: -1 });
  1623. Boards._collection.createIndex(
  1624. {
  1625. _id: 1,
  1626. 'members.userId': 1,
  1627. },
  1628. { unique: true },
  1629. );
  1630. Boards._collection.createIndex({ 'members.userId': 1 });
  1631. });
  1632. // Genesis: the first activity of the newly created board
  1633. Boards.after.insert((userId, doc) => {
  1634. Activities.insert({
  1635. userId,
  1636. type: 'board',
  1637. activityTypeId: doc._id,
  1638. activityType: 'createBoard',
  1639. boardId: doc._id,
  1640. });
  1641. });
  1642. // If the user remove one label from a board, we cant to remove reference of
  1643. // this label in any card of this board.
  1644. Boards.after.update((userId, doc, fieldNames, modifier) => {
  1645. if (
  1646. !_.contains(fieldNames, 'labels') ||
  1647. !modifier.$pull ||
  1648. !modifier.$pull.labels ||
  1649. !modifier.$pull.labels._id
  1650. ) {
  1651. return;
  1652. }
  1653. const removedLabelId = modifier.$pull.labels._id;
  1654. Cards.update(
  1655. { boardId: doc._id },
  1656. {
  1657. $pull: {
  1658. labelIds: removedLabelId,
  1659. },
  1660. },
  1661. { multi: true },
  1662. );
  1663. });
  1664. const foreachRemovedMember = (doc, modifier, callback) => {
  1665. Object.keys(modifier).forEach(set => {
  1666. if (modifier[set] !== false) {
  1667. return;
  1668. }
  1669. const parts = set.split('.');
  1670. if (
  1671. parts.length === 3 &&
  1672. parts[0] === 'members' &&
  1673. parts[2] === 'isActive'
  1674. ) {
  1675. callback(doc.members[parts[1]].userId);
  1676. }
  1677. });
  1678. };
  1679. // Remove a member from all objects of the board before leaving the board
  1680. Boards.before.update((userId, doc, fieldNames, modifier) => {
  1681. if (!_.contains(fieldNames, 'members')) {
  1682. return;
  1683. }
  1684. if (modifier.$set) {
  1685. const boardId = doc._id;
  1686. foreachRemovedMember(doc, modifier.$set, memberId => {
  1687. Cards.update(
  1688. { boardId },
  1689. {
  1690. $pull: {
  1691. members: memberId,
  1692. watchers: memberId,
  1693. },
  1694. },
  1695. { multi: true },
  1696. );
  1697. Lists.update(
  1698. { boardId },
  1699. {
  1700. $pull: {
  1701. watchers: memberId,
  1702. },
  1703. },
  1704. { multi: true },
  1705. );
  1706. const board = Boards._transform(doc);
  1707. board.setWatcher(memberId, false);
  1708. // Remove board from users starred list
  1709. if (!board.isPublic()) {
  1710. Users.update(memberId, {
  1711. $pull: {
  1712. 'profile.starredBoards': boardId,
  1713. },
  1714. });
  1715. }
  1716. });
  1717. }
  1718. });
  1719. Boards.before.remove((userId, doc) => {
  1720. boardRemover(userId, doc);
  1721. // Add removeBoard activity to keep it
  1722. Activities.insert({
  1723. userId,
  1724. type: 'board',
  1725. activityTypeId: doc._id,
  1726. activityType: 'removeBoard',
  1727. boardId: doc._id,
  1728. });
  1729. });
  1730. // Add a new activity if we add or remove a member to the board
  1731. Boards.after.update((userId, doc, fieldNames, modifier) => {
  1732. if (!_.contains(fieldNames, 'members')) {
  1733. return;
  1734. }
  1735. // Say hello to the new member
  1736. if (modifier.$push && modifier.$push.members) {
  1737. const memberId = modifier.$push.members.userId;
  1738. Activities.insert({
  1739. userId,
  1740. memberId,
  1741. type: 'member',
  1742. activityType: 'addBoardMember',
  1743. boardId: doc._id,
  1744. });
  1745. }
  1746. // Say goodbye to the former member
  1747. if (modifier.$set) {
  1748. foreachRemovedMember(doc, modifier.$set, memberId => {
  1749. Activities.insert({
  1750. userId,
  1751. memberId,
  1752. type: 'member',
  1753. activityType: 'removeBoardMember',
  1754. boardId: doc._id,
  1755. });
  1756. });
  1757. }
  1758. });
  1759. }
  1760. //BOARDS REST API
  1761. if (Meteor.isServer) {
  1762. /**
  1763. * @operation get_boards_from_user
  1764. * @summary Get all boards attached to a user
  1765. *
  1766. * @param {string} userId the ID of the user to retrieve the data
  1767. * @return_type [{_id: string,
  1768. title: string}]
  1769. */
  1770. JsonRoutes.add('GET', '/api/users/:userId/boards', function(req, res) {
  1771. try {
  1772. Authentication.checkLoggedIn(req.userId);
  1773. const paramUserId = req.params.userId;
  1774. // A normal user should be able to see their own boards,
  1775. // admins can access boards of any user
  1776. Authentication.checkAdminOrCondition(
  1777. req.userId,
  1778. req.userId === paramUserId,
  1779. );
  1780. const data = ReactiveCache.getBoards(
  1781. {
  1782. archived: false,
  1783. 'members.userId': paramUserId,
  1784. },
  1785. {
  1786. sort: { sort: 1 /* boards default sorting */ },
  1787. },
  1788. ).map(function(board) {
  1789. return {
  1790. _id: board._id,
  1791. title: board.title,
  1792. };
  1793. });
  1794. JsonRoutes.sendResult(res, { code: 200, data });
  1795. } catch (error) {
  1796. JsonRoutes.sendResult(res, {
  1797. code: 200,
  1798. data: error,
  1799. });
  1800. }
  1801. });
  1802. /**
  1803. * @operation get_public_boards
  1804. * @summary Get all public boards
  1805. *
  1806. * @return_type [{_id: string,
  1807. title: string}]
  1808. */
  1809. JsonRoutes.add('GET', '/api/boards', function(req, res) {
  1810. try {
  1811. Authentication.checkUserId(req.userId);
  1812. JsonRoutes.sendResult(res, {
  1813. code: 200,
  1814. data: ReactiveCache.getBoards(
  1815. { permission: 'public' },
  1816. {
  1817. sort: { sort: 1 /* boards default sorting */ },
  1818. },
  1819. ).map(function(doc) {
  1820. return {
  1821. _id: doc._id,
  1822. title: doc.title,
  1823. };
  1824. }),
  1825. });
  1826. } catch (error) {
  1827. JsonRoutes.sendResult(res, {
  1828. code: 200,
  1829. data: error,
  1830. });
  1831. }
  1832. });
  1833. /**
  1834. * @operation get_boards_count
  1835. * @summary Get public and private boards count
  1836. *
  1837. * @return_type {private: integer, public: integer}
  1838. */
  1839. JsonRoutes.add('GET', '/api/boards_count', function(req, res) {
  1840. try {
  1841. Authentication.checkUserId(req.userId);
  1842. JsonRoutes.sendResult(res, {
  1843. code: 200,
  1844. data: {
  1845. private: ReactiveCache.getBoards({ permission: 'private' }).length,
  1846. public: ReactiveCache.getBoards({ permission: 'public' }).length,
  1847. },
  1848. });
  1849. } catch (error) {
  1850. JsonRoutes.sendResult(res, {
  1851. code: 200,
  1852. data: error,
  1853. });
  1854. }
  1855. });
  1856. /**
  1857. * @operation get_board
  1858. * @summary Get the board with that particular ID
  1859. *
  1860. * @param {string} boardId the ID of the board to retrieve the data
  1861. * @return_type Boards
  1862. */
  1863. JsonRoutes.add('GET', '/api/boards/:boardId', function(req, res) {
  1864. try {
  1865. const paramBoardId = req.params.boardId;
  1866. Authentication.checkBoardAccess(req.userId, paramBoardId);
  1867. JsonRoutes.sendResult(res, {
  1868. code: 200,
  1869. data: ReactiveCache.getBoard(paramBoardId),
  1870. });
  1871. } catch (error) {
  1872. JsonRoutes.sendResult(res, {
  1873. code: 200,
  1874. data: error,
  1875. });
  1876. }
  1877. });
  1878. /**
  1879. * @operation new_board
  1880. * @summary Create a board
  1881. *
  1882. * @description This allows to create a board.
  1883. *
  1884. * The color has to be chosen between `belize`, `nephritis`, `pomegranate`,
  1885. * `pumpkin`, `wisteria`, `moderatepink`, `strongcyan`,
  1886. * `limegreen`, `midnight`, `dark`, `relax`, `corteza`:
  1887. *
  1888. * <img src="https://wekan.github.io/board-colors.png" width="40%" alt="Wekan logo" />
  1889. *
  1890. * @param {string} title the new title of the board
  1891. * @param {string} owner "ABCDE12345" <= User ID in Wekan.
  1892. * (Not username or email)
  1893. * @param {boolean} [isAdmin] is the owner an admin of the board (default true)
  1894. * @param {boolean} [isActive] is the board active (default true)
  1895. * @param {boolean} [isNoComments] disable comments (default false)
  1896. * @param {boolean} [isCommentOnly] only enable comments (default false)
  1897. * @param {boolean} [isWorker] only move cards, assign himself to card and comment (default false)
  1898. * @param {string} [permission] "private" board <== Set to "public" if you
  1899. * want public Wekan board
  1900. * @param {string} [color] the color of the board
  1901. *
  1902. * @return_type {_id: string,
  1903. defaultSwimlaneId: string}
  1904. */
  1905. JsonRoutes.add('POST', '/api/boards', function(req, res) {
  1906. try {
  1907. Authentication.checkLoggedIn(req.userId);
  1908. const id = Boards.insert({
  1909. title: req.body.title,
  1910. members: [
  1911. {
  1912. userId: req.body.owner,
  1913. isAdmin: req.body.isAdmin || true,
  1914. isActive: req.body.isActive || true,
  1915. isNoComments: req.body.isNoComments || false,
  1916. isCommentOnly: req.body.isCommentOnly || false,
  1917. isWorker: req.body.isWorker || false,
  1918. },
  1919. ],
  1920. permission: req.body.permission || 'private',
  1921. color: req.body.color || 'belize',
  1922. });
  1923. const swimlaneId = Swimlanes.insert({
  1924. title: TAPi18n.__('default'),
  1925. boardId: id,
  1926. });
  1927. JsonRoutes.sendResult(res, {
  1928. code: 200,
  1929. data: {
  1930. _id: id,
  1931. defaultSwimlaneId: swimlaneId,
  1932. },
  1933. });
  1934. } catch (error) {
  1935. JsonRoutes.sendResult(res, {
  1936. code: 200,
  1937. data: error,
  1938. });
  1939. }
  1940. });
  1941. /**
  1942. * @operation delete_board
  1943. * @summary Delete a board
  1944. *
  1945. * @param {string} boardId the ID of the board
  1946. */
  1947. JsonRoutes.add('DELETE', '/api/boards/:boardId', function(req, res) {
  1948. try {
  1949. Authentication.checkUserId(req.userId);
  1950. const id = req.params.boardId;
  1951. Boards.remove({ _id: id });
  1952. JsonRoutes.sendResult(res, {
  1953. code: 200,
  1954. data: {
  1955. _id: id,
  1956. },
  1957. });
  1958. } catch (error) {
  1959. JsonRoutes.sendResult(res, {
  1960. code: 200,
  1961. data: error,
  1962. });
  1963. }
  1964. });
  1965. /**
  1966. * @operation add_board_label
  1967. * @summary Add a label to a board
  1968. *
  1969. * @description If the board doesn't have the name/color label, this function
  1970. * adds the label to the board.
  1971. *
  1972. * @param {string} boardId the board
  1973. * @param {string} color the color of the new label
  1974. * @param {string} name the name of the new label
  1975. *
  1976. * @return_type string
  1977. */
  1978. JsonRoutes.add('PUT', '/api/boards/:boardId/labels', function(req, res) {
  1979. const id = req.params.boardId;
  1980. Authentication.checkBoardAccess(req.userId, id);
  1981. try {
  1982. if (req.body.hasOwnProperty('label')) {
  1983. const board = ReactiveCache.getBoard(id);
  1984. const color = req.body.label.color;
  1985. const name = req.body.label.name;
  1986. const labelId = Random.id(6);
  1987. if (!board.getLabel(name, color)) {
  1988. Boards.direct.update(
  1989. { _id: id },
  1990. { $push: { labels: { _id: labelId, name, color } } },
  1991. );
  1992. JsonRoutes.sendResult(res, {
  1993. code: 200,
  1994. data: labelId,
  1995. });
  1996. } else {
  1997. JsonRoutes.sendResult(res, {
  1998. code: 200,
  1999. });
  2000. }
  2001. }
  2002. } catch (error) {
  2003. JsonRoutes.sendResult(res, {
  2004. data: error,
  2005. });
  2006. }
  2007. });
  2008. /**
  2009. * @operation set_board_member_permission
  2010. * @tag Users
  2011. * @summary Change the permission of a member of a board
  2012. *
  2013. * @param {string} boardId the ID of the board that we are changing
  2014. * @param {string} memberId the ID of the user to change permissions
  2015. * @param {boolean} isAdmin admin capability
  2016. * @param {boolean} isNoComments NoComments capability
  2017. * @param {boolean} isCommentOnly CommentsOnly capability
  2018. * @param {boolean} isWorker Worker capability
  2019. */
  2020. JsonRoutes.add('POST', '/api/boards/:boardId/members/:memberId', function(
  2021. req,
  2022. res,
  2023. ) {
  2024. try {
  2025. Authentication.checkUserId(req.userId);
  2026. const boardId = req.params.boardId;
  2027. const memberId = req.params.memberId;
  2028. const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
  2029. const board = ReactiveCache.getBoard(boardId);
  2030. function isTrue(data) {
  2031. try {
  2032. return data.toLowerCase() === 'true';
  2033. } catch (error) {
  2034. return data;
  2035. }
  2036. }
  2037. const query = board.setMemberPermission(
  2038. memberId,
  2039. isTrue(isAdmin),
  2040. isTrue(isNoComments),
  2041. isTrue(isCommentOnly),
  2042. isTrue(isWorker),
  2043. req.userId,
  2044. );
  2045. JsonRoutes.sendResult(res, {
  2046. code: 200,
  2047. data: query,
  2048. });
  2049. } catch (error) {
  2050. JsonRoutes.sendResult(res, {
  2051. code: 200,
  2052. data: error,
  2053. });
  2054. }
  2055. });
  2056. //ATTACHMENTS REST API
  2057. /**
  2058. * @operation get_board_attachments
  2059. * @summary Get the list of attachments of a board
  2060. *
  2061. * @param {string} boardId the board ID
  2062. * @return_type [{attachmentId: string,
  2063. * attachmentName: string,
  2064. * attachmentType: string,
  2065. * url: string,
  2066. * urlDownload: string,
  2067. * boardId: string,
  2068. * swimlaneId: string,
  2069. * listId: string,
  2070. * cardId: string
  2071. * }]
  2072. */
  2073. JsonRoutes.add('GET', '/api/boards/:boardId/attachments', function(req, res) {
  2074. const paramBoardId = req.params.boardId;
  2075. Authentication.checkBoardAccess(req.userId, paramBoardId);
  2076. JsonRoutes.sendResult(res, {
  2077. code: 200,
  2078. data: Attachments
  2079. .find({'meta.boardId': paramBoardId })
  2080. .each()
  2081. .map(function(attachment) {
  2082. return {
  2083. attachmentId: attachment._id,
  2084. attachmentName: attachment.name,
  2085. attachmentType: attachment.type,
  2086. url: attachment.link(),
  2087. urlDownload: `${attachment.link()}?download=true&token=`,
  2088. boardId: attachment.meta.boardId,
  2089. swimlaneId: attachment.meta.swimlaneId,
  2090. listId: attachment.meta.listId,
  2091. cardId: attachment.meta.cardId
  2092. };
  2093. }),
  2094. });
  2095. });
  2096. }
  2097. export default Boards;