cardDetails.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882
  1. import moment from 'moment/min/moment-with-locales';
  2. import { TAPi18n } from '/imports/i18n';
  3. import { DatePicker } from '/client/lib/datepicker';
  4. import Cards from '/models/cards';
  5. import Boards from '/models/boards';
  6. import Checklists from '/models/checklists';
  7. import Integrations from '/models/integrations';
  8. import Users from '/models/users';
  9. import Lists from '/models/lists';
  10. import CardComments from '/models/cardComments';
  11. import { ALLOWED_COLORS } from '/config/const';
  12. import { UserAvatar } from '../users/userAvatar';
  13. const subManager = new SubsManager();
  14. const { calculateIndexData } = Utils;
  15. BlazeComponent.extendComponent({
  16. mixins() {
  17. return [Mixins.InfiniteScrolling];
  18. },
  19. calculateNextPeak() {
  20. const cardElement = this.find('.js-card-details');
  21. if (cardElement) {
  22. const altitude = cardElement.scrollHeight;
  23. this.callFirstWith(this, 'setNextPeak', altitude);
  24. }
  25. },
  26. reachNextPeak() {
  27. const activitiesComponent = this.childComponents('activities')[0];
  28. activitiesComponent.loadNextPage();
  29. },
  30. onCreated() {
  31. this.currentBoard = Utils.getCurrentBoard();
  32. this.isLoaded = new ReactiveVar(false);
  33. if (this.parentComponent() && this.parentComponent().parentComponent()) {
  34. const boardBody = this.parentComponent().parentComponent();
  35. //in Miniview parent is Board, not BoardBody.
  36. if (boardBody !== null) {
  37. boardBody.showOverlay.set(true);
  38. boardBody.mouseHasEnterCardDetails = false;
  39. }
  40. }
  41. this.calculateNextPeak();
  42. Meteor.subscribe('unsaved-edits');
  43. // this.findUsersOptions = new ReactiveVar({});
  44. // this.page = new ReactiveVar(1);
  45. // this.autorun(() => {
  46. // const limitUsers = this.page.get() * Number.MAX_SAFE_INTEGER;
  47. // this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});
  48. // });
  49. },
  50. isWatching() {
  51. const card = this.currentData();
  52. return card.findWatcher(Meteor.userId());
  53. },
  54. hiddenSystemMessages() {
  55. return Meteor.user().hasHiddenSystemMessages();
  56. },
  57. customFieldsGrid() {
  58. return Meteor.user().hasCustomFieldsGrid();
  59. },
  60. cardMaximized() {
  61. return !Utils.getPopupCardId() && Meteor.user().hasCardMaximized();
  62. },
  63. canModifyCard() {
  64. return (
  65. Meteor.user() &&
  66. Meteor.user().isBoardMember() &&
  67. !Meteor.user().isCommentOnly() &&
  68. !Meteor.user().isWorker()
  69. );
  70. },
  71. scrollParentContainer() {
  72. const cardPanelWidth = 600;
  73. const parentComponent = this.parentComponent();
  74. /*
  75. // Incomplete fix about bug where opening card scrolls to wrong place
  76. // https://github.com/wekan/wekan/issues/4572#issuecomment-1184149395
  77. // TODO sometimes parentComponent is not available, maybe because it's not
  78. // yet created?!
  79. if (!parentComponent) return;
  80. const bodyBoardComponent = parentComponent.parentComponent();
  81. */
  82. //On Mobile View Parent is Board, Not Board Body. I cant see how this funciton should work then.
  83. if (bodyBoardComponent === null) return;
  84. const $cardView = this.$(this.firstNode());
  85. const $cardContainer = bodyBoardComponent.$('.js-swimlanes');
  86. /*
  87. // Incomplete fix about bug where opening card scrolls to wrong place
  88. // https://github.com/wekan/wekan/issues/4572#issuecomment-1184149395
  89. // TODO sometimes cardContainer is not available, maybe because it's not yet
  90. // created?!
  91. if (!$cardContainer) return;
  92. */
  93. const cardContainerScroll = $cardContainer.scrollLeft();
  94. const cardContainerWidth = $cardContainer.width();
  95. const cardViewStart = $cardView.offset().left;
  96. const cardViewEnd = cardViewStart + cardPanelWidth;
  97. let offset = false;
  98. if (cardViewStart < 0) {
  99. offset = cardViewStart;
  100. } else if (cardViewEnd > cardContainerWidth) {
  101. offset = cardViewEnd - cardContainerWidth;
  102. }
  103. if (offset) {
  104. bodyBoardComponent.scrollLeft(cardContainerScroll + offset);
  105. }
  106. //Scroll top
  107. const cardViewStartTop = $cardView.offset().top;
  108. const cardContainerScrollTop = $cardContainer.scrollTop();
  109. let topOffset = false;
  110. if (cardViewStartTop !== 100) {
  111. topOffset = cardViewStartTop - 100;
  112. }
  113. if (topOffset !== false) {
  114. bodyBoardComponent.scrollTop(cardContainerScrollTop + topOffset);
  115. }
  116. },
  117. presentParentTask() {
  118. let result = this.currentBoard.presentParentTask;
  119. if (result === null || result === undefined) {
  120. result = 'no-parent';
  121. }
  122. return result;
  123. },
  124. linkForCard() {
  125. const card = this.currentData();
  126. let result = '#';
  127. if (card) {
  128. const board = Boards.findOne(card.boardId);
  129. if (board) {
  130. result = FlowRouter.path('card', {
  131. boardId: card.boardId,
  132. slug: board.slug,
  133. cardId: card._id,
  134. });
  135. }
  136. }
  137. return result;
  138. },
  139. showVotingButtons() {
  140. const card = this.currentData();
  141. return (
  142. (currentUser.isBoardMember() ||
  143. (currentUser && card.voteAllowNonBoardMembers())) &&
  144. !card.expiredVote()
  145. );
  146. },
  147. showPlanningPokerButtons() {
  148. const card = this.currentData();
  149. return (
  150. (currentUser.isBoardMember() ||
  151. (currentUser && card.pokerAllowNonBoardMembers())) &&
  152. !card.expiredPoker()
  153. );
  154. },
  155. /** returns if the list id is the current list id
  156. * @param listId list id to check
  157. * @return is the list id the current list id ?
  158. */
  159. isCurrentListId(listId) {
  160. const ret = this.data().listId == listId;
  161. return ret;
  162. },
  163. onRendered() {
  164. if (Meteor.settings.public.CARD_OPENED_WEBHOOK_ENABLED) {
  165. // Send Webhook but not create Activities records ---
  166. const card = this.currentData();
  167. const userId = Meteor.userId();
  168. const params = {
  169. userId,
  170. cardId: card._id,
  171. boardId: card.boardId,
  172. listId: card.listId,
  173. user: Meteor.user().username,
  174. url: '',
  175. };
  176. const integrations = Integrations.find({
  177. boardId: { $in: [card.boardId, Integrations.Const.GLOBAL_WEBHOOK_ID] },
  178. enabled: true,
  179. activities: { $in: ['CardDetailsRendered', 'all'] },
  180. }).fetch();
  181. if (integrations.length > 0) {
  182. integrations.forEach((integration) => {
  183. Meteor.call(
  184. 'outgoingWebhooks',
  185. integration,
  186. 'CardSelected',
  187. params,
  188. () => { },
  189. );
  190. });
  191. }
  192. //-------------
  193. }
  194. const $checklistsDom = this.$('.card-checklist-items');
  195. $checklistsDom.sortable({
  196. tolerance: 'pointer',
  197. helper: 'clone',
  198. handle: '.checklist-title',
  199. items: '.js-checklist',
  200. placeholder: 'checklist placeholder',
  201. distance: 7,
  202. start(evt, ui) {
  203. ui.placeholder.height(ui.helper.height());
  204. EscapeActions.clickExecute(evt.target, 'inlinedForm');
  205. },
  206. stop(evt, ui) {
  207. let prevChecklist = ui.item.prev('.js-checklist').get(0);
  208. if (prevChecklist) {
  209. prevChecklist = Blaze.getData(prevChecklist).checklist;
  210. }
  211. let nextChecklist = ui.item.next('.js-checklist').get(0);
  212. if (nextChecklist) {
  213. nextChecklist = Blaze.getData(nextChecklist).checklist;
  214. }
  215. const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);
  216. $checklistsDom.sortable('cancel');
  217. const checklist = Blaze.getData(ui.item.get(0)).checklist;
  218. Checklists.update(checklist._id, {
  219. $set: {
  220. sort: sortIndex.base,
  221. },
  222. });
  223. },
  224. });
  225. const $subtasksDom = this.$('.card-subtasks-items');
  226. $subtasksDom.sortable({
  227. tolerance: 'pointer',
  228. helper: 'clone',
  229. handle: '.subtask-title',
  230. items: '.js-subtasks',
  231. placeholder: 'subtasks placeholder',
  232. distance: 7,
  233. start(evt, ui) {
  234. ui.placeholder.height(ui.helper.height());
  235. EscapeActions.executeUpTo('popup-close');
  236. },
  237. stop(evt, ui) {
  238. let prevChecklist = ui.item.prev('.js-subtasks').get(0);
  239. if (prevChecklist) {
  240. prevChecklist = Blaze.getData(prevChecklist).subtask;
  241. }
  242. let nextChecklist = ui.item.next('.js-subtasks').get(0);
  243. if (nextChecklist) {
  244. nextChecklist = Blaze.getData(nextChecklist).subtask;
  245. }
  246. const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);
  247. $subtasksDom.sortable('cancel');
  248. const subtask = Blaze.getData(ui.item.get(0)).subtask;
  249. Subtasks.update(subtask._id, {
  250. $set: {
  251. subtaskSort: sortIndex.base,
  252. },
  253. });
  254. },
  255. });
  256. function userIsMember() {
  257. return Meteor.user() && Meteor.user().isBoardMember();
  258. }
  259. // Disable sorting if the current user is not a board member
  260. this.autorun(() => {
  261. const disabled = !userIsMember();
  262. if (
  263. $checklistsDom.data('uiSortable') ||
  264. $checklistsDom.data('sortable')
  265. ) {
  266. $checklistsDom.sortable('option', 'disabled', disabled);
  267. if (Utils.isTouchScreenOrShowDesktopDragHandles()) {
  268. $checklistsDom.sortable({ handle: '.checklist-handle' });
  269. }
  270. }
  271. if ($subtasksDom.data('uiSortable') || $subtasksDom.data('sortable')) {
  272. $subtasksDom.sortable('option', 'disabled', disabled);
  273. }
  274. });
  275. },
  276. onDestroyed() {
  277. if (this.parentComponent() === null) return;
  278. const parentComponent = this.parentComponent().parentComponent();
  279. //on mobile view parent is Board, not board body.
  280. if (parentComponent === null) return;
  281. parentComponent.showOverlay.set(false);
  282. },
  283. events() {
  284. const events = {
  285. [`${CSSEvents.transitionend} .js-card-details`]() {
  286. this.isLoaded.set(true);
  287. },
  288. [`${CSSEvents.animationend} .js-card-details`]() {
  289. this.isLoaded.set(true);
  290. },
  291. };
  292. return [
  293. {
  294. ...events,
  295. 'click .js-close-card-details'() {
  296. Utils.goBoardId(this.data().boardId);
  297. },
  298. 'click .js-copy-link'(event) {
  299. event.preventDefault();
  300. const promise = Utils.copyTextToClipboard(event.target.href);
  301. const $tooltip = this.$('.card-details-header .copied-tooltip');
  302. Utils.showCopied(promise, $tooltip);
  303. },
  304. 'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
  305. 'submit .js-card-description'(event) {
  306. event.preventDefault();
  307. const description = this.currentComponent().getValue();
  308. this.data().setDescription(description);
  309. },
  310. 'submit .js-card-details-title'(event) {
  311. event.preventDefault();
  312. const title = this.currentComponent().getValue().trim();
  313. if (title) {
  314. this.data().setTitle(title);
  315. } else {
  316. this.data().setTitle('');
  317. }
  318. },
  319. 'submit .js-card-details-assigner'(event) {
  320. event.preventDefault();
  321. const assigner = this.currentComponent().getValue().trim();
  322. if (assigner) {
  323. this.data().setAssignedBy(assigner);
  324. } else {
  325. this.data().setAssignedBy('');
  326. }
  327. },
  328. 'submit .js-card-details-requester'(event) {
  329. event.preventDefault();
  330. const requester = this.currentComponent().getValue().trim();
  331. if (requester) {
  332. this.data().setRequestedBy(requester);
  333. } else {
  334. this.data().setRequestedBy('');
  335. }
  336. },
  337. 'keydown input.js-edit-card-sort'(evt) {
  338. // enter = save
  339. if (evt.keyCode === 13) {
  340. this.find('button[type=submit]').click();
  341. }
  342. },
  343. 'submit .js-card-details-sort'(event) {
  344. event.preventDefault();
  345. const sort = parseFloat(this.currentComponent()
  346. .getValue()
  347. .trim());
  348. if (!Number.isNaN(sort)) {
  349. let card = this.data();
  350. card.move(card.boardId, card.swimlaneId, card.listId, sort);
  351. }
  352. },
  353. 'change .js-select-card-details-lists'(event) {
  354. let card = this.data();
  355. const listSelect = this.$('.js-select-card-details-lists')[0];
  356. const listId = listSelect.options[listSelect.selectedIndex].value;
  357. const minOrder = card.getMinSort(listId, card.swimlaneId);
  358. card.move(card.boardId, card.swimlaneId, listId, minOrder - 1);
  359. },
  360. 'click .js-go-to-linked-card'() {
  361. Utils.goCardId(this.data().linkedId);
  362. },
  363. 'click .js-member': Popup.open('cardMember'),
  364. 'click .js-add-members': Popup.open('cardMembers'),
  365. 'click .js-assignee': Popup.open('cardAssignee'),
  366. 'click .js-add-assignees': Popup.open('cardAssignees'),
  367. 'click .js-add-labels': Popup.open('cardLabels'),
  368. 'click .js-received-date': Popup.open('editCardReceivedDate'),
  369. 'click .js-start-date': Popup.open('editCardStartDate'),
  370. 'click .js-due-date': Popup.open('editCardDueDate'),
  371. 'click .js-end-date': Popup.open('editCardEndDate'),
  372. 'click .js-show-positive-votes': Popup.open('positiveVoteMembers'),
  373. 'click .js-show-negative-votes': Popup.open('negativeVoteMembers'),
  374. 'click .js-custom-fields': Popup.open('cardCustomFields'),
  375. 'mouseenter .js-card-details'() {
  376. if (this.parentComponent() === null) return;
  377. const parentComponent = this.parentComponent().parentComponent();
  378. //on mobile view parent is Board, not BoardBody.
  379. if (parentComponent === null) return;
  380. parentComponent.showOverlay.set(true);
  381. parentComponent.mouseHasEnterCardDetails = true;
  382. },
  383. 'mousedown .js-card-details'() {
  384. Session.set('cardDetailsIsDragging', false);
  385. Session.set('cardDetailsIsMouseDown', true);
  386. },
  387. 'mousemove .js-card-details'() {
  388. if (Session.get('cardDetailsIsMouseDown')) {
  389. Session.set('cardDetailsIsDragging', true);
  390. }
  391. },
  392. 'mouseup .js-card-details'() {
  393. Session.set('cardDetailsIsDragging', false);
  394. Session.set('cardDetailsIsMouseDown', false);
  395. },
  396. 'click #toggleButton'() {
  397. Meteor.call('toggleSystemMessages');
  398. },
  399. 'click #toggleCustomFieldsGridButton'() {
  400. Meteor.call('toggleCustomFieldsGrid');
  401. },
  402. 'click .js-maximize-card-details'() {
  403. Meteor.call('toggleCardMaximized');
  404. autosize($('.card-details'));
  405. if (!Utils.isMiniScreen()) {
  406. Meteor.setTimeout(() => {
  407. this.scrollParentContainer();
  408. }, 500);
  409. }
  410. },
  411. 'click .js-minimize-card-details'() {
  412. Meteor.call('toggleCardMaximized');
  413. autosize($('.card-details'));
  414. if (!Utils.isMiniScreen()) {
  415. Meteor.setTimeout(() => {
  416. this.scrollParentContainer();
  417. }, 500);
  418. }
  419. },
  420. 'click .js-vote'(e) {
  421. const forIt = $(e.target).hasClass('js-vote-positive');
  422. let newState = null;
  423. if (
  424. this.data().voteState() === null ||
  425. (this.data().voteState() === false && forIt) ||
  426. (this.data().voteState() === true && !forIt)
  427. ) {
  428. newState = forIt;
  429. }
  430. this.data().setVote(Meteor.userId(), newState);
  431. },
  432. 'click .js-poker'(e) {
  433. let newState = null;
  434. if ($(e.target).hasClass('js-poker-vote-one')) {
  435. newState = 'one';
  436. this.data().setPoker(Meteor.userId(), newState);
  437. }
  438. if ($(e.target).hasClass('js-poker-vote-two')) {
  439. newState = 'two';
  440. this.data().setPoker(Meteor.userId(), newState);
  441. }
  442. if ($(e.target).hasClass('js-poker-vote-three')) {
  443. newState = 'three';
  444. this.data().setPoker(Meteor.userId(), newState);
  445. }
  446. if ($(e.target).hasClass('js-poker-vote-five')) {
  447. newState = 'five';
  448. this.data().setPoker(Meteor.userId(), newState);
  449. }
  450. if ($(e.target).hasClass('js-poker-vote-eight')) {
  451. newState = 'eight';
  452. this.data().setPoker(Meteor.userId(), newState);
  453. }
  454. if ($(e.target).hasClass('js-poker-vote-thirteen')) {
  455. newState = 'thirteen';
  456. this.data().setPoker(Meteor.userId(), newState);
  457. }
  458. if ($(e.target).hasClass('js-poker-vote-twenty')) {
  459. newState = 'twenty';
  460. this.data().setPoker(Meteor.userId(), newState);
  461. }
  462. if ($(e.target).hasClass('js-poker-vote-forty')) {
  463. newState = 'forty';
  464. this.data().setPoker(Meteor.userId(), newState);
  465. }
  466. if ($(e.target).hasClass('js-poker-vote-one-hundred')) {
  467. newState = 'oneHundred';
  468. this.data().setPoker(Meteor.userId(), newState);
  469. }
  470. if ($(e.target).hasClass('js-poker-vote-unsure')) {
  471. newState = 'unsure';
  472. this.data().setPoker(Meteor.userId(), newState);
  473. }
  474. },
  475. 'click .js-poker-finish'(e) {
  476. if ($(e.target).hasClass('js-poker-finish')) {
  477. e.preventDefault();
  478. const now = moment().format('YYYY-MM-DD HH:mm');
  479. this.data().setPokerEnd(now);
  480. }
  481. },
  482. 'click .js-poker-replay'(e) {
  483. if ($(e.target).hasClass('js-poker-replay')) {
  484. e.preventDefault();
  485. this.currentCard = this.currentData();
  486. this.currentCard.replayPoker();
  487. this.data().unsetPokerEnd();
  488. this.data().unsetPokerEstimation();
  489. }
  490. },
  491. 'click .js-poker-estimation'(event) {
  492. event.preventDefault();
  493. const ruleTitle = this.find('#pokerEstimation').value;
  494. if (ruleTitle !== undefined && ruleTitle !== '') {
  495. this.find('#pokerEstimation').value = '';
  496. if (ruleTitle) {
  497. this.data().setPokerEstimation(parseInt(ruleTitle, 10));
  498. } else {
  499. this.data().setPokerEstimation('');
  500. }
  501. }
  502. },
  503. },
  504. ];
  505. },
  506. }).register('cardDetails');
  507. Template.cardDetails.helpers({
  508. isPopup() {
  509. let ret = !!Utils.getPopupCardId();
  510. return ret;
  511. }
  512. });
  513. Template.cardDetailsPopup.onDestroyed(() => {
  514. Session.delete('popupCardId');
  515. Session.delete('popupCardBoardId');
  516. });
  517. Template.cardDetailsPopup.helpers({
  518. popupCard() {
  519. const ret = Utils.getPopupCard();
  520. return ret;
  521. },
  522. });
  523. BlazeComponent.extendComponent({
  524. template() {
  525. return 'exportCard';
  526. },
  527. withApi() {
  528. return Template.instance().apiEnabled.get();
  529. },
  530. exportUrlCardPDF() {
  531. const params = {
  532. boardId: Session.get('currentBoard'),
  533. listId: this.listId,
  534. cardId: this.cardId,
  535. };
  536. const queryParams = {
  537. authToken: Accounts._storedLoginToken(),
  538. };
  539. return FlowRouter.path(
  540. '/api/boards/:boardId/lists/:listId/cards/:cardId/exportPDF',
  541. params,
  542. queryParams,
  543. );
  544. },
  545. exportFilenameCardPDF() {
  546. //const boardId = Session.get('currentBoard');
  547. //return `export-card-pdf-${boardId}.xlsx`;
  548. return `export-card.pdf`;
  549. },
  550. }).register('exportCardPopup');
  551. // only allow number input
  552. Template.editCardSortOrderForm.onRendered(function () {
  553. this.$('input').on("keypress paste", function (event) {
  554. let keyCode = event.keyCode;
  555. let charCode = String.fromCharCode(keyCode);
  556. let regex = new RegExp('[-0-9.]');
  557. let ret = regex.test(charCode);
  558. // only working here, defining in events() doesn't handle the return value correctly
  559. return ret;
  560. });
  561. });
  562. // We extends the normal InlinedForm component to support UnsavedEdits draft
  563. // feature.
  564. (class extends InlinedForm {
  565. _getUnsavedEditKey() {
  566. return {
  567. fieldName: 'cardDescription',
  568. // XXX Recovering the currentCard identifier form a session variable is
  569. // fragile because this variable may change for instance if the route
  570. // change. We should use some component props instead.
  571. docId: Utils.getCurrentCardId(),
  572. };
  573. }
  574. close(isReset = false) {
  575. if (this.isOpen.get() && !isReset) {
  576. const draft = this.getValue().trim();
  577. let card = Utils.getCurrentCard();
  578. if (card && draft !== card.getDescription()) {
  579. UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());
  580. }
  581. }
  582. super.close();
  583. }
  584. reset() {
  585. UnsavedEdits.reset(this._getUnsavedEditKey());
  586. this.close(true);
  587. }
  588. events() {
  589. const parentEvents = InlinedForm.prototype.events()[0];
  590. return [
  591. {
  592. ...parentEvents,
  593. 'click .js-close-inlined-form': this.reset,
  594. },
  595. ];
  596. }
  597. }.register('inlinedCardDescription'));
  598. Template.cardDetailsActionsPopup.helpers({
  599. isWatching() {
  600. return this.findWatcher(Meteor.userId());
  601. },
  602. isBoardAdmin() {
  603. return Meteor.user().isBoardAdmin();
  604. },
  605. canModifyCard() {
  606. return (
  607. Meteor.user() &&
  608. Meteor.user().isBoardMember() &&
  609. !Meteor.user().isCommentOnly()
  610. );
  611. },
  612. });
  613. Template.cardDetailsActionsPopup.events({
  614. 'click .js-export-card': Popup.open('exportCard'),
  615. 'click .js-members': Popup.open('cardMembers'),
  616. 'click .js-assignees': Popup.open('cardAssignees'),
  617. 'click .js-attachments': Popup.open('cardAttachments'),
  618. 'click .js-start-voting': Popup.open('cardStartVoting'),
  619. 'click .js-start-planning-poker': Popup.open('cardStartPlanningPoker'),
  620. 'click .js-custom-fields': Popup.open('cardCustomFields'),
  621. 'click .js-received-date': Popup.open('editCardReceivedDate'),
  622. 'click .js-start-date': Popup.open('editCardStartDate'),
  623. 'click .js-due-date': Popup.open('editCardDueDate'),
  624. 'click .js-end-date': Popup.open('editCardEndDate'),
  625. 'click .js-spent-time': Popup.open('editCardSpentTime'),
  626. 'click .js-move-card': Popup.open('moveCard'),
  627. 'click .js-copy-card': Popup.open('copyCard'),
  628. 'click .js-convert-checklist-item-to-card': Popup.open('convertChecklistItemToCard'),
  629. 'click .js-copy-checklist-cards': Popup.open('copyManyCards'),
  630. 'click .js-set-card-color': Popup.open('setCardColor'),
  631. 'click .js-move-card-to-top'(event) {
  632. event.preventDefault();
  633. const minOrder = this.getMinSort();
  634. this.move(this.boardId, this.swimlaneId, this.listId, minOrder - 1);
  635. Popup.back();
  636. },
  637. 'click .js-move-card-to-bottom'(event) {
  638. event.preventDefault();
  639. const maxOrder = this.getMaxSort();
  640. this.move(this.boardId, this.swimlaneId, this.listId, maxOrder + 1);
  641. Popup.back();
  642. },
  643. 'click .js-archive': Popup.afterConfirm('cardArchive', function () {
  644. Popup.close();
  645. this.archive();
  646. Utils.goBoardId(this.boardId);
  647. }),
  648. 'click .js-more': Popup.open('cardMore'),
  649. 'click .js-toggle-watch-card'() {
  650. const currentCard = this;
  651. const level = currentCard.findWatcher(Meteor.userId()) ? null : 'watching';
  652. Meteor.call('watch', 'card', currentCard._id, level, (err, ret) => {
  653. if (!err && ret) Popup.close();
  654. });
  655. },
  656. });
  657. BlazeComponent.extendComponent({
  658. onRendered() {
  659. autosize(this.$('textarea.js-edit-card-title'));
  660. },
  661. events() {
  662. return [
  663. {
  664. 'click a.fa.fa-copy'(event) {
  665. const $editor = this.$('textarea');
  666. const promise = Utils.copyTextToClipboard($editor[0].value);
  667. const $tooltip = this.$('.copied-tooltip');
  668. Utils.showCopied(promise, $tooltip);
  669. },
  670. 'keydown .js-edit-card-title'(event) {
  671. // If enter key was pressed, submit the data
  672. // Unless the shift key is also being pressed
  673. if (event.keyCode === 13 && !event.shiftKey) {
  674. $('.js-submit-edit-card-title-form').click();
  675. }
  676. },
  677. }
  678. ];
  679. }
  680. }).register('editCardTitleForm');
  681. Template.cardMembersPopup.onCreated(function () {
  682. let currBoard = Boards.findOne(Session.get('currentBoard'));
  683. let members = currBoard.activeMembers();
  684. // let query = {
  685. // "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },
  686. // };
  687. // let boardTeamUsers = Users.find(query, {
  688. // sort: { sort: 1 },
  689. // });
  690. // members = currBoard.activeMembers2(members, boardTeamUsers);
  691. this.members = new ReactiveVar(members);
  692. });
  693. Template.cardMembersPopup.events({
  694. 'keyup .card-members-filter'(event) {
  695. const members = filterMembers(event.target.value);
  696. Template.instance().members.set(members);
  697. }
  698. });
  699. Template.cardMembersPopup.helpers({
  700. members() {
  701. return Template.instance().members.get();
  702. },
  703. });
  704. const filterMembers = (filterTerm) => {
  705. let currBoard = Boards.findOne(Session.get('currentBoard'));
  706. let members = currBoard.activeMembers();
  707. // let query = {
  708. // "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },
  709. // };
  710. // let boardTeamUsers = Users.find(query, {
  711. // sort: { sort: 1 },
  712. // });
  713. // members = currBoard.activeMembers2(members, boardTeamUsers);
  714. if (filterTerm) {
  715. members = members
  716. .map(member => ({
  717. member,
  718. user: Users.findOne(member.userId)
  719. }))
  720. .filter(({ user }) =>
  721. (user.profile.fullname !== undefined && user.profile.fullname.toLowerCase().indexOf(filterTerm.toLowerCase()) !== -1)
  722. || user.profile.fullname === undefined && user.profile.username !== undefined && user.profile.username.toLowerCase().indexOf(filterTerm.toLowerCase()) !== -1)
  723. .map(({ member }) => member);
  724. }
  725. return members;
  726. }
  727. Template.editCardRequesterForm.onRendered(function () {
  728. autosize(this.$('.js-edit-card-requester'));
  729. });
  730. Template.editCardRequesterForm.events({
  731. 'keydown .js-edit-card-requester'(event) {
  732. // If enter key was pressed, submit the data
  733. if (event.keyCode === 13) {
  734. $('.js-submit-edit-card-requester-form').click();
  735. }
  736. },
  737. });
  738. Template.editCardAssignerForm.onRendered(function () {
  739. autosize(this.$('.js-edit-card-assigner'));
  740. });
  741. Template.editCardAssignerForm.events({
  742. 'keydown .js-edit-card-assigner'(event) {
  743. // If enter key was pressed, submit the data
  744. if (event.keyCode === 13) {
  745. $('.js-submit-edit-card-assigner-form').click();
  746. }
  747. },
  748. });
  749. class DialogWithBoardSwimlaneList extends BlazeComponent {
  750. /** returns the card dialog options
  751. * @return Object with properties { boardId, swimlaneId, listId }
  752. */
  753. getCardDialogOptions() {
  754. }
  755. /** list is done
  756. * @param listId the selected list id
  757. * @param options the selected options (Object with properties { boardId, swimlaneId, listId })
  758. */
  759. setDone(listId, options) {
  760. }
  761. onCreated() {
  762. this.currentBoardId = Utils.getCurrentBoardId();
  763. this.selectedBoardId = new ReactiveVar(this.currentBoardId);
  764. this.selectedSwimlaneId = new ReactiveVar('');
  765. this.selectedListId = new ReactiveVar('');
  766. this.setCardDialogOption(this.currentBoardId);
  767. }
  768. /** set the last confirmed dialog field values
  769. * @param boardId the current board id
  770. */
  771. setCardDialogOption(boardId) {
  772. this.cardDialogOption = {
  773. 'boardId' : "",
  774. 'swimlaneId' : "",
  775. 'listId' : "",
  776. }
  777. let currentOptions = this.getCardDialogOptions();
  778. if (currentOptions && boardId && currentOptions[boardId]) {
  779. this.cardDialogOption = currentOptions[boardId];
  780. if (this.cardDialogOption.boardId &&
  781. this.cardDialogOption.swimlaneId &&
  782. this.cardDialogOption.listId
  783. )
  784. {
  785. this.selectedBoardId.set(this.cardDialogOption.boardId)
  786. this.selectedSwimlaneId.set(this.cardDialogOption.swimlaneId);
  787. this.selectedListId.set(this.cardDialogOption.listId);
  788. }
  789. }
  790. this.getBoardData(this.selectedBoardId.get());
  791. if (!this.selectedSwimlaneId.get() || !Swimlanes.findOne({_id: this.selectedSwimlaneId.get(), boardId: this.selectedBoardId.get()})) {
  792. this.setFirstSwimlaneId();
  793. }
  794. if (!this.selectedListId.get() || !Lists.findOne({_id: this.selectedListId.get(), boardId: this.selectedBoardId.get()})) {
  795. this.setFirstListId();
  796. }
  797. }
  798. /** sets the first swimlane id */
  799. setFirstSwimlaneId() {
  800. try {
  801. const board = Boards.findOne(this.selectedBoardId.get());
  802. const swimlaneId = board.swimlanes().fetch()[0]._id;
  803. this.selectedSwimlaneId.set(swimlaneId);
  804. } catch (e) {}
  805. }
  806. /** sets the first list id */
  807. setFirstListId() {
  808. try {
  809. const board = Boards.findOne(this.selectedBoardId.get());
  810. const listId = board.lists().fetch()[0]._id;
  811. this.selectedListId.set(listId);
  812. } catch (e) {}
  813. }
  814. /** returns if the board id was the last confirmed one
  815. * @param boardId check this board id
  816. * @return if the board id was the last confirmed one
  817. */
  818. isCardDialogOptionBoardId(boardId) {
  819. let ret = this.cardDialogOption.boardId == boardId;
  820. return ret;
  821. }
  822. /** returns if the swimlane id was the last confirmed one
  823. * @param swimlaneId check this swimlane id
  824. * @return if the swimlane id was the last confirmed one
  825. */
  826. isCardDialogOptionSwimlaneId(swimlaneId) {
  827. let ret = this.cardDialogOption.swimlaneId == swimlaneId;
  828. return ret;
  829. }
  830. /** returns if the list id was the last confirmed one
  831. * @param listId check this list id
  832. * @return if the list id was the last confirmed one
  833. */
  834. isCardDialogOptionListId(listId) {
  835. let ret = this.cardDialogOption.listId == listId;
  836. return ret;
  837. }
  838. /** returns all available board */
  839. boards() {
  840. const ret = Boards.find(
  841. {
  842. archived: false,
  843. 'members.userId': Meteor.userId(),
  844. _id: { $ne: Meteor.user().getTemplatesBoardId() },
  845. },
  846. {
  847. sort: { sort: 1 },
  848. },
  849. );
  850. return ret;
  851. }
  852. /** returns all available swimlanes of the current board */
  853. swimlanes() {
  854. const board = Boards.findOne(this.selectedBoardId.get());
  855. const ret = board.swimlanes();
  856. return ret;
  857. }
  858. /** returns all available lists of the current board */
  859. lists() {
  860. const board = Boards.findOne(this.selectedBoardId.get());
  861. const ret = board.lists();
  862. return ret;
  863. }
  864. /** get the board data from the server
  865. * @param boardId get the board data of this board id
  866. */
  867. getBoardData(boardId) {
  868. const self = this;
  869. Meteor.subscribe('board', boardId, false, {
  870. onReady() {
  871. const sameBoardId = self.selectedBoardId.get() == boardId;
  872. self.selectedBoardId.set(boardId);
  873. if (!sameBoardId) {
  874. // reset swimlane id (for selection in cards())
  875. self.setFirstSwimlaneId();
  876. // reset list id (for selection in cards())
  877. self.setFirstListId();
  878. }
  879. },
  880. });
  881. }
  882. events() {
  883. return [
  884. {
  885. 'click .js-done'() {
  886. const boardSelect = this.$('.js-select-boards')[0];
  887. const boardId = boardSelect.options[boardSelect.selectedIndex].value;
  888. const listSelect = this.$('.js-select-lists')[0];
  889. const listId = listSelect.options[listSelect.selectedIndex].value;
  890. const swimlaneSelect = this.$('.js-select-swimlanes')[0];
  891. const swimlaneId = swimlaneSelect.options[swimlaneSelect.selectedIndex].value;
  892. const options = {
  893. 'boardId' : boardId,
  894. 'swimlaneId' : swimlaneId,
  895. 'listId' : listId,
  896. }
  897. this.setDone(boardId, swimlaneId, listId, options);
  898. Popup.back(2);
  899. },
  900. 'change .js-select-boards'(event) {
  901. const boardId = $(event.currentTarget).val();
  902. this.getBoardData(boardId);
  903. },
  904. 'change .js-select-swimlanes'(event) {
  905. this.selectedSwimlaneId.set($(event.currentTarget).val());
  906. },
  907. },
  908. ];
  909. }
  910. }
  911. /** Move Card Dialog */
  912. (class extends DialogWithBoardSwimlaneList {
  913. getCardDialogOptions() {
  914. const ret = Meteor.user().getMoveAndCopyDialogOptions();
  915. return ret;
  916. }
  917. setDone(boardId, swimlaneId, listId, options) {
  918. Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
  919. const card = this.data();
  920. const minOrder = card.getMinSort(listId, swimlaneId);
  921. card.move(boardId, swimlaneId, listId, minOrder - 1);
  922. }
  923. }).register('moveCardPopup');
  924. /** Copy Card Dialog */
  925. (class extends DialogWithBoardSwimlaneList {
  926. getCardDialogOptions() {
  927. const ret = Meteor.user().getMoveAndCopyDialogOptions();
  928. return ret;
  929. }
  930. setDone(boardId, swimlaneId, listId, options) {
  931. Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
  932. const card = this.data();
  933. // const textarea = $('#copy-card-title');
  934. const textarea = this.$('#copy-card-title');
  935. const title = textarea.val().trim();
  936. if (title) {
  937. // insert new card to the top of new list
  938. const newCardId = Meteor.call('copyCard', card._id, boardId, swimlaneId, listId, true, {title: title});
  939. // In case the filter is active we need to add the newly inserted card in
  940. // the list of exceptions -- cards that are not filtered. Otherwise the
  941. // card will disappear instantly.
  942. // See https://github.com/wekan/wekan/issues/80
  943. Filter.addException(newCardId);
  944. }
  945. }
  946. }).register('copyCardPopup');
  947. Template.convertChecklistItemToCardPopup.events({
  948. 'click .js-done'() {
  949. const card = Utils.getCurrentCard();
  950. const lSelect = $('.js-select-lists')[0];
  951. const listId = lSelect.options[lSelect.selectedIndex].value;
  952. const slSelect = $('.js-select-swimlanes')[0];
  953. const swimlaneId = slSelect.options[slSelect.selectedIndex].value;
  954. const bSelect = $('.js-select-boards')[0];
  955. const boardId = bSelect.options[bSelect.selectedIndex].value;
  956. const textarea = $('#copy-card-title');
  957. const title = textarea.val().trim();
  958. if (title) {
  959. const _id = Cards.insert({
  960. title: title,
  961. listId: listId,
  962. boardId: boardId,
  963. swimlaneId: swimlaneId,
  964. sort: 0,
  965. });
  966. Filter.addException(_id);
  967. Popup.back();
  968. }
  969. },
  970. });
  971. /** Copy many cards dialog */
  972. (class extends DialogWithBoardSwimlaneList {
  973. getCardDialogOptions() {
  974. const ret = Meteor.user().getMoveAndCopyDialogOptions();
  975. return ret;
  976. }
  977. setDone(boardId, swimlaneId, listId, options) {
  978. Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
  979. const card = this.data();
  980. const textarea = this.$('#copy-card-title');
  981. const title = textarea.val().trim();
  982. if (title) {
  983. const titleList = JSON.parse(title);
  984. for (const obj of titleList) {
  985. const newCardId = Meteor.call('copyCard', card._id, boardId, swimlaneId, listId, false, {title: obj.title, description: obj.description});
  986. // In case the filter is active we need to add the newly inserted card in
  987. // the list of exceptions -- cards that are not filtered. Otherwise the
  988. // card will disappear instantly.
  989. // See https://github.com/wekan/wekan/issues/80
  990. Filter.addException(newCardId);
  991. }
  992. }
  993. }
  994. }).register('copyManyCardsPopup');
  995. BlazeComponent.extendComponent({
  996. onCreated() {
  997. this.currentCard = this.currentData();
  998. this.currentColor = new ReactiveVar(this.currentCard.color);
  999. },
  1000. colors() {
  1001. return ALLOWED_COLORS.map((color) => ({ color, name: '' }));
  1002. },
  1003. isSelected(color) {
  1004. if (this.currentColor.get() === null) {
  1005. return color === 'white';
  1006. }
  1007. return this.currentColor.get() === color;
  1008. },
  1009. events() {
  1010. return [
  1011. {
  1012. 'click .js-palette-color'() {
  1013. this.currentColor.set(this.currentData().color);
  1014. },
  1015. 'click .js-submit'() {
  1016. this.currentCard.setColor(this.currentColor.get());
  1017. Popup.close();
  1018. },
  1019. 'click .js-remove-color'() {
  1020. this.currentCard.setColor(null);
  1021. Popup.close();
  1022. },
  1023. },
  1024. ];
  1025. },
  1026. }).register('setCardColorPopup');
  1027. BlazeComponent.extendComponent({
  1028. onCreated() {
  1029. this.currentCard = this.currentData();
  1030. this.parentBoard = new ReactiveVar(null);
  1031. this.parentCard = this.currentCard.parentCard();
  1032. if (this.parentCard) {
  1033. const list = $('.js-field-parent-card');
  1034. list.val(this.parentCard._id);
  1035. this.parentBoard.set(this.parentCard.board()._id);
  1036. } else {
  1037. this.parentBoard.set(null);
  1038. }
  1039. },
  1040. boards() {
  1041. return Boards.find(
  1042. {
  1043. archived: false,
  1044. 'members.userId': Meteor.userId(),
  1045. _id: {
  1046. $ne: Meteor.user().getTemplatesBoardId(),
  1047. },
  1048. },
  1049. {
  1050. sort: { sort: 1 /* boards default sorting */ },
  1051. },
  1052. );
  1053. },
  1054. cards() {
  1055. const currentId = Utils.getCurrentCardId();
  1056. if (this.parentBoard.get()) {
  1057. return Cards.find({
  1058. boardId: this.parentBoard.get(),
  1059. _id: { $ne: currentId },
  1060. });
  1061. } else {
  1062. return [];
  1063. }
  1064. },
  1065. isParentBoard() {
  1066. const board = this.currentData();
  1067. if (this.parentBoard.get()) {
  1068. return board._id === this.parentBoard.get();
  1069. }
  1070. return false;
  1071. },
  1072. isParentCard() {
  1073. const card = this.currentData();
  1074. if (this.parentCard) {
  1075. return card._id === this.parentCard;
  1076. }
  1077. return false;
  1078. },
  1079. setParentCardId(cardId) {
  1080. if (cardId) {
  1081. this.parentCard = Cards.findOne(cardId);
  1082. } else {
  1083. this.parentCard = null;
  1084. }
  1085. this.currentCard.setParentId(cardId);
  1086. },
  1087. events() {
  1088. return [
  1089. {
  1090. 'click .js-copy-card-link-to-clipboard'(event) {
  1091. const promise = Utils.copyTextToClipboard(location.origin + document.getElementById('cardURL').value);
  1092. const $tooltip = this.$('.copied-tooltip');
  1093. Utils.showCopied(promise, $tooltip);
  1094. },
  1095. 'click .js-delete': Popup.afterConfirm('cardDelete', function () {
  1096. Popup.close();
  1097. // verify that there are no linked cards
  1098. if (Cards.find({ linkedId: this._id }).count() === 0) {
  1099. Cards.remove(this._id);
  1100. } else {
  1101. // TODO: Maybe later we can list where the linked cards are.
  1102. // Now here is popup with a hint that the card cannot be deleted
  1103. // as there are linked cards.
  1104. // Related:
  1105. // client/components/lists/listHeader.js about line 248
  1106. // https://github.com/wekan/wekan/issues/2785
  1107. const message = `${TAPi18n.__(
  1108. 'delete-linked-card-before-this-card',
  1109. )} linkedId: ${this._id
  1110. } at client/components/cards/cardDetails.js and https://github.com/wekan/wekan/issues/2785`;
  1111. alert(message);
  1112. }
  1113. Utils.goBoardId(this.boardId);
  1114. }),
  1115. 'change .js-field-parent-board'(event) {
  1116. const selection = $(event.currentTarget).val();
  1117. const list = $('.js-field-parent-card');
  1118. if (selection === 'none') {
  1119. this.parentBoard.set(null);
  1120. } else {
  1121. subManager.subscribe('board', $(event.currentTarget).val(), false);
  1122. this.parentBoard.set(selection);
  1123. list.prop('disabled', false);
  1124. }
  1125. this.setParentCardId(null);
  1126. },
  1127. 'change .js-field-parent-card'(event) {
  1128. const selection = $(event.currentTarget).val();
  1129. this.setParentCardId(selection);
  1130. },
  1131. },
  1132. ];
  1133. },
  1134. }).register('cardMorePopup');
  1135. BlazeComponent.extendComponent({
  1136. onCreated() {
  1137. this.currentCard = this.currentData();
  1138. this.voteQuestion = new ReactiveVar(this.currentCard.voteQuestion);
  1139. },
  1140. events() {
  1141. return [
  1142. {
  1143. 'click .js-end-date': Popup.open('editVoteEndDate'),
  1144. 'submit .edit-vote-question'(evt) {
  1145. evt.preventDefault();
  1146. const voteQuestion = evt.target.vote.value;
  1147. const publicVote = $('#vote-public').hasClass('is-checked');
  1148. const allowNonBoardMembers = $('#vote-allow-non-members').hasClass(
  1149. 'is-checked',
  1150. );
  1151. const endString = this.currentCard.getVoteEnd();
  1152. this.currentCard.setVoteQuestion(
  1153. voteQuestion,
  1154. publicVote,
  1155. allowNonBoardMembers,
  1156. );
  1157. if (endString) {
  1158. this.currentCard.setVoteEnd(endString);
  1159. }
  1160. Popup.back();
  1161. },
  1162. 'click .js-remove-vote': Popup.afterConfirm('deleteVote', () => {
  1163. event.preventDefault();
  1164. this.currentCard.unsetVote();
  1165. Popup.back();
  1166. }),
  1167. 'click a.js-toggle-vote-public'(event) {
  1168. event.preventDefault();
  1169. $('#vote-public').toggleClass('is-checked');
  1170. },
  1171. 'click a.js-toggle-vote-allow-non-members'(event) {
  1172. event.preventDefault();
  1173. $('#vote-allow-non-members').toggleClass('is-checked');
  1174. },
  1175. },
  1176. ];
  1177. },
  1178. }).register('cardStartVotingPopup');
  1179. // editVoteEndDatePopup
  1180. (class extends DatePicker {
  1181. onCreated() {
  1182. super.onCreated(moment().format('YYYY-MM-DD HH:mm'));
  1183. this.data().getVoteEnd() && this.date.set(moment(this.data().getVoteEnd()));
  1184. }
  1185. events() {
  1186. return [
  1187. {
  1188. 'submit .edit-date'(evt) {
  1189. evt.preventDefault();
  1190. // if no time was given, init with 12:00
  1191. const time =
  1192. evt.target.time.value ||
  1193. moment(new Date().setHours(12, 0, 0)).format('LT');
  1194. const dateString = `${evt.target.date.value} ${time}`;
  1195. /*
  1196. const newDate = moment(dateString, 'L LT', true);
  1197. if (newDate.isValid()) {
  1198. // if active vote - store it
  1199. if (this.currentData().getVoteQuestion()) {
  1200. this._storeDate(newDate.toDate());
  1201. Popup.back();
  1202. } else {
  1203. this.currentData().vote = { end: newDate.toDate() }; // set vote end temp
  1204. Popup.back();
  1205. }
  1206. */
  1207. // Try to parse different date formats of all languages.
  1208. // This code is same for vote and planning poker.
  1209. const usaDate = moment(dateString, 'L LT', true);
  1210. const euroAmDate = moment(dateString, 'DD.MM.YYYY LT', true);
  1211. const euro24hDate = moment(dateString, 'DD.MM.YYYY HH.mm', true);
  1212. const eurodotDate = moment(dateString, 'DD.MM.YYYY HH:mm', true);
  1213. const minusDate = moment(dateString, 'YYYY-MM-DD HH:mm', true);
  1214. const slashDate = moment(dateString, 'DD/MM/YYYY HH.mm', true);
  1215. const dotDate = moment(dateString, 'DD/MM/YYYY HH:mm', true);
  1216. const brezhonegDate = moment(dateString, 'DD/MM/YYYY h[e]mm A', true);
  1217. const hrvatskiDate = moment(dateString, 'DD. MM. YYYY H:mm', true);
  1218. const latviaDate = moment(dateString, 'YYYY.MM.DD. H:mm', true);
  1219. const nederlandsDate = moment(dateString, 'DD-MM-YYYY HH:mm', true);
  1220. // greekDate does not work: el Greek Ελληνικά ,
  1221. // it has date format DD/MM/YYYY h:mm MM like 20/06/2021 11:15 MM
  1222. // where MM is maybe some text like AM/PM ?
  1223. // Also some other languages that have non-ascii characters in dates
  1224. // do not work.
  1225. const greekDate = moment(dateString, 'DD/MM/YYYY h:mm A', true);
  1226. const macedonianDate = moment(dateString, 'D.MM.YYYY H:mm', true);
  1227. if (usaDate.isValid()) {
  1228. // if active poker - store it
  1229. if (this.currentData().getPokerQuestion()) {
  1230. this._storeDate(usaDate.toDate());
  1231. } else {
  1232. this.currentData().poker = { end: usaDate.toDate() }; // set poker end temp
  1233. }
  1234. Popup.back();
  1235. } else if (euroAmDate.isValid()) {
  1236. // if active poker - store it
  1237. if (this.currentData().getPokerQuestion()) {
  1238. this._storeDate(euroAmDate.toDate());
  1239. } else {
  1240. this.currentData().poker = { end: euroAmDate.toDate() }; // set poker end temp
  1241. }
  1242. Popup.back();
  1243. } else if (euro24hDate.isValid()) {
  1244. // if active poker - store it
  1245. if (this.currentData().getPokerQuestion()) {
  1246. this._storeDate(euro24hDate.toDate());
  1247. this.card.setPokerEnd(euro24hDate.toDate());
  1248. } else {
  1249. this.currentData().poker = { end: euro24hDate.toDate() }; // set poker end temp
  1250. }
  1251. Popup.back();
  1252. } else if (eurodotDate.isValid()) {
  1253. // if active poker - store it
  1254. if (this.currentData().getPokerQuestion()) {
  1255. this._storeDate(eurodotDate.toDate());
  1256. this.card.setPokerEnd(eurodotDate.toDate());
  1257. } else {
  1258. this.currentData().poker = { end: eurodotDate.toDate() }; // set poker end temp
  1259. }
  1260. Popup.back();
  1261. } else if (minusDate.isValid()) {
  1262. // if active poker - store it
  1263. if (this.currentData().getPokerQuestion()) {
  1264. this._storeDate(minusDate.toDate());
  1265. this.card.setPokerEnd(minusDate.toDate());
  1266. } else {
  1267. this.currentData().poker = { end: minusDate.toDate() }; // set poker end temp
  1268. }
  1269. Popup.back();
  1270. } else if (slashDate.isValid()) {
  1271. // if active poker - store it
  1272. if (this.currentData().getPokerQuestion()) {
  1273. this._storeDate(slashDate.toDate());
  1274. this.card.setPokerEnd(slashDate.toDate());
  1275. } else {
  1276. this.currentData().poker = { end: slashDate.toDate() }; // set poker end temp
  1277. }
  1278. Popup.back();
  1279. } else if (dotDate.isValid()) {
  1280. // if active poker - store it
  1281. if (this.currentData().getPokerQuestion()) {
  1282. this._storeDate(dotDate.toDate());
  1283. this.card.setPokerEnd(dotDate.toDate());
  1284. } else {
  1285. this.currentData().poker = { end: dotDate.toDate() }; // set poker end temp
  1286. }
  1287. Popup.back();
  1288. } else if (brezhonegDate.isValid()) {
  1289. // if active poker - store it
  1290. if (this.currentData().getPokerQuestion()) {
  1291. this._storeDate(brezhonegDate.toDate());
  1292. this.card.setPokerEnd(brezhonegDate.toDate());
  1293. } else {
  1294. this.currentData().poker = { end: brezhonegDate.toDate() }; // set poker end temp
  1295. }
  1296. Popup.back();
  1297. } else if (hrvatskiDate.isValid()) {
  1298. // if active poker - store it
  1299. if (this.currentData().getPokerQuestion()) {
  1300. this._storeDate(hrvatskiDate.toDate());
  1301. this.card.setPokerEnd(hrvatskiDate.toDate());
  1302. } else {
  1303. this.currentData().poker = { end: hrvatskiDate.toDate() }; // set poker end temp
  1304. Popup.back();
  1305. }
  1306. } else if (latviaDate.isValid()) {
  1307. // if active poker - store it
  1308. if (this.currentData().getPokerQuestion()) {
  1309. this._storeDate(latviaDate.toDate());
  1310. this.card.setPokerEnd(latviaDate.toDate());
  1311. } else {
  1312. this.currentData().poker = { end: latviaDate.toDate() }; // set poker end temp
  1313. }
  1314. Popup.back();
  1315. } else if (nederlandsDate.isValid()) {
  1316. // if active poker - store it
  1317. if (this.currentData().getPokerQuestion()) {
  1318. this._storeDate(nederlandsDate.toDate());
  1319. this.card.setPokerEnd(nederlandsDate.toDate());
  1320. } else {
  1321. this.currentData().poker = { end: nederlandsDate.toDate() }; // set poker end temp
  1322. }
  1323. Popup.back();
  1324. } else if (greekDate.isValid()) {
  1325. // if active poker - store it
  1326. if (this.currentData().getPokerQuestion()) {
  1327. this._storeDate(greekDate.toDate());
  1328. this.card.setPokerEnd(greekDate.toDate());
  1329. } else {
  1330. this.currentData().poker = { end: greekDate.toDate() }; // set poker end temp
  1331. }
  1332. Popup.back();
  1333. } else if (macedonianDate.isValid()) {
  1334. // if active poker - store it
  1335. if (this.currentData().getPokerQuestion()) {
  1336. this._storeDate(macedonianDate.toDate());
  1337. this.card.setPokerEnd(macedonianDate.toDate());
  1338. } else {
  1339. this.currentData().poker = { end: macedonianDate.toDate() }; // set poker end temp
  1340. }
  1341. Popup.back();
  1342. } else {
  1343. this.error.set('invalid-date');
  1344. evt.target.date.focus();
  1345. }
  1346. },
  1347. 'click .js-delete-date'(evt) {
  1348. evt.preventDefault();
  1349. this._deleteDate();
  1350. Popup.back();
  1351. },
  1352. },
  1353. ];
  1354. }
  1355. _storeDate(newDate) {
  1356. this.card.setVoteEnd(newDate);
  1357. }
  1358. _deleteDate() {
  1359. this.card.unsetVoteEnd();
  1360. }
  1361. }.register('editVoteEndDatePopup'));
  1362. BlazeComponent.extendComponent({
  1363. onCreated() {
  1364. this.currentCard = this.currentData();
  1365. this.pokerQuestion = new ReactiveVar(this.currentCard.pokerQuestion);
  1366. },
  1367. events() {
  1368. return [
  1369. {
  1370. 'click .js-end-date': Popup.open('editPokerEndDate'),
  1371. 'submit .edit-poker-question'(evt) {
  1372. evt.preventDefault();
  1373. const pokerQuestion = true;
  1374. const allowNonBoardMembers = $('#poker-allow-non-members').hasClass(
  1375. 'is-checked',
  1376. );
  1377. const endString = this.currentCard.getPokerEnd();
  1378. this.currentCard.setPokerQuestion(
  1379. pokerQuestion,
  1380. allowNonBoardMembers,
  1381. );
  1382. if (endString) {
  1383. this.currentCard.setPokerEnd(endString);
  1384. }
  1385. Popup.back();
  1386. },
  1387. 'click .js-remove-poker': Popup.afterConfirm('deletePoker', (event) => {
  1388. this.currentCard.unsetPoker();
  1389. Popup.back();
  1390. }),
  1391. 'click a.js-toggle-poker-allow-non-members'(event) {
  1392. event.preventDefault();
  1393. $('#poker-allow-non-members').toggleClass('is-checked');
  1394. },
  1395. },
  1396. ];
  1397. },
  1398. }).register('cardStartPlanningPokerPopup');
  1399. // editPokerEndDatePopup
  1400. (class extends DatePicker {
  1401. onCreated() {
  1402. super.onCreated(moment().format('YYYY-MM-DD HH:mm'));
  1403. this.data().getPokerEnd() &&
  1404. this.date.set(moment(this.data().getPokerEnd()));
  1405. }
  1406. /*
  1407. Tried to use dateFormat and timeFormat from client/components/lib/datepicker.js
  1408. to make detecting all date formats not necessary,
  1409. but got error "language mk does not exist".
  1410. Maybe client/components/lib/datepicker.jade could have hidden input field for
  1411. datepicker format that could be used to detect date format?
  1412. dateFormat() {
  1413. return moment.localeData().longDateFormat('L');
  1414. }
  1415. timeFormat() {
  1416. return moment.localeData().longDateFormat('LT');
  1417. }
  1418. const newDate = moment(dateString, dateformat() + ' ' + timeformat(), true);
  1419. */
  1420. events() {
  1421. return [
  1422. {
  1423. 'submit .edit-date'(evt) {
  1424. evt.preventDefault();
  1425. // if no time was given, init with 12:00
  1426. const time =
  1427. evt.target.time.value ||
  1428. moment(new Date().setHours(12, 0, 0)).format('LT');
  1429. const dateString = `${evt.target.date.value} ${time}`;
  1430. /*
  1431. Tried to use dateFormat and timeFormat from client/components/lib/datepicker.js
  1432. to make detecting all date formats not necessary,
  1433. but got error "language mk does not exist".
  1434. Maybe client/components/lib/datepicker.jade could have hidden input field for
  1435. datepicker format that could be used to detect date format?
  1436. const newDate = moment(dateString, dateformat() + ' ' + timeformat(), true);
  1437. if (newDate.isValid()) {
  1438. // if active poker - store it
  1439. if (this.currentData().getPokerQuestion()) {
  1440. this._storeDate(newDate.toDate());
  1441. Popup.back();
  1442. } else {
  1443. this.currentData().poker = { end: newDate.toDate() }; // set poker end temp
  1444. Popup.back();
  1445. }
  1446. */
  1447. // Try to parse different date formats of all languages.
  1448. // This code is same for vote and planning poker.
  1449. const usaDate = moment(dateString, 'L LT', true);
  1450. const euroAmDate = moment(dateString, 'DD.MM.YYYY LT', true);
  1451. const euro24hDate = moment(dateString, 'DD.MM.YYYY HH.mm', true);
  1452. const eurodotDate = moment(dateString, 'DD.MM.YYYY HH:mm', true);
  1453. const minusDate = moment(dateString, 'YYYY-MM-DD HH:mm', true);
  1454. const slashDate = moment(dateString, 'DD/MM/YYYY HH.mm', true);
  1455. const dotDate = moment(dateString, 'DD/MM/YYYY HH:mm', true);
  1456. const brezhonegDate = moment(dateString, 'DD/MM/YYYY h[e]mm A', true);
  1457. const hrvatskiDate = moment(dateString, 'DD. MM. YYYY H:mm', true);
  1458. const latviaDate = moment(dateString, 'YYYY.MM.DD. H:mm', true);
  1459. const nederlandsDate = moment(dateString, 'DD-MM-YYYY HH:mm', true);
  1460. // greekDate does not work: el Greek Ελληνικά ,
  1461. // it has date format DD/MM/YYYY h:mm MM like 20/06/2021 11:15 MM
  1462. // where MM is maybe some text like AM/PM ?
  1463. // Also some other languages that have non-ascii characters in dates
  1464. // do not work.
  1465. const greekDate = moment(dateString, 'DD/MM/YYYY h:mm A', true);
  1466. const macedonianDate = moment(dateString, 'D.MM.YYYY H:mm', true);
  1467. if (usaDate.isValid()) {
  1468. // if active poker - store it
  1469. if (this.currentData().getPokerQuestion()) {
  1470. this._storeDate(usaDate.toDate());
  1471. } else {
  1472. this.currentData().poker = { end: usaDate.toDate() }; // set poker end temp
  1473. }
  1474. Popup.back();
  1475. } else if (euroAmDate.isValid()) {
  1476. // if active poker - store it
  1477. if (this.currentData().getPokerQuestion()) {
  1478. this._storeDate(euroAmDate.toDate());
  1479. } else {
  1480. this.currentData().poker = { end: euroAmDate.toDate() }; // set poker end temp
  1481. }
  1482. Popup.back();
  1483. } else if (euro24hDate.isValid()) {
  1484. // if active poker - store it
  1485. if (this.currentData().getPokerQuestion()) {
  1486. this._storeDate(euro24hDate.toDate());
  1487. this.card.setPokerEnd(euro24hDate.toDate());
  1488. } else {
  1489. this.currentData().poker = { end: euro24hDate.toDate() }; // set poker end temp
  1490. }
  1491. Popup.back();
  1492. } else if (eurodotDate.isValid()) {
  1493. // if active poker - store it
  1494. if (this.currentData().getPokerQuestion()) {
  1495. this._storeDate(eurodotDate.toDate());
  1496. this.card.setPokerEnd(eurodotDate.toDate());
  1497. } else {
  1498. this.currentData().poker = { end: eurodotDate.toDate() }; // set poker end temp
  1499. }
  1500. Popup.back();
  1501. } else if (minusDate.isValid()) {
  1502. // if active poker - store it
  1503. if (this.currentData().getPokerQuestion()) {
  1504. this._storeDate(minusDate.toDate());
  1505. this.card.setPokerEnd(minusDate.toDate());
  1506. } else {
  1507. this.currentData().poker = { end: minusDate.toDate() }; // set poker end temp
  1508. }
  1509. Popup.back();
  1510. } else if (slashDate.isValid()) {
  1511. // if active poker - store it
  1512. if (this.currentData().getPokerQuestion()) {
  1513. this._storeDate(slashDate.toDate());
  1514. this.card.setPokerEnd(slashDate.toDate());
  1515. } else {
  1516. this.currentData().poker = { end: slashDate.toDate() }; // set poker end temp
  1517. }
  1518. Popup.back();
  1519. } else if (dotDate.isValid()) {
  1520. // if active poker - store it
  1521. if (this.currentData().getPokerQuestion()) {
  1522. this._storeDate(dotDate.toDate());
  1523. this.card.setPokerEnd(dotDate.toDate());
  1524. } else {
  1525. this.currentData().poker = { end: dotDate.toDate() }; // set poker end temp
  1526. }
  1527. Popup.back();
  1528. } else if (brezhonegDate.isValid()) {
  1529. // if active poker - store it
  1530. if (this.currentData().getPokerQuestion()) {
  1531. this._storeDate(brezhonegDate.toDate());
  1532. this.card.setPokerEnd(brezhonegDate.toDate());
  1533. } else {
  1534. this.currentData().poker = { end: brezhonegDate.toDate() }; // set poker end temp
  1535. }
  1536. Popup.back();
  1537. } else if (hrvatskiDate.isValid()) {
  1538. // if active poker - store it
  1539. if (this.currentData().getPokerQuestion()) {
  1540. this._storeDate(hrvatskiDate.toDate());
  1541. this.card.setPokerEnd(hrvatskiDate.toDate());
  1542. } else {
  1543. this.currentData().poker = { end: hrvatskiDate.toDate() }; // set poker end temp
  1544. }
  1545. Popup.back();
  1546. } else if (latviaDate.isValid()) {
  1547. // if active poker - store it
  1548. if (this.currentData().getPokerQuestion()) {
  1549. this._storeDate(latviaDate.toDate());
  1550. this.card.setPokerEnd(latviaDate.toDate());
  1551. } else {
  1552. this.currentData().poker = { end: latviaDate.toDate() }; // set poker end temp
  1553. }
  1554. Popup.back();
  1555. } else if (nederlandsDate.isValid()) {
  1556. // if active poker - store it
  1557. if (this.currentData().getPokerQuestion()) {
  1558. this._storeDate(nederlandsDate.toDate());
  1559. this.card.setPokerEnd(nederlandsDate.toDate());
  1560. } else {
  1561. this.currentData().poker = { end: nederlandsDate.toDate() }; // set poker end temp
  1562. }
  1563. Popup.back();
  1564. } else if (greekDate.isValid()) {
  1565. // if active poker - store it
  1566. if (this.currentData().getPokerQuestion()) {
  1567. this._storeDate(greekDate.toDate());
  1568. this.card.setPokerEnd(greekDate.toDate());
  1569. } else {
  1570. this.currentData().poker = { end: greekDate.toDate() }; // set poker end temp
  1571. }
  1572. Popup.back();
  1573. } else if (macedonianDate.isValid()) {
  1574. // if active poker - store it
  1575. if (this.currentData().getPokerQuestion()) {
  1576. this._storeDate(macedonianDate.toDate());
  1577. this.card.setPokerEnd(macedonianDate.toDate());
  1578. } else {
  1579. this.currentData().poker = { end: macedonianDate.toDate() }; // set poker end temp
  1580. }
  1581. Popup.back();
  1582. } else {
  1583. // this.error.set('invalid-date);
  1584. this.error.set('invalid-date' + ' ' + dateString);
  1585. evt.target.date.focus();
  1586. }
  1587. },
  1588. 'click .js-delete-date'(evt) {
  1589. evt.preventDefault();
  1590. this._deleteDate();
  1591. Popup.back();
  1592. },
  1593. },
  1594. ];
  1595. }
  1596. _storeDate(newDate) {
  1597. this.card.setPokerEnd(newDate);
  1598. }
  1599. _deleteDate() {
  1600. this.card.unsetPokerEnd();
  1601. }
  1602. }.register('editPokerEndDatePopup'));
  1603. // Close the card details pane by pressing escape
  1604. EscapeActions.register(
  1605. 'detailsPane',
  1606. () => {
  1607. // if card description diverges from database due to editing
  1608. // ask user whether changes should be applied
  1609. if (currentUser.profile.rescueCardDescription == true) {
  1610. currentDescription = document.getElementsByClassName("editor js-new-description-input").item(0)
  1611. if (currentDescription?.value && !(currentDescription.value === Utils.getCurrentCard().getDescription())) {
  1612. if (confirm(TAPi18n.__('rescue-card-description-dialogue'))) {
  1613. Utils.getCurrentCard().setDescription(document.getElementsByClassName("editor js-new-description-input").item(0).value);
  1614. // Save it!
  1615. console.log(document.getElementsByClassName("editor js-new-description-input").item(0).value);
  1616. console.log("current description", Utils.getCurrentCard().getDescription());
  1617. } else {
  1618. // Do nothing!
  1619. console.log('Description changes were not saved to the database.');
  1620. }
  1621. }
  1622. }
  1623. if (Session.get('cardDetailsIsDragging')) {
  1624. // Reset dragging status as the mouse landed outside the cardDetails template area and this will prevent a mousedown event from firing
  1625. Session.set('cardDetailsIsDragging', false);
  1626. Session.set('cardDetailsIsMouseDown', false);
  1627. } else {
  1628. // Prevent close card when the user is selecting text and moves the mouse cursor outside the card detail area
  1629. Utils.goBoardId(Session.get('currentBoard'));
  1630. }
  1631. },
  1632. () => {
  1633. return !Session.equals('currentCard', null);
  1634. },
  1635. {
  1636. noClickEscapeOn: '.js-card-details,.board-sidebar,#header',
  1637. },
  1638. );
  1639. Template.cardAssigneesPopup.onCreated(function () {
  1640. let currBoard = Boards.findOne(Session.get('currentBoard'));
  1641. let members = currBoard.activeMembers();
  1642. // let query = {
  1643. // "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },
  1644. // };
  1645. // let boardTeamUsers = Users.find(query, {
  1646. // sort: { sort: 1 },
  1647. // });
  1648. // members = currBoard.activeMembers2(members, boardTeamUsers);
  1649. this.members = new ReactiveVar(members);
  1650. });
  1651. Template.cardAssigneesPopup.events({
  1652. 'click .js-select-assignee'(event) {
  1653. const card = Utils.getCurrentCard();
  1654. const assigneeId = this.userId;
  1655. card.toggleAssignee(assigneeId);
  1656. event.preventDefault();
  1657. },
  1658. 'keyup .card-assignees-filter'(event) {
  1659. const members = filterMembers(event.target.value);
  1660. Template.instance().members.set(members);
  1661. },
  1662. });
  1663. Template.cardAssigneesPopup.helpers({
  1664. isCardAssignee() {
  1665. const card = Template.parentData();
  1666. const cardAssignees = card.getAssignees();
  1667. return _.contains(cardAssignees, this.userId);
  1668. },
  1669. members() {
  1670. return Template.instance().members.get();
  1671. },
  1672. user() {
  1673. return Users.findOne(this.userId);
  1674. },
  1675. });
  1676. Template.cardAssigneePopup.helpers({
  1677. userData() {
  1678. return Users.findOne(this.userId, {
  1679. fields: {
  1680. profile: 1,
  1681. username: 1,
  1682. },
  1683. });
  1684. },
  1685. memberType() {
  1686. const user = Users.findOne(this.userId);
  1687. return user && user.isBoardAdmin() ? 'admin' : 'normal';
  1688. },
  1689. /*
  1690. presenceStatusClassName() {
  1691. const user = Users.findOne(this.userId);
  1692. const userPresence = presences.findOne({ userId: this.userId });
  1693. if (user && user.isInvitedTo(Session.get('currentBoard'))) return 'pending';
  1694. else if (!userPresence) return 'disconnected';
  1695. else if (Session.equals('currentBoard', userPresence.state.currentBoardId))
  1696. return 'active';
  1697. else return 'idle';
  1698. },
  1699. */
  1700. isCardAssignee() {
  1701. const card = Template.parentData();
  1702. const cardAssignees = card.getAssignees();
  1703. return _.contains(cardAssignees, this.userId);
  1704. },
  1705. user() {
  1706. return Users.findOne(this.userId);
  1707. },
  1708. });
  1709. Template.cardAssigneePopup.events({
  1710. 'click .js-remove-assignee'() {
  1711. Cards.findOne(this.cardId).unassignAssignee(this.userId);
  1712. Popup.back();
  1713. },
  1714. 'click .js-edit-profile': Popup.open('editProfile'),
  1715. });