sidebar.js 58 KB

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