|
@@ -1,22 +1,23 @@
|
|
|
-const subManager = new SubsManager();
|
|
|
-Meteor.subscribe('myCards');
|
|
|
-Meteor.subscribe('mySwimlanes');
|
|
|
-Meteor.subscribe('myLists');
|
|
|
-
|
|
|
-Template.myCardsHeaderBar.events({
|
|
|
- 'click .js-open-archived-board'() {
|
|
|
- Modal.open('archivedBoards');
|
|
|
+BlazeComponent.extendComponent({
|
|
|
+ myCardsSort() {
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ // console.log('sort:', Utils.myCardsSort());
|
|
|
+ return Utils.myCardsSort();
|
|
|
},
|
|
|
-});
|
|
|
|
|
|
-Template.myCardsHeaderBar.helpers({
|
|
|
- title() {
|
|
|
- return FlowRouter.getRouteName() === 'home' ? 'my-boards' : 'public';
|
|
|
- },
|
|
|
- templatesUser() {
|
|
|
- return Meteor.user();
|
|
|
+ events() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ 'click .js-toggle-my-cards-choose-sort'() {
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ // console.log('open sort');
|
|
|
+ // Popup.open('myCardsSortChange');
|
|
|
+ Utils.myCardsSortToggle();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
},
|
|
|
-});
|
|
|
+}).register('myCardsHeaderBar');
|
|
|
|
|
|
Template.myCards.helpers({
|
|
|
userId() {
|
|
@@ -24,10 +25,40 @@ Template.myCards.helpers({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+BlazeComponent.extendComponent({
|
|
|
+ events() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ 'click .js-my-cards-sort-board'() {
|
|
|
+ Utils.setMyCardsSort('board');
|
|
|
+ Popup.close();
|
|
|
+ },
|
|
|
+
|
|
|
+ 'click .js-my-cards-sort-dueat'() {
|
|
|
+ Utils.setMyCardsSort('dueAt');
|
|
|
+ Popup.close();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ },
|
|
|
+}).register('myCardsSortChangePopup');
|
|
|
+
|
|
|
BlazeComponent.extendComponent({
|
|
|
onCreated() {
|
|
|
Meteor.subscribe('setting');
|
|
|
- // subManager.subscribe('myCards');
|
|
|
+ Meteor.subscribe('myCards');
|
|
|
+ Meteor.subscribe('mySwimlanes');
|
|
|
+ Meteor.subscribe('myLists');
|
|
|
+ },
|
|
|
+
|
|
|
+ myCardsSort() {
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ console.log('sort:', Utils.myCardsSort());
|
|
|
+ return Utils.myCardsSort();
|
|
|
+ },
|
|
|
+
|
|
|
+ sortByBoard() {
|
|
|
+ return this.myCardsSort() === 'board';
|
|
|
},
|
|
|
|
|
|
myBoards() {
|
|
@@ -145,20 +176,62 @@ BlazeComponent.extendComponent({
|
|
|
return boards;
|
|
|
},
|
|
|
|
|
|
+ myCardsList() {
|
|
|
+ const userId = Meteor.userId();
|
|
|
+
|
|
|
+ const cursor = Cards.find(
|
|
|
+ {
|
|
|
+ $or: [{ members: userId }, { assignees: userId }],
|
|
|
+ archived: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ sort: {
|
|
|
+ dueAt: -1,
|
|
|
+ boardId: 1,
|
|
|
+ swimlaneId: 1,
|
|
|
+ listId: 1,
|
|
|
+ sort: 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ // console.log('cursor:', cursor);
|
|
|
+
|
|
|
+ const cards = [];
|
|
|
+ cursor.forEach(card => {
|
|
|
+ cards.push(card);
|
|
|
+ });
|
|
|
+
|
|
|
+ cards.sort((a, b) => {
|
|
|
+ const x = a.dueAt === null ? Date('2100-12-31') : a.dueAt;
|
|
|
+ const y = b.dueAt === null ? Date('2100-12-31') : b.dueAt;
|
|
|
+
|
|
|
+ if (x > y) return 1;
|
|
|
+ else if (x < y) return -1;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ // console.log('cursor:', cards);
|
|
|
+ return cards;
|
|
|
+ },
|
|
|
+
|
|
|
events() {
|
|
|
return [
|
|
|
{
|
|
|
- 'click .js-my-card'(evt) {
|
|
|
- const card = this.currentData().card;
|
|
|
- // eslint-disable-next-line no-console
|
|
|
- console.log('currentData():', this.currentData());
|
|
|
- // eslint-disable-next-line no-console
|
|
|
- console.log('card:', card);
|
|
|
- if (card) {
|
|
|
- Utils.goCardId(card._id);
|
|
|
- }
|
|
|
- evt.preventDefault();
|
|
|
- },
|
|
|
+ // 'click .js-my-card'(evt) {
|
|
|
+ // const card = this.currentData().card;
|
|
|
+ // // eslint-disable-next-line no-console
|
|
|
+ // console.log('currentData():', this.currentData());
|
|
|
+ // // eslint-disable-next-line no-console
|
|
|
+ // console.log('card:', card);
|
|
|
+ // if (card) {
|
|
|
+ // Utils.goCardId(card._id);
|
|
|
+ // }
|
|
|
+ // evt.preventDefault();
|
|
|
+ // },
|
|
|
},
|
|
|
];
|
|
|
},
|