| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976 | import { ReactiveCache } from '/imports/reactiveCache';import { TAPi18n } from '/imports/i18n';Sidebar = null;const defaultView = 'home';const MCB = '.materialCheckBox';const CKCLS = 'is-checked';const viewTitles = {  filter: 'filter-cards',  search: 'search-cards',  multiselection: 'multi-selection',  customFields: 'custom-fields',  archives: 'archives',};BlazeComponent.extendComponent({  mixins() {    return [Mixins.InfiniteScrolling];  },  onCreated() {    this._isOpen = new ReactiveVar(false);    this._view = new ReactiveVar(defaultView);    this._hideCardCounterList = new ReactiveVar(false);    this._hideBoardMemberList = new ReactiveVar(false);    Sidebar = this;    // Subscribe to accessibility settings    Meteor.subscribe('accessibilitySettings');  },  onDestroyed() {    Sidebar = null;  },  isOpen() {    return this._isOpen.get();  },  open() {    if (!this._isOpen.get()) {      this._isOpen.set(true);      EscapeActions.executeUpTo('detailsPane');    }  },  hide() {    if (this._isOpen.get()) {      this._isOpen.set(false);    }  },  toggle() {    this._isOpen.set(!this._isOpen.get());  },  calculateNextPeak() {    const sidebarElement = this.find('.js-board-sidebar-content');    if (sidebarElement) {      const altitude = sidebarElement.scrollHeight;      this.callFirstWith(this, 'setNextPeak', altitude);    }  },  reachNextPeak() {    const activitiesChildren = this.childComponents('activities');    if (activitiesChildren && activitiesChildren.length > 0 && activitiesChildren[0] && typeof activitiesChildren[0].loadNextPage === 'function') {      activitiesChildren[0].loadNextPage();    }  },  isTongueHidden() {    return this.isOpen() && this.getView() !== defaultView;  },  scrollTop() {    this.$('.js-board-sidebar-content').scrollTop(0);  },  getView() {    return this._view.get();  },  setView(view) {    view = _.isString(view) ? view : defaultView;    if (this._view.get() !== view) {      this._view.set(view);      this.scrollTop();      EscapeActions.executeUpTo('detailsPane');    }    this.open();  },  isDefaultView() {    return this.getView() === defaultView;  },  getViewTemplate() {    return `${this.getView()}Sidebar`;  },  getViewTitle() {    return TAPi18n.__(viewTitles[this.getView()]);  },  showTongueTitle() {    if (this.isOpen()) return `${TAPi18n.__('sidebar-close')}`;    else return `${TAPi18n.__('sidebar-open')}`;  },  isKeyboardShortcuts() {    const user = ReactiveCache.getCurrentUser();    return user && user.isKeyboardShortcuts();  },  isVerticalScrollbars() {    const user = ReactiveCache.getCurrentUser();    return user && user.isVerticalScrollbars();  },  isAccessibilityEnabled() {    const setting = AccessibilitySettings.findOne({});    return setting && setting.enabled;  },  events() {    return [      {        'click .js-hide-sidebar': this.hide,        'click .js-toggle-sidebar': this.toggle,        'click .js-back-home': this.setView,        'click .js-toggle-minicard-label-text'() {          currentUser = ReactiveCache.getCurrentUser();          if (currentUser) {            Meteor.call('toggleMinicardLabelText');          } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {            window.localStorage.removeItem('hiddenMinicardLabelText');            location.reload();          } else {            window.localStorage.setItem('hiddenMinicardLabelText', 'true');            location.reload();          }        },        'click .js-shortcuts'() {          FlowRouter.go('shortcuts');        },        'click .js-keyboard-shortcuts-toggle'() {          ReactiveCache.getCurrentUser().toggleKeyboardShortcuts();        },        'click .js-vertical-scrollbars-toggle'() {          ReactiveCache.getCurrentUser().toggleVerticalScrollbars();        },        'click .js-show-week-of-year-toggle'() {          ReactiveCache.getCurrentUser().toggleShowWeekOfYear();        },        'click .sidebar-accessibility'() {          FlowRouter.go('accessibility');          Sidebar.toggle();        },        'click .js-close-sidebar'() {          Sidebar.toggle()        },      },    ];  },}).register('sidebar');Blaze.registerHelper('Sidebar', () => Sidebar);BlazeComponent.extendComponent({  hiddenMinicardLabelText() {    currentUser = ReactiveCache.getCurrentUser();    if (currentUser) {      return (currentUser.profile || {}).hiddenMinicardLabelText;    } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {      return true;    } else {      return false;    }  },  isVerticalScrollbars() {    const user = ReactiveCache.getCurrentUser();    return user && user.isVerticalScrollbars();  },  isShowWeekOfYear() {    const user = ReactiveCache.getCurrentUser();    return user && user.isShowWeekOfYear();  },  showActivities() {    let ret = Utils.getCurrentBoard().showActivities ?? false;    return ret;  },  events() {    return [      {        'click #toggleShowActivitiesBoard'() {          Utils.getCurrentBoard().toggleShowActivities();        },      },    ];  },}).register('homeSidebar');Template.boardInfoOnMyBoardsPopup.helpers({  hideCardCounterList() {    return Utils.isMiniScreen() && Session.get('currentBoard');  },  hideBoardMemberList() {    return Utils.isMiniScreen() && Session.get('currentBoard');  },});EscapeActions.register(  'sidebarView',  () => {    Sidebar.setView(defaultView);  },  () => {    return Sidebar && Sidebar.getView() !== defaultView;  },);Template.memberPopup.helpers({  user() {    return ReactiveCache.getUser(this.userId);  },  isBoardAdmin() {    return ReactiveCache.getCurrentUser().isBoardAdmin();  },  memberType() {    const type = ReactiveCache.getUser(this.userId).isBoardAdmin() ? 'admin' : 'normal';    if (type === 'normal') {      const currentBoard = Utils.getCurrentBoard();      const commentOnly = currentBoard.hasCommentOnly(this.userId);      const noComments = currentBoard.hasNoComments(this.userId);      const worker = currentBoard.hasWorker(this.userId);      if (commentOnly) {        return TAPi18n.__('comment-only');      } else if (noComments) {        return TAPi18n.__('no-comments');      } else if (worker) {        return TAPi18n.__('worker');      } else {        return TAPi18n.__(type);      }    } else {      return TAPi18n.__(type);    }  },  isInvited() {    return ReactiveCache.getUser(this.userId).isInvitedTo(Session.get('currentBoard'));  },});Template.boardMenuPopup.events({  'click .js-rename-board': Popup.open('boardChangeTitle'),  'click .js-open-rules-view'() {    Modal.openWide('rulesMain');    Popup.back();  },  'click .js-custom-fields'() {    Sidebar.setView('customFields');    Popup.back();  },  'click .js-open-archives'() {    Sidebar.setView('archives');    Popup.back();  },  'click .js-change-board-color': Popup.open('boardChangeColor'),  'click .js-change-background-image': Popup.open('boardChangeBackgroundImage'),  'click .js-board-info-on-my-boards': Popup.open('boardInfoOnMyBoards'),  'click .js-change-language': Popup.open('changeLanguage'),  'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {    const currentBoard = Utils.getCurrentBoard();    currentBoard.archive();    // XXX We should have some kind of notification on top of the page to    // confirm that the board was successfully archived.    FlowRouter.go('home');  }),  'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {    const currentBoard = Utils.getCurrentBoard();    Popup.back();    Boards.remove(currentBoard._id);    FlowRouter.go('home');  }),  'click .js-outgoing-webhooks': Popup.open('outgoingWebhooks'),  'click .js-import-board': Popup.open('chooseBoardSource'),  'click .js-subtask-settings': Popup.open('boardSubtaskSettings'),  'click .js-card-settings': Popup.open('boardCardSettings'),  'click .js-export-board': Popup.open('exportBoard'),});Template.boardMenuPopup.onCreated(function() {  this.apiEnabled = new ReactiveVar(false);  Meteor.call('_isApiEnabled', (e, result) => {    this.apiEnabled.set(result);  });});Template.boardMenuPopup.helpers({  isBoardAdmin() {    return ReactiveCache.getCurrentUser().isBoardAdmin();  },  withApi() {    return Template.instance().apiEnabled.get();  },  exportUrl() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),    };    return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);  },  exportFilename() {    const boardId = Session.get('currentBoard');    return `export-board-${boardId}.json`;  },});Template.memberPopup.events({  'click .js-filter-member'() {    Filter.members.toggle(this.userId);    Popup.back();  },  'click .js-change-role': Popup.open('changePermissions'),  'click .js-remove-member': Popup.afterConfirm('removeMember', function() {    // This works from removing member from board, card members and assignees.    const boardId = Session.get('currentBoard');    const memberId = this.userId;    ReactiveCache.getCards({ boardId, members: memberId }).forEach(card => {      card.unassignMember(memberId);    });    ReactiveCache.getCards({ boardId, assignees: memberId }).forEach(card => {      card.unassignAssignee(memberId);    });    ReactiveCache.getBoard(boardId).removeMember(memberId);    Popup.back();  }),  'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => {    const boardId = Session.get('currentBoard');    Meteor.call('quitBoard', boardId, () => {      Popup.back();      FlowRouter.go('home');    });  }),});Template.removeMemberPopup.helpers({  user() {    return ReactiveCache.getUser(this.userId);  },  board() {    return Utils.getCurrentBoard();  },});Template.leaveBoardPopup.helpers({  board() {    return Utils.getCurrentBoard();  },});BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);    this.findOrgsOptions = new ReactiveVar({});    this.findTeamsOptions = new ReactiveVar({});    this.page = new ReactiveVar(1);    this.teamPage = new ReactiveVar(1);    this.autorun(() => {      const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});    });    this.autorun(() => {      const limitTeams = this.teamPage.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('team', this.findTeamsOptions.get(), limitTeams, () => {});    });  },  onRendered() {    this.setLoading(false);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  tabs() {    return [      { name: TAPi18n.__('people'), slug: 'people' },      { name: TAPi18n.__('organizations'), slug: 'organizations' },      { name: TAPi18n.__('teams'), slug: 'teams' },    ];  },}).register('membersWidget');Template.membersWidget.helpers({  isInvited() {    const user = ReactiveCache.getCurrentUser();    return user && user.isInvitedTo(Session.get('currentBoard'));  },  isWorker() {    const user = ReactiveCache.getCurrentUser();    if (user) {      return Meteor.call(Boards.hasWorker(user.memberId));    } else {      return false;    }  },  isBoardAdmin() {    return ReactiveCache.getCurrentUser().isBoardAdmin();  },  AtLeastOneOrgWasCreated(){    let orgs = ReactiveCache.getOrgs({}, {sort: { createdAt: -1 }});    if(orgs === undefined)      return false;    return orgs.length > 0;  },  AtLeastOneTeamWasCreated(){    let teams = ReactiveCache.getTeams({}, {sort: { createdAt: -1 }});    if(teams === undefined)      return false;    return teams.length > 0;  },});Template.membersWidget.events({  'click .js-member': Popup.open('member'),  'click .js-open-board-menu': Popup.open('boardMenu'),  'click .js-manage-board-members': Popup.open('addMember'),  'click .js-manage-board-addOrg': Popup.open('addBoardOrg'),  'click .js-manage-board-addTeam': Popup.open('addBoardTeam'),  'click .js-import': Popup.open('boardImportBoard'),  submit: this.onSubmit,  'click .js-import-board': Popup.open('chooseBoardSource'),  'click .js-open-archived-board'() {    Modal.open('archivedBoards');  },  'click .sandstorm-powerbox-request-identity'() {    window.sandstormRequestIdentity();  },  'click .js-member-invite-accept'() {    const boardId = Session.get('currentBoard');    ReactiveCache.getCurrentUser().removeInvite(boardId);  },  'click .js-member-invite-decline'() {    const boardId = Session.get('currentBoard');    Meteor.call('quitBoard', boardId, (err, ret) => {      if (!err && ret) {        ReactiveCache.getCurrentUser().removeInvite(boardId);        FlowRouter.go('home');      }    });  },});BlazeComponent.extendComponent({  boardId() {    return Session.get('currentBoard') || Integrations.Const.GLOBAL_WEBHOOK_ID;  },  integrations() {    const boardId = this.boardId();    const ret = ReactiveCache.getIntegrations({ boardId });    return ret;  },  types() {    return Integrations.Const.WEBHOOK_TYPES;  },  integration(cond) {    const boardId = this.boardId();    const condition = { boardId, ...cond };    for (const k in condition) {      if (!condition[k]) delete condition[k];    }    return ReactiveCache.getIntegration(condition);  },  onCreated() {    this.disabled = new ReactiveVar(false);  },  events() {    return [      {        'click a.flex'(evt) {          this.disabled.set(!this.disabled.get());          $(evt.target).toggleClass(CKCLS, this.disabled.get());        },        submit(evt) {          evt.preventDefault();          const url = evt.target.url.value;          const boardId = this.boardId();          let id = null;          let integration = null;          const title = evt.target.title.value;          const token = evt.target.token.value;          const type = evt.target.type.value;          const enabled = !this.disabled.get();          let remove = false;          const values = {            url,            type,            token,            title,            enabled,          };          if (evt.target.id) {            id = evt.target.id.value;            integration = this.integration({ _id: id });            remove = !url;          } else if (url) {            integration = this.integration({ url, token });          }          if (remove) {            Integrations.remove(integration._id);          } else if (integration && integration._id) {            Integrations.update(integration._id, {              $set: values,            });          } else if (url) {            Integrations.insert({              ...values,              userId: Meteor.userId(),              enabled: true,              boardId,              activities: ['all'],            });          }          Popup.back();        },      },    ];  },}).register('outgoingWebhooksPopup');BlazeComponent.extendComponent({  template() {    return 'chooseBoardSource';  },}).register('chooseBoardSourcePopup');BlazeComponent.extendComponent({  template() {    return 'exportBoard';  },  withApi() {    return Template.instance().apiEnabled.get();  },  exportUrl() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),    };    return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);  },  exportUrlExcel() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),    };    return FlowRouter.path(      '/api/boards/:boardId/exportExcel',      params,      queryParams,    );  },  exportFilenameExcel() {    const boardId = Session.get('currentBoard');    return `export-board-excel-${boardId}.xlsx`;  },  exportCsvUrl() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),      delimiter: ',',    };    return FlowRouter.path(      '/api/boards/:boardId/export/csv',      params,      queryParams,    );  },  exportScsvUrl() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),      delimiter: ';',    };    return FlowRouter.path(      '/api/boards/:boardId/export/csv',      params,      queryParams,    );  },  exportTsvUrl() {    const params = {      boardId: Session.get('currentBoard'),    };    const queryParams = {      authToken: Accounts._storedLoginToken(),      delimiter: '\t',    };    return FlowRouter.path(      '/api/boards/:boardId/export/csv',      params,      queryParams,    );  },  exportJsonFilename() {    const boardId = Session.get('currentBoard');    return `export-board-${boardId}.json`;  },  exportCsvFilename() {    const boardId = Session.get('currentBoard');    return `export-board-${boardId}.csv`;  },  exportTsvFilename() {    const boardId = Session.get('currentBoard');    return `export-board-${boardId}.tsv`;  },}).register('exportBoardPopup');Template.exportBoard.events({  'click .html-export-board': async event => {    event.preventDefault();    await ExportHtml(Popup)();  },});Template.labelsWidget.events({  'click .js-label': Popup.open('editLabel'),  'click .js-add-label': Popup.open('createLabel'),});Template.labelsWidget.helpers({  isBoardAdmin() {    return ReactiveCache.getCurrentUser().isBoardAdmin();  },});// Board members can assign people or labels by drag-dropping elements from the// sidebar to the cards on the board. In order to re-initialize the jquery-ui// plugin any time a draggable member or label is modified or removed we use a// autorun function and register a dependency on the both members and labels// fields of the current board document.function draggableMembersLabelsWidgets() {  this.autorun(() => {    const currentBoardId = Tracker.nonreactive(() => {      return Session.get('currentBoard');    });    ReactiveCache.getBoard(currentBoardId, {      fields: {        members: 1,        labels: 1,      },    });    Tracker.afterFlush(() => {      const $draggables = this.$('.js-member,.js-label');      $draggables.draggable({        appendTo: 'body',        helper: 'clone',        revert: 'invalid',        revertDuration: 150,        snap: false,        snapMode: 'both',        start() {          EscapeActions.executeUpTo('popup-back');        },      });      function userIsMember() {        return ReactiveCache.getCurrentUser()?.isBoardMember();      }      this.autorun(() => {        $draggables.draggable('option', 'disabled', !userIsMember());      });    });  });}Template.membersWidget.onRendered(draggableMembersLabelsWidgets);Template.labelsWidget.onRendered(draggableMembersLabelsWidgets);BlazeComponent.extendComponent({  backgroundColors() {    return Boards.simpleSchema()._schema.color.allowedValues;  },  isSelected() {    const currentBoard = Utils.getCurrentBoard();    return currentBoard.color === this.currentData().toString();  },  events() {    return [      {        'click .js-select-background'(evt) {          const currentBoard = Utils.getCurrentBoard();          const newColor = this.currentData().toString();          currentBoard.setColor(newColor);          evt.preventDefault();        },      },    ];  },}).register('boardChangeColorPopup');BlazeComponent.extendComponent({  events() {    return [      {        submit(event) {          const currentBoard = Utils.getCurrentBoard();          const backgroundImageURL = this.find('.js-board-background-image-url').value.trim();          currentBoard.setBackgroundImageURL(backgroundImageURL);          Utils.setBackgroundImage();          Popup.back();          event.preventDefault();        },        'click .js-remove-background-image'() {          const currentBoard = Utils.getCurrentBoard();          currentBoard.setBackgroundImageURL("");          Popup.back();          Utils.reload();          event.preventDefault();        },      },    ];  },}).register('boardChangeBackgroundImagePopup');Template.boardChangeBackgroundImagePopup.helpers({  backgroundImageURL() {    const currentBoard = Utils.getCurrentBoard();    return currentBoard.backgroundImageURL;  },});BlazeComponent.extendComponent({  onCreated() {    this.currentBoard = Utils.getCurrentBoard();  },  allowsCardCounterList() {    return this.currentBoard.allowsCardCounterList;  },  allowsBoardMemberList() {    return this.currentBoard.allowsBoardMemberList;  },  events() {    return [      {        'click .js-field-has-cardcounterlist'(evt) {          evt.preventDefault();          this.currentBoard.allowsCardCounterList = !this.currentBoard            .allowsCardCounterList;            this.currentBoard.setAllowsCardCounterList(              this.currentBoard.allowsCardCounterList,          );          $(`.js-field-has-cardcounterlist ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCardCounterList,          );          $('.js-field-has-cardcounterlist').toggleClass(            CKCLS,            this.currentBoard.allowsCardCounterList,          );        },        'click .js-field-has-boardmemberlist'(evt) {          evt.preventDefault();          this.currentBoard.allowsBoardMemberList = !this.currentBoard            .allowsBoardMemberList;            this.currentBoard.setAllowsBoardMemberList(              this.currentBoard.allowsBoardMemberList,          );          $(`.js-field-has-boardmemberlist ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsBoardMemberList,          );          $('.js-field-has-boardmemberlist').toggleClass(            CKCLS,            this.currentBoard.allowsBoardMemberList,          );        },      },    ];  },}).register('boardInfoOnMyBoardsPopup');BlazeComponent.extendComponent({  onCreated() {    this.currentBoard = Utils.getCurrentBoard();  },  allowsSubtasks() {    return this.currentBoard.allowsSubtasks;  },  allowsReceivedDate() {    return this.currentBoard.allowsReceivedDate;  },  isBoardSelected() {    return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;  },  isNullBoardSelected() {    return (      this.currentBoard.subtasksDefaultBoardId === null ||      this.currentBoard.subtasksDefaultBoardId === undefined    );  },  boards() {    const ret = ReactiveCache.getBoards(      {        archived: false,        'members.userId': Meteor.userId(),      },      {        sort: { sort: 1 /* boards default sorting */ },      },    );    return ret;  },  lists() {    return ReactiveCache.getLists(      {        boardId: this.currentBoard._id,        archived: false,      },      {        sort: ['title'],      },    );  },  hasLists() {    return this.lists().length > 0;  },  isListSelected() {    return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;  },  presentParentTask() {    let result = this.currentBoard.presentParentTask;    if (result === null || result === undefined) {      result = 'no-parent';    }    return result;  },  events() {    return [      {        'click .js-field-has-subtasks'(evt) {          evt.preventDefault();          this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;          this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);          $(`.js-field-has-subtasks ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsSubtasks,          );          $('.js-field-has-subtasks').toggleClass(            CKCLS,            this.currentBoard.allowsSubtasks,          );          $('.js-field-deposit-board').prop(            'disabled',            !this.currentBoard.allowsSubtasks,          );        },        'change .js-field-deposit-board'(evt) {          let value = evt.target.value;          if (value === 'null') {            value = null;          }          this.currentBoard.setSubtasksDefaultBoardId(value);          evt.preventDefault();        },        'change .js-field-deposit-list'(evt) {          this.currentBoard.setSubtasksDefaultListId(evt.target.value);          evt.preventDefault();        },        'click .js-field-show-parent-in-minicard'(evt) {          const value =            evt.target.id ||            $(evt.target).parent()[0].id ||            $(evt.target)              .parent()[0]              .parent()[0].id;          const options = [            'prefix-with-full-path',            'prefix-with-parent',            'subtext-with-full-path',            'subtext-with-parent',            'no-parent',          ];          options.forEach(function(element) {            if (element !== value) {              $(`#${element} ${MCB}`).toggleClass(CKCLS, false);              $(`#${element}`).toggleClass(CKCLS, false);            }          });          $(`#${value} ${MCB}`).toggleClass(CKCLS, true);          $(`#${value}`).toggleClass(CKCLS, true);          this.currentBoard.setPresentParentTask(value);          evt.preventDefault();        },      },    ];  },}).register('boardSubtaskSettingsPopup');BlazeComponent.extendComponent({  onCreated() {    this.currentBoard = Utils.getCurrentBoard();  },  allowsReceivedDate() {    return this.currentBoard.allowsReceivedDate;  },  allowsStartDate() {    return this.currentBoard.allowsStartDate;  },  allowsDueDate() {    return this.currentBoard.allowsDueDate;  },  allowsEndDate() {    return this.currentBoard.allowsEndDate;  },  allowsSubtasks() {    return this.currentBoard.allowsSubtasks;  },  allowsCreator() {    return this.currentBoard.allowsCreator ?? false;  },  allowsCreatorOnMinicard() {    return this.currentBoard.allowsCreatorOnMinicard ?? false;  },  allowsMembers() {    return this.currentBoard.allowsMembers;  },  allowsAssignee() {    return this.currentBoard.allowsAssignee;  },  allowsAssignedBy() {    return this.currentBoard.allowsAssignedBy;  },  allowsRequestedBy() {    return this.currentBoard.allowsRequestedBy;  },  allowsCardSortingByNumber() {    return this.currentBoard.allowsCardSortingByNumber;  },  allowsShowLists() {    return this.currentBoard.allowsShowLists;  },  allowsLabels() {    return this.currentBoard.allowsLabels;  },  allowsShowListsOnMinicard() {    return this.currentBoard.allowsShowListsOnMinicard;  },  allowsChecklists() {    return this.currentBoard.allowsChecklists;  },  allowsAttachments() {    return this.currentBoard.allowsAttachments;  },  allowsComments() {    return this.currentBoard.allowsComments;  },  allowsCardNumber() {    return this.currentBoard.allowsCardNumber;  },  allowsDescriptionTitle() {    return this.currentBoard.allowsDescriptionTitle;  },  allowsDescriptionText() {    return this.currentBoard.allowsDescriptionText;  },  isBoardSelected() {    return this.currentBoard.dateSettingsDefaultBoardID;  },  isNullBoardSelected() {    return (      this.currentBoard.dateSettingsDefaultBoardId === null ||      this.currentBoard.dateSettingsDefaultBoardId === undefined    );  },  allowsDescriptionTextOnMinicard() {    return this.currentBoard.allowsDescriptionTextOnMinicard;  },  allowsCoverAttachmentOnMinicard() {    return this.currentBoard.allowsCoverAttachmentOnMinicard;  },  allowsBadgeAttachmentOnMinicard() {    return this.currentBoard.allowsBadgeAttachmentOnMinicard;  },  allowsCardSortingByNumberOnMinicard() {    return this.currentBoard.allowsCardSortingByNumberOnMinicard;  },  boards() {    const ret = ReactiveCache.getBoards(      {        archived: false,        'members.userId': Meteor.userId(),      },      {        sort: { sort: 1 /* boards default sorting */ },      },    );    return ret;  },  lists() {    return ReactiveCache.getLists(      {        boardId: this.currentBoard._id,        archived: false,      },      {        sort: ['title'],      },    );  },  hasLists() {    return this.lists().length > 0;  },  isListSelected() {    return (      this.currentBoard.dateSettingsDefaultBoardId === this.currentData()._id    );  },  events() {    return [      {        'click .js-field-has-receiveddate'(evt) {          evt.preventDefault();          this.currentBoard.allowsReceivedDate = !this.currentBoard            .allowsReceivedDate;          this.currentBoard.setAllowsReceivedDate(            this.currentBoard.allowsReceivedDate,          );          $(`.js-field-has-receiveddate ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsReceivedDate,          );          $('.js-field-has-receiveddate').toggleClass(            CKCLS,            this.currentBoard.allowsReceivedDate,          );        },        'click .js-field-has-startdate'(evt) {          evt.preventDefault();          this.currentBoard.allowsStartDate = !this.currentBoard            .allowsStartDate;          this.currentBoard.setAllowsStartDate(            this.currentBoard.allowsStartDate,          );          $(`.js-field-has-startdate ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsStartDate,          );          $('.js-field-has-startdate').toggleClass(            CKCLS,            this.currentBoard.allowsStartDate,          );        },        'click .js-field-has-enddate'(evt) {          evt.preventDefault();          this.currentBoard.allowsEndDate = !this.currentBoard.allowsEndDate;          this.currentBoard.setAllowsEndDate(this.currentBoard.allowsEndDate);          $(`.js-field-has-enddate ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsEndDate,          );          $('.js-field-has-enddate').toggleClass(            CKCLS,            this.currentBoard.allowsEndDate,          );        },        'click .js-field-has-duedate'(evt) {          evt.preventDefault();          this.currentBoard.allowsDueDate = !this.currentBoard.allowsDueDate;          this.currentBoard.setAllowsDueDate(this.currentBoard.allowsDueDate);          $(`.js-field-has-duedate ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsDueDate,          );          $('.js-field-has-duedate').toggleClass(            CKCLS,            this.currentBoard.allowsDueDate,          );        },        'click .js-field-has-subtasks'(evt) {          evt.preventDefault();          this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;          this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);          $(`.js-field-has-subtasks ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsSubtasks,          );          $('.js-field-has-subtasks').toggleClass(            CKCLS,            this.currentBoard.allowsSubtasks,          );        },        'click .js-field-has-creator'(evt) {          evt.preventDefault();          this.currentBoard.allowsCreator = !this.currentBoard.allowsCreator;          this.currentBoard.setAllowsCreator(this.currentBoard.allowsCreator);          $(`.js-field-has-creator ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCreator,          );          $('.js-field-has-creator').toggleClass(            CKCLS,            this.currentBoard.allowsCreator,          );        },        'click .js-field-has-creator-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsCreatorOnMinicard = !this.currentBoard.allowsCreatorOnMinicard;          this.currentBoard.setAllowsCreatorOnMinicard(this.currentBoard.allowsCreatorOnMinicard);          $(`.js-field-has-creator-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCreatorOnMinicard,          );          $('.js-field-has-creator-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsCreatorOnMinicard,          );        },        'click .js-field-has-members'(evt) {          evt.preventDefault();          this.currentBoard.allowsMembers = !this.currentBoard.allowsMembers;          this.currentBoard.setAllowsMembers(this.currentBoard.allowsMembers);          $(`.js-field-has-members ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsMembers,          );          $('.js-field-has-members').toggleClass(            CKCLS,            this.currentBoard.allowsMembers,          );        },        'click .js-field-has-assignee'(evt) {          evt.preventDefault();          this.currentBoard.allowsAssignee = !this.currentBoard.allowsAssignee;          this.currentBoard.setAllowsAssignee(this.currentBoard.allowsAssignee);          $(`.js-field-has-assignee ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsAssignee,          );          $('.js-field-has-assignee').toggleClass(            CKCLS,            this.currentBoard.allowsAssignee,          );        },        'click .js-field-has-assigned-by'(evt) {          evt.preventDefault();          this.currentBoard.allowsAssignedBy = !this.currentBoard            .allowsAssignedBy;          this.currentBoard.setAllowsAssignedBy(            this.currentBoard.allowsAssignedBy,          );          $(`.js-field-has-assigned-by ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsAssignedBy,          );          $('.js-field-has-assigned-by').toggleClass(            CKCLS,            this.currentBoard.allowsAssignedBy,          );        },        'click .js-field-has-requested-by'(evt) {          evt.preventDefault();          this.currentBoard.allowsRequestedBy = !this.currentBoard            .allowsRequestedBy;          this.currentBoard.setAllowsRequestedBy(            this.currentBoard.allowsRequestedBy,          );          $(`.js-field-has-requested-by ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsRequestedBy,          );          $('.js-field-has-requested-by').toggleClass(            CKCLS,            this.currentBoard.allowsRequestedBy,          );        },        'click .js-field-has-card-sorting-by-number'(evt) {          evt.preventDefault();          this.currentBoard.allowsCardSortingByNumber = !this.currentBoard            .allowsCardSortingByNumber;          this.currentBoard.setAllowsCardSortingByNumber(            this.currentBoard.allowsCardSortingByNumber,          );          $(`.js-field-has-card-sorting-by-number ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCardSortingByNumber,          );          $('.js-field-has-card-sorting-by-number').toggleClass(            CKCLS,            this.currentBoard.allowsCardSortingByNumber,          );        },        'click .js-field-has-card-show-lists'(evt) {          evt.preventDefault();          this.currentBoard.allowsShowLists = !this.currentBoard            .allowsShowLists;          this.currentBoard.setAllowsShowLists(            this.currentBoard.allowsShowLists,          );          $(`.js-field-has-card-show-lists ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsShowLists,          );          $('.js-field-has-card-show-lists').toggleClass(            CKCLS,            this.currentBoard.allowsShowLists,          );        },        'click .js-field-has-labels'(evt) {          evt.preventDefault();          this.currentBoard.allowsLabels = !this.currentBoard.allowsLabels;          this.currentBoard.setAllowsLabels(this.currentBoard.allowsLabels);          $(`.js-field-has-labels ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsLabels,          );          $('.js-field-has-labels').toggleClass(            CKCLS,            this.currentBoard.allowsLabels,          );        },        'click .js-field-has-card-show-lists-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsShowListsOnMinicard = !this.currentBoard            .allowsShowListsOnMinicard;          this.currentBoard.setAllowsShowListsOnMinicard(            this.currentBoard.allowsShowListsOnMinicard,          );          $(`.js-field-has-card-show-lists-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsShowListsOnMinicard,          );          $('.js-field-has-card-show-lists-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsShowListsOnMinicard,          );        },        'click .js-field-has-description-title'(evt) {          evt.preventDefault();          this.currentBoard.allowsDescriptionTitle = !this.currentBoard            .allowsDescriptionTitle;          this.currentBoard.setAllowsDescriptionTitle(            this.currentBoard.allowsDescriptionTitle,          );          $(`.js-field-has-description-title ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionTitle,          );          $('.js-field-has-description-title').toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionTitle,          );        },        'click .js-field-has-card-number'(evt) {          evt.preventDefault();          this.currentBoard.allowsCardNumber = !this.currentBoard            .allowsCardNumber;          this.currentBoard.setAllowsCardNumber(            this.currentBoard.allowsCardNumber,          );          $(`.js-field-has-card-number ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCardNumber,          );          $('.js-field-has-card-number').toggleClass(            CKCLS,            this.currentBoard.allowsCardNumber,          );        },        'click .js-field-has-description-text-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsDescriptionTextOnMinicard = !this.currentBoard            .allowsDescriptionTextOnMinicard;          this.currentBoard.setallowsDescriptionTextOnMinicard(            this.currentBoard.allowsDescriptionTextOnMinicard,          );          $(`.js-field-has-description-text-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionTextOnMinicard,          );          $('.js-field-has-description-text-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionTextOnMinicard,          );        },        'click .js-field-has-description-text'(evt) {          evt.preventDefault();          this.currentBoard.allowsDescriptionText = !this.currentBoard            .allowsDescriptionText;          this.currentBoard.setAllowsDescriptionText(            this.currentBoard.allowsDescriptionText,          );          $(`.js-field-has-description-text ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionText,          );          $('.js-field-has-description-text').toggleClass(            CKCLS,            this.currentBoard.allowsDescriptionText,          );        },        'click .js-field-has-checklists'(evt) {          evt.preventDefault();          this.currentBoard.allowsChecklists = !this.currentBoard            .allowsChecklists;          this.currentBoard.setAllowsChecklists(            this.currentBoard.allowsChecklists,          );          $(`.js-field-has-checklists ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsChecklists,          );          $('.js-field-has-checklists').toggleClass(            CKCLS,            this.currentBoard.allowsChecklists,          );        },        'click .js-field-has-attachments'(evt) {          evt.preventDefault();          this.currentBoard.allowsAttachments = !this.currentBoard            .allowsAttachments;          this.currentBoard.setAllowsAttachments(            this.currentBoard.allowsAttachments,          );          $(`.js-field-has-attachments ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsAttachments,          );          $('.js-field-has-attachments').toggleClass(            CKCLS,            this.currentBoard.allowsAttachments,          );        },        'click .js-field-has-comments'(evt) {          evt.preventDefault();          this.currentBoard.allowsComments = !this.currentBoard.allowsComments;          this.currentBoard.setAllowsComments(this.currentBoard.allowsComments);          $(`.js-field-has-comments ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsComments,          );          $('.js-field-has-comments').toggleClass(            CKCLS,            this.currentBoard.allowsComments,          );        },        'click .js-field-has-activities'(evt) {          evt.preventDefault();          this.currentBoard.allowsActivities = !this.currentBoard            .allowsActivities;          this.currentBoard.setAllowsActivities(            this.currentBoard.allowsActivities,          );          $(`.js-field-has-activities ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsActivities,          );          $('.js-field-has-activities').toggleClass(            CKCLS,            this.currentBoard.allowsActivities,          );        },        'click .js-field-has-cover-attachment-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsCoverAttachmentOnMinicard = !this.currentBoard            .allowsCoverAttachmentOnMinicard;          this.currentBoard.setallowsCoverAttachmentOnMinicard(            this.currentBoard.allowsCoverAttachmentOnMinicard,          );          $(`.js-field-has-cover-attachment-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCoverAttachmentOnMinicard,          );          $('.js-field-has-cover-attachment-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsCoverAttachmentOnMinicard,          );        },        'click .js-field-has-badge-attachment-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsBadgeAttachmentOnMinicard = !this.currentBoard            .allowsBadgeAttachmentOnMinicard;          this.currentBoard.setallowsBadgeAttachmentOnMinicard(            this.currentBoard.allowsBadgeAttachmentOnMinicard,          );          $(`.js-field-has-badge-attachment-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsBadgeAttachmentOnMinicard,          );          $('.js-field-has-badge-attachment-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsBadgeAttachmentOnMinicard,          );        },        'click .js-field-has-card-sorting-by-number-on-minicard'(evt) {          evt.preventDefault();          this.currentBoard.allowsCardSortingByNumberOnMinicard = !this.currentBoard            .allowsCardSortingByNumberOnMinicard;          this.currentBoard.setallowsCardSortingByNumberOnMinicard(            this.currentBoard.allowsCardSortingByNumberOnMinicard,          );          $(`.js-field-has-card-sorting-by-number-on-minicard ${MCB}`).toggleClass(            CKCLS,            this.currentBoard.allowsCardSortingByNumberOnMinicard,          );          $('.js-field-has-card-sorting-by-number-on-minicard').toggleClass(            CKCLS,            this.currentBoard.allowsCardSortingByNumberOnMinicard,          );        },      },    ];  },}).register('boardCardSettingsPopup');BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);  },  onRendered() {    this.find('.js-search-member input').focus();    this.setLoading(false);  },  isBoardMember() {    const userId = this.currentData().__originalId;    const user = ReactiveCache.getUser(userId);    return user && user.isBoardMember();  },  isValidEmail(email) {    return SimpleSchema.RegEx.Email.test(email);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  inviteUser(idNameEmail) {    const boardId = Session.get('currentBoard');    this.setLoading(true);    const self = this;    Meteor.call('inviteUserToBoard', idNameEmail, boardId, (err, ret) => {      self.setLoading(false);      if (err) self.setError(err.error);      else if (ret.email) self.setError('email-sent');      else Popup.back();    });  },  events() {    return [      {        'keyup input'() {          this.setError('');        },        'click .js-select-member'() {          const userId = this.currentData().__originalId;          const currentBoard = Utils.getCurrentBoard();          if (!currentBoard.hasMember(userId)) {            this.inviteUser(userId);          }        },        'click .js-email-invite'() {          const idNameEmail = $('.js-search-member input').val();          if (idNameEmail.indexOf('@') < 0 || this.isValidEmail(idNameEmail)) {            this.inviteUser(idNameEmail);          } else this.setError('email-invalid');        },      },    ];  },}).register('addMemberPopup');Template.addMemberPopup.helpers({  searchIndex: () => UserSearchIndex,})BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);    this.findOrgsOptions = new ReactiveVar({});    this.page = new ReactiveVar(1);    this.autorun(() => {      const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});    });  },  onRendered() {    this.setLoading(false);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  events() {    return [      {        'keyup input'() {          this.setError('');        },        'change #jsBoardOrgs'() {          let currentBoard = Utils.getCurrentBoard();          let selectElt = document.getElementById("jsBoardOrgs");          let selectedOrgId = selectElt.options[selectElt.selectedIndex].value;          let selectedOrgDisplayName = selectElt.options[selectElt.selectedIndex].text;          let boardOrganizations = [];          if(currentBoard.orgs !== undefined){            for(let i = 0; i < currentBoard.orgs.length; i++){              boardOrganizations.push(currentBoard.orgs[i]);            }          }          if(!boardOrganizations.some((org) => org.orgDisplayName == selectedOrgDisplayName)){            boardOrganizations.push({              "orgId": selectedOrgId,              "orgDisplayName": selectedOrgDisplayName,              "isActive" : true,            })            if (selectedOrgId != "-1") {              Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);            }          }          Popup.back();        },      },    ];  },}).register('addBoardOrgPopup');Template.addBoardOrgPopup.helpers({  orgsDatas() {    let ret = ReactiveCache.getOrgs({}, {sort: { orgDisplayName: 1 }});    return ret;  },});BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);    this.findOrgsOptions = new ReactiveVar({});    this.page = new ReactiveVar(1);    this.autorun(() => {      const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});    });  },  onRendered() {    this.setLoading(false);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  events() {    return [      {        'keyup input'() {          this.setError('');        },        'click #leaveBoardBtn'(){          let stringOrgId = document.getElementById('hideOrgId').value;          let currentBoard = Utils.getCurrentBoard();          let boardOrganizations = [];          if(currentBoard.orgs !== undefined){            for(let i = 0; i < currentBoard.orgs.length; i++){              if(currentBoard.orgs[i].orgId != stringOrgId){                boardOrganizations.push(currentBoard.orgs[i]);              }            }          }          Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);          Popup.back();        },        'click #cancelLeaveBoardBtn'(){          Popup.back();        },      },    ];  },}).register('removeBoardOrgPopup');Template.removeBoardOrgPopup.helpers({  org() {    return ReactiveCache.getOrg(this.orgId);  },});BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);    this.findOrgsOptions = new ReactiveVar({});    this.page = new ReactiveVar(1);    this.autorun(() => {      const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});    });    this.findUsersOptions = new ReactiveVar({});    this.userPage = new ReactiveVar(1);    this.autorun(() => {      const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});    });  },  onRendered() {    this.setLoading(false);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  events() {    return [      {        'keyup input'() {          this.setError('');        },        'change #jsBoardTeams'() {          let currentBoard = Utils.getCurrentBoard();          let selectElt = document.getElementById("jsBoardTeams");          let selectedTeamId = selectElt.options[selectElt.selectedIndex].value;          let selectedTeamDisplayName = selectElt.options[selectElt.selectedIndex].text;          let boardTeams = [];          if(currentBoard.teams !== undefined){            for(let i = 0; i < currentBoard.teams.length; i++){              boardTeams.push(currentBoard.teams[i]);            }          }          if(!boardTeams.some((team) => team.teamDisplayName == selectedTeamDisplayName)){            boardTeams.push({              "teamId": selectedTeamId,              "teamDisplayName": selectedTeamDisplayName,              "isActive" : true,            })            if (selectedTeamId != "-1") {              let members = currentBoard.members;              let query = {                "teams.teamId": { $in: boardTeams.map(t => t.teamId) },              };              const boardTeamUsers = ReactiveCache.getUsers(query, {                sort: { sort: 1 },              });              if(boardTeams !== undefined && boardTeams.length > 0){                let index;                if (boardTeamUsers && boardTeamUsers.length > 0) {                  boardTeamUsers.forEach((u) => {                    index = members.findIndex(function(m){ return m.userId == u._id});                    if(index == -1){                      members.push({                        "isActive": true,                        "isAdmin": u.isAdmin !== undefined ? u.isAdmin : false,                        "isCommentOnly" : false,                        "isNoComments" : false,                        "userId": u._id,                      });                    }                  });                }              }              Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);            }          }          Popup.back();        },      },    ];  },}).register('addBoardTeamPopup');Template.addBoardTeamPopup.helpers({  teamsDatas() {    let ret = ReactiveCache.getTeams({}, {sort: { teamDisplayName: 1 }});    return ret;  },});BlazeComponent.extendComponent({  onCreated() {    this.error = new ReactiveVar('');    this.loading = new ReactiveVar(false);    this.findOrgsOptions = new ReactiveVar({});    this.page = new ReactiveVar(1);    this.autorun(() => {      const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});    });    this.findUsersOptions = new ReactiveVar({});    this.userPage = new ReactiveVar(1);    this.autorun(() => {      const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;      this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});    });  },  onRendered() {    this.setLoading(false);  },  setError(error) {    this.error.set(error);  },  setLoading(w) {    this.loading.set(w);  },  isLoading() {    return this.loading.get();  },  events() {    return [      {        'keyup input'() {          this.setError('');        },        'click #leaveBoardTeamBtn'(){          let stringTeamId = document.getElementById('hideTeamId').value;          let currentBoard = Utils.getCurrentBoard();          let boardTeams = [];          if(currentBoard.teams !== undefined){            for(let i = 0; i < currentBoard.teams.length; i++){              if(currentBoard.teams[i].teamId != stringTeamId){                boardTeams.push(currentBoard.teams[i]);              }            }          }          let members = currentBoard.members;          let query = {            "teams.teamId": stringTeamId          };          const boardTeamUsers = ReactiveCache.getUsers(query, {            sort: { sort: 1 },          });          if(currentBoard.teams !== undefined && currentBoard.teams.length > 0){            let index;            if (boardTeamUsers && boardTeamUsers.length > 0) {              boardTeamUsers.forEach((u) => {                index = members.findIndex(function(m){ return m.userId == u._id});                if(index !== -1 && (u.isAdmin === undefined || u.isAdmin == false)){                  members.splice(index, 1);                }              });            }          }          Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);          Popup.back();        },        'click #cancelLeaveBoardTeamBtn'(){          Popup.back();        },      },    ];  },}).register('removeBoardTeamPopup');Template.removeBoardTeamPopup.helpers({  team() {    return ReactiveCache.getTeam(this.teamId);  },});Template.changePermissionsPopup.events({  'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'(    event,  ) {    const currentBoard = Utils.getCurrentBoard();    const memberId = this.userId;    const isAdmin = $(event.currentTarget).hasClass('js-set-admin');    const isCommentOnly = $(event.currentTarget).hasClass(      'js-set-comment-only',    );    const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments');    const isWorker = $(event.currentTarget).hasClass('js-set-worker');    currentBoard.setMemberPermission(      memberId,      isAdmin,      isNoComments,      isCommentOnly,      isWorker,    );    Popup.back(1);  },});Template.changePermissionsPopup.helpers({  isAdmin() {    const currentBoard = Utils.getCurrentBoard();    return currentBoard.hasAdmin(this.userId);  },  isNormal() {    const currentBoard = Utils.getCurrentBoard();    return (      !currentBoard.hasAdmin(this.userId) &&      !currentBoard.hasNoComments(this.userId) &&      !currentBoard.hasCommentOnly(this.userId) &&      !currentBoard.hasWorker(this.userId)    );  },  isNoComments() {    const currentBoard = Utils.getCurrentBoard();    return (      !currentBoard.hasAdmin(this.userId) &&      currentBoard.hasNoComments(this.userId)    );  },  isCommentOnly() {    const currentBoard = Utils.getCurrentBoard();    return (      !currentBoard.hasAdmin(this.userId) &&      currentBoard.hasCommentOnly(this.userId)    );  },  isWorker() {    const currentBoard = Utils.getCurrentBoard();    return (      !currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)    );  },  isLastAdmin() {    const currentBoard = Utils.getCurrentBoard();    return (      currentBoard.hasAdmin(this.userId) && currentBoard.activeAdmins() === 1    );  },});
 |