cardDetails.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. const subManager = new SubsManager();
  2. const { calculateIndexData, enableClickOnTouch } = Utils;
  3. BlazeComponent.extendComponent({
  4. mixins() {
  5. return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
  6. },
  7. calculateNextPeak() {
  8. const cardElement = this.find('.js-card-details');
  9. if (cardElement) {
  10. const altitude = cardElement.scrollHeight;
  11. this.callFirstWith(this, 'setNextPeak', altitude);
  12. }
  13. },
  14. reachNextPeak() {
  15. const activitiesComponent = this.childComponents('activities')[0];
  16. activitiesComponent.loadNextPage();
  17. },
  18. onCreated() {
  19. this.currentBoard = Boards.findOne(Session.get('currentBoard'));
  20. this.isLoaded = new ReactiveVar(false);
  21. const boardBody = this.parentComponent().parentComponent();
  22. //in Miniview parent is Board, not BoardBody.
  23. if (boardBody !== null) {
  24. boardBody.showOverlay.set(true);
  25. boardBody.mouseHasEnterCardDetails = false;
  26. }
  27. this.calculateNextPeak();
  28. Meteor.subscribe('unsaved-edits');
  29. },
  30. isWatching() {
  31. const card = this.currentData();
  32. return card.findWatcher(Meteor.userId());
  33. },
  34. hiddenSystemMessages() {
  35. return Meteor.user().hasHiddenSystemMessages();
  36. },
  37. canModifyCard() {
  38. return Meteor.user() && Meteor.user().isBoardMember() &&
  39. !Meteor.user().isCommentOnly() && !this.currentData().isImported();
  40. },
  41. scrollParentContainer() {
  42. const cardPanelWidth = 510;
  43. const bodyBoardComponent = this.parentComponent().parentComponent();
  44. //On Mobile View Parent is Board, Not Board Body. I cant see how this funciton should work then.
  45. if (bodyBoardComponent === null) return;
  46. const $cardView = this.$(this.firstNode());
  47. const $cardContainer = bodyBoardComponent.$('.js-swimlanes');
  48. const cardContainerScroll = $cardContainer.scrollLeft();
  49. const cardContainerWidth = $cardContainer.width();
  50. const cardViewStart = $cardView.offset().left;
  51. const cardViewEnd = cardViewStart + cardPanelWidth;
  52. let offset = false;
  53. if (cardViewStart < 0) {
  54. offset = cardViewStart;
  55. } else if (cardViewEnd > cardContainerWidth) {
  56. offset = cardViewEnd - cardContainerWidth;
  57. }
  58. if (offset) {
  59. bodyBoardComponent.scrollLeft(cardContainerScroll + offset);
  60. }
  61. },
  62. presentParentTask() {
  63. let result = this.currentBoard.presentParentTask;
  64. if ((result === null) || (result === undefined)) {
  65. result = 'no-parent';
  66. }
  67. return result;
  68. },
  69. linkForCard() {
  70. const card = this.currentData();
  71. let result = '#';
  72. if (card) {
  73. const board = Boards.findOne(card.boardId);
  74. if (board) {
  75. result = FlowRouter.url('card', {
  76. boardId: card.boardId,
  77. slug: board.slug,
  78. cardId: card._id,
  79. });
  80. }
  81. }
  82. return result;
  83. },
  84. onRendered() {
  85. if (!Utils.isMiniScreen()) this.scrollParentContainer();
  86. const $checklistsDom = this.$('.card-checklist-items');
  87. $checklistsDom.sortable({
  88. tolerance: 'pointer',
  89. helper: 'clone',
  90. handle: '.checklist-title',
  91. items: '.js-checklist',
  92. placeholder: 'checklist placeholder',
  93. distance: 7,
  94. start(evt, ui) {
  95. ui.placeholder.height(ui.helper.height());
  96. EscapeActions.executeUpTo('popup-close');
  97. },
  98. stop(evt, ui) {
  99. let prevChecklist = ui.item.prev('.js-checklist').get(0);
  100. if (prevChecklist) {
  101. prevChecklist = Blaze.getData(prevChecklist).checklist;
  102. }
  103. let nextChecklist = ui.item.next('.js-checklist').get(0);
  104. if (nextChecklist) {
  105. nextChecklist = Blaze.getData(nextChecklist).checklist;
  106. }
  107. const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);
  108. $checklistsDom.sortable('cancel');
  109. const checklist = Blaze.getData(ui.item.get(0)).checklist;
  110. Checklists.update(checklist._id, {
  111. $set: {
  112. sort: sortIndex.base,
  113. },
  114. });
  115. },
  116. });
  117. // ugly touch event hotfix
  118. enableClickOnTouch('.card-checklist-items .js-checklist');
  119. const $subtasksDom = this.$('.card-subtasks-items');
  120. $subtasksDom.sortable({
  121. tolerance: 'pointer',
  122. helper: 'clone',
  123. handle: '.subtask-title',
  124. items: '.js-subtasks',
  125. placeholder: 'subtasks placeholder',
  126. distance: 7,
  127. start(evt, ui) {
  128. ui.placeholder.height(ui.helper.height());
  129. EscapeActions.executeUpTo('popup-close');
  130. },
  131. stop(evt, ui) {
  132. let prevChecklist = ui.item.prev('.js-subtasks').get(0);
  133. if (prevChecklist) {
  134. prevChecklist = Blaze.getData(prevChecklist).subtask;
  135. }
  136. let nextChecklist = ui.item.next('.js-subtasks').get(0);
  137. if (nextChecklist) {
  138. nextChecklist = Blaze.getData(nextChecklist).subtask;
  139. }
  140. const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);
  141. $subtasksDom.sortable('cancel');
  142. const subtask = Blaze.getData(ui.item.get(0)).subtask;
  143. Subtasks.update(subtask._id, {
  144. $set: {
  145. subtaskSort: sortIndex.base,
  146. },
  147. });
  148. },
  149. });
  150. // ugly touch event hotfix
  151. enableClickOnTouch('.card-subtasks-items .js-subtasks');
  152. function userIsMember() {
  153. return Meteor.user() && Meteor.user().isBoardMember();
  154. }
  155. // Disable sorting if the current user is not a board member
  156. this.autorun(() => {
  157. if ($checklistsDom.data('sortable')) {
  158. $checklistsDom.sortable('option', 'disabled', !userIsMember());
  159. }
  160. if ($subtasksDom.data('sortable')) {
  161. $subtasksDom.sortable('option', 'disabled', !userIsMember());
  162. }
  163. });
  164. },
  165. onDestroyed() {
  166. const parentComponent = this.parentComponent().parentComponent();
  167. //on mobile view parent is Board, not board body.
  168. if (parentComponent === null) return;
  169. parentComponent.showOverlay.set(false);
  170. },
  171. events() {
  172. const events = {
  173. [`${CSSEvents.transitionend} .js-card-details`]() {
  174. this.isLoaded.set(true);
  175. },
  176. [`${CSSEvents.animationend} .js-card-details`]() {
  177. this.isLoaded.set(true);
  178. },
  179. };
  180. return [{
  181. ...events,
  182. 'click .js-close-card-details' () {
  183. Utils.goBoardId(this.data().boardId);
  184. },
  185. 'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
  186. 'submit .js-card-description' (evt) {
  187. evt.preventDefault();
  188. const description = this.currentComponent().getValue();
  189. this.data().setDescription(description);
  190. },
  191. 'submit .js-card-details-title' (evt) {
  192. evt.preventDefault();
  193. const title = this.currentComponent().getValue().trim();
  194. if (title) {
  195. this.data().setTitle(title);
  196. }
  197. },
  198. 'submit .js-card-details-assigner'(evt) {
  199. evt.preventDefault();
  200. const assigner = this.currentComponent().getValue().trim();
  201. if (assigner) {
  202. this.data().setAssignedBy(assigner);
  203. }
  204. },
  205. 'submit .js-card-details-requester'(evt) {
  206. evt.preventDefault();
  207. const requester = this.currentComponent().getValue().trim();
  208. if (requester) {
  209. this.data().setRequestedBy(requester);
  210. }
  211. },
  212. 'click .js-member': Popup.open('cardMember'),
  213. 'click .js-add-members': Popup.open('cardMembers'),
  214. 'click .js-add-labels': Popup.open('cardLabels'),
  215. 'click .js-received-date': Popup.open('editCardReceivedDate'),
  216. 'click .js-start-date': Popup.open('editCardStartDate'),
  217. 'click .js-due-date': Popup.open('editCardDueDate'),
  218. 'click .js-end-date': Popup.open('editCardEndDate'),
  219. 'mouseenter .js-card-details' () {
  220. const parentComponent = this.parentComponent().parentComponent();
  221. //on mobile view parent is Board, not BoardBody.
  222. if (parentComponent === null) return;
  223. parentComponent.showOverlay.set(true);
  224. parentComponent.mouseHasEnterCardDetails = true;
  225. },
  226. 'click #toggleButton'() {
  227. Meteor.call('toggleSystemMessages');
  228. },
  229. }];
  230. },
  231. }).register('cardDetails');
  232. // We extends the normal InlinedForm component to support UnsavedEdits draft
  233. // feature.
  234. (class extends InlinedForm {
  235. _getUnsavedEditKey() {
  236. return {
  237. fieldName: 'cardDescription',
  238. // XXX Recovering the currentCard identifier form a session variable is
  239. // fragile because this variable may change for instance if the route
  240. // change. We should use some component props instead.
  241. docId: Session.get('currentCard'),
  242. };
  243. }
  244. close(isReset = false) {
  245. if (this.isOpen.get() && !isReset) {
  246. const draft = this.getValue().trim();
  247. if (draft !== Cards.findOne(Session.get('currentCard')).description) {
  248. UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());
  249. }
  250. }
  251. super.close();
  252. }
  253. reset() {
  254. UnsavedEdits.reset(this._getUnsavedEditKey());
  255. this.close(true);
  256. }
  257. events() {
  258. const parentEvents = InlinedForm.prototype.events()[0];
  259. return [{
  260. ...parentEvents,
  261. 'click .js-close-inlined-form': this.reset,
  262. }];
  263. }
  264. }).register('inlinedCardDescription');
  265. Template.cardDetailsActionsPopup.helpers({
  266. isWatching() {
  267. return this.findWatcher(Meteor.userId());
  268. },
  269. canModifyCard() {
  270. return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
  271. },
  272. });
  273. Template.cardDetailsActionsPopup.events({
  274. 'click .js-members': Popup.open('cardMembers'),
  275. 'click .js-labels': Popup.open('cardLabels'),
  276. 'click .js-attachments': Popup.open('cardAttachments'),
  277. 'click .js-custom-fields': Popup.open('cardCustomFields'),
  278. 'click .js-received-date': Popup.open('editCardReceivedDate'),
  279. 'click .js-start-date': Popup.open('editCardStartDate'),
  280. 'click .js-due-date': Popup.open('editCardDueDate'),
  281. 'click .js-end-date': Popup.open('editCardEndDate'),
  282. 'click .js-spent-time': Popup.open('editCardSpentTime'),
  283. 'click .js-move-card': Popup.open('moveCard'),
  284. 'click .js-copy-card': Popup.open('copyCard'),
  285. 'click .js-copy-checklist-cards': Popup.open('copyChecklistToManyCards'),
  286. 'click .js-move-card-to-top' (evt) {
  287. evt.preventDefault();
  288. const minOrder = _.min(this.list().cards(this.swimlaneId).map((c) => c.sort));
  289. this.move(this.swimlaneId, this.listId, minOrder - 1);
  290. },
  291. 'click .js-move-card-to-bottom' (evt) {
  292. evt.preventDefault();
  293. const maxOrder = _.max(this.list().cards(this.swimlaneId).map((c) => c.sort));
  294. this.move(this.swimlaneId, this.listId, maxOrder + 1);
  295. },
  296. 'click .js-archive' (evt) {
  297. evt.preventDefault();
  298. this.archive();
  299. Popup.close();
  300. },
  301. 'click .js-more': Popup.open('cardMore'),
  302. 'click .js-toggle-watch-card' () {
  303. const currentCard = this;
  304. const level = currentCard.findWatcher(Meteor.userId()) ? null : 'watching';
  305. Meteor.call('watch', 'card', currentCard._id, level, (err, ret) => {
  306. if (!err && ret) Popup.close();
  307. });
  308. },
  309. });
  310. Template.editCardTitleForm.onRendered(function () {
  311. autosize(this.$('.js-edit-card-title'));
  312. });
  313. Template.editCardTitleForm.events({
  314. 'keydown .js-edit-card-title' (evt) {
  315. // If enter key was pressed, submit the data
  316. // Unless the shift key is also being pressed
  317. if (evt.keyCode === 13 && !evt.shiftKey) {
  318. $('.js-submit-edit-card-title-form').click();
  319. }
  320. },
  321. });
  322. Template.editCardRequesterForm.onRendered(function() {
  323. autosize(this.$('.js-edit-card-requester'));
  324. });
  325. Template.editCardRequesterForm.events({
  326. 'keydown .js-edit-card-requester'(evt) {
  327. // If enter key was pressed, submit the data
  328. if (evt.keyCode === 13) {
  329. $('.js-submit-edit-card-requester-form').click();
  330. }
  331. },
  332. });
  333. Template.editCardAssignerForm.onRendered(function() {
  334. autosize(this.$('.js-edit-card-assigner'));
  335. });
  336. Template.editCardAssignerForm.events({
  337. 'keydown .js-edit-card-assigner'(evt) {
  338. // If enter key was pressed, submit the data
  339. if (evt.keyCode === 13) {
  340. $('.js-submit-edit-card-assigner-form').click();
  341. }
  342. },
  343. });
  344. Template.moveCardPopup.events({
  345. 'click .js-done' () {
  346. // XXX We should *not* get the currentCard from the global state, but
  347. // instead from a “component” state.
  348. const card = Cards.findOne(Session.get('currentCard'));
  349. const lSelect = $('.js-select-lists')[0];
  350. const newListId = lSelect.options[lSelect.selectedIndex].value;
  351. const slSelect = $('.js-select-swimlanes')[0];
  352. card.swimlaneId = slSelect.options[slSelect.selectedIndex].value;
  353. card.move(card.swimlaneId, newListId, 0);
  354. Popup.close();
  355. },
  356. });
  357. BlazeComponent.extendComponent({
  358. onCreated() {
  359. subManager.subscribe('board', Session.get('currentBoard'));
  360. this.selectedBoardId = new ReactiveVar(Session.get('currentBoard'));
  361. },
  362. boards() {
  363. const boards = Boards.find({
  364. archived: false,
  365. 'members.userId': Meteor.userId(),
  366. }, {
  367. sort: ['title'],
  368. });
  369. return boards;
  370. },
  371. swimlanes() {
  372. const board = Boards.findOne(this.selectedBoardId.get());
  373. return board.swimlanes();
  374. },
  375. aBoardLists() {
  376. const board = Boards.findOne(this.selectedBoardId.get());
  377. return board.lists();
  378. },
  379. events() {
  380. return [{
  381. 'change .js-select-boards'(evt) {
  382. this.selectedBoardId.set($(evt.currentTarget).val());
  383. subManager.subscribe('board', this.selectedBoardId.get());
  384. },
  385. }];
  386. },
  387. }).register('boardsAndLists');
  388. function cloneCheckList(_id, checklist) {
  389. 'use strict';
  390. const checklistId = checklist._id;
  391. checklist.cardId = _id;
  392. checklist._id = null;
  393. const newChecklistId = Checklists.insert(checklist);
  394. ChecklistItems.find({checklistId}).forEach(function(item) {
  395. item._id = null;
  396. item.checklistId = newChecklistId;
  397. item.cardId = _id;
  398. ChecklistItems.insert(item);
  399. });
  400. }
  401. Template.copyCardPopup.events({
  402. 'click .js-done'() {
  403. const card = Cards.findOne(Session.get('currentCard'));
  404. const oldId = card._id;
  405. card._id = null;
  406. const lSelect = $('.js-select-lists')[0];
  407. card.listId = lSelect.options[lSelect.selectedIndex].value;
  408. const slSelect = $('.js-select-swimlanes')[0];
  409. card.swimlaneId = slSelect.options[slSelect.selectedIndex].value;
  410. const bSelect = $('.js-select-boards')[0];
  411. card.boardId = bSelect.options[bSelect.selectedIndex].value;
  412. const textarea = $('#copy-card-title');
  413. const title = textarea.val().trim();
  414. // insert new card to the bottom of new list
  415. card.sort = Lists.findOne(card.listId).cards().count();
  416. if (title) {
  417. card.title = title;
  418. card.coverId = '';
  419. const _id = Cards.insert(card);
  420. // In case the filter is active we need to add the newly inserted card in
  421. // the list of exceptions -- cards that are not filtered. Otherwise the
  422. // card will disappear instantly.
  423. // See https://github.com/wekan/wekan/issues/80
  424. Filter.addException(_id);
  425. // copy checklists
  426. let cursor = Checklists.find({cardId: oldId});
  427. cursor.forEach(function() {
  428. cloneCheckList(_id, arguments[0]);
  429. });
  430. // copy subtasks
  431. cursor = Cards.find({parentId: oldId});
  432. cursor.forEach(function() {
  433. 'use strict';
  434. const subtask = arguments[0];
  435. subtask.parentId = _id;
  436. subtask._id = null;
  437. /* const newSubtaskId = */ Cards.insert(subtask);
  438. });
  439. // copy card comments
  440. cursor = CardComments.find({cardId: oldId});
  441. cursor.forEach(function () {
  442. 'use strict';
  443. const comment = arguments[0];
  444. comment.cardId = _id;
  445. comment._id = null;
  446. CardComments.insert(comment);
  447. });
  448. Popup.close();
  449. }
  450. },
  451. });
  452. Template.copyChecklistToManyCardsPopup.events({
  453. 'click .js-done' () {
  454. const card = Cards.findOne(Session.get('currentCard'));
  455. const oldId = card._id;
  456. card._id = null;
  457. const lSelect = $('.js-select-lists')[0];
  458. card.listId = lSelect.options[lSelect.selectedIndex].value;
  459. const slSelect = $('.js-select-swimlanes')[0];
  460. card.swimlaneId = slSelect.options[slSelect.selectedIndex].value;
  461. const bSelect = $('.js-select-boards')[0];
  462. card.boardId = bSelect.options[bSelect.selectedIndex].value;
  463. const textarea = $('#copy-card-title');
  464. const titleEntry = textarea.val().trim();
  465. // insert new card to the bottom of new list
  466. card.sort = Lists.findOne(card.listId).cards().count();
  467. if (titleEntry) {
  468. const titleList = JSON.parse(titleEntry);
  469. for (let i = 0; i < titleList.length; i++){
  470. const obj = titleList[i];
  471. card.title = obj.title;
  472. card.description = obj.description;
  473. card.coverId = '';
  474. const _id = Cards.insert(card);
  475. // In case the filter is active we need to add the newly inserted card in
  476. // the list of exceptions -- cards that are not filtered. Otherwise the
  477. // card will disappear instantly.
  478. // See https://github.com/wekan/wekan/issues/80
  479. Filter.addException(_id);
  480. // copy checklists
  481. let cursor = Checklists.find({cardId: oldId});
  482. cursor.forEach(function() {
  483. cloneCheckList(_id, arguments[0]);
  484. });
  485. // copy subtasks
  486. cursor = Cards.find({parentId: oldId});
  487. cursor.forEach(function() {
  488. 'use strict';
  489. const subtask = arguments[0];
  490. subtask.parentId = _id;
  491. subtask._id = null;
  492. /* const newSubtaskId = */ Cards.insert(subtask);
  493. });
  494. // copy card comments
  495. cursor = CardComments.find({cardId: oldId});
  496. cursor.forEach(function () {
  497. 'use strict';
  498. const comment = arguments[0];
  499. comment.cardId = _id;
  500. comment._id = null;
  501. CardComments.insert(comment);
  502. });
  503. }
  504. Popup.close();
  505. }
  506. },
  507. });
  508. BlazeComponent.extendComponent({
  509. onCreated() {
  510. this.currentCard = this.currentData();
  511. this.parentCard = this.currentCard.parentCard();
  512. if (this.parentCard) {
  513. this.parentBoard = this.parentCard.board();
  514. } else {
  515. this.parentBoard = null;
  516. }
  517. },
  518. boards() {
  519. const boards = Boards.find({
  520. archived: false,
  521. 'members.userId': Meteor.userId(),
  522. }, {
  523. sort: ['title'],
  524. });
  525. return boards;
  526. },
  527. cards() {
  528. if (this.parentBoard) {
  529. return this.parentBoard.cards();
  530. } else {
  531. return [];
  532. }
  533. },
  534. isParentBoard() {
  535. const board = this.currentData();
  536. if (this.parentBoard) {
  537. return board._id === this.parentBoard;
  538. }
  539. return false;
  540. },
  541. isParentCard() {
  542. const card = this.currentData();
  543. if (this.parentCard) {
  544. return card._id === this.parentCard;
  545. }
  546. return false;
  547. },
  548. setParentCardId(cardId) {
  549. if (cardId === 'null') {
  550. cardId = null;
  551. this.parentCard = null;
  552. } else {
  553. this.parentCard = Cards.findOne(cardId);
  554. }
  555. this.currentCard.setParentId(cardId);
  556. },
  557. events() {
  558. return [{
  559. 'click .js-copy-card-link-to-clipboard' () {
  560. // Clipboard code from:
  561. // https://stackoverflow.com/questions/6300213/copy-selected-text-to-the-clipboard-without-using-flash-must-be-cross-browser
  562. const StringToCopyElement = document.getElementById('cardURL');
  563. StringToCopyElement.select();
  564. if (document.execCommand('copy')) {
  565. StringToCopyElement.blur();
  566. } else {
  567. document.getElementById('cardURL').selectionStart = 0;
  568. document.getElementById('cardURL').selectionEnd = 999;
  569. document.execCommand('copy');
  570. if (window.getSelection) {
  571. if (window.getSelection().empty) { // Chrome
  572. window.getSelection().empty();
  573. } else if (window.getSelection().removeAllRanges) { // Firefox
  574. window.getSelection().removeAllRanges();
  575. }
  576. } else if (document.selection) { // IE?
  577. document.selection.empty();
  578. }
  579. }
  580. },
  581. 'click .js-delete': Popup.afterConfirm('cardDelete', function () {
  582. Popup.close();
  583. Cards.remove(this._id);
  584. Utils.goBoardId(this.boardId);
  585. }),
  586. 'change .js-field-parent-board'(evt) {
  587. const selection = $(evt.currentTarget).val();
  588. const list = $('.js-field-parent-card');
  589. list.empty();
  590. if (selection === 'none') {
  591. this.parentBoard = null;
  592. list.prop('disabled', true);
  593. } else {
  594. this.parentBoard = Boards.findOne(selection);
  595. this.parentBoard.cards().forEach(function(card) {
  596. list.append(
  597. $('<option></option>').val(card._id).html(card.title)
  598. );
  599. });
  600. list.prop('disabled', false);
  601. }
  602. list.append(
  603. `<option value='none' selected='selected'>${TAPi18n.__('custom-field-dropdown-none')}</option>`
  604. );
  605. this.setParentCardId('null');
  606. },
  607. 'change .js-field-parent-card'(evt) {
  608. const selection = $(evt.currentTarget).val();
  609. this.setParentCardId(selection);
  610. },
  611. }];
  612. },
  613. }).register('cardMorePopup');
  614. // Close the card details pane by pressing escape
  615. EscapeActions.register('detailsPane',
  616. () => {
  617. Utils.goBoardId(Session.get('currentBoard'));
  618. },
  619. () => {
  620. return !Session.equals('currentCard', null);
  621. }, {
  622. noClickEscapeOn: '.js-card-details,.board-sidebar,#header',
  623. }
  624. );