| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826 | import { DatePicker } from '/client/lib/datepicker';import Cards from '/models/cards';import Boards from '/models/boards';import Checklists from '/models/checklists';import Integrations from '/models/integrations';import Users from '/models/users';import Lists from '/models/lists';import CardComments from '/models/cardComments';import { ALLOWED_COLORS } from '/config/const';import moment from 'moment';import { UserAvatar } from '../users/userAvatar';const subManager = new SubsManager();const { calculateIndexData } = Utils;BlazeComponent.extendComponent({  mixins() {    return [Mixins.InfiniteScrolling];  },  calculateNextPeak() {    const cardElement = this.find('.js-card-details');    if (cardElement) {      const altitude = cardElement.scrollHeight;      this.callFirstWith(this, 'setNextPeak', altitude);    }  },  reachNextPeak() {    const activitiesComponent = this.childComponents('activities')[0];    activitiesComponent.loadNextPage();  },  onCreated() {    this.currentBoard = Boards.findOne(Session.get('currentBoard'));    this.isLoaded = new ReactiveVar(false);    if (this.parentComponent() && this.parentComponent().parentComponent()) {      const boardBody = this.parentComponent().parentComponent();      //in Miniview parent is Board, not BoardBody.      if (boardBody !== null) {        boardBody.showOverlay.set(true);        boardBody.mouseHasEnterCardDetails = false;      }    }    this.calculateNextPeak();    Meteor.subscribe('unsaved-edits');    // this.findUsersOptions = new ReactiveVar({});    // this.page = new ReactiveVar(1);    // this.autorun(() => {    //   const limitUsers = this.page.get() * Number.MAX_SAFE_INTEGER;    //   this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});    // });  },  isWatching() {    const card = this.currentData();    return card.findWatcher(Meteor.userId());  },  hiddenSystemMessages() {    return Meteor.user().hasHiddenSystemMessages();  },  customFieldsGrid() {    return Meteor.user().hasCustomFieldsGrid();  },  cardMaximized() {    return !Utils.getPopupCardId() && Meteor.user().hasCardMaximized();  },  canModifyCard() {    return (      Meteor.user() &&      Meteor.user().isBoardMember() &&      !Meteor.user().isCommentOnly() &&      !Meteor.user().isWorker()    );  },  scrollParentContainer() {    const cardPanelWidth = 600;    const parentComponent = this.parentComponent();    // TODO sometimes parentComponent is not available, maybe because it's not    // yet created?!    if (!parentComponent) return;    const bodyBoardComponent = parentComponent.parentComponent();    //On Mobile View Parent is Board, Not Board Body. I cant see how this funciton should work then.    if (bodyBoardComponent === null) return;    const $cardView = this.$(this.firstNode());    const $cardContainer = bodyBoardComponent.$('.js-swimlanes');    // TODO sometimes cardContainer is not available, maybe because it's not yet    // created?!    if (!$cardContainer) return;    const cardContainerScroll = $cardContainer.scrollLeft();    const cardContainerWidth = $cardContainer.width();    const cardViewStart = $cardView.offset().left;    const cardViewEnd = cardViewStart + cardPanelWidth;    let offset = false;    if (cardViewStart < 0) {      offset = cardViewStart;    } else if (cardViewEnd > cardContainerWidth) {      offset = cardViewEnd - cardContainerWidth;    }    if (offset) {      bodyBoardComponent.scrollLeft(cardContainerScroll + offset);    }    //Scroll top    const cardViewStartTop = $cardView.offset().top;    const cardContainerScrollTop = $cardContainer.scrollTop();    let topOffset = false;    if (cardViewStartTop !== 100) {      topOffset = cardViewStartTop - 100;    }    if (topOffset !== false) {      bodyBoardComponent.scrollTop(cardContainerScrollTop + topOffset);    }  },  presentParentTask() {    let result = this.currentBoard.presentParentTask;    if (result === null || result === undefined) {      result = 'no-parent';    }    return result;  },  linkForCard() {    const card = this.currentData();    let result = '#';    if (card) {      const board = Boards.findOne(card.boardId);      if (board) {        result = FlowRouter.path('card', {          boardId: card.boardId,          slug: board.slug,          cardId: card._id,        });      }    }    return result;  },  showVotingButtons() {    const card = this.currentData();    return (      (currentUser.isBoardMember() ||        (currentUser && card.voteAllowNonBoardMembers())) &&      !card.expiredVote()    );  },  showPlanningPokerButtons() {    const card = this.currentData();    return (      (currentUser.isBoardMember() ||        (currentUser && card.pokerAllowNonBoardMembers())) &&      !card.expiredPoker()    );  },  /** returns if the list id is the current list id   * @param listId list id to check   * @return is the list id the current list id ?   */  isCurrentListId(listId) {    const ret = this.data().listId == listId;    return ret;  },  onRendered() {    if (Meteor.settings.public.CARD_OPENED_WEBHOOK_ENABLED) {      // Send Webhook but not create Activities records ---      const card = this.currentData();      const userId = Meteor.userId();      const params = {        userId,        cardId: card._id,        boardId: card.boardId,        listId: card.listId,        user: Meteor.user().username,        url: '',      };      const integrations = Integrations.find({        boardId: { $in: [card.boardId, Integrations.Const.GLOBAL_WEBHOOK_ID] },        enabled: true,        activities: { $in: ['CardDetailsRendered', 'all'] },      }).fetch();      if (integrations.length > 0) {        integrations.forEach((integration) => {          Meteor.call(            'outgoingWebhooks',            integration,            'CardSelected',            params,            () => { },          );        });      }      //-------------    }    if (!Utils.isMiniScreen()) {      Meteor.setTimeout(() => {        this.scrollParentContainer();      }, 500);    }    const $checklistsDom = this.$('.card-checklist-items');    $checklistsDom.sortable({      tolerance: 'pointer',      helper: 'clone',      handle: '.checklist-title',      items: '.js-checklist',      placeholder: 'checklist placeholder',      distance: 7,      start(evt, ui) {        ui.placeholder.height(ui.helper.height());        EscapeActions.clickExecute(evt.target, 'inlinedForm');      },      stop(evt, ui) {        let prevChecklist = ui.item.prev('.js-checklist').get(0);        if (prevChecklist) {          prevChecklist = Blaze.getData(prevChecklist).checklist;        }        let nextChecklist = ui.item.next('.js-checklist').get(0);        if (nextChecklist) {          nextChecklist = Blaze.getData(nextChecklist).checklist;        }        const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);        $checklistsDom.sortable('cancel');        const checklist = Blaze.getData(ui.item.get(0)).checklist;        Checklists.update(checklist._id, {          $set: {            sort: sortIndex.base,          },        });      },    });    const $subtasksDom = this.$('.card-subtasks-items');    $subtasksDom.sortable({      tolerance: 'pointer',      helper: 'clone',      handle: '.subtask-title',      items: '.js-subtasks',      placeholder: 'subtasks placeholder',      distance: 7,      start(evt, ui) {        ui.placeholder.height(ui.helper.height());        EscapeActions.executeUpTo('popup-close');      },      stop(evt, ui) {        let prevChecklist = ui.item.prev('.js-subtasks').get(0);        if (prevChecklist) {          prevChecklist = Blaze.getData(prevChecklist).subtask;        }        let nextChecklist = ui.item.next('.js-subtasks').get(0);        if (nextChecklist) {          nextChecklist = Blaze.getData(nextChecklist).subtask;        }        const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1);        $subtasksDom.sortable('cancel');        const subtask = Blaze.getData(ui.item.get(0)).subtask;        Subtasks.update(subtask._id, {          $set: {            subtaskSort: sortIndex.base,          },        });      },    });    function userIsMember() {      return Meteor.user() && Meteor.user().isBoardMember();    }    // Disable sorting if the current user is not a board member    this.autorun(() => {      const disabled = !userIsMember();      if (        $checklistsDom.data('uiSortable') ||        $checklistsDom.data('sortable')      ) {        $checklistsDom.sortable('option', 'disabled', disabled);        if (Utils.isMiniScreenOrShowDesktopDragHandles()) {          $checklistsDom.sortable({ handle: '.checklist-handle' });        }      }      if ($subtasksDom.data('uiSortable') || $subtasksDom.data('sortable')) {        $subtasksDom.sortable('option', 'disabled', disabled);      }    });  },  onDestroyed() {    if (this.parentComponent() === null) return;    const parentComponent = this.parentComponent().parentComponent();    //on mobile view parent is Board, not board body.    if (parentComponent === null) return;    parentComponent.showOverlay.set(false);  },  events() {    const events = {      [`${CSSEvents.transitionend} .js-card-details`]() {        this.isLoaded.set(true);      },      [`${CSSEvents.animationend} .js-card-details`]() {        this.isLoaded.set(true);      },    };    return [      {        ...events,        'click .js-close-card-details'() {          Utils.goBoardId(this.data().boardId);        },        'click .js-copy-link'(event) {          event.preventDefault();          const promise = Utils.copyTextToClipboard(event.target.href);          const $tooltip = this.$('.card-details-header .copied-tooltip');          Utils.showCopied(promise, $tooltip);        },        'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),        'submit .js-card-description'(event) {          event.preventDefault();          const description = this.currentComponent().getValue();          this.data().setDescription(description);        },        'submit .js-card-details-title'(event) {          event.preventDefault();          const title = this.currentComponent().getValue().trim();          if (title) {            this.data().setTitle(title);          } else {            this.data().setTitle('');          }        },        'submit .js-card-details-assigner'(event) {          event.preventDefault();          const assigner = this.currentComponent().getValue().trim();          if (assigner) {            this.data().setAssignedBy(assigner);          } else {            this.data().setAssignedBy('');          }        },        'submit .js-card-details-requester'(event) {          event.preventDefault();          const requester = this.currentComponent().getValue().trim();          if (requester) {            this.data().setRequestedBy(requester);          } else {            this.data().setRequestedBy('');          }        },        'keydown input.js-edit-card-sort'(evt) {          // enter = save          if (evt.keyCode === 13) {            this.find('button[type=submit]').click();          }        },        'submit .js-card-details-sort'(event) {          event.preventDefault();          const sort = parseFloat(this.currentComponent()            .getValue()            .trim());          if (!Number.isNaN(sort)) {            let card = this.data();            card.move(card.boardId, card.swimlaneId, card.listId, sort);          }        },        'change .js-select-card-details-lists'(event) {          let card = this.data();          const listSelect = this.$('.js-select-card-details-lists')[0];          const listId = listSelect.options[listSelect.selectedIndex].value;          card.move(card.boardId, card.swimlaneId, listId, card.sort);        },        'click .js-go-to-linked-card'() {          Utils.goCardId(this.data().linkedId);        },        'click .js-member': Popup.open('cardMember'),        'click .js-add-members': Popup.open('cardMembers'),        'click .js-assignee': Popup.open('cardAssignee'),        'click .js-add-assignees': Popup.open('cardAssignees'),        'click .js-add-labels': Popup.open('cardLabels'),        'click .js-received-date': Popup.open('editCardReceivedDate'),        'click .js-start-date': Popup.open('editCardStartDate'),        'click .js-due-date': Popup.open('editCardDueDate'),        'click .js-end-date': Popup.open('editCardEndDate'),        'click .js-show-positive-votes': Popup.open('positiveVoteMembers'),        'click .js-show-negative-votes': Popup.open('negativeVoteMembers'),        'click .js-custom-fields': Popup.open('cardCustomFields'),        'mouseenter .js-card-details'() {          if (this.parentComponent() === null) return;          const parentComponent = this.parentComponent().parentComponent();          //on mobile view parent is Board, not BoardBody.          if (parentComponent === null) return;          parentComponent.showOverlay.set(true);          parentComponent.mouseHasEnterCardDetails = true;        },        'mousedown .js-card-details'() {          Session.set('cardDetailsIsDragging', false);          Session.set('cardDetailsIsMouseDown', true);        },        'mousemove .js-card-details'() {          if (Session.get('cardDetailsIsMouseDown')) {            Session.set('cardDetailsIsDragging', true);          }        },        'mouseup .js-card-details'() {          Session.set('cardDetailsIsDragging', false);          Session.set('cardDetailsIsMouseDown', false);        },        'click #toggleButton'() {          Meteor.call('toggleSystemMessages');        },        'click #toggleCustomFieldsGridButton'() {          Meteor.call('toggleCustomFieldsGrid');        },        'click .js-maximize-card-details'() {          Meteor.call('toggleCardMaximized');          autosize($('.card-details'));        },        'click .js-minimize-card-details'() {          Meteor.call('toggleCardMaximized');          autosize($('.card-details'));        },        'click .js-vote'(e) {          const forIt = $(e.target).hasClass('js-vote-positive');          let newState = null;          if (            this.data().voteState() === null ||            (this.data().voteState() === false && forIt) ||            (this.data().voteState() === true && !forIt)          ) {            newState = forIt;          }          this.data().setVote(Meteor.userId(), newState);        },        'click .js-poker'(e) {          let newState = null;          if ($(e.target).hasClass('js-poker-vote-one')) {            newState = 'one';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-two')) {            newState = 'two';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-three')) {            newState = 'three';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-five')) {            newState = 'five';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-eight')) {            newState = 'eight';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-thirteen')) {            newState = 'thirteen';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-twenty')) {            newState = 'twenty';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-forty')) {            newState = 'forty';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-one-hundred')) {            newState = 'oneHundred';            this.data().setPoker(Meteor.userId(), newState);          }          if ($(e.target).hasClass('js-poker-vote-unsure')) {            newState = 'unsure';            this.data().setPoker(Meteor.userId(), newState);          }        },        'click .js-poker-finish'(e) {          if ($(e.target).hasClass('js-poker-finish')) {            e.preventDefault();            const now = moment().format('YYYY-MM-DD HH:mm');            this.data().setPokerEnd(now);          }        },        'click .js-poker-replay'(e) {          if ($(e.target).hasClass('js-poker-replay')) {            e.preventDefault();            this.currentCard = this.currentData();            this.currentCard.replayPoker();            this.data().unsetPokerEnd();            this.data().unsetPokerEstimation();          }        },        'click .js-poker-estimation'(event) {          event.preventDefault();          const ruleTitle = this.find('#pokerEstimation').value;          if (ruleTitle !== undefined && ruleTitle !== '') {            this.find('#pokerEstimation').value = '';            if (ruleTitle) {              this.data().setPokerEstimation(parseInt(ruleTitle, 10));            } else {              this.data().setPokerEstimation('');            }          }        },      },    ];  },}).register('cardDetails');Template.cardDetails.helpers({  isPopup() {    let ret = !!Utils.getPopupCardId();    return ret;  }});Template.cardDetailsPopup.onDestroyed(() => {  Session.delete('popupCardId');  Session.delete('popupCardBoardId');});Template.cardDetailsPopup.helpers({  popupCard() {    const ret = Utils.getPopupCard();    return ret;  },});BlazeComponent.extendComponent({  template() {    return 'exportCard';  },  withApi() {    return Template.instance().apiEnabled.get();  },  exportUrlCardPDF() {    const params = {      boardId: Session.get('currentBoard'),      listId: this.listId,      cardId: this.cardId,    };    const queryParams = {      authToken: Accounts._storedLoginToken(),    };    return FlowRouter.path(      '/api/boards/:boardId/lists/:listId/cards/:cardId/exportPDF',      params,      queryParams,    );  },  exportFilenameCardPDF() {    //const boardId = Session.get('currentBoard');    //return `export-card-pdf-${boardId}.xlsx`;    return `export-card.pdf`;  },}).register('exportCardPopup');// only allow number inputTemplate.editCardSortOrderForm.onRendered(function () {  this.$('input').on("keypress paste", function (event) {    let keyCode = event.keyCode;    let charCode = String.fromCharCode(keyCode);    let regex = new RegExp('[-0-9.]');    let ret = regex.test(charCode);    // only working here, defining in events() doesn't handle the return value correctly    return ret;  });});// We extends the normal InlinedForm component to support UnsavedEdits draft// feature.(class extends InlinedForm {  _getUnsavedEditKey() {    return {      fieldName: 'cardDescription',      // XXX Recovering the currentCard identifier form a session variable is      // fragile because this variable may change for instance if the route      // change. We should use some component props instead.      docId: Utils.getCurrentCardId(),    };  }  close(isReset = false) {    if (this.isOpen.get() && !isReset) {      const draft = this.getValue().trim();      let card = Utils.getCurrentCard();      if (card && draft !== card.getDescription()) {        UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue());      }    }    super.close();  }  reset() {    UnsavedEdits.reset(this._getUnsavedEditKey());    this.close(true);  }  events() {    const parentEvents = InlinedForm.prototype.events()[0];    return [      {        ...parentEvents,        'click .js-close-inlined-form': this.reset,      },    ];  }}.register('inlinedCardDescription'));Template.cardDetailsActionsPopup.helpers({  isWatching() {    return this.findWatcher(Meteor.userId());  },  isBoardAdmin() {    return Meteor.user().isBoardAdmin();  },  canModifyCard() {    return (      Meteor.user() &&      Meteor.user().isBoardMember() &&      !Meteor.user().isCommentOnly()    );  },});Template.cardDetailsActionsPopup.events({  'click .js-export-card': Popup.open('exportCard'),  'click .js-members': Popup.open('cardMembers'),  'click .js-assignees': Popup.open('cardAssignees'),  'click .js-attachments': Popup.open('cardAttachments'),  'click .js-start-voting': Popup.open('cardStartVoting'),  'click .js-start-planning-poker': Popup.open('cardStartPlanningPoker'),  'click .js-custom-fields': Popup.open('cardCustomFields'),  'click .js-received-date': Popup.open('editCardReceivedDate'),  'click .js-start-date': Popup.open('editCardStartDate'),  'click .js-due-date': Popup.open('editCardDueDate'),  'click .js-end-date': Popup.open('editCardEndDate'),  'click .js-spent-time': Popup.open('editCardSpentTime'),  'click .js-move-card': Popup.open('moveCard'),  'click .js-copy-card': Popup.open('copyCard'),  'click .js-convert-checklist-item-to-card': Popup.open('convertChecklistItemToCard'),  'click .js-copy-checklist-cards': Popup.open('copyChecklistToManyCards'),  'click .js-set-card-color': Popup.open('setCardColor'),  'click .js-move-card-to-top'(event) {    event.preventDefault();    const minOrder = _.min(      this.list()        .cardsUnfiltered(this.swimlaneId)        .map((c) => c.sort),    );    this.move(this.boardId, this.swimlaneId, this.listId, minOrder - 1);    Popup.back();  },  'click .js-move-card-to-bottom'(event) {    event.preventDefault();    const maxOrder = _.max(      this.list()        .cardsUnfiltered(this.swimlaneId)        .map((c) => c.sort),    );    this.move(this.boardId, this.swimlaneId, this.listId, maxOrder + 1);    Popup.back();  },  'click .js-archive': Popup.afterConfirm('cardArchive', function () {    Popup.close();    this.archive();    Utils.goBoardId(this.boardId);  }),  'click .js-more': Popup.open('cardMore'),  'click .js-toggle-watch-card'() {    const currentCard = this;    const level = currentCard.findWatcher(Meteor.userId()) ? null : 'watching';    Meteor.call('watch', 'card', currentCard._id, level, (err, ret) => {      if (!err && ret) Popup.close();    });  },});BlazeComponent.extendComponent({  onRendered() {    autosize(this.$('textarea.js-edit-card-title'));  },  events() {    return [      {        'click a.fa.fa-copy'(event) {          const $editor = this.$('textarea');          const promise = Utils.copyTextToClipboard($editor[0].value);          const $tooltip = this.$('.copied-tooltip');          Utils.showCopied(promise, $tooltip);        },        'keydown .js-edit-card-title'(event) {          // If enter key was pressed, submit the data          // Unless the shift key is also being pressed          if (event.keyCode === 13 && !event.shiftKey) {            $('.js-submit-edit-card-title-form').click();          }        },      }    ];  }}).register('editCardTitleForm');Template.cardMembersPopup.onCreated(function () {  let currBoard = Boards.findOne(Session.get('currentBoard'));  let members = currBoard.activeMembers();  // let query = {  //   "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },  // };  // let boardTeamUsers = Users.find(query, {  //   sort: { sort: 1 },  // });  // members = currBoard.activeMembers2(members, boardTeamUsers);  this.members = new ReactiveVar(members);});Template.cardMembersPopup.events({  'keyup .card-members-filter'(event) {    const members = filterMembers(event.target.value);    Template.instance().members.set(members);  }});Template.cardMembersPopup.helpers({  members() {    return Template.instance().members.get();  },});const filterMembers = (filterTerm) => {  let currBoard = Boards.findOne(Session.get('currentBoard'));  let members = currBoard.activeMembers();  // let query = {  //   "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },  // };  // let boardTeamUsers = Users.find(query, {  //   sort: { sort: 1 },  // });  // members = currBoard.activeMembers2(members, boardTeamUsers);  if (filterTerm) {    members = members      .map(member => ({        member,        user: Users.findOne(member.userId)      }))      .filter(({ user }) =>      (user.profile.fullname !== undefined && user.profile.fullname.toLowerCase().indexOf(filterTerm.toLowerCase()) !== -1)      || user.profile.fullname === undefined && user.profile.username !== undefined && user.profile.username.toLowerCase().indexOf(filterTerm.toLowerCase()) !== -1)      .map(({ member }) => member);  }  return members;}Template.editCardRequesterForm.onRendered(function () {  autosize(this.$('.js-edit-card-requester'));});Template.editCardRequesterForm.events({  'keydown .js-edit-card-requester'(event) {    // If enter key was pressed, submit the data    if (event.keyCode === 13) {      $('.js-submit-edit-card-requester-form').click();    }  },});Template.editCardAssignerForm.onRendered(function () {  autosize(this.$('.js-edit-card-assigner'));});Template.editCardAssignerForm.events({  'keydown .js-edit-card-assigner'(event) {    // If enter key was pressed, submit the data    if (event.keyCode === 13) {      $('.js-submit-edit-card-assigner-form').click();    }  },});Template.moveCardPopup.events({  'click .js-done'() {    const card = Cards.findOne(this._id);    const bSelect = $('.js-select-boards')[0];    let boardId;    // if we are a worker, we won't have a board select so we just use the    // current boardId of the card.    if (bSelect) {      boardId = bSelect.options[bSelect.selectedIndex].value;    } else {      boardId = card.boardId;    }    const lSelect = $('.js-select-lists')[0];    const listId = lSelect.options[lSelect.selectedIndex].value;    const slSelect = $('.js-select-swimlanes')[0];    const swimlaneId = slSelect.options[slSelect.selectedIndex].value;    card.move(boardId, swimlaneId, listId, 0);    // set new id's to card object in case the card is moved to top by the comment "moveCard" after this command (.js-move-card)    this.boardId = boardId;    this.swimlaneId = swimlaneId;    this.listId = listId;    Popup.back();  },});BlazeComponent.extendComponent({  onCreated() {    this.currentBoardId = Utils.getCurrentBoardId();    this.selectedBoardId = new ReactiveVar(this.currentBoardId);    this.setMoveAndCopyDialogOption(this.currentBoardId);  },  /** set the last confirmed dialog field values   * @param boardId the current board id   */  setMoveAndCopyDialogOption(boardId) {    this.moveAndCopyDialogOption = {      'boardId' : "",      'swimlaneId' : "",      'listId' : "",    }    let currentOptions = Meteor.user().getMoveAndCopyDialogOptions();    if (currentOptions && boardId && currentOptions[boardId]) {      this.moveAndCopyDialogOption = currentOptions[boardId];      if (this.moveAndCopyDialogOption.boardId) {        this.selectedBoardId.set(this.moveAndCopyDialogOption.boardId)      }    }    subManager.subscribe('board', this.selectedBoardId.get(), false);  },  /** returns if the board id was the last confirmed one   * @param boardId check this board id   * @return if the board id was the last confirmed one   */  isMoveAndCopyDialogOptionBoardId(boardId) {    let ret = this.moveAndCopyDialogOption.boardId == boardId;    return ret;  },  /** returns if the swimlane id was the last confirmed one   * @param swimlaneId check this swimlane id   * @return if the swimlane id was the last confirmed one   */  isMoveAndCopyDialogOptionSwimlaneId(swimlaneId) {    let ret = this.moveAndCopyDialogOption.swimlaneId == swimlaneId;    return ret;  },  /** returns if the list id was the last confirmed one   * @param listId check this list id   * @return if the list id was the last confirmed one   */  isMoveAndCopyDialogOptionListId(listId) {    let ret = this.moveAndCopyDialogOption.listId == listId;    return ret;  },  boards() {    return Boards.find(      {        archived: false,        'members.userId': Meteor.userId(),        _id: { $ne: Meteor.user().getTemplatesBoardId() },      },      {        sort: { sort: 1 /* boards default sorting */ },      },    );  },  swimlanes() {    const board = Boards.findOne(this.selectedBoardId.get());    return board.swimlanes();  },  aBoardLists() {    const board = Boards.findOne(this.selectedBoardId.get());    return board.lists();  },  events() {    return [      {        'click .js-done'() {          const boardSelect = this.$('.js-select-boards')[0];          const boardId = boardSelect.options[boardSelect.selectedIndex].value;          const listSelect = this.$('.js-select-lists')[0];          const listId = listSelect.options[listSelect.selectedIndex].value;          const swimlaneSelect = this.$('.js-select-swimlanes')[0];          const swimlaneId = swimlaneSelect.options[swimlaneSelect.selectedIndex].value;          const options = {            'boardId' : boardId,            'swimlaneId' : swimlaneId,            'listId' : listId,          }          Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);        },        'change .js-select-boards'(event) {          const boardId = $(event.currentTarget).val();          this.selectedBoardId.set(boardId);          subManager.subscribe('board', boardId, false);        },      },    ];  },}).register('boardsAndLists');Template.copyCardPopup.events({  'click .js-done'() {    const card = Utils.getCurrentCard();    const lSelect = $('.js-select-lists')[0];    const listId = lSelect.options[lSelect.selectedIndex].value;    const slSelect = $('.js-select-swimlanes')[0];    const swimlaneId = slSelect.options[slSelect.selectedIndex].value;    const bSelect = $('.js-select-boards')[0];    const boardId = bSelect.options[bSelect.selectedIndex].value;    const textarea = $('#copy-card-title');    const title = textarea.val().trim();    // insert new card to the bottom of new list    card.sort = Lists.findOne(card.listId).cards().count();    if (title) {      card.title = title;      card.coverId = '';      const _id = card.copy(boardId, swimlaneId, listId);      // In case the filter is active we need to add the newly inserted card in      // the list of exceptions -- cards that are not filtered. Otherwise the      // card will disappear instantly.      // See https://github.com/wekan/wekan/issues/80      Filter.addException(_id);      Popup.back();    }  },});Template.convertChecklistItemToCardPopup.events({  'click .js-done'() {    const card = Utils.getCurrentCard();    const lSelect = $('.js-select-lists')[0];    const listId = lSelect.options[lSelect.selectedIndex].value;    const slSelect = $('.js-select-swimlanes')[0];    const swimlaneId = slSelect.options[slSelect.selectedIndex].value;    const bSelect = $('.js-select-boards')[0];    const boardId = bSelect.options[bSelect.selectedIndex].value;    const textarea = $('#copy-card-title');    const title = textarea.val().trim();    if (title) {      const _id = Cards.insert({        title: title,        listId: listId,        boardId: boardId,        swimlaneId: swimlaneId,        sort: 0,      });      Filter.addException(_id);      Popup.back();    }  },});Template.copyChecklistToManyCardsPopup.events({  'click .js-done'() {    const card = Utils.getCurrentCard();    const oldId = card._id;    card._id = null;    const lSelect = $('.js-select-lists')[0];    card.listId = lSelect.options[lSelect.selectedIndex].value;    const slSelect = $('.js-select-swimlanes')[0];    card.swimlaneId = slSelect.options[slSelect.selectedIndex].value;    const bSelect = $('.js-select-boards')[0];    card.boardId = bSelect.options[bSelect.selectedIndex].value;    const textarea = $('#copy-card-title');    const titleEntry = textarea.val().trim();    // insert new card to the bottom of new list    card.sort = Lists.findOne(card.listId).cards().count();    if (titleEntry) {      const titleList = JSON.parse(titleEntry);      for (let i = 0; i < titleList.length; i++) {        const obj = titleList[i];        card.title = obj.title;        card.description = obj.description;        card.coverId = '';        const _id = Cards.insert(card);        // In case the filter is active we need to add the newly inserted card in        // the list of exceptions -- cards that are not filtered. Otherwise the        // card will disappear instantly.        // See https://github.com/wekan/wekan/issues/80        Filter.addException(_id);        // copy checklists        Checklists.find({ cardId: oldId }).forEach((ch) => {          ch.copy(_id);        });        // copy subtasks        const cursor = Cards.find({ parentId: oldId });        cursor.forEach(function () {          'use strict';          const subtask = arguments[0];          subtask.parentId = _id;          subtask._id = null;          /* const newSubtaskId = */ Cards.insert(subtask);        });        // copy card comments        CardComments.find({ cardId: oldId }).forEach((cmt) => {          cmt.copy(_id);        });      }      Popup.back();    }  },});BlazeComponent.extendComponent({  onCreated() {    this.currentCard = this.currentData();    this.currentColor = new ReactiveVar(this.currentCard.color);  },  colors() {    return ALLOWED_COLORS.map((color) => ({ color, name: '' }));  },  isSelected(color) {    if (this.currentColor.get() === null) {      return color === 'white';    }    return this.currentColor.get() === color;  },  events() {    return [      {        'click .js-palette-color'() {          this.currentColor.set(this.currentData().color);        },        'click .js-submit'() {          this.currentCard.setColor(this.currentColor.get());          Popup.close();        },        'click .js-remove-color'() {          this.currentCard.setColor(null);          Popup.close();        },      },    ];  },}).register('setCardColorPopup');BlazeComponent.extendComponent({  onCreated() {    this.currentCard = this.currentData();    this.parentBoard = new ReactiveVar(null);    this.parentCard = this.currentCard.parentCard();    if (this.parentCard) {      const list = $('.js-field-parent-card');      list.val(this.parentCard._id);      this.parentBoard.set(this.parentCard.board()._id);    } else {      this.parentBoard.set(null);    }  },  boards() {    return Boards.find(      {        archived: false,        'members.userId': Meteor.userId(),        _id: {          $ne: Meteor.user().getTemplatesBoardId(),        },      },      {        sort: { sort: 1 /* boards default sorting */ },      },    );  },  cards() {    const currentId = Utils.getCurrentCardId();    if (this.parentBoard.get()) {      return Cards.find({        boardId: this.parentBoard.get(),        _id: { $ne: currentId },      });    } else {      return [];    }  },  isParentBoard() {    const board = this.currentData();    if (this.parentBoard.get()) {      return board._id === this.parentBoard.get();    }    return false;  },  isParentCard() {    const card = this.currentData();    if (this.parentCard) {      return card._id === this.parentCard;    }    return false;  },  setParentCardId(cardId) {    if (cardId) {      this.parentCard = Cards.findOne(cardId);    } else {      this.parentCard = null;    }    this.currentCard.setParentId(cardId);  },  events() {    return [      {        'click .js-copy-card-link-to-clipboard'(event) {          const promise = Utils.copyTextToClipboard(location.origin + document.getElementById('cardURL').value);          const $tooltip = this.$('.copied-tooltip');          Utils.showCopied(promise, $tooltip);        },        'click .js-delete': Popup.afterConfirm('cardDelete', function () {          Popup.close();          // verify that there are no linked cards          if (Cards.find({ linkedId: this._id }).count() === 0) {            Cards.remove(this._id);          } else {            // TODO: Maybe later we can list where the linked cards are.            // Now here is popup with a hint that the card cannot be deleted            // as there are linked cards.            // Related:            //   client/components/lists/listHeader.js about line 248            //   https://github.com/wekan/wekan/issues/2785            const message = `${TAPi18n.__(              'delete-linked-card-before-this-card',            )} linkedId: ${this._id              } at client/components/cards/cardDetails.js and https://github.com/wekan/wekan/issues/2785`;            alert(message);          }          Utils.goBoardId(this.boardId);        }),        'change .js-field-parent-board'(event) {          const selection = $(event.currentTarget).val();          const list = $('.js-field-parent-card');          if (selection === 'none') {            this.parentBoard.set(null);          } else {            subManager.subscribe('board', $(event.currentTarget).val(), false);            this.parentBoard.set(selection);            list.prop('disabled', false);          }          this.setParentCardId(null);        },        'change .js-field-parent-card'(event) {          const selection = $(event.currentTarget).val();          this.setParentCardId(selection);        },      },    ];  },}).register('cardMorePopup');BlazeComponent.extendComponent({  onCreated() {    this.currentCard = this.currentData();    this.voteQuestion = new ReactiveVar(this.currentCard.voteQuestion);  },  events() {    return [      {        'click .js-end-date': Popup.open('editVoteEndDate'),        'submit .edit-vote-question'(evt) {          evt.preventDefault();          const voteQuestion = evt.target.vote.value;          const publicVote = $('#vote-public').hasClass('is-checked');          const allowNonBoardMembers = $('#vote-allow-non-members').hasClass(            'is-checked',          );          const endString = this.currentCard.getVoteEnd();          this.currentCard.setVoteQuestion(            voteQuestion,            publicVote,            allowNonBoardMembers,          );          if (endString) {            this.currentCard.setVoteEnd(endString);          }          Popup.back();        },        'click .js-remove-vote': Popup.afterConfirm('deleteVote', () => {          event.preventDefault();          this.currentCard.unsetVote();          Popup.back();        }),        'click a.js-toggle-vote-public'(event) {          event.preventDefault();          $('#vote-public').toggleClass('is-checked');        },        'click a.js-toggle-vote-allow-non-members'(event) {          event.preventDefault();          $('#vote-allow-non-members').toggleClass('is-checked');        },      },    ];  },}).register('cardStartVotingPopup');// editVoteEndDatePopup(class extends DatePicker {  onCreated() {    super.onCreated(moment().format('YYYY-MM-DD HH:mm'));    this.data().getVoteEnd() && this.date.set(moment(this.data().getVoteEnd()));  }  events() {    return [      {        'submit .edit-date'(evt) {          evt.preventDefault();          // if no time was given, init with 12:00          const time =            evt.target.time.value ||            moment(new Date().setHours(12, 0, 0)).format('LT');          const dateString = `${evt.target.date.value} ${time}`;          /*          const newDate = moment(dateString, 'L LT', true);          if (newDate.isValid()) {            // if active vote -  store it            if (this.currentData().getVoteQuestion()) {              this._storeDate(newDate.toDate());              Popup.back();            } else {              this.currentData().vote = { end: newDate.toDate() }; // set vote end temp              Popup.back();            }          */          // Try to parse different date formats of all languages.          // This code is same for vote and planning poker.          const usaDate = moment(dateString, 'L LT', true);          const euroAmDate = moment(dateString, 'DD.MM.YYYY LT', true);          const euro24hDate = moment(dateString, 'DD.MM.YYYY HH.mm', true);          const eurodotDate = moment(dateString, 'DD.MM.YYYY HH:mm', true);          const minusDate = moment(dateString, 'YYYY-MM-DD HH:mm', true);          const slashDate = moment(dateString, 'DD/MM/YYYY HH.mm', true);          const dotDate = moment(dateString, 'DD/MM/YYYY HH:mm', true);          const brezhonegDate = moment(dateString, 'DD/MM/YYYY h[e]mm A', true);          const hrvatskiDate = moment(dateString, 'DD. MM. YYYY H:mm', true);          const latviaDate = moment(dateString, 'YYYY.MM.DD. H:mm', true);          const nederlandsDate = moment(dateString, 'DD-MM-YYYY HH:mm', true);          // greekDate does not work: el Greek Ελληνικά ,          // it has date format DD/MM/YYYY h:mm MM like 20/06/2021 11:15 MM          // where MM is maybe some text like AM/PM ?          // Also some other languages that have non-ascii characters in dates          // do not work.          const greekDate = moment(dateString, 'DD/MM/YYYY h:mm A', true);          const macedonianDate = moment(dateString, 'D.MM.YYYY H:mm', true);          if (usaDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(usaDate.toDate());            } else {              this.currentData().poker = { end: usaDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (euroAmDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(euroAmDate.toDate());            } else {              this.currentData().poker = { end: euroAmDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (euro24hDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(euro24hDate.toDate());              this.card.setPokerEnd(euro24hDate.toDate());            } else {              this.currentData().poker = { end: euro24hDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (eurodotDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(eurodotDate.toDate());              this.card.setPokerEnd(eurodotDate.toDate());            } else {              this.currentData().poker = { end: eurodotDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (minusDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(minusDate.toDate());              this.card.setPokerEnd(minusDate.toDate());            } else {              this.currentData().poker = { end: minusDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (slashDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(slashDate.toDate());              this.card.setPokerEnd(slashDate.toDate());            } else {              this.currentData().poker = { end: slashDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (dotDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(dotDate.toDate());              this.card.setPokerEnd(dotDate.toDate());            } else {              this.currentData().poker = { end: dotDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (brezhonegDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(brezhonegDate.toDate());              this.card.setPokerEnd(brezhonegDate.toDate());            } else {              this.currentData().poker = { end: brezhonegDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (hrvatskiDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(hrvatskiDate.toDate());              this.card.setPokerEnd(hrvatskiDate.toDate());            } else {              this.currentData().poker = { end: hrvatskiDate.toDate() }; // set poker end temp              Popup.back();            }          } else if (latviaDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(latviaDate.toDate());              this.card.setPokerEnd(latviaDate.toDate());            } else {              this.currentData().poker = { end: latviaDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (nederlandsDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(nederlandsDate.toDate());              this.card.setPokerEnd(nederlandsDate.toDate());            } else {              this.currentData().poker = { end: nederlandsDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (greekDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(greekDate.toDate());              this.card.setPokerEnd(greekDate.toDate());            } else {              this.currentData().poker = { end: greekDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (macedonianDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(macedonianDate.toDate());              this.card.setPokerEnd(macedonianDate.toDate());            } else {              this.currentData().poker = { end: macedonianDate.toDate() }; // set poker end temp            }            Popup.back();          } else {            this.error.set('invalid-date');            evt.target.date.focus();          }        },        'click .js-delete-date'(evt) {          evt.preventDefault();          this._deleteDate();          Popup.back();        },      },    ];  }  _storeDate(newDate) {    this.card.setVoteEnd(newDate);  }  _deleteDate() {    this.card.unsetVoteEnd();  }}.register('editVoteEndDatePopup'));BlazeComponent.extendComponent({  onCreated() {    this.currentCard = this.currentData();    this.pokerQuestion = new ReactiveVar(this.currentCard.pokerQuestion);  },  events() {    return [      {        'click .js-end-date': Popup.open('editPokerEndDate'),        'submit .edit-poker-question'(evt) {          evt.preventDefault();          const pokerQuestion = true;          const allowNonBoardMembers = $('#poker-allow-non-members').hasClass(            'is-checked',          );          const endString = this.currentCard.getPokerEnd();          this.currentCard.setPokerQuestion(            pokerQuestion,            allowNonBoardMembers,          );          if (endString) {            this.currentCard.setPokerEnd(endString);          }          Popup.back();        },        'click .js-remove-poker': Popup.afterConfirm('deletePoker', (event) => {          this.currentCard.unsetPoker();          Popup.back();        }),        'click a.js-toggle-poker-allow-non-members'(event) {          event.preventDefault();          $('#poker-allow-non-members').toggleClass('is-checked');        },      },    ];  },}).register('cardStartPlanningPokerPopup');// editPokerEndDatePopup(class extends DatePicker {  onCreated() {    super.onCreated(moment().format('YYYY-MM-DD HH:mm'));    this.data().getPokerEnd() &&      this.date.set(moment(this.data().getPokerEnd()));  }  /*  Tried to use dateFormat and timeFormat from client/components/lib/datepicker.js  to make detecting all date formats not necessary,  but got error "language mk does not exist".  Maybe client/components/lib/datepicker.jade could have hidden input field for  datepicker format that could be used to detect date format?  dateFormat() {    return moment.localeData().longDateFormat('L');  }  timeFormat() {    return moment.localeData().longDateFormat('LT');  }  const newDate = moment(dateString, dateformat() + ' ' + timeformat(), true);  */  events() {    return [      {        'submit .edit-date'(evt) {          evt.preventDefault();          // if no time was given, init with 12:00          const time =            evt.target.time.value ||            moment(new Date().setHours(12, 0, 0)).format('LT');          const dateString = `${evt.target.date.value} ${time}`;          /*          Tried to use dateFormat and timeFormat from client/components/lib/datepicker.js          to make detecting all date formats not necessary,          but got error "language mk does not exist".          Maybe client/components/lib/datepicker.jade could have hidden input field for          datepicker format that could be used to detect date format?          const newDate = moment(dateString, dateformat() + ' ' + timeformat(), true);          if (newDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(newDate.toDate());              Popup.back();            } else {              this.currentData().poker = { end: newDate.toDate() }; // set poker end temp              Popup.back();            }          */          // Try to parse different date formats of all languages.          // This code is same for vote and planning poker.          const usaDate = moment(dateString, 'L LT', true);          const euroAmDate = moment(dateString, 'DD.MM.YYYY LT', true);          const euro24hDate = moment(dateString, 'DD.MM.YYYY HH.mm', true);          const eurodotDate = moment(dateString, 'DD.MM.YYYY HH:mm', true);          const minusDate = moment(dateString, 'YYYY-MM-DD HH:mm', true);          const slashDate = moment(dateString, 'DD/MM/YYYY HH.mm', true);          const dotDate = moment(dateString, 'DD/MM/YYYY HH:mm', true);          const brezhonegDate = moment(dateString, 'DD/MM/YYYY h[e]mm A', true);          const hrvatskiDate = moment(dateString, 'DD. MM. YYYY H:mm', true);          const latviaDate = moment(dateString, 'YYYY.MM.DD. H:mm', true);          const nederlandsDate = moment(dateString, 'DD-MM-YYYY HH:mm', true);          // greekDate does not work: el Greek Ελληνικά ,          // it has date format DD/MM/YYYY h:mm MM like 20/06/2021 11:15 MM          // where MM is maybe some text like AM/PM ?          // Also some other languages that have non-ascii characters in dates          // do not work.          const greekDate = moment(dateString, 'DD/MM/YYYY h:mm A', true);          const macedonianDate = moment(dateString, 'D.MM.YYYY H:mm', true);          if (usaDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(usaDate.toDate());            } else {              this.currentData().poker = { end: usaDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (euroAmDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(euroAmDate.toDate());            } else {              this.currentData().poker = { end: euroAmDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (euro24hDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(euro24hDate.toDate());              this.card.setPokerEnd(euro24hDate.toDate());            } else {              this.currentData().poker = { end: euro24hDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (eurodotDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(eurodotDate.toDate());              this.card.setPokerEnd(eurodotDate.toDate());            } else {              this.currentData().poker = { end: eurodotDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (minusDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(minusDate.toDate());              this.card.setPokerEnd(minusDate.toDate());            } else {              this.currentData().poker = { end: minusDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (slashDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(slashDate.toDate());              this.card.setPokerEnd(slashDate.toDate());            } else {              this.currentData().poker = { end: slashDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (dotDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(dotDate.toDate());              this.card.setPokerEnd(dotDate.toDate());            } else {              this.currentData().poker = { end: dotDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (brezhonegDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(brezhonegDate.toDate());              this.card.setPokerEnd(brezhonegDate.toDate());            } else {              this.currentData().poker = { end: brezhonegDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (hrvatskiDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(hrvatskiDate.toDate());              this.card.setPokerEnd(hrvatskiDate.toDate());            } else {              this.currentData().poker = { end: hrvatskiDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (latviaDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(latviaDate.toDate());              this.card.setPokerEnd(latviaDate.toDate());            } else {              this.currentData().poker = { end: latviaDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (nederlandsDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(nederlandsDate.toDate());              this.card.setPokerEnd(nederlandsDate.toDate());            } else {              this.currentData().poker = { end: nederlandsDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (greekDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(greekDate.toDate());              this.card.setPokerEnd(greekDate.toDate());            } else {              this.currentData().poker = { end: greekDate.toDate() }; // set poker end temp            }            Popup.back();          } else if (macedonianDate.isValid()) {            // if active poker -  store it            if (this.currentData().getPokerQuestion()) {              this._storeDate(macedonianDate.toDate());              this.card.setPokerEnd(macedonianDate.toDate());            } else {              this.currentData().poker = { end: macedonianDate.toDate() }; // set poker end temp            }            Popup.back();          } else {            // this.error.set('invalid-date);            this.error.set('invalid-date' + ' ' + dateString);            evt.target.date.focus();          }        },        'click .js-delete-date'(evt) {          evt.preventDefault();          this._deleteDate();          Popup.back();        },      },    ];  }  _storeDate(newDate) {    this.card.setPokerEnd(newDate);  }  _deleteDate() {    this.card.unsetPokerEnd();  }}.register('editPokerEndDatePopup'));// Close the card details pane by pressing escapeEscapeActions.register(  'detailsPane',  () => {    if (Session.get('cardDetailsIsDragging')) {      // Reset dragging status as the mouse landed outside the cardDetails template area and this will prevent a mousedown event from firing      Session.set('cardDetailsIsDragging', false);      Session.set('cardDetailsIsMouseDown', false);    } else {      // Prevent close card when the user is selecting text and moves the mouse cursor outside the card detail area      Utils.goBoardId(Session.get('currentBoard'));    }  },  () => {    return !Session.equals('currentCard', null);  },  {    noClickEscapeOn: '.js-card-details,.board-sidebar,#header',  },);Template.cardAssigneesPopup.onCreated(function () {  let currBoard = Boards.findOne(Session.get('currentBoard'));  let members = currBoard.activeMembers();  // let query = {  //   "teams.teamId": { $in: currBoard.teams.map(t => t.teamId) },  // };  // let boardTeamUsers = Users.find(query, {  //   sort: { sort: 1 },  // });  // members = currBoard.activeMembers2(members, boardTeamUsers);  this.members = new ReactiveVar(members);});Template.cardAssigneesPopup.events({  'click .js-select-assignee'(event) {    const card = Utils.getCurrentCard();    const assigneeId = this.userId;    card.toggleAssignee(assigneeId);    event.preventDefault();  },  'keyup .card-assignees-filter'(event) {    const members = filterMembers(event.target.value);    Template.instance().members.set(members);  },});Template.cardAssigneesPopup.helpers({  isCardAssignee() {    const card = Template.parentData();    const cardAssignees = card.getAssignees();    return _.contains(cardAssignees, this.userId);  },  members() {    return Template.instance().members.get();  },  user() {    return Users.findOne(this.userId);  },});Template.cardAssigneePopup.helpers({  userData() {    // We need to handle a special case for the search results provided by the    // `matteodem:easy-search` package. Since these results gets published in a    // separate collection, and not in the standard Meteor.Users collection as    // expected, we use a component parameter ("property") to distinguish the    // two cases.    const userCollection = this.esSearch ? ESSearchResults : Users;    return userCollection.findOne(this.userId, {      fields: {        profile: 1,        username: 1,      },    });  },  memberType() {    const user = Users.findOne(this.userId);    return user && user.isBoardAdmin() ? 'admin' : 'normal';  },  presenceStatusClassName() {    const user = Users.findOne(this.userId);    const userPresence = presences.findOne({ userId: this.userId });    if (user && user.isInvitedTo(Session.get('currentBoard'))) return 'pending';    else if (!userPresence) return 'disconnected';    else if (Session.equals('currentBoard', userPresence.state.currentBoardId))      return 'active';    else return 'idle';  },  isCardAssignee() {    const card = Template.parentData();    const cardAssignees = card.getAssignees();    return _.contains(cardAssignees, this.userId);  },  user() {    return Users.findOne(this.userId);  },});Template.cardAssigneePopup.events({  'click .js-remove-assignee'() {    Cards.findOne(this.cardId).unassignAssignee(this.userId);    Popup.back();  },  'click .js-edit-profile': Popup.open('editProfile'),});
 |