sidebar.js 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991
  1. import { ReactiveCache } from '/imports/reactiveCache';
  2. import { TAPi18n } from '/imports/i18n';
  3. Sidebar = null;
  4. const defaultView = 'home';
  5. const MCB = '.materialCheckBox';
  6. const CKCLS = 'is-checked';
  7. const viewTitles = {
  8. filter: 'filter-cards',
  9. search: 'search-cards',
  10. multiselection: 'multi-selection',
  11. customFields: 'custom-fields',
  12. archives: 'archives',
  13. };
  14. BlazeComponent.extendComponent({
  15. mixins() {
  16. return [Mixins.InfiniteScrolling];
  17. },
  18. onCreated() {
  19. this._isOpen = new ReactiveVar(false);
  20. this._view = new ReactiveVar(defaultView);
  21. this._hideCardCounterList = new ReactiveVar(false);
  22. this._hideBoardMemberList = new ReactiveVar(false);
  23. Sidebar = this;
  24. // Subscribe to accessibility settings
  25. Meteor.subscribe('accessibilitySettings');
  26. },
  27. onDestroyed() {
  28. Sidebar = null;
  29. },
  30. isOpen() {
  31. return this._isOpen.get();
  32. },
  33. open() {
  34. if (!this._isOpen.get()) {
  35. this._isOpen.set(true);
  36. EscapeActions.executeUpTo('detailsPane');
  37. }
  38. },
  39. hide() {
  40. if (this._isOpen.get()) {
  41. this._isOpen.set(false);
  42. }
  43. },
  44. toggle() {
  45. this._isOpen.set(!this._isOpen.get());
  46. },
  47. calculateNextPeak() {
  48. const sidebarElement = this.find('.js-board-sidebar-content');
  49. if (sidebarElement) {
  50. const altitude = sidebarElement.scrollHeight;
  51. this.callFirstWith(this, 'setNextPeak', altitude);
  52. }
  53. },
  54. reachNextPeak() {
  55. const activitiesChildren = this.childComponents('activities');
  56. if (activitiesChildren && activitiesChildren.length > 0 && activitiesChildren[0] && typeof activitiesChildren[0].loadNextPage === 'function') {
  57. activitiesChildren[0].loadNextPage();
  58. }
  59. },
  60. isTongueHidden() {
  61. return this.isOpen() && this.getView() !== defaultView;
  62. },
  63. scrollTop() {
  64. this.$('.js-board-sidebar-content').scrollTop(0);
  65. },
  66. getView() {
  67. return this._view.get();
  68. },
  69. setView(view) {
  70. view = _.isString(view) ? view : defaultView;
  71. if (this._view.get() !== view) {
  72. this._view.set(view);
  73. this.scrollTop();
  74. EscapeActions.executeUpTo('detailsPane');
  75. }
  76. this.open();
  77. },
  78. isDefaultView() {
  79. return this.getView() === defaultView;
  80. },
  81. getViewTemplate() {
  82. return `${this.getView()}Sidebar`;
  83. },
  84. getViewTitle() {
  85. return TAPi18n.__(viewTitles[this.getView()]);
  86. },
  87. showTongueTitle() {
  88. if (this.isOpen()) return `${TAPi18n.__('sidebar-close')}`;
  89. else return `${TAPi18n.__('sidebar-open')}`;
  90. },
  91. isKeyboardShortcuts() {
  92. const user = ReactiveCache.getCurrentUser();
  93. return user && user.isKeyboardShortcuts();
  94. },
  95. isVerticalScrollbars() {
  96. const user = ReactiveCache.getCurrentUser();
  97. return user && user.isVerticalScrollbars();
  98. },
  99. isAccessibilityEnabled() {
  100. const setting = AccessibilitySettings.findOne({});
  101. return setting && setting.enabled;
  102. },
  103. events() {
  104. return [
  105. {
  106. 'click .js-hide-sidebar': this.hide,
  107. 'click .js-toggle-sidebar': this.toggle,
  108. 'click .js-back-home': this.setView,
  109. 'click .js-toggle-minicard-label-text'() {
  110. currentUser = ReactiveCache.getCurrentUser();
  111. if (currentUser) {
  112. Meteor.call('toggleMinicardLabelText');
  113. } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
  114. window.localStorage.removeItem('hiddenMinicardLabelText');
  115. location.reload();
  116. } else {
  117. window.localStorage.setItem('hiddenMinicardLabelText', 'true');
  118. location.reload();
  119. }
  120. },
  121. 'click .js-shortcuts'() {
  122. FlowRouter.go('shortcuts');
  123. },
  124. 'click .js-keyboard-shortcuts-toggle'() {
  125. ReactiveCache.getCurrentUser().toggleKeyboardShortcuts();
  126. },
  127. 'click .js-vertical-scrollbars-toggle'() {
  128. ReactiveCache.getCurrentUser().toggleVerticalScrollbars();
  129. },
  130. 'click .js-show-week-of-year-toggle'() {
  131. ReactiveCache.getCurrentUser().toggleShowWeekOfYear();
  132. },
  133. 'click .sidebar-accessibility'() {
  134. FlowRouter.go('accessibility');
  135. Sidebar.toggle();
  136. },
  137. 'click .js-close-sidebar'() {
  138. Sidebar.toggle()
  139. },
  140. },
  141. ];
  142. },
  143. }).register('sidebar');
  144. Blaze.registerHelper('Sidebar', () => Sidebar);
  145. BlazeComponent.extendComponent({
  146. hiddenMinicardLabelText() {
  147. currentUser = ReactiveCache.getCurrentUser();
  148. if (currentUser) {
  149. return (currentUser.profile || {}).hiddenMinicardLabelText;
  150. } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
  151. return true;
  152. } else {
  153. return false;
  154. }
  155. },
  156. isVerticalScrollbars() {
  157. const user = ReactiveCache.getCurrentUser();
  158. return user && user.isVerticalScrollbars();
  159. },
  160. isShowWeekOfYear() {
  161. const user = ReactiveCache.getCurrentUser();
  162. return user && user.isShowWeekOfYear();
  163. },
  164. showActivities() {
  165. let ret = Utils.getCurrentBoard().showActivities ?? false;
  166. return ret;
  167. },
  168. events() {
  169. return [
  170. {
  171. 'click .js-toggle-show-activities'() {
  172. Utils.getCurrentBoard().toggleShowActivities();
  173. },
  174. },
  175. ];
  176. },
  177. }).register('homeSidebar');
  178. Template.boardInfoOnMyBoardsPopup.helpers({
  179. hideCardCounterList() {
  180. return Utils.isMiniScreen() && Session.get('currentBoard');
  181. },
  182. hideBoardMemberList() {
  183. return Utils.isMiniScreen() && Session.get('currentBoard');
  184. },
  185. });
  186. EscapeActions.register(
  187. 'sidebarView',
  188. () => {
  189. Sidebar.setView(defaultView);
  190. },
  191. () => {
  192. return Sidebar && Sidebar.getView() !== defaultView;
  193. },
  194. );
  195. Template.memberPopup.helpers({
  196. user() {
  197. return ReactiveCache.getUser(this.userId);
  198. },
  199. isBoardAdmin() {
  200. return ReactiveCache.getCurrentUser().isBoardAdmin();
  201. },
  202. memberType() {
  203. const type = ReactiveCache.getUser(this.userId).isBoardAdmin() ? 'admin' : 'normal';
  204. if (type === 'normal') {
  205. const currentBoard = Utils.getCurrentBoard();
  206. const commentOnly = currentBoard.hasCommentOnly(this.userId);
  207. const noComments = currentBoard.hasNoComments(this.userId);
  208. const worker = currentBoard.hasWorker(this.userId);
  209. if (commentOnly) {
  210. return TAPi18n.__('comment-only');
  211. } else if (noComments) {
  212. return TAPi18n.__('no-comments');
  213. } else if (worker) {
  214. return TAPi18n.__('worker');
  215. } else {
  216. return TAPi18n.__(type);
  217. }
  218. } else {
  219. return TAPi18n.__(type);
  220. }
  221. },
  222. isInvited() {
  223. return ReactiveCache.getUser(this.userId).isInvitedTo(Session.get('currentBoard'));
  224. },
  225. });
  226. Template.boardMenuPopup.events({
  227. 'click .js-rename-board': Popup.open('boardChangeTitle'),
  228. 'click .js-open-rules-view'() {
  229. Modal.openWide('rulesMain');
  230. Popup.back();
  231. },
  232. 'click .js-custom-fields'() {
  233. Sidebar.setView('customFields');
  234. Popup.back();
  235. },
  236. 'click .js-open-archives'() {
  237. Sidebar.setView('archives');
  238. Popup.back();
  239. },
  240. 'click .js-change-board-color': Popup.open('boardChangeColor'),
  241. 'click .js-change-background-image': Popup.open('boardChangeBackgroundImage'),
  242. 'click .js-board-info-on-my-boards': Popup.open('boardInfoOnMyBoards'),
  243. 'click .js-change-language': Popup.open('changeLanguage'),
  244. 'click .js-delete-duplicate-lists': Popup.afterConfirm('deleteDuplicateLists', function() {
  245. const currentBoard = Utils.getCurrentBoard();
  246. if (!currentBoard) return;
  247. // Get all lists in the current board
  248. const allLists = ReactiveCache.getLists({ boardId: currentBoard._id, archived: false });
  249. // Group lists by title to find duplicates
  250. const listsByTitle = {};
  251. allLists.forEach(list => {
  252. if (!listsByTitle[list.title]) {
  253. listsByTitle[list.title] = [];
  254. }
  255. listsByTitle[list.title].push(list);
  256. });
  257. // Find and delete duplicate lists that have no cards
  258. let deletedCount = 0;
  259. Object.keys(listsByTitle).forEach(title => {
  260. const listsWithSameTitle = listsByTitle[title];
  261. if (listsWithSameTitle.length > 1) {
  262. // Keep the first list, delete the rest if they have no cards
  263. for (let i = 1; i < listsWithSameTitle.length; i++) {
  264. const list = listsWithSameTitle[i];
  265. const cardsInList = ReactiveCache.getCards({ listId: list._id, archived: false });
  266. if (cardsInList.length === 0) {
  267. Lists.remove(list._id);
  268. deletedCount++;
  269. }
  270. }
  271. }
  272. });
  273. // Show notification
  274. if (deletedCount > 0) {
  275. // You could add a toast notification here if available
  276. }
  277. }),
  278. 'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
  279. const currentBoard = Utils.getCurrentBoard();
  280. currentBoard.archive();
  281. // XXX We should have some kind of notification on top of the page to
  282. // confirm that the board was successfully archived.
  283. FlowRouter.go('home');
  284. }),
  285. 'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
  286. const currentBoard = Utils.getCurrentBoard();
  287. Popup.back();
  288. Boards.remove(currentBoard._id);
  289. FlowRouter.go('home');
  290. }),
  291. 'click .js-outgoing-webhooks': Popup.open('outgoingWebhooks'),
  292. 'click .js-import-board': Popup.open('chooseBoardSource'),
  293. 'click .js-subtask-settings': Popup.open('boardSubtaskSettings'),
  294. 'click .js-card-settings': Popup.open('boardCardSettings'),
  295. 'click .js-export-board': Popup.open('exportBoard'),
  296. });
  297. Template.boardMenuPopup.onCreated(function() {
  298. this.apiEnabled = new ReactiveVar(false);
  299. Meteor.call('_isApiEnabled', (e, result) => {
  300. this.apiEnabled.set(result);
  301. });
  302. });
  303. Template.boardMenuPopup.helpers({
  304. isBoardAdmin() {
  305. return ReactiveCache.getCurrentUser().isBoardAdmin();
  306. },
  307. withApi() {
  308. return Template.instance().apiEnabled.get();
  309. },
  310. exportUrl() {
  311. const params = {
  312. boardId: Session.get('currentBoard'),
  313. };
  314. const queryParams = {
  315. authToken: Accounts._storedLoginToken(),
  316. };
  317. return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
  318. },
  319. exportFilename() {
  320. const boardId = Session.get('currentBoard');
  321. return `export-board-${boardId}.json`;
  322. },
  323. });
  324. Template.memberPopup.events({
  325. 'click .js-filter-member'() {
  326. Filter.members.toggle(this.userId);
  327. Popup.back();
  328. },
  329. 'click .js-change-role': Popup.open('changePermissions'),
  330. 'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
  331. // This works from removing member from board, card members and assignees.
  332. const boardId = Session.get('currentBoard');
  333. const memberId = this.userId;
  334. ReactiveCache.getCards({ boardId, members: memberId }).forEach(card => {
  335. card.unassignMember(memberId);
  336. });
  337. ReactiveCache.getCards({ boardId, assignees: memberId }).forEach(card => {
  338. card.unassignAssignee(memberId);
  339. });
  340. ReactiveCache.getBoard(boardId).removeMember(memberId);
  341. Popup.back();
  342. }),
  343. 'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => {
  344. const boardId = Session.get('currentBoard');
  345. Meteor.call('quitBoard', boardId, () => {
  346. Popup.back();
  347. FlowRouter.go('home');
  348. });
  349. }),
  350. });
  351. Template.removeMemberPopup.helpers({
  352. user() {
  353. return ReactiveCache.getUser(this.userId);
  354. },
  355. board() {
  356. return Utils.getCurrentBoard();
  357. },
  358. });
  359. Template.leaveBoardPopup.helpers({
  360. board() {
  361. return Utils.getCurrentBoard();
  362. },
  363. });
  364. BlazeComponent.extendComponent({
  365. onCreated() {
  366. this.error = new ReactiveVar('');
  367. this.loading = new ReactiveVar(false);
  368. this.findOrgsOptions = new ReactiveVar({});
  369. this.findTeamsOptions = new ReactiveVar({});
  370. this.page = new ReactiveVar(1);
  371. this.teamPage = new ReactiveVar(1);
  372. this.autorun(() => {
  373. const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
  374. this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
  375. });
  376. this.autorun(() => {
  377. const limitTeams = this.teamPage.get() * Number.MAX_SAFE_INTEGER;
  378. this.subscribe('team', this.findTeamsOptions.get(), limitTeams, () => {});
  379. });
  380. },
  381. onRendered() {
  382. this.setLoading(false);
  383. },
  384. setError(error) {
  385. this.error.set(error);
  386. },
  387. setLoading(w) {
  388. this.loading.set(w);
  389. },
  390. isLoading() {
  391. return this.loading.get();
  392. },
  393. tabs() {
  394. return [
  395. { name: TAPi18n.__('people'), slug: 'people' },
  396. { name: TAPi18n.__('organizations'), slug: 'organizations' },
  397. { name: TAPi18n.__('teams'), slug: 'teams' },
  398. ];
  399. },
  400. }).register('membersWidget');
  401. Template.membersWidget.helpers({
  402. isInvited() {
  403. const user = ReactiveCache.getCurrentUser();
  404. return user && user.isInvitedTo(Session.get('currentBoard'));
  405. },
  406. isWorker() {
  407. const user = ReactiveCache.getCurrentUser();
  408. if (user) {
  409. return Meteor.call(Boards.hasWorker(user.memberId));
  410. } else {
  411. return false;
  412. }
  413. },
  414. isBoardAdmin() {
  415. return ReactiveCache.getCurrentUser().isBoardAdmin();
  416. },
  417. AtLeastOneOrgWasCreated(){
  418. let orgs = ReactiveCache.getOrgs({}, {sort: { createdAt: -1 }});
  419. if(orgs === undefined)
  420. return false;
  421. return orgs.length > 0;
  422. },
  423. AtLeastOneTeamWasCreated(){
  424. let teams = ReactiveCache.getTeams({}, {sort: { createdAt: -1 }});
  425. if(teams === undefined)
  426. return false;
  427. return teams.length > 0;
  428. },
  429. });
  430. Template.membersWidget.events({
  431. 'click .js-member': Popup.open('member'),
  432. 'click .js-open-board-menu': Popup.open('boardMenu'),
  433. 'click .js-manage-board-members': Popup.open('addMember'),
  434. 'click .js-manage-board-addOrg': Popup.open('addBoardOrg'),
  435. 'click .js-manage-board-addTeam': Popup.open('addBoardTeam'),
  436. 'click .js-import': Popup.open('boardImportBoard'),
  437. submit: this.onSubmit,
  438. 'click .js-import-board': Popup.open('chooseBoardSource'),
  439. 'click .js-open-archived-board'() {
  440. Modal.open('archivedBoards');
  441. },
  442. 'click .sandstorm-powerbox-request-identity'() {
  443. window.sandstormRequestIdentity();
  444. },
  445. 'click .js-member-invite-accept'() {
  446. const boardId = Session.get('currentBoard');
  447. ReactiveCache.getCurrentUser().removeInvite(boardId);
  448. },
  449. 'click .js-member-invite-decline'() {
  450. const boardId = Session.get('currentBoard');
  451. Meteor.call('quitBoard', boardId, (err, ret) => {
  452. if (!err && ret) {
  453. ReactiveCache.getCurrentUser().removeInvite(boardId);
  454. FlowRouter.go('home');
  455. }
  456. });
  457. },
  458. });
  459. BlazeComponent.extendComponent({
  460. boardId() {
  461. return Session.get('currentBoard') || Integrations.Const.GLOBAL_WEBHOOK_ID;
  462. },
  463. integrations() {
  464. const boardId = this.boardId();
  465. const ret = ReactiveCache.getIntegrations({ boardId });
  466. return ret;
  467. },
  468. types() {
  469. return Integrations.Const.WEBHOOK_TYPES;
  470. },
  471. integration(cond) {
  472. const boardId = this.boardId();
  473. const condition = { boardId, ...cond };
  474. for (const k in condition) {
  475. if (!condition[k]) delete condition[k];
  476. }
  477. return ReactiveCache.getIntegration(condition);
  478. },
  479. onCreated() {
  480. this.disabled = new ReactiveVar(false);
  481. },
  482. events() {
  483. return [
  484. {
  485. 'click a.flex'(evt) {
  486. this.disabled.set(!this.disabled.get());
  487. $(evt.target).toggleClass(CKCLS, this.disabled.get());
  488. },
  489. submit(evt) {
  490. evt.preventDefault();
  491. const url = evt.target.url.value;
  492. const boardId = this.boardId();
  493. let id = null;
  494. let integration = null;
  495. const title = evt.target.title.value;
  496. const token = evt.target.token.value;
  497. const type = evt.target.type.value;
  498. const enabled = !this.disabled.get();
  499. let remove = false;
  500. const values = {
  501. url,
  502. type,
  503. token,
  504. title,
  505. enabled,
  506. };
  507. if (evt.target.id) {
  508. id = evt.target.id.value;
  509. integration = this.integration({ _id: id });
  510. remove = !url;
  511. } else if (url) {
  512. integration = this.integration({ url, token });
  513. }
  514. if (remove) {
  515. Integrations.remove(integration._id);
  516. } else if (integration && integration._id) {
  517. Integrations.update(integration._id, {
  518. $set: values,
  519. });
  520. } else if (url) {
  521. Integrations.insert({
  522. ...values,
  523. userId: Meteor.userId(),
  524. enabled: true,
  525. boardId,
  526. activities: ['all'],
  527. });
  528. }
  529. Popup.back();
  530. },
  531. },
  532. ];
  533. },
  534. }).register('outgoingWebhooksPopup');
  535. BlazeComponent.extendComponent({
  536. template() {
  537. return 'chooseBoardSource';
  538. },
  539. }).register('chooseBoardSourcePopup');
  540. BlazeComponent.extendComponent({
  541. template() {
  542. return 'exportBoard';
  543. },
  544. withApi() {
  545. return Template.instance().apiEnabled.get();
  546. },
  547. exportUrl() {
  548. const params = {
  549. boardId: Session.get('currentBoard'),
  550. };
  551. const queryParams = {
  552. authToken: Accounts._storedLoginToken(),
  553. };
  554. return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
  555. },
  556. exportUrlExcel() {
  557. const params = {
  558. boardId: Session.get('currentBoard'),
  559. };
  560. const queryParams = {
  561. authToken: Accounts._storedLoginToken(),
  562. };
  563. return FlowRouter.path(
  564. '/api/boards/:boardId/exportExcel',
  565. params,
  566. queryParams,
  567. );
  568. },
  569. exportFilenameExcel() {
  570. const boardId = Session.get('currentBoard');
  571. return `export-board-excel-${boardId}.xlsx`;
  572. },
  573. exportCsvUrl() {
  574. const params = {
  575. boardId: Session.get('currentBoard'),
  576. };
  577. const queryParams = {
  578. authToken: Accounts._storedLoginToken(),
  579. delimiter: ',',
  580. };
  581. return FlowRouter.path(
  582. '/api/boards/:boardId/export/csv',
  583. params,
  584. queryParams,
  585. );
  586. },
  587. exportScsvUrl() {
  588. const params = {
  589. boardId: Session.get('currentBoard'),
  590. };
  591. const queryParams = {
  592. authToken: Accounts._storedLoginToken(),
  593. delimiter: ';',
  594. };
  595. return FlowRouter.path(
  596. '/api/boards/:boardId/export/csv',
  597. params,
  598. queryParams,
  599. );
  600. },
  601. exportTsvUrl() {
  602. const params = {
  603. boardId: Session.get('currentBoard'),
  604. };
  605. const queryParams = {
  606. authToken: Accounts._storedLoginToken(),
  607. delimiter: '\t',
  608. };
  609. return FlowRouter.path(
  610. '/api/boards/:boardId/export/csv',
  611. params,
  612. queryParams,
  613. );
  614. },
  615. exportJsonFilename() {
  616. const boardId = Session.get('currentBoard');
  617. return `export-board-${boardId}.json`;
  618. },
  619. exportCsvFilename() {
  620. const boardId = Session.get('currentBoard');
  621. return `export-board-${boardId}.csv`;
  622. },
  623. exportTsvFilename() {
  624. const boardId = Session.get('currentBoard');
  625. return `export-board-${boardId}.tsv`;
  626. },
  627. }).register('exportBoardPopup');
  628. Template.exportBoard.events({
  629. 'click .html-export-board': async event => {
  630. event.preventDefault();
  631. await ExportHtml(Popup)();
  632. },
  633. });
  634. Template.labelsWidget.events({
  635. 'click .js-label': Popup.open('editLabel'),
  636. 'click .js-add-label': Popup.open('createLabel'),
  637. });
  638. Template.labelsWidget.helpers({
  639. isBoardAdmin() {
  640. return ReactiveCache.getCurrentUser().isBoardAdmin();
  641. },
  642. });
  643. // Board members can assign people or labels by drag-dropping elements from the
  644. // sidebar to the cards on the board. In order to re-initialize the jquery-ui
  645. // plugin any time a draggable member or label is modified or removed we use a
  646. // autorun function and register a dependency on the both members and labels
  647. // fields of the current board document.
  648. function draggableMembersLabelsWidgets() {
  649. this.autorun(() => {
  650. const currentBoardId = Tracker.nonreactive(() => {
  651. return Session.get('currentBoard');
  652. });
  653. ReactiveCache.getBoard(currentBoardId, {
  654. fields: {
  655. members: 1,
  656. labels: 1,
  657. },
  658. });
  659. Tracker.afterFlush(() => {
  660. const $draggables = this.$('.js-member,.js-label');
  661. $draggables.draggable({
  662. appendTo: 'body',
  663. helper: 'clone',
  664. revert: 'invalid',
  665. revertDuration: 150,
  666. snap: false,
  667. snapMode: 'both',
  668. start() {
  669. EscapeActions.executeUpTo('popup-back');
  670. },
  671. });
  672. function userIsMember() {
  673. return ReactiveCache.getCurrentUser()?.isBoardMember();
  674. }
  675. this.autorun(() => {
  676. $draggables.draggable('option', 'disabled', !userIsMember());
  677. });
  678. });
  679. });
  680. }
  681. Template.membersWidget.onRendered(draggableMembersLabelsWidgets);
  682. Template.labelsWidget.onRendered(draggableMembersLabelsWidgets);
  683. BlazeComponent.extendComponent({
  684. backgroundColors() {
  685. return Boards.simpleSchema()._schema.color.allowedValues;
  686. },
  687. isSelected() {
  688. const currentBoard = Utils.getCurrentBoard();
  689. return currentBoard.color === this.currentData().toString();
  690. },
  691. events() {
  692. return [
  693. {
  694. 'click .js-select-background'(evt) {
  695. const currentBoard = Utils.getCurrentBoard();
  696. const newColor = this.currentData().toString();
  697. currentBoard.setColor(newColor);
  698. evt.preventDefault();
  699. },
  700. },
  701. ];
  702. },
  703. }).register('boardChangeColorPopup');
  704. BlazeComponent.extendComponent({
  705. events() {
  706. return [
  707. {
  708. submit(event) {
  709. const currentBoard = Utils.getCurrentBoard();
  710. const backgroundImageURL = this.find('.js-board-background-image-url').value.trim();
  711. currentBoard.setBackgroundImageURL(backgroundImageURL);
  712. Utils.setBackgroundImage();
  713. Popup.back();
  714. event.preventDefault();
  715. },
  716. 'click .js-remove-background-image'() {
  717. const currentBoard = Utils.getCurrentBoard();
  718. currentBoard.setBackgroundImageURL("");
  719. Popup.back();
  720. Utils.reload();
  721. event.preventDefault();
  722. },
  723. },
  724. ];
  725. },
  726. }).register('boardChangeBackgroundImagePopup');
  727. Template.boardChangeBackgroundImagePopup.helpers({
  728. backgroundImageURL() {
  729. const currentBoard = Utils.getCurrentBoard();
  730. return currentBoard.backgroundImageURL;
  731. },
  732. });
  733. BlazeComponent.extendComponent({
  734. onCreated() {
  735. this.currentBoard = Utils.getCurrentBoard();
  736. },
  737. allowsCardCounterList() {
  738. return this.currentBoard.allowsCardCounterList;
  739. },
  740. allowsBoardMemberList() {
  741. return this.currentBoard.allowsBoardMemberList;
  742. },
  743. events() {
  744. return [
  745. {
  746. 'click .js-field-has-cardcounterlist'(evt) {
  747. evt.preventDefault();
  748. this.currentBoard.allowsCardCounterList = !this.currentBoard
  749. .allowsCardCounterList;
  750. this.currentBoard.setAllowsCardCounterList(
  751. this.currentBoard.allowsCardCounterList,
  752. );
  753. $(`.js-field-has-cardcounterlist ${MCB}`).toggleClass(
  754. CKCLS,
  755. this.currentBoard.allowsCardCounterList,
  756. );
  757. $('.js-field-has-cardcounterlist').toggleClass(
  758. CKCLS,
  759. this.currentBoard.allowsCardCounterList,
  760. );
  761. },
  762. 'click .js-field-has-boardmemberlist'(evt) {
  763. evt.preventDefault();
  764. this.currentBoard.allowsBoardMemberList = !this.currentBoard
  765. .allowsBoardMemberList;
  766. this.currentBoard.setAllowsBoardMemberList(
  767. this.currentBoard.allowsBoardMemberList,
  768. );
  769. $(`.js-field-has-boardmemberlist ${MCB}`).toggleClass(
  770. CKCLS,
  771. this.currentBoard.allowsBoardMemberList,
  772. );
  773. $('.js-field-has-boardmemberlist').toggleClass(
  774. CKCLS,
  775. this.currentBoard.allowsBoardMemberList,
  776. );
  777. },
  778. },
  779. ];
  780. },
  781. }).register('boardInfoOnMyBoardsPopup');
  782. BlazeComponent.extendComponent({
  783. onCreated() {
  784. this.currentBoard = Utils.getCurrentBoard();
  785. },
  786. allowsSubtasks() {
  787. // Get the current board reactively using board ID from Session
  788. const boardId = Session.get('currentBoard');
  789. const currentBoard = ReactiveCache.getBoard(boardId);
  790. const result = currentBoard ? currentBoard.allowsSubtasks : false;
  791. return result;
  792. },
  793. allowsReceivedDate() {
  794. return this.currentBoard.allowsReceivedDate;
  795. },
  796. isBoardSelected() {
  797. return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;
  798. },
  799. isNullBoardSelected() {
  800. return (
  801. this.currentBoard.subtasksDefaultBoardId === null ||
  802. this.currentBoard.subtasksDefaultBoardId === undefined
  803. );
  804. },
  805. boards() {
  806. const ret = ReactiveCache.getBoards(
  807. {
  808. archived: false,
  809. 'members.userId': Meteor.userId(),
  810. },
  811. {
  812. sort: { sort: 1 /* boards default sorting */ },
  813. },
  814. );
  815. return ret;
  816. },
  817. lists() {
  818. return ReactiveCache.getLists(
  819. {
  820. boardId: this.currentBoard._id,
  821. archived: false,
  822. },
  823. {
  824. sort: ['title'],
  825. },
  826. );
  827. },
  828. hasLists() {
  829. return this.lists().length > 0;
  830. },
  831. isListSelected() {
  832. return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;
  833. },
  834. presentParentTask() {
  835. // Get the current board reactively using board ID from Session
  836. const boardId = Session.get('currentBoard');
  837. const currentBoard = ReactiveCache.getBoard(boardId);
  838. let result = currentBoard ? currentBoard.presentParentTask : null;
  839. if (result === null || result === undefined) {
  840. result = 'no-parent';
  841. }
  842. return result;
  843. },
  844. events() {
  845. return [
  846. {
  847. 'click .js-field-has-subtasks'(evt) {
  848. evt.preventDefault();
  849. const newValue = !this.currentBoard.allowsSubtasks;
  850. Boards.update(this.currentBoard._id, { $set: { allowsSubtasks: newValue } });
  851. $('.js-field-deposit-board').prop(
  852. 'disabled',
  853. !newValue,
  854. );
  855. },
  856. 'change .js-field-deposit-board'(evt) {
  857. let value = evt.target.value;
  858. if (value === 'null') {
  859. value = null;
  860. }
  861. this.currentBoard.setSubtasksDefaultBoardId(value);
  862. evt.preventDefault();
  863. },
  864. 'change .js-field-deposit-list'(evt) {
  865. this.currentBoard.setSubtasksDefaultListId(evt.target.value);
  866. evt.preventDefault();
  867. },
  868. 'click .js-field-show-parent-in-minicard'(evt) {
  869. // Get the ID from the anchor element, not the span
  870. const anchorElement = $(evt.target).closest('.js-field-show-parent-in-minicard')[0];
  871. const value = anchorElement ? anchorElement.id : null;
  872. if (value) {
  873. Boards.update(this.currentBoard._id, { $set: { presentParentTask: value } });
  874. }
  875. evt.preventDefault();
  876. },
  877. },
  878. ];
  879. },
  880. }).register('boardSubtaskSettingsPopup');
  881. BlazeComponent.extendComponent({
  882. onCreated() {
  883. this.currentBoard = Utils.getCurrentBoard();
  884. },
  885. allowsReceivedDate() {
  886. const boardId = Session.get('currentBoard');
  887. const currentBoard = ReactiveCache.getBoard(boardId);
  888. return currentBoard ? currentBoard.allowsReceivedDate : false;
  889. },
  890. allowsStartDate() {
  891. const boardId = Session.get('currentBoard');
  892. const currentBoard = ReactiveCache.getBoard(boardId);
  893. return currentBoard ? currentBoard.allowsStartDate : false;
  894. },
  895. allowsDueDate() {
  896. const boardId = Session.get('currentBoard');
  897. const currentBoard = ReactiveCache.getBoard(boardId);
  898. return currentBoard ? currentBoard.allowsDueDate : false;
  899. },
  900. allowsEndDate() {
  901. const boardId = Session.get('currentBoard');
  902. const currentBoard = ReactiveCache.getBoard(boardId);
  903. return currentBoard ? currentBoard.allowsEndDate : false;
  904. },
  905. allowsSubtasks() {
  906. const boardId = Session.get('currentBoard');
  907. const currentBoard = ReactiveCache.getBoard(boardId);
  908. return currentBoard ? currentBoard.allowsSubtasks : false;
  909. },
  910. allowsCreator() {
  911. const boardId = Session.get('currentBoard');
  912. const currentBoard = ReactiveCache.getBoard(boardId);
  913. return currentBoard ? (currentBoard.allowsCreator ?? false) : false;
  914. },
  915. allowsCreatorOnMinicard() {
  916. const boardId = Session.get('currentBoard');
  917. const currentBoard = ReactiveCache.getBoard(boardId);
  918. return currentBoard ? (currentBoard.allowsCreatorOnMinicard ?? false) : false;
  919. },
  920. allowsMembers() {
  921. const boardId = Session.get('currentBoard');
  922. const currentBoard = ReactiveCache.getBoard(boardId);
  923. return currentBoard ? currentBoard.allowsMembers : false;
  924. },
  925. allowsAssignee() {
  926. const boardId = Session.get('currentBoard');
  927. const currentBoard = ReactiveCache.getBoard(boardId);
  928. return currentBoard ? currentBoard.allowsAssignee : false;
  929. },
  930. allowsAssignedBy() {
  931. const boardId = Session.get('currentBoard');
  932. const currentBoard = ReactiveCache.getBoard(boardId);
  933. return currentBoard ? currentBoard.allowsAssignedBy : false;
  934. },
  935. allowsRequestedBy() {
  936. const boardId = Session.get('currentBoard');
  937. const currentBoard = ReactiveCache.getBoard(boardId);
  938. return currentBoard ? currentBoard.allowsRequestedBy : false;
  939. },
  940. allowsCardSortingByNumber() {
  941. const boardId = Session.get('currentBoard');
  942. const currentBoard = ReactiveCache.getBoard(boardId);
  943. return currentBoard ? currentBoard.allowsCardSortingByNumber : false;
  944. },
  945. allowsShowLists() {
  946. const boardId = Session.get('currentBoard');
  947. const currentBoard = ReactiveCache.getBoard(boardId);
  948. return currentBoard ? currentBoard.allowsShowLists : false;
  949. },
  950. allowsLabels() {
  951. const boardId = Session.get('currentBoard');
  952. const currentBoard = ReactiveCache.getBoard(boardId);
  953. return currentBoard ? currentBoard.allowsLabels : false;
  954. },
  955. allowsShowListsOnMinicard() {
  956. const boardId = Session.get('currentBoard');
  957. const currentBoard = ReactiveCache.getBoard(boardId);
  958. return currentBoard ? currentBoard.allowsShowListsOnMinicard : false;
  959. },
  960. allowsChecklists() {
  961. const boardId = Session.get('currentBoard');
  962. const currentBoard = ReactiveCache.getBoard(boardId);
  963. return currentBoard ? currentBoard.allowsChecklists : false;
  964. },
  965. allowsAttachments() {
  966. const boardId = Session.get('currentBoard');
  967. const currentBoard = ReactiveCache.getBoard(boardId);
  968. return currentBoard ? currentBoard.allowsAttachments : false;
  969. },
  970. allowsComments() {
  971. const boardId = Session.get('currentBoard');
  972. const currentBoard = ReactiveCache.getBoard(boardId);
  973. return currentBoard ? currentBoard.allowsComments : false;
  974. },
  975. allowsCardNumber() {
  976. const boardId = Session.get('currentBoard');
  977. const currentBoard = ReactiveCache.getBoard(boardId);
  978. return currentBoard ? currentBoard.allowsCardNumber : false;
  979. },
  980. allowsDescriptionTitle() {
  981. const boardId = Session.get('currentBoard');
  982. const currentBoard = ReactiveCache.getBoard(boardId);
  983. return currentBoard ? currentBoard.allowsDescriptionTitle : false;
  984. },
  985. allowsDescriptionText() {
  986. const boardId = Session.get('currentBoard');
  987. const currentBoard = ReactiveCache.getBoard(boardId);
  988. return currentBoard ? currentBoard.allowsDescriptionText : false;
  989. },
  990. isBoardSelected() {
  991. const boardId = Session.get('currentBoard');
  992. const currentBoard = ReactiveCache.getBoard(boardId);
  993. return currentBoard ? currentBoard.dateSettingsDefaultBoardID : false;
  994. },
  995. isNullBoardSelected() {
  996. const boardId = Session.get('currentBoard');
  997. const currentBoard = ReactiveCache.getBoard(boardId);
  998. return currentBoard ? (
  999. currentBoard.dateSettingsDefaultBoardId === null ||
  1000. currentBoard.dateSettingsDefaultBoardId === undefined
  1001. ) : true;
  1002. },
  1003. allowsDescriptionTextOnMinicard() {
  1004. const boardId = Session.get('currentBoard');
  1005. const currentBoard = ReactiveCache.getBoard(boardId);
  1006. return currentBoard ? currentBoard.allowsDescriptionTextOnMinicard : false;
  1007. },
  1008. allowsCoverAttachmentOnMinicard() {
  1009. const boardId = Session.get('currentBoard');
  1010. const currentBoard = ReactiveCache.getBoard(boardId);
  1011. return currentBoard ? currentBoard.allowsCoverAttachmentOnMinicard : false;
  1012. },
  1013. allowsBadgeAttachmentOnMinicard() {
  1014. const boardId = Session.get('currentBoard');
  1015. const currentBoard = ReactiveCache.getBoard(boardId);
  1016. return currentBoard ? currentBoard.allowsBadgeAttachmentOnMinicard : false;
  1017. },
  1018. allowsCardSortingByNumberOnMinicard() {
  1019. const boardId = Session.get('currentBoard');
  1020. const currentBoard = ReactiveCache.getBoard(boardId);
  1021. return currentBoard ? currentBoard.allowsCardSortingByNumberOnMinicard : false;
  1022. },
  1023. boards() {
  1024. const ret = ReactiveCache.getBoards(
  1025. {
  1026. archived: false,
  1027. 'members.userId': Meteor.userId(),
  1028. },
  1029. {
  1030. sort: { sort: 1 /* boards default sorting */ },
  1031. },
  1032. );
  1033. return ret;
  1034. },
  1035. lists() {
  1036. return ReactiveCache.getLists(
  1037. {
  1038. boardId: this.currentBoard._id,
  1039. archived: false,
  1040. },
  1041. {
  1042. sort: ['title'],
  1043. },
  1044. );
  1045. },
  1046. hasLists() {
  1047. return this.lists().length > 0;
  1048. },
  1049. isListSelected() {
  1050. return (
  1051. this.currentBoard.dateSettingsDefaultBoardId === this.currentData()._id
  1052. );
  1053. },
  1054. events() {
  1055. return [
  1056. {
  1057. 'click .js-field-has-receiveddate'(evt) {
  1058. evt.preventDefault();
  1059. const newValue = !this.currentBoard.allowsReceivedDate;
  1060. Boards.update(this.currentBoard._id, { $set: { allowsReceivedDate: newValue } });
  1061. },
  1062. 'click .js-field-has-startdate'(evt) {
  1063. evt.preventDefault();
  1064. const newValue = !this.currentBoard.allowsStartDate;
  1065. Boards.update(this.currentBoard._id, { $set: { allowsStartDate: newValue } });
  1066. },
  1067. 'click .js-field-has-enddate'(evt) {
  1068. evt.preventDefault();
  1069. const newValue = !this.currentBoard.allowsEndDate;
  1070. Boards.update(this.currentBoard._id, { $set: { allowsEndDate: newValue } });
  1071. },
  1072. 'click .js-field-has-duedate'(evt) {
  1073. evt.preventDefault();
  1074. const newValue = !this.currentBoard.allowsDueDate;
  1075. Boards.update(this.currentBoard._id, { $set: { allowsDueDate: newValue } });
  1076. },
  1077. 'click .js-field-has-subtasks'(evt) {
  1078. evt.preventDefault();
  1079. const newValue = !this.currentBoard.allowsSubtasks;
  1080. Boards.update(this.currentBoard._id, { $set: { allowsSubtasks: newValue } });
  1081. },
  1082. 'click .js-field-has-creator'(evt) {
  1083. evt.preventDefault();
  1084. const newValue = !this.currentBoard.allowsCreator;
  1085. Boards.update(this.currentBoard._id, { $set: { allowsCreator: newValue } });
  1086. },
  1087. 'click .js-field-has-creator-on-minicard'(evt) {
  1088. evt.preventDefault();
  1089. const newValue = !this.currentBoard.allowsCreatorOnMinicard;
  1090. Boards.update(this.currentBoard._id, { $set: { allowsCreatorOnMinicard: newValue } });
  1091. },
  1092. 'click .js-field-has-members'(evt) {
  1093. evt.preventDefault();
  1094. const newValue = !this.currentBoard.allowsMembers;
  1095. Boards.update(this.currentBoard._id, { $set: { allowsMembers: newValue } });
  1096. },
  1097. 'click .js-field-has-assignee'(evt) {
  1098. evt.preventDefault();
  1099. const newValue = !this.currentBoard.allowsAssignee;
  1100. Boards.update(this.currentBoard._id, { $set: { allowsAssignee: newValue } });
  1101. },
  1102. 'click .js-field-has-assigned-by'(evt) {
  1103. evt.preventDefault();
  1104. const newValue = !this.currentBoard.allowsAssignedBy;
  1105. Boards.update(this.currentBoard._id, { $set: { allowsAssignedBy: newValue } });
  1106. },
  1107. 'click .js-field-has-requested-by'(evt) {
  1108. evt.preventDefault();
  1109. const newValue = !this.currentBoard.allowsRequestedBy;
  1110. Boards.update(this.currentBoard._id, { $set: { allowsRequestedBy: newValue } });
  1111. },
  1112. 'click .js-field-has-card-sorting-by-number'(evt) {
  1113. evt.preventDefault();
  1114. const newValue = !this.currentBoard.allowsCardSortingByNumber;
  1115. Boards.update(this.currentBoard._id, { $set: { allowsCardSortingByNumber: newValue } });
  1116. },
  1117. 'click .js-field-has-card-show-lists'(evt) {
  1118. evt.preventDefault();
  1119. const newValue = !this.currentBoard.allowsShowLists;
  1120. Boards.update(this.currentBoard._id, { $set: { allowsShowLists: newValue } });
  1121. },
  1122. 'click .js-field-has-labels'(evt) {
  1123. evt.preventDefault();
  1124. const newValue = !this.currentBoard.allowsLabels;
  1125. Boards.update(this.currentBoard._id, { $set: { allowsLabels: newValue } });
  1126. },
  1127. 'click .js-field-has-card-show-lists-on-minicard'(evt) {
  1128. evt.preventDefault();
  1129. this.currentBoard.allowsShowListsOnMinicard = !this.currentBoard
  1130. .allowsShowListsOnMinicard;
  1131. this.currentBoard.setAllowsShowListsOnMinicard(
  1132. this.currentBoard.allowsShowListsOnMinicard,
  1133. );
  1134. $(`.js-field-has-card-show-lists-on-minicard ${MCB}`).toggleClass(
  1135. CKCLS,
  1136. this.currentBoard.allowsShowListsOnMinicard,
  1137. );
  1138. $('.js-field-has-card-show-lists-on-minicard').toggleClass(
  1139. CKCLS,
  1140. this.currentBoard.allowsShowListsOnMinicard,
  1141. );
  1142. },
  1143. 'click .js-field-has-description-title'(evt) {
  1144. evt.preventDefault();
  1145. this.currentBoard.allowsDescriptionTitle = !this.currentBoard
  1146. .allowsDescriptionTitle;
  1147. this.currentBoard.setAllowsDescriptionTitle(
  1148. this.currentBoard.allowsDescriptionTitle,
  1149. );
  1150. $(`.js-field-has-description-title ${MCB}`).toggleClass(
  1151. CKCLS,
  1152. this.currentBoard.allowsDescriptionTitle,
  1153. );
  1154. $('.js-field-has-description-title').toggleClass(
  1155. CKCLS,
  1156. this.currentBoard.allowsDescriptionTitle,
  1157. );
  1158. },
  1159. 'click .js-field-has-card-number'(evt) {
  1160. evt.preventDefault();
  1161. this.currentBoard.allowsCardNumber = !this.currentBoard
  1162. .allowsCardNumber;
  1163. this.currentBoard.setAllowsCardNumber(
  1164. this.currentBoard.allowsCardNumber,
  1165. );
  1166. $(`.js-field-has-card-number ${MCB}`).toggleClass(
  1167. CKCLS,
  1168. this.currentBoard.allowsCardNumber,
  1169. );
  1170. $('.js-field-has-card-number').toggleClass(
  1171. CKCLS,
  1172. this.currentBoard.allowsCardNumber,
  1173. );
  1174. },
  1175. 'click .js-field-has-description-text-on-minicard'(evt) {
  1176. evt.preventDefault();
  1177. this.currentBoard.allowsDescriptionTextOnMinicard = !this.currentBoard
  1178. .allowsDescriptionTextOnMinicard;
  1179. this.currentBoard.setallowsDescriptionTextOnMinicard(
  1180. this.currentBoard.allowsDescriptionTextOnMinicard,
  1181. );
  1182. $(`.js-field-has-description-text-on-minicard ${MCB}`).toggleClass(
  1183. CKCLS,
  1184. this.currentBoard.allowsDescriptionTextOnMinicard,
  1185. );
  1186. $('.js-field-has-description-text-on-minicard').toggleClass(
  1187. CKCLS,
  1188. this.currentBoard.allowsDescriptionTextOnMinicard,
  1189. );
  1190. },
  1191. 'click .js-field-has-description-text'(evt) {
  1192. evt.preventDefault();
  1193. this.currentBoard.allowsDescriptionText = !this.currentBoard
  1194. .allowsDescriptionText;
  1195. this.currentBoard.setAllowsDescriptionText(
  1196. this.currentBoard.allowsDescriptionText,
  1197. );
  1198. $(`.js-field-has-description-text ${MCB}`).toggleClass(
  1199. CKCLS,
  1200. this.currentBoard.allowsDescriptionText,
  1201. );
  1202. $('.js-field-has-description-text').toggleClass(
  1203. CKCLS,
  1204. this.currentBoard.allowsDescriptionText,
  1205. );
  1206. },
  1207. 'click .js-field-has-checklists'(evt) {
  1208. evt.preventDefault();
  1209. this.currentBoard.allowsChecklists = !this.currentBoard
  1210. .allowsChecklists;
  1211. this.currentBoard.setAllowsChecklists(
  1212. this.currentBoard.allowsChecklists,
  1213. );
  1214. $(`.js-field-has-checklists ${MCB}`).toggleClass(
  1215. CKCLS,
  1216. this.currentBoard.allowsChecklists,
  1217. );
  1218. $('.js-field-has-checklists').toggleClass(
  1219. CKCLS,
  1220. this.currentBoard.allowsChecklists,
  1221. );
  1222. },
  1223. 'click .js-field-has-attachments'(evt) {
  1224. evt.preventDefault();
  1225. this.currentBoard.allowsAttachments = !this.currentBoard
  1226. .allowsAttachments;
  1227. this.currentBoard.setAllowsAttachments(
  1228. this.currentBoard.allowsAttachments,
  1229. );
  1230. $(`.js-field-has-attachments ${MCB}`).toggleClass(
  1231. CKCLS,
  1232. this.currentBoard.allowsAttachments,
  1233. );
  1234. $('.js-field-has-attachments').toggleClass(
  1235. CKCLS,
  1236. this.currentBoard.allowsAttachments,
  1237. );
  1238. },
  1239. 'click .js-field-has-comments'(evt) {
  1240. evt.preventDefault();
  1241. this.currentBoard.allowsComments = !this.currentBoard.allowsComments;
  1242. this.currentBoard.setAllowsComments(this.currentBoard.allowsComments);
  1243. $(`.js-field-has-comments ${MCB}`).toggleClass(
  1244. CKCLS,
  1245. this.currentBoard.allowsComments,
  1246. );
  1247. $('.js-field-has-comments').toggleClass(
  1248. CKCLS,
  1249. this.currentBoard.allowsComments,
  1250. );
  1251. },
  1252. 'click .js-field-has-activities'(evt) {
  1253. evt.preventDefault();
  1254. this.currentBoard.allowsActivities = !this.currentBoard
  1255. .allowsActivities;
  1256. this.currentBoard.setAllowsActivities(
  1257. this.currentBoard.allowsActivities,
  1258. );
  1259. $(`.js-field-has-activities ${MCB}`).toggleClass(
  1260. CKCLS,
  1261. this.currentBoard.allowsActivities,
  1262. );
  1263. $('.js-field-has-activities').toggleClass(
  1264. CKCLS,
  1265. this.currentBoard.allowsActivities,
  1266. );
  1267. },
  1268. 'click .js-field-has-cover-attachment-on-minicard'(evt) {
  1269. evt.preventDefault();
  1270. this.currentBoard.allowsCoverAttachmentOnMinicard = !this.currentBoard
  1271. .allowsCoverAttachmentOnMinicard;
  1272. this.currentBoard.setallowsCoverAttachmentOnMinicard(
  1273. this.currentBoard.allowsCoverAttachmentOnMinicard,
  1274. );
  1275. $(`.js-field-has-cover-attachment-on-minicard ${MCB}`).toggleClass(
  1276. CKCLS,
  1277. this.currentBoard.allowsCoverAttachmentOnMinicard,
  1278. );
  1279. $('.js-field-has-cover-attachment-on-minicard').toggleClass(
  1280. CKCLS,
  1281. this.currentBoard.allowsCoverAttachmentOnMinicard,
  1282. );
  1283. },
  1284. 'click .js-field-has-badge-attachment-on-minicard'(evt) {
  1285. evt.preventDefault();
  1286. this.currentBoard.allowsBadgeAttachmentOnMinicard = !this.currentBoard
  1287. .allowsBadgeAttachmentOnMinicard;
  1288. this.currentBoard.setallowsBadgeAttachmentOnMinicard(
  1289. this.currentBoard.allowsBadgeAttachmentOnMinicard,
  1290. );
  1291. $(`.js-field-has-badge-attachment-on-minicard ${MCB}`).toggleClass(
  1292. CKCLS,
  1293. this.currentBoard.allowsBadgeAttachmentOnMinicard,
  1294. );
  1295. $('.js-field-has-badge-attachment-on-minicard').toggleClass(
  1296. CKCLS,
  1297. this.currentBoard.allowsBadgeAttachmentOnMinicard,
  1298. );
  1299. },
  1300. 'click .js-field-has-card-sorting-by-number-on-minicard'(evt) {
  1301. evt.preventDefault();
  1302. this.currentBoard.allowsCardSortingByNumberOnMinicard = !this.currentBoard
  1303. .allowsCardSortingByNumberOnMinicard;
  1304. this.currentBoard.setallowsCardSortingByNumberOnMinicard(
  1305. this.currentBoard.allowsCardSortingByNumberOnMinicard,
  1306. );
  1307. $(`.js-field-has-card-sorting-by-number-on-minicard ${MCB}`).toggleClass(
  1308. CKCLS,
  1309. this.currentBoard.allowsCardSortingByNumberOnMinicard,
  1310. );
  1311. $('.js-field-has-card-sorting-by-number-on-minicard').toggleClass(
  1312. CKCLS,
  1313. this.currentBoard.allowsCardSortingByNumberOnMinicard,
  1314. );
  1315. },
  1316. },
  1317. ];
  1318. },
  1319. }).register('boardCardSettingsPopup');
  1320. // Use Session variables instead of global ReactiveVars
  1321. Session.setDefault('addMemberPopup.searchResults', []);
  1322. Session.setDefault('addMemberPopup.searching', false);
  1323. Session.setDefault('addMemberPopup.noResults', false);
  1324. Session.setDefault('addMemberPopup.loading', false);
  1325. Session.setDefault('addMemberPopup.error', '');
  1326. BlazeComponent.extendComponent({
  1327. onCreated() {
  1328. // Use Session variables
  1329. this.searchTimeout = null;
  1330. },
  1331. onRendered() {
  1332. this.find('.js-search-member-input').focus();
  1333. this.setLoading(false);
  1334. },
  1335. isBoardMember() {
  1336. const userId = this.currentData()._id;
  1337. const user = ReactiveCache.getUser(userId);
  1338. return user && user.isBoardMember();
  1339. },
  1340. isValidEmail(email) {
  1341. return SimpleSchema.RegEx.Email.test(email);
  1342. },
  1343. setError(error) {
  1344. Session.set('addMemberPopup.error', error);
  1345. },
  1346. setLoading(w) {
  1347. Session.set('addMemberPopup.loading', w);
  1348. },
  1349. isLoading() {
  1350. return Session.get('addMemberPopup.loading');
  1351. },
  1352. performSearch(query) {
  1353. if (!query || query.length < 2) {
  1354. Session.set('addMemberPopup.searchResults', []);
  1355. Session.set('addMemberPopup.noResults', false);
  1356. return;
  1357. }
  1358. Session.set('addMemberPopup.searching', true);
  1359. Session.set('addMemberPopup.noResults', false);
  1360. // Use the fallback search
  1361. const results = UserSearchIndex.search(query, { limit: 20 }).fetch();
  1362. Session.set('addMemberPopup.searchResults', results);
  1363. Session.set('addMemberPopup.searching', false);
  1364. if (results.length === 0) {
  1365. Session.set('addMemberPopup.noResults', true);
  1366. }
  1367. },
  1368. inviteUser(idNameEmail) {
  1369. const boardId = Session.get('currentBoard');
  1370. this.setLoading(true);
  1371. const self = this;
  1372. Meteor.call('inviteUserToBoard', idNameEmail, boardId, (err, ret) => {
  1373. self.setLoading(false);
  1374. if (err) self.setError(err.error);
  1375. else if (ret.email) self.setError('email-sent');
  1376. else Popup.back();
  1377. });
  1378. },
  1379. events() {
  1380. return [
  1381. {
  1382. 'keyup .js-search-member-input'(event) {
  1383. this.setError('');
  1384. const query = event.target.value.trim();
  1385. this.searchQuery.set(query);
  1386. // Clear previous timeout
  1387. if (this.searchTimeout) {
  1388. clearTimeout(this.searchTimeout);
  1389. }
  1390. // Debounce search
  1391. this.searchTimeout = setTimeout(() => {
  1392. this.performSearch(query);
  1393. }, 300);
  1394. },
  1395. 'click .js-select-member'() {
  1396. const userId = this.currentData()._id;
  1397. const currentBoard = Utils.getCurrentBoard();
  1398. if (!currentBoard.hasMember(userId)) {
  1399. this.inviteUser(userId);
  1400. }
  1401. },
  1402. 'click .js-email-invite'() {
  1403. const idNameEmail = $('.js-search-member-input').val();
  1404. if (idNameEmail.indexOf('@') < 0 || this.isValidEmail(idNameEmail)) {
  1405. this.inviteUser(idNameEmail);
  1406. } else this.setError('email-invalid');
  1407. },
  1408. },
  1409. ];
  1410. },
  1411. }).register('addMemberPopup');
  1412. Template.addMemberPopup.helpers({
  1413. searchResults() {
  1414. const results = Session.get('addMemberPopup.searchResults');
  1415. console.log('searchResults helper called, returning:', results);
  1416. return results;
  1417. },
  1418. searching() {
  1419. return Session.get('addMemberPopup.searching');
  1420. },
  1421. noResults() {
  1422. return Session.get('addMemberPopup.noResults');
  1423. },
  1424. loading() {
  1425. return Session.get('addMemberPopup.loading');
  1426. },
  1427. error() {
  1428. return Session.get('addMemberPopup.error');
  1429. },
  1430. isBoardMember() {
  1431. const userId = this._id;
  1432. const user = ReactiveCache.getUser(userId);
  1433. return user && user.isBoardMember();
  1434. }
  1435. })
  1436. Template.addMemberPopupTest.helpers({
  1437. searchResults() {
  1438. console.log('addMemberPopupTest searchResults helper called');
  1439. return Session.get('addMemberPopup.searchResults') || [];
  1440. }
  1441. })
  1442. BlazeComponent.extendComponent({
  1443. onCreated() {
  1444. this.error = new ReactiveVar('');
  1445. this.loading = new ReactiveVar(false);
  1446. this.findOrgsOptions = new ReactiveVar({});
  1447. this.page = new ReactiveVar(1);
  1448. this.autorun(() => {
  1449. const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
  1450. this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
  1451. });
  1452. },
  1453. onRendered() {
  1454. this.setLoading(false);
  1455. },
  1456. setError(error) {
  1457. this.error.set(error);
  1458. },
  1459. setLoading(w) {
  1460. this.loading.set(w);
  1461. },
  1462. isLoading() {
  1463. return this.loading.get();
  1464. },
  1465. events() {
  1466. return [
  1467. {
  1468. 'keyup input'() {
  1469. this.setError('');
  1470. },
  1471. 'change #jsBoardOrgs'() {
  1472. let currentBoard = Utils.getCurrentBoard();
  1473. let selectElt = document.getElementById("jsBoardOrgs");
  1474. let selectedOrgId = selectElt.options[selectElt.selectedIndex].value;
  1475. let selectedOrgDisplayName = selectElt.options[selectElt.selectedIndex].text;
  1476. let boardOrganizations = [];
  1477. if(currentBoard.orgs !== undefined){
  1478. for(let i = 0; i < currentBoard.orgs.length; i++){
  1479. boardOrganizations.push(currentBoard.orgs[i]);
  1480. }
  1481. }
  1482. if(!boardOrganizations.some((org) => org.orgDisplayName == selectedOrgDisplayName)){
  1483. boardOrganizations.push({
  1484. "orgId": selectedOrgId,
  1485. "orgDisplayName": selectedOrgDisplayName,
  1486. "isActive" : true,
  1487. })
  1488. if (selectedOrgId != "-1") {
  1489. Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);
  1490. }
  1491. }
  1492. Popup.back();
  1493. },
  1494. },
  1495. ];
  1496. },
  1497. }).register('addBoardOrgPopup');
  1498. Template.addBoardOrgPopup.helpers({
  1499. orgsDatas() {
  1500. let ret = ReactiveCache.getOrgs({}, {sort: { orgDisplayName: 1 }});
  1501. return ret;
  1502. },
  1503. });
  1504. BlazeComponent.extendComponent({
  1505. onCreated() {
  1506. this.error = new ReactiveVar('');
  1507. this.loading = new ReactiveVar(false);
  1508. this.findOrgsOptions = new ReactiveVar({});
  1509. this.page = new ReactiveVar(1);
  1510. this.autorun(() => {
  1511. const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
  1512. this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
  1513. });
  1514. },
  1515. onRendered() {
  1516. this.setLoading(false);
  1517. },
  1518. setError(error) {
  1519. this.error.set(error);
  1520. },
  1521. setLoading(w) {
  1522. this.loading.set(w);
  1523. },
  1524. isLoading() {
  1525. return this.loading.get();
  1526. },
  1527. events() {
  1528. return [
  1529. {
  1530. 'keyup input'() {
  1531. this.setError('');
  1532. },
  1533. 'click #leaveBoardBtn'(){
  1534. let stringOrgId = document.getElementById('hideOrgId').value;
  1535. let currentBoard = Utils.getCurrentBoard();
  1536. let boardOrganizations = [];
  1537. if(currentBoard.orgs !== undefined){
  1538. for(let i = 0; i < currentBoard.orgs.length; i++){
  1539. if(currentBoard.orgs[i].orgId != stringOrgId){
  1540. boardOrganizations.push(currentBoard.orgs[i]);
  1541. }
  1542. }
  1543. }
  1544. Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);
  1545. Popup.back();
  1546. },
  1547. 'click #cancelLeaveBoardBtn'(){
  1548. Popup.back();
  1549. },
  1550. },
  1551. ];
  1552. },
  1553. }).register('removeBoardOrgPopup');
  1554. Template.removeBoardOrgPopup.helpers({
  1555. org() {
  1556. return ReactiveCache.getOrg(this.orgId);
  1557. },
  1558. });
  1559. BlazeComponent.extendComponent({
  1560. onCreated() {
  1561. this.error = new ReactiveVar('');
  1562. this.loading = new ReactiveVar(false);
  1563. this.findOrgsOptions = new ReactiveVar({});
  1564. this.page = new ReactiveVar(1);
  1565. this.autorun(() => {
  1566. const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;
  1567. this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});
  1568. });
  1569. this.findUsersOptions = new ReactiveVar({});
  1570. this.userPage = new ReactiveVar(1);
  1571. this.autorun(() => {
  1572. const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;
  1573. this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});
  1574. });
  1575. },
  1576. onRendered() {
  1577. this.setLoading(false);
  1578. },
  1579. setError(error) {
  1580. this.error.set(error);
  1581. },
  1582. setLoading(w) {
  1583. this.loading.set(w);
  1584. },
  1585. isLoading() {
  1586. return this.loading.get();
  1587. },
  1588. events() {
  1589. return [
  1590. {
  1591. 'keyup input'() {
  1592. this.setError('');
  1593. },
  1594. 'change #jsBoardTeams'() {
  1595. let currentBoard = Utils.getCurrentBoard();
  1596. let selectElt = document.getElementById("jsBoardTeams");
  1597. let selectedTeamId = selectElt.options[selectElt.selectedIndex].value;
  1598. let selectedTeamDisplayName = selectElt.options[selectElt.selectedIndex].text;
  1599. let boardTeams = [];
  1600. if(currentBoard.teams !== undefined){
  1601. for(let i = 0; i < currentBoard.teams.length; i++){
  1602. boardTeams.push(currentBoard.teams[i]);
  1603. }
  1604. }
  1605. if(!boardTeams.some((team) => team.teamDisplayName == selectedTeamDisplayName)){
  1606. boardTeams.push({
  1607. "teamId": selectedTeamId,
  1608. "teamDisplayName": selectedTeamDisplayName,
  1609. "isActive" : true,
  1610. })
  1611. if (selectedTeamId != "-1") {
  1612. let members = currentBoard.members;
  1613. let query = {
  1614. "teams.teamId": { $in: boardTeams.map(t => t.teamId) },
  1615. };
  1616. const boardTeamUsers = ReactiveCache.getUsers(query, {
  1617. sort: { sort: 1 },
  1618. });
  1619. if(boardTeams !== undefined && boardTeams.length > 0){
  1620. let index;
  1621. if (boardTeamUsers && boardTeamUsers.length > 0) {
  1622. boardTeamUsers.forEach((u) => {
  1623. index = members.findIndex(function(m){ return m.userId == u._id});
  1624. if(index == -1){
  1625. members.push({
  1626. "isActive": true,
  1627. "isAdmin": u.isAdmin !== undefined ? u.isAdmin : false,
  1628. "isCommentOnly" : false,
  1629. "isNoComments" : false,
  1630. "userId": u._id,
  1631. });
  1632. }
  1633. });
  1634. }
  1635. }
  1636. Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);
  1637. }
  1638. }
  1639. Popup.back();
  1640. },
  1641. },
  1642. ];
  1643. },
  1644. }).register('addBoardTeamPopup');
  1645. Template.addBoardTeamPopup.helpers({
  1646. teamsDatas() {
  1647. let ret = ReactiveCache.getTeams({}, {sort: { teamDisplayName: 1 }});
  1648. return ret;
  1649. },
  1650. });
  1651. BlazeComponent.extendComponent({
  1652. onCreated() {
  1653. this.error = new ReactiveVar('');
  1654. this.loading = new ReactiveVar(false);
  1655. this.findOrgsOptions = new ReactiveVar({});
  1656. this.page = new ReactiveVar(1);
  1657. this.autorun(() => {
  1658. const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;
  1659. this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});
  1660. });
  1661. this.findUsersOptions = new ReactiveVar({});
  1662. this.userPage = new ReactiveVar(1);
  1663. this.autorun(() => {
  1664. const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;
  1665. this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});
  1666. });
  1667. },
  1668. onRendered() {
  1669. this.setLoading(false);
  1670. },
  1671. setError(error) {
  1672. this.error.set(error);
  1673. },
  1674. setLoading(w) {
  1675. this.loading.set(w);
  1676. },
  1677. isLoading() {
  1678. return this.loading.get();
  1679. },
  1680. events() {
  1681. return [
  1682. {
  1683. 'keyup input'() {
  1684. this.setError('');
  1685. },
  1686. 'click #leaveBoardTeamBtn'(){
  1687. let stringTeamId = document.getElementById('hideTeamId').value;
  1688. let currentBoard = Utils.getCurrentBoard();
  1689. let boardTeams = [];
  1690. if(currentBoard.teams !== undefined){
  1691. for(let i = 0; i < currentBoard.teams.length; i++){
  1692. if(currentBoard.teams[i].teamId != stringTeamId){
  1693. boardTeams.push(currentBoard.teams[i]);
  1694. }
  1695. }
  1696. }
  1697. let members = currentBoard.members;
  1698. let query = {
  1699. "teams.teamId": stringTeamId
  1700. };
  1701. const boardTeamUsers = ReactiveCache.getUsers(query, {
  1702. sort: { sort: 1 },
  1703. });
  1704. if(currentBoard.teams !== undefined && currentBoard.teams.length > 0){
  1705. let index;
  1706. if (boardTeamUsers && boardTeamUsers.length > 0) {
  1707. boardTeamUsers.forEach((u) => {
  1708. index = members.findIndex(function(m){ return m.userId == u._id});
  1709. if(index !== -1 && (u.isAdmin === undefined || u.isAdmin == false)){
  1710. members.splice(index, 1);
  1711. }
  1712. });
  1713. }
  1714. }
  1715. Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);
  1716. Popup.back();
  1717. },
  1718. 'click #cancelLeaveBoardTeamBtn'(){
  1719. Popup.back();
  1720. },
  1721. },
  1722. ];
  1723. },
  1724. }).register('removeBoardTeamPopup');
  1725. Template.removeBoardTeamPopup.helpers({
  1726. team() {
  1727. return ReactiveCache.getTeam(this.teamId);
  1728. },
  1729. });
  1730. Template.changePermissionsPopup.events({
  1731. 'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'(
  1732. event,
  1733. ) {
  1734. const currentBoard = Utils.getCurrentBoard();
  1735. const memberId = this.userId;
  1736. const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
  1737. const isCommentOnly = $(event.currentTarget).hasClass(
  1738. 'js-set-comment-only',
  1739. );
  1740. const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments');
  1741. const isWorker = $(event.currentTarget).hasClass('js-set-worker');
  1742. currentBoard.setMemberPermission(
  1743. memberId,
  1744. isAdmin,
  1745. isNoComments,
  1746. isCommentOnly,
  1747. isWorker,
  1748. );
  1749. Popup.back(1);
  1750. },
  1751. });
  1752. Template.changePermissionsPopup.helpers({
  1753. isAdmin() {
  1754. const currentBoard = Utils.getCurrentBoard();
  1755. return currentBoard.hasAdmin(this.userId);
  1756. },
  1757. isNormal() {
  1758. const currentBoard = Utils.getCurrentBoard();
  1759. return (
  1760. !currentBoard.hasAdmin(this.userId) &&
  1761. !currentBoard.hasNoComments(this.userId) &&
  1762. !currentBoard.hasCommentOnly(this.userId) &&
  1763. !currentBoard.hasWorker(this.userId)
  1764. );
  1765. },
  1766. isNoComments() {
  1767. const currentBoard = Utils.getCurrentBoard();
  1768. return (
  1769. !currentBoard.hasAdmin(this.userId) &&
  1770. currentBoard.hasNoComments(this.userId)
  1771. );
  1772. },
  1773. isCommentOnly() {
  1774. const currentBoard = Utils.getCurrentBoard();
  1775. return (
  1776. !currentBoard.hasAdmin(this.userId) &&
  1777. currentBoard.hasCommentOnly(this.userId)
  1778. );
  1779. },
  1780. isWorker() {
  1781. const currentBoard = Utils.getCurrentBoard();
  1782. return (
  1783. !currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
  1784. );
  1785. },
  1786. isLastAdmin() {
  1787. const currentBoard = Utils.getCurrentBoard();
  1788. return (
  1789. currentBoard.hasAdmin(this.userId) && currentBoard.activeAdmins() === 1
  1790. );
  1791. },
  1792. });