mirror of
https://github.com/wekan/wekan.git
synced 2025-12-19 17:00:13 +01:00
My Cards page development
* rename `findCards()` to `myBoards()` * return model objects for Boards, Swimlanes, Lists, and Cards. Previously created a data structure with limited properties. * Sort the myBoards data structure according to the `sort` property * add a `swimlane()` method in the cards model
This commit is contained in:
parent
0497d38c1d
commit
5e68362352
4 changed files with 67 additions and 56 deletions
|
|
@ -11,20 +11,23 @@ template(name="myCardsModalTitle")
|
||||||
|
|
||||||
template(name="myCards")
|
template(name="myCards")
|
||||||
.wrapper
|
.wrapper
|
||||||
each board in cardsFind
|
each board in myBoards
|
||||||
.my-cards-board-wrapper
|
.my-cards-board-wrapper
|
||||||
.board-title
|
.board-title
|
||||||
+viewer
|
+viewer
|
||||||
= board.title
|
= board.title
|
||||||
each swimlane in board.swimlanes
|
| {{#if board.archived}} ({{_ 'archived' }}){{/if}}
|
||||||
|
each swimlane in board.mySwimlanes
|
||||||
.swimlane-title(class=swimlane.colorClass)
|
.swimlane-title(class=swimlane.colorClass)
|
||||||
+viewer
|
+viewer
|
||||||
= swimlane.title
|
= swimlane.title
|
||||||
each list in swimlane.lists
|
| {{#if swimlane.archived}} ({{_ 'archived' }}){{/if}}
|
||||||
|
each list in swimlane.myLists
|
||||||
.my-cards-list-wrapper
|
.my-cards-list-wrapper
|
||||||
.list-title(class=list.colorClass)
|
.list-title(class=list.colorClass)
|
||||||
+viewer
|
+viewer
|
||||||
= list.title
|
= list.title
|
||||||
each card in list.cards
|
| {{#if list.archived}} ({{_ 'archived' }}){{/if}}
|
||||||
|
each card in list.myCards
|
||||||
a.minicard-wrapper.card-title(href=card.absoluteUrl)
|
a.minicard-wrapper.card-title(href=card.absoluteUrl)
|
||||||
+minicard(card)
|
+minicard(card)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ BlazeComponent.extendComponent({
|
||||||
// subManager.subscribe('myCards');
|
// subManager.subscribe('myCards');
|
||||||
},
|
},
|
||||||
|
|
||||||
cardsFind() {
|
myBoards() {
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
const boards = [];
|
const boards = [];
|
||||||
let board = null;
|
let board = null;
|
||||||
|
|
@ -39,8 +39,8 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
const cursor = Cards.find(
|
const cursor = Cards.find(
|
||||||
{
|
{
|
||||||
archived: false,
|
|
||||||
$or: [{ members: userId }, { assignees: userId }],
|
$or: [{ members: userId }, { assignees: userId }],
|
||||||
|
archived: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sort: {
|
sort: {
|
||||||
|
|
@ -51,8 +51,6 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
// console.log('cursor:', cursor);
|
|
||||||
|
|
||||||
let newBoard = false;
|
let newBoard = false;
|
||||||
let newSwimlane = false;
|
let newSwimlane = false;
|
||||||
|
|
@ -61,74 +59,50 @@ BlazeComponent.extendComponent({
|
||||||
cursor.forEach(card => {
|
cursor.forEach(card => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('card:', card.title);
|
// console.log('card:', card.title);
|
||||||
if (list === null || list.id !== card.listId) {
|
if (list === null || card.listId !== list._id) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('new list');
|
// console.log('new list');
|
||||||
let l = Lists.findOne(card.listId);
|
list = card.list();
|
||||||
if (!l) {
|
if (list.archived) {
|
||||||
l = {
|
list = null;
|
||||||
_id: card.listId,
|
return;
|
||||||
title: 'undefined list',
|
|
||||||
colorClass: '',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-console
|
list.myCards = [card];
|
||||||
// console.log('list:', l);
|
|
||||||
list = {
|
|
||||||
id: l._id,
|
|
||||||
title: l.title,
|
|
||||||
colorClass: l.colorClass(),
|
|
||||||
cards: [card],
|
|
||||||
};
|
|
||||||
newList = true;
|
newList = true;
|
||||||
}
|
}
|
||||||
if (swimlane === null || card.swimlaneId !== swimlane.id) {
|
if (swimlane === null || card.swimlaneId !== swimlane._id) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('new swimlane');
|
// console.log('new swimlane');
|
||||||
let s = Swimlanes.findOne(card.swimlaneId);
|
swimlane = card.swimlane();
|
||||||
if (!s) {
|
if (swimlane.archived) {
|
||||||
s = {
|
swimlane = null;
|
||||||
_id: card.swimlaneId,
|
return;
|
||||||
colorClass: '',
|
|
||||||
title: 'undefined swimlane',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-console
|
swimlane.myLists = [list];
|
||||||
// console.log('swimlane:', s);
|
|
||||||
swimlane = {
|
|
||||||
id: s._id,
|
|
||||||
colorClass: s.colorClass()
|
|
||||||
? s.colorClass()
|
|
||||||
: 'swimlane-default-color',
|
|
||||||
title: s.title,
|
|
||||||
lists: [list],
|
|
||||||
};
|
|
||||||
newSwimlane = true;
|
newSwimlane = true;
|
||||||
}
|
}
|
||||||
if (board === null || card.boardId !== board.id) {
|
if (board === null || card.boardId !== board._id) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('new board');
|
// console.log('new board');
|
||||||
const b = Boards.findOne(card.boardId);
|
board = card.board();
|
||||||
|
if (board.archived) {
|
||||||
|
board = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('board:', b, b._id, b.title);
|
// console.log('board:', b, b._id, b.title);
|
||||||
board = {
|
board.mySwimlanes = [swimlane];
|
||||||
id: b._id,
|
|
||||||
colorClass: b.colorClass(),
|
|
||||||
title: b.title,
|
|
||||||
slug: b.slug,
|
|
||||||
swimlanes: [swimlane],
|
|
||||||
};
|
|
||||||
newBoard = true;
|
newBoard = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newBoard) {
|
if (newBoard) {
|
||||||
boards.push(board);
|
boards.push(board);
|
||||||
} else if (newSwimlane) {
|
} else if (newSwimlane) {
|
||||||
board.swimlanes.push(swimlane);
|
board.mySwimlanes.push(swimlane);
|
||||||
} else if (newList) {
|
} else if (newList) {
|
||||||
swimlane.lists.push(list);
|
swimlane.myLists.push(list);
|
||||||
} else {
|
} else {
|
||||||
list.cards.push(card);
|
list.myCards.push(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
newBoard = false;
|
newBoard = false;
|
||||||
|
|
@ -136,6 +110,36 @@ BlazeComponent.extendComponent({
|
||||||
newList = false;
|
newList = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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
|
// eslint-disable-next-line no-console
|
||||||
// console.log('boards:', boards);
|
// console.log('boards:', boards);
|
||||||
return boards;
|
return boards;
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,10 @@ Cards.helpers({
|
||||||
return Lists.findOne(this.listId);
|
return Lists.findOne(this.listId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
swimlane() {
|
||||||
|
return Swimlanes.findOne(this.swimlaneId);
|
||||||
|
},
|
||||||
|
|
||||||
board() {
|
board() {
|
||||||
return Boards.findOne(this.boardId);
|
return Boards.findOne(this.boardId);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ Meteor.publish('mySwimlanes', function() {
|
||||||
|
|
||||||
return Swimlanes.find(
|
return Swimlanes.find(
|
||||||
{
|
{
|
||||||
archived: false,
|
// archived: false,
|
||||||
_id: { $in: swimlanes },
|
_id: { $in: swimlanes },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +88,7 @@ Meteor.publish('myLists', function() {
|
||||||
|
|
||||||
return Lists.find(
|
return Lists.find(
|
||||||
{
|
{
|
||||||
archived: false,
|
// archived: false,
|
||||||
_id: { $in: lists },
|
_id: { $in: lists },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue