123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import { CardSearchPagedComponent } from '../../lib/cardSearch';
- BlazeComponent.extendComponent({
- myCardsSort() {
- // eslint-disable-next-line no-console
- // console.log('sort:', Utils.myCardsSort());
- return Utils.myCardsSort();
- },
- myCardsView() {
- // eslint-disable-next-line no-console
- // console.log('sort:', Utils.myCardsView());
- return Utils.myCardsView();
- },
- events() {
- return [
- {
- 'click .js-toggle-my-cards-choose-sort': Popup.open(
- 'myCardsSortChange',
- ),
- 'click .js-my-cards-view-change': Popup.open(
- 'myCardsViewChange'),
- },
- ];
- },
- }).register('myCardsHeaderBar');
- Template.myCards.helpers({
- userId() {
- return Meteor.userId();
- },
- });
- BlazeComponent.extendComponent({
- events() {
- return [
- {
- 'click .js-my-cards-view-boards'() {
- Utils.setMyCardsView('boards');
- Popup.back();
- },
- 'click .js-my-cards-view-table'() {
- Utils.setMyCardsView('table');
- Popup.back();
- },
- },
- ];
- },
- }).register('myCardsViewChangePopup');
- class MyCardsComponent extends CardSearchPagedComponent {
- onCreated() {
- super.onCreated();
- this.runGlobalSearch(null);
- Meteor.subscribe('setting');
- }
- // eslint-disable-next-line no-unused-vars
- getSubscription(queryParams) {
- return Meteor.subscribe(
- 'myCards',
- this.sessionId,
- this.subscriptionCallbacks,
- );
- }
- myCardsView() {
- // eslint-disable-next-line no-console
- //console.log('sort:', Utils.myCardsView());
- return Utils.myCardsView();
- }
- labelName(board, labelId) {
- const label = board.getLabelById(labelId)
- const name = label.name
- return name
- }
- labelColor(board, labelId) {
- const label = board.getLabelById(labelId)
- const color = label.color
- return color
- }
- myCardsList() {
- const boards = [];
- let board = null;
- let swimlane = null;
- let list = null;
- const cursor = this.getResults();
- if (cursor) {
- cursor.forEach(card => {
- // eslint-disable-next-line no-console
- // console.log('card:', card.title);
- if (board === null || card.boardId !== board._id) {
- // eslint-disable-next-line no-console
- // console.log('new board');
- board = card.getBoard();
- if (board.archived) {
- board = null;
- return;
- }
- // eslint-disable-next-line no-console
- // console.log('board:', b, b._id, b.title);
- boards.push(board);
- board.mySwimlanes = [];
- swimlane = null;
- list = null;
- }
- if (swimlane === null || card.swimlaneId !== swimlane._id) {
- // eslint-disable-next-line no-console
- // console.log('new swimlane');
- swimlane = card.getSwimlane();
- if (swimlane.archived) {
- swimlane = null;
- return;
- }
- board.mySwimlanes.push(swimlane);
- swimlane.myLists = [];
- list = null;
- }
- if (list === null || card.listId !== list._id) {
- // eslint-disable-next-line no-console
- // console.log('new list');
- list = card.getList();
- if (list.archived) {
- list = null;
- return;
- }
- swimlane.myLists.push(list);
- list.myCards = [];
- }
- list.myCards.push(card);
- });
- // sort the data structure
- boards.forEach(board => {
- board.mySwimlanes.forEach(swimlane => {
- swimlane.myLists.forEach(list => {
- list.myCards.sort((a, b) => {
- return a.sort - b.sort;
- });
- });
- swimlane.myLists.sort((a, b) => {
- return a.sort - b.sort;
- });
- });
- board.mySwimlanes.sort((a, b) => {
- return a.sort - b.sort;
- });
- });
- boards.sort((a, b) => {
- let x = a.sort;
- let y = b.sort;
- // show the template board last
- if (a.type === 'template-container') {
- x = 99999999;
- } else if (b.type === 'template-container') {
- y = 99999999;
- }
- return x - y;
- });
- // eslint-disable-next-line no-console
- // console.log('boards:', boards);
- return boards;
- }
- return [];
- }
- }
- MyCardsComponent.register('myCards');
|