From 3eb4d2c341b712268bd321173909e0a7b19a88c9 Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Fri, 28 Jun 2019 12:52:09 -0500 Subject: Prettier & eslint project style update --- client/components/boards/boardArchive.js | 63 ++++++---- client/components/boards/boardBody.js | 138 ++++++++++++--------- client/components/boards/boardHeader.js | 206 ++++++++++++++++++------------- client/components/boards/boardsList.js | 94 +++++++------- 4 files changed, 288 insertions(+), 213 deletions(-) (limited to 'client/components/boards') diff --git a/client/components/boards/boardArchive.js b/client/components/boards/boardArchive.js index c8bbb341..d3e65bd8 100644 --- a/client/components/boards/boardArchive.js +++ b/client/components/boards/boardArchive.js @@ -4,36 +4,45 @@ BlazeComponent.extendComponent({ }, archivedBoards() { - return Boards.find({ archived: true }, { - sort: ['title'], - }); + return Boards.find( + { archived: true }, + { + sort: ['title'], + }, + ); }, events() { - return [{ - 'click .js-restore-board'() { - // TODO : Make isSandstorm variable global - const isSandstorm = Meteor.settings && Meteor.settings.public && - Meteor.settings.public.sandstorm; - if (isSandstorm && Session.get('currentBoard')) { - const currentBoard = Boards.findOne(Session.get('currentBoard')); - currentBoard.archive(); - } - const board = this.currentData(); - board.restore(); - Utils.goBoardId(board._id); + return [ + { + 'click .js-restore-board'() { + // TODO : Make isSandstorm variable global + const isSandstorm = + Meteor.settings && + Meteor.settings.public && + Meteor.settings.public.sandstorm; + if (isSandstorm && Session.get('currentBoard')) { + const currentBoard = Boards.findOne(Session.get('currentBoard')); + currentBoard.archive(); + } + const board = this.currentData(); + board.restore(); + Utils.goBoardId(board._id); + }, + 'click .js-delete-board': Popup.afterConfirm('boardDelete', function() { + Popup.close(); + const isSandstorm = + Meteor.settings && + Meteor.settings.public && + Meteor.settings.public.sandstorm; + if (isSandstorm && Session.get('currentBoard')) { + const currentBoard = Boards.findOne(Session.get('currentBoard')); + Boards.remove(currentBoard._id); + } + Boards.remove(this._id); + FlowRouter.go('home'); + }), }, - 'click .js-delete-board': Popup.afterConfirm('boardDelete', function() { - Popup.close(); - const isSandstorm = Meteor.settings && Meteor.settings.public && - Meteor.settings.public.sandstorm; - if (isSandstorm && Session.get('currentBoard')) { - const currentBoard = Boards.findOne(Session.get('currentBoard')); - Boards.remove(currentBoard._id); - } - Boards.remove(this._id); - FlowRouter.go('home'); - }), - }]; + ]; }, }).register('archivedBoards'); diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index e9b9f88a..81fa3d87 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -12,8 +12,7 @@ BlazeComponent.extendComponent({ // unfortunatly, Blaze doesn't have this notion. this.autorun(() => { const currentBoardId = Session.get('currentBoard'); - if (!currentBoardId) - return; + if (!currentBoardId) return; const handle = subManager.subscribe('board', currentBoardId, false); Tracker.nonreactive(() => { Tracker.autorun(() => { @@ -30,7 +29,6 @@ BlazeComponent.extendComponent({ goHome() { FlowRouter.go('home'); }, - }).register('board'); BlazeComponent.extendComponent({ @@ -47,7 +45,7 @@ BlazeComponent.extendComponent({ if (nullSortSwimlanes.count() > 0) { const swimlanes = currentBoardData.swimlanes(); let count = 0; - swimlanes.forEach((s) => { + swimlanes.forEach(s => { Swimlanes.update(s._id, { $set: { sort: count, @@ -62,7 +60,7 @@ BlazeComponent.extendComponent({ if (nullSortLists.count() > 0) { const lists = currentBoardData.lists(); let count = 0; - lists.forEach((l) => { + lists.forEach(l => { Lists.update(l._id, { $set: { sort: count, @@ -110,12 +108,15 @@ BlazeComponent.extendComponent({ // resize all swimlanes + headers to be a total of 150 px per row // this could be achieved by setIsDragging(true) but we want immediate // result - ui.item.siblings('.js-swimlane').css('height', `${swimlaneWhileSortingHeight - 26}px`); + ui.item + .siblings('.js-swimlane') + .css('height', `${swimlaneWhileSortingHeight - 26}px`); // set the new scroll height after the resize and insertion of // the placeholder. We want the element under the cursor to stay // at the same place on the screen - ui.item.parent().get(0).scrollTop = ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; + ui.item.parent().get(0).scrollTop = + ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; }, beforeStop(evt, ui) { const parentOffset = ui.item.parent().offset(); @@ -124,7 +125,8 @@ BlazeComponent.extendComponent({ // compute the new scroll height after the resize and removal of // the placeholder - const scrollTop = ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; + const scrollTop = + ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; // then reset the original view of the swimlane siblings.removeClass('moving-swimlane'); @@ -154,11 +156,14 @@ BlazeComponent.extendComponent({ sort(evt, ui) { // get the mouse position in the sortable const parentOffset = ui.item.parent().offset(); - const cursorY = evt.pageY - parentOffset.top + ui.item.parent().scrollTop(); + const cursorY = + evt.pageY - parentOffset.top + ui.item.parent().scrollTop(); // compute the intended index of the placeholder (we need to skip the // slots between the headers and the list of cards) - const newplaceholderIndex = Math.floor(cursorY / swimlaneWhileSortingHeight); + const newplaceholderIndex = Math.floor( + cursorY / swimlaneWhileSortingHeight, + ); let destPlaceholderIndex = (newplaceholderIndex + 1) * 2; // if we are scrolling far away from the bottom of the list @@ -169,9 +174,17 @@ BlazeComponent.extendComponent({ // update the placeholder position in the DOM tree if (destPlaceholderIndex !== ui.placeholder.index()) { if (destPlaceholderIndex < boardComponent.origPlaceholderIndex) { - ui.placeholder.insertBefore(ui.placeholder.siblings().slice(destPlaceholderIndex - 2, destPlaceholderIndex - 1)); + ui.placeholder.insertBefore( + ui.placeholder + .siblings() + .slice(destPlaceholderIndex - 2, destPlaceholderIndex - 1), + ); } else { - ui.placeholder.insertAfter(ui.placeholder.siblings().slice(destPlaceholderIndex - 1, destPlaceholderIndex)); + ui.placeholder.insertAfter( + ui.placeholder + .siblings() + .slice(destPlaceholderIndex - 1, destPlaceholderIndex), + ); } } }, @@ -181,7 +194,11 @@ BlazeComponent.extendComponent({ enableClickOnTouch('.js-swimlane:not(.placeholder)'); function userIsMember() { - return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); + return ( + Meteor.user() && + Meteor.user().isBoardMember() && + !Meteor.user().isCommentOnly() + ); } // If there is no data in the board (ie, no lists) we autofocus the list @@ -195,45 +212,49 @@ BlazeComponent.extendComponent({ isViewSwimlanes() { const currentUser = Meteor.user(); if (!currentUser) return false; - return ((currentUser.profile || {}).boardView === 'board-view-swimlanes'); + return (currentUser.profile || {}).boardView === 'board-view-swimlanes'; }, isViewLists() { const currentUser = Meteor.user(); if (!currentUser) return true; - return ((currentUser.profile || {}).boardView === 'board-view-lists'); + return (currentUser.profile || {}).boardView === 'board-view-lists'; }, isViewCalendar() { const currentUser = Meteor.user(); if (!currentUser) return false; - return ((currentUser.profile || {}).boardView === 'board-view-cal'); + return (currentUser.profile || {}).boardView === 'board-view-cal'; }, openNewListForm() { if (this.isViewSwimlanes()) { this.childComponents('swimlane')[0] - .childComponents('addListAndSwimlaneForm')[0].open(); + .childComponents('addListAndSwimlaneForm')[0] + .open(); } else if (this.isViewLists()) { this.childComponents('listsGroup')[0] - .childComponents('addListForm')[0].open(); + .childComponents('addListForm')[0] + .open(); } }, events() { - return [{ - // XXX The board-overlay div should probably be moved to the parent - // component. - 'mouseenter .board-overlay'() { - if (this.mouseHasEnterCardDetails) { - this.showOverlay.set(false); - } - }, - 'mouseup'() { - if (this._isDragging) { - this._isDragging = false; - } + return [ + { + // XXX The board-overlay div should probably be moved to the parent + // component. + 'mouseenter .board-overlay'() { + if (this.mouseHasEnterCardDetails) { + this.showOverlay.set(false); + } + }, + mouseup() { + if (this._isDragging) { + this._isDragging = false; + } + }, }, - }]; + ]; }, // XXX Flow components allow us to avoid creating these two setter methods by @@ -245,23 +266,24 @@ BlazeComponent.extendComponent({ scrollLeft(position = 0) { const swimlanes = this.$('.js-swimlanes'); - swimlanes && swimlanes.animate({ - scrollLeft: position, - }); + swimlanes && + swimlanes.animate({ + scrollLeft: position, + }); }, scrollTop(position = 0) { const swimlanes = this.$('.js-swimlanes'); - swimlanes && swimlanes.animate({ - scrollTop: position, - }); + swimlanes && + swimlanes.animate({ + scrollTop: position, + }); }, - }).register('boardBody'); BlazeComponent.extendComponent({ onRendered() { - this.autorun(function(){ + this.autorun(function() { $('#calendar-view').fullCalendar('refetchEvents'); }); }, @@ -273,7 +295,8 @@ BlazeComponent.extendComponent({ timezone: 'local', header: { left: 'title today prev,next', - center: 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear', + center: + 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear', right: '', }, // height: 'parent', nope, doesn't work as the parent might be small @@ -283,7 +306,7 @@ BlazeComponent.extendComponent({ nowIndicator: true, businessHours: { // days of week. an array of zero-based day of week integers (0=Sunday) - dow: [ 1, 2, 3, 4, 5 ], // Monday - Friday + dow: [1, 2, 3, 4, 5], // Monday - Friday start: '8:00', end: '18:00', }, @@ -291,20 +314,25 @@ BlazeComponent.extendComponent({ events(start, end, timezone, callback) { const currentBoard = Boards.findOne(Session.get('currentBoard')); const events = []; - currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){ - events.push({ - id: card._id, - title: card.title, - start: card.startAt, - end: card.endAt, - allDay: Math.abs(card.endAt.getTime() - card.startAt.getTime()) / 1000 === 24*3600, - url: FlowRouter.url('card', { - boardId: currentBoard._id, - slug: currentBoard.slug, - cardId: card._id, - }), + currentBoard + .cardsInInterval(start.toDate(), end.toDate()) + .forEach(function(card) { + events.push({ + id: card._id, + title: card.title, + start: card.startAt, + end: card.endAt, + allDay: + Math.abs(card.endAt.getTime() - card.startAt.getTime()) / + 1000 === + 24 * 3600, + url: FlowRouter.url('card', { + boardId: currentBoard._id, + slug: currentBoard.slug, + cardId: card._id, + }), + }); }); - }); callback(events); }, eventResize(event, delta, revertFunc) { @@ -339,6 +367,6 @@ BlazeComponent.extendComponent({ isViewCalendar() { const currentUser = Meteor.user(); if (!currentUser) return false; - return ((currentUser.profile || {}).boardView === 'board-view-cal'); + return (currentUser.profile || {}).boardView === 'board-view-cal'; }, }).register('calendarView'); diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index f2b5c4f5..cb84c233 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -45,15 +45,21 @@ Template.boardMenuPopup.helpers({ }); Template.boardChangeTitlePopup.events({ - submit(evt, tpl) { - const newTitle = tpl.$('.js-board-name').val().trim(); - const newDesc = tpl.$('.js-board-desc').val().trim(); + submit(event, templateInstance) { + const newTitle = templateInstance + .$('.js-board-name') + .val() + .trim(); + const newDesc = templateInstance + .$('.js-board-desc') + .val() + .trim(); if (newTitle) { this.rename(newTitle); this.setDescription(newDesc); Popup.close(); } - evt.preventDefault(); + event.preventDefault(); }, }); @@ -76,67 +82,79 @@ BlazeComponent.extendComponent({ }, events() { - return [{ - 'click .js-edit-board-title': Popup.open('boardChangeTitle'), - 'click .js-star-board'() { - Meteor.user().toggleBoardStar(Session.get('currentBoard')); + return [ + { + 'click .js-edit-board-title': Popup.open('boardChangeTitle'), + 'click .js-star-board'() { + Meteor.user().toggleBoardStar(Session.get('currentBoard')); + }, + 'click .js-open-board-menu': Popup.open('boardMenu'), + 'click .js-change-visibility': Popup.open('boardChangeVisibility'), + 'click .js-watch-board': Popup.open('boardChangeWatch'), + 'click .js-open-archived-board'() { + Modal.open('archivedBoards'); + }, + 'click .js-toggle-board-view'() { + const currentUser = Meteor.user(); + if ( + (currentUser.profile || {}).boardView === 'board-view-swimlanes' + ) { + currentUser.setBoardView('board-view-cal'); + } else if ( + (currentUser.profile || {}).boardView === 'board-view-lists' + ) { + currentUser.setBoardView('board-view-swimlanes'); + } else if ( + (currentUser.profile || {}).boardView === 'board-view-cal' + ) { + currentUser.setBoardView('board-view-lists'); + } else { + currentUser.setBoardView('board-view-swimlanes'); + } + }, + 'click .js-toggle-sidebar'() { + Sidebar.toggle(); + }, + 'click .js-open-filter-view'() { + Sidebar.setView('filter'); + }, + 'click .js-filter-reset'(event) { + event.stopPropagation(); + Sidebar.setView(); + Filter.reset(); + }, + 'click .js-open-search-view'() { + Sidebar.setView('search'); + }, + 'click .js-open-rules-view'() { + Modal.openWide('rulesMain'); + }, + 'click .js-multiselection-activate'() { + const currentCard = Session.get('currentCard'); + MultiSelection.activate(); + if (currentCard) { + MultiSelection.add(currentCard); + } + }, + 'click .js-multiselection-reset'(event) { + event.stopPropagation(); + MultiSelection.disable(); + }, + 'click .js-log-in'() { + FlowRouter.go('atSignIn'); + }, }, - 'click .js-open-board-menu': Popup.open('boardMenu'), - 'click .js-change-visibility': Popup.open('boardChangeVisibility'), - 'click .js-watch-board': Popup.open('boardChangeWatch'), - 'click .js-open-archived-board'() { - Modal.open('archivedBoards'); - }, - 'click .js-toggle-board-view'() { - const currentUser = Meteor.user(); - if ((currentUser.profile || {}).boardView === 'board-view-swimlanes') { - currentUser.setBoardView('board-view-cal'); - } else if ((currentUser.profile || {}).boardView === 'board-view-lists') { - currentUser.setBoardView('board-view-swimlanes'); - } else if ((currentUser.profile || {}).boardView === 'board-view-cal') { - currentUser.setBoardView('board-view-lists'); - } else { - currentUser.setBoardView('board-view-swimlanes'); - } - }, - 'click .js-toggle-sidebar'() { - Sidebar.toggle(); - }, - 'click .js-open-filter-view'() { - Sidebar.setView('filter'); - }, - 'click .js-filter-reset'(evt) { - evt.stopPropagation(); - Sidebar.setView(); - Filter.reset(); - }, - 'click .js-open-search-view'() { - Sidebar.setView('search'); - }, - 'click .js-open-rules-view'() { - Modal.openWide('rulesMain'); - }, - 'click .js-multiselection-activate'() { - const currentCard = Session.get('currentCard'); - MultiSelection.activate(); - if (currentCard) { - MultiSelection.add(currentCard); - } - }, - 'click .js-multiselection-reset'(evt) { - evt.stopPropagation(); - MultiSelection.disable(); - }, - 'click .js-log-in'() { - FlowRouter.go('atSignIn'); - }, - }]; + ]; }, }).register('boardHeaderBar'); Template.boardHeaderBar.helpers({ canModifyBoard() { - return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); + return ( + Meteor.user() && + Meteor.user().isBoardMember() && + !Meteor.user().isCommentOnly() + ); }, }); @@ -164,15 +182,17 @@ const CreateBoard = BlazeComponent.extendComponent({ this.visibilityMenuIsOpen.set(!this.visibilityMenuIsOpen.get()); }, - onSubmit(evt) { - evt.preventDefault(); + onSubmit(event) { + event.preventDefault(); const title = this.find('.js-new-board-title').value; const visibility = this.visibility.get(); - this.boardId.set(Boards.insert({ - title, - permission: visibility, - })); + this.boardId.set( + Boards.insert({ + title, + permission: visibility, + }), + ); Swimlanes.insert({ title: 'Default', @@ -183,26 +203,28 @@ const CreateBoard = BlazeComponent.extendComponent({ }, events() { - return [{ - 'click .js-select-visibility'() { - this.setVisibility(this.currentData()); + return [ + { + 'click .js-select-visibility'() { + this.setVisibility(this.currentData()); + }, + 'click .js-change-visibility': this.toggleVisibilityMenu, + 'click .js-import': Popup.open('boardImportBoard'), + submit: this.onSubmit, + 'click .js-import-board': Popup.open('chooseBoardSource'), + 'click .js-board-template': Popup.open('searchElement'), }, - 'click .js-change-visibility': this.toggleVisibilityMenu, - 'click .js-import': Popup.open('boardImportBoard'), - submit: this.onSubmit, - 'click .js-import-board': Popup.open('chooseBoardSource'), - 'click .js-board-template': Popup.open('searchElement'), - }]; + ]; }, }).register('createBoardPopup'); (class HeaderBarCreateBoard extends CreateBoard { - onSubmit(evt) { - super.onSubmit(evt); + onSubmit(event) { + super.onSubmit(event); // Immediately star boards crated with the headerbar popup. Meteor.user().toggleBoardStar(this.boardId.get()); } -}).register('headerBarCreateBoardPopup'); +}.register('headerBarCreateBoardPopup')); BlazeComponent.extendComponent({ visibilityCheck() { @@ -218,9 +240,11 @@ BlazeComponent.extendComponent({ }, events() { - return [{ - 'click .js-select-visibility': this.selectBoardVisibility, - }]; + return [ + { + 'click .js-select-visibility': this.selectBoardVisibility, + }, + ]; }, }).register('boardChangeVisibilityPopup'); @@ -235,13 +259,21 @@ BlazeComponent.extendComponent({ }, events() { - return [{ - 'click .js-select-watch'() { - const level = this.currentData(); - Meteor.call('watch', 'board', Session.get('currentBoard'), level, (err, ret) => { - if (!err && ret) Popup.close(); - }); + return [ + { + 'click .js-select-watch'() { + const level = this.currentData(); + Meteor.call( + 'watch', + 'board', + Session.get('currentBoard'), + level, + (err, ret) => { + if (!err && ret) Popup.close(); + }, + ); + }, }, - }]; + ]; }, }).register('boardChangeWatchPopup'); diff --git a/client/components/boards/boardsList.js b/client/components/boards/boardsList.js index 0fb80230..cc586b1f 100644 --- a/client/components/boards/boardsList.js +++ b/client/components/boards/boardsList.js @@ -21,11 +21,14 @@ BlazeComponent.extendComponent({ }, boards() { - return Boards.find({ - archived: false, - 'members.userId': Meteor.userId(), - type: 'board', - }, { sort: ['title'] }); + return Boards.find( + { + archived: false, + 'members.userId': Meteor.userId(), + type: 'board', + }, + { sort: ['title'] }, + ); }, isStarred() { const user = Meteor.user(); @@ -48,46 +51,49 @@ BlazeComponent.extendComponent({ }, events() { - return [{ - 'click .js-add-board': Popup.open('createBoard'), - 'click .js-star-board'(evt) { - const boardId = this.currentData()._id; - Meteor.user().toggleBoardStar(boardId); - evt.preventDefault(); - }, - 'click .js-clone-board'(evt) { - Meteor.call('cloneBoard', - this.currentData()._id, - Session.get('fromBoard'), - (err, res) => { - if (err) { - this.setError(err.error); - } else { - Session.set('fromBoard', null); - Utils.goBoardId(res); + return [ + { + 'click .js-add-board': Popup.open('createBoard'), + 'click .js-star-board'(evt) { + const boardId = this.currentData()._id; + Meteor.user().toggleBoardStar(boardId); + evt.preventDefault(); + }, + 'click .js-clone-board'(evt) { + Meteor.call( + 'cloneBoard', + this.currentData()._id, + Session.get('fromBoard'), + (err, res) => { + if (err) { + this.setError(err.error); + } else { + Session.set('fromBoard', null); + Utils.goBoardId(res); + } + }, + ); + evt.preventDefault(); + }, + 'click .js-archive-board'(evt) { + const boardId = this.currentData()._id; + Meteor.call('archiveBoard', boardId); + evt.preventDefault(); + }, + 'click .js-accept-invite'() { + const boardId = this.currentData()._id; + Meteor.user().removeInvite(boardId); + }, + 'click .js-decline-invite'() { + const boardId = this.currentData()._id; + Meteor.call('quitBoard', boardId, (err, ret) => { + if (!err && ret) { + Meteor.user().removeInvite(boardId); + FlowRouter.go('home'); } - } - ); - evt.preventDefault(); - }, - 'click .js-archive-board'(evt) { - const boardId = this.currentData()._id; - Meteor.call('archiveBoard', boardId); - evt.preventDefault(); - }, - 'click .js-accept-invite'() { - const boardId = this.currentData()._id; - Meteor.user().removeInvite(boardId); - }, - 'click .js-decline-invite'() { - const boardId = this.currentData()._id; - Meteor.call('quitBoard', boardId, (err, ret) => { - if (!err && ret) { - Meteor.user().removeInvite(boardId); - FlowRouter.go('home'); - } - }); + }); + }, }, - }]; + ]; }, }).register('boardList'); -- cgit v1.2.3-1-g7c22