From 5cc6a2f7d01c33f93d426f0b563d8344e2de8fbd Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Thu, 1 Apr 2021 23:40:07 +0200 Subject: [PATCH 1/6] Add an avatar for the card creator * Add avatar to minicard * Add field to card details * Add show option in Board / Card Settings --- client/components/activities/comments.jade | 2 +- client/components/cards/cardDetails.jade | 11 ++++++++++- client/components/cards/cardDetails.js | 2 +- client/components/cards/cardDetails.styl | 1 + client/components/cards/minicard.jade | 4 ++++ client/components/cards/minicard.js | 12 ++++++++++++ client/components/cards/minicard.styl | 8 ++++++-- client/components/sidebar/sidebar.jade | 8 ++++++++ client/components/sidebar/sidebar.js | 21 +++++++++++++++++++++ client/components/users/userAvatar.jade | 7 ++++--- client/components/users/userAvatar.js | 1 + i18n/en.i18n.json | 3 ++- models/boards.js | 12 ++++++++++++ server/publications/cards.js | 4 ++++ 14 files changed, 87 insertions(+), 9 deletions(-) diff --git a/client/components/activities/comments.jade b/client/components/activities/comments.jade index 405778de0..4cddf4c23 100644 --- a/client/components/activities/comments.jade +++ b/client/components/activities/comments.jade @@ -1,7 +1,7 @@ template(name="commentForm") .new-comment.js-new-comment( class="{{#if commentFormIsOpen}}is-open{{/if}}") - +userAvatar(userId=currentUser._id) + +userAvatar(userId=currentUser._id noRemove=true) form.js-new-comment-form +editor(class="js-new-comment-input") | {{getUnsavedValue 'cardComment' currentCard._id}} diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index 245ab773d..42426e92f 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -110,9 +110,18 @@ template(name="cardDetails") a.card-label.add-label.js-end-date i.fa.fa-plus + hr + if currentBoard.allowsCreator + .card-details-item.card-details-item-creator + h3.card-details-item-title + i.fa.fa-user + | {{_ 'creator'}} + + +userAvatar(userId=userId noRemove=true) + | {{! XXX Hack to hide syntaxic coloration /// }} + //.card-details-items if currentBoard.allowsMembers - hr .card-details-item.card-details-item-members h3.card-details-item-title i.fa.fa-users diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index c745f0730..4278bdd07 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -356,7 +356,7 @@ BlazeComponent.extendComponent({ 'click .js-go-to-linked-card'() { Utils.goCardId(this.data().linkedId); }, - 'click .js-member': Popup.open('cardMember'), + // 'click .js-member': Popup.open('cardMember'), 'click .js-add-members': Popup.open('cardMembers'), 'click .js-assignee': Popup.open('cardAssignee'), 'click .js-add-assignees': Popup.open('cardAssignees'), diff --git a/client/components/cards/cardDetails.styl b/client/components/cards/cardDetails.styl index a2216390f..5e57d49bc 100644 --- a/client/components/cards/cardDetails.styl +++ b/client/components/cards/cardDetails.styl @@ -211,6 +211,7 @@ avatar-radius = 50% word-wrap: break-word max-width: 36% flex-grow: 1 + &.card-details-item-creator, &.card-details-item-received, &.card-details-item-start, &.card-details-item-due, diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade index 3931bffbc..764eb6481 100644 --- a/client/components/cards/minicard.jade +++ b/client/components/cards/minicard.jade @@ -96,6 +96,10 @@ template(name="minicard") each getMembers +userAvatar(userId=this) + if showCreator + .minicard-creator + +userAvatar(userId=this.userId noRemove=true) + .badges unless currentUser.isNoComments if comments.count diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js index 88348fc48..94cff243e 100644 --- a/client/components/cards/minicard.js +++ b/client/components/cards/minicard.js @@ -21,6 +21,18 @@ BlazeComponent.extendComponent({ }).format(customFieldTrueValue); }, + showCreator() { + if (this.data().board()) { + return ( + this.data().board.allowsCreator === null || + this.data().board().allowsCreator === undefined || + this.data().board().allowsCreator + ); + // return this.data().board().allowsCreator; + } + return false; + }, + events() { return [ { diff --git a/client/components/cards/minicard.styl b/client/components/cards/minicard.styl index 003c677b5..4e7bf53b7 100644 --- a/client/components/cards/minicard.styl +++ b/client/components/cards/minicard.styl @@ -89,7 +89,7 @@ border-radius: 2px margin-right: 3px margin-bottom: 3px - + .minicard-custom-fields display:block; .minicard-custom-field @@ -163,7 +163,8 @@ line-height: 12px .minicard-members, - .minicard-assignees + .minicard-assignees, + .minicard-creator float: right margin-left: 5px margin-bottom: 4px @@ -187,6 +188,9 @@ .minicard-assignees border-bottom: 1px solid red + .minicard-creator + border-bottom: 1px solid green + .minicard-members:empty, .minicard-assignees:empty display: none diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade index 09af600bb..85394f027 100644 --- a/client/components/sidebar/sidebar.jade +++ b/client/components/sidebar/sidebar.jade @@ -105,6 +105,14 @@ template(name="boardCardSettingsPopup") span i.fa.fa-users | {{_ 'members'}} + + div.check-div + a.flex.js-field-has-creator(class="{{#if allowsCreator}}is-checked{{/if}}") + .materialCheckBox(class="{{#if allowsCreator}}is-checked{{/if}}") + span + i.fa.fa-user + | {{_ 'creator'}} + div.check-div a.flex.js-field-has-assignee(class="{{#if allowsAssignee}}is-checked{{/if}}") .materialCheckBox(class="{{#if allowsAssignee}}is-checked{{/if}}") diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index f4f7f45cb..5c1026c12 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -730,6 +730,14 @@ BlazeComponent.extendComponent({ return this.currentBoard.allowsSubtasks; }, + allowsCreator() { + return ( + this.currentBoard.allowsCreator === null || + this.currentBoard.allowsCreator === undefined || + this.currentBoard.allowsCreator + ); + }, + allowsMembers() { return this.currentBoard.allowsMembers; }, @@ -889,6 +897,19 @@ BlazeComponent.extendComponent({ this.currentBoard.allowsSubtasks, ); }, + 'click .js-field-has-creator'(evt) { + evt.preventDefault(); + this.currentBoard.allowsCreator = !this.currentBoard.allowsCreator; + this.currentBoard.setAllowsCreator(this.currentBoard.allowsCreator); + $(`.js-field-has-creator ${MCB}`).toggleClass( + CKCLS, + this.currentBoard.allowsCreator, + ); + $('.js-field-has-creator').toggleClass( + CKCLS, + this.currentBoard.allowsCreator, + ); + }, 'click .js-field-has-members'(evt) { evt.preventDefault(); this.currentBoard.allowsMembers = !this.currentBoard.allowsMembers; diff --git a/client/components/users/userAvatar.jade b/client/components/users/userAvatar.jade index 988a2626d..87bbb8c6a 100644 --- a/client/components/users/userAvatar.jade +++ b/client/components/users/userAvatar.jade @@ -72,9 +72,10 @@ template(name="cardMemberPopup") h3= user.profile.fullname p.quiet @{{ user.username }} ul.pop-over-list - if currentUser.isNotCommentOnly - if currentUser.isNotWorker - li: a.js-remove-member {{_ 'remove-member-from-card'}} + unless noRemove + if currentUser.isNotCommentOnly + if currentUser.isNotWorker + li: a.js-remove-member {{_ 'remove-member-from-card'}} if $eq currentUser._id user._id with currentUser diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js index 262a63aff..7b8a32145 100644 --- a/client/components/users/userAvatar.js +++ b/client/components/users/userAvatar.js @@ -32,6 +32,7 @@ Template.userAvatar.helpers({ Template.userAvatar.events({ 'click .js-change-avatar': Popup.open('changeAvatar'), + 'click .js-member': Popup.open('cardMember'), }); Template.userAvatarInitials.helpers({ diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index e20645c51..916351156 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -988,5 +988,6 @@ "hide-system-messages-of-all-users": "Hide system messages of all users", "now-system-messages-of-all-users-are-hidden": "Now system messages of all users are hidden", "move-swimlane": "Move Swimlane", - "moveSwimlanePopup-title": "Move Swimlane" + "moveSwimlanePopup-title": "Move Swimlane", + "creator": "Creator" } diff --git a/models/boards.js b/models/boards.js index b78d43a8e..598ae53c3 100644 --- a/models/boards.js +++ b/models/boards.js @@ -372,6 +372,14 @@ Boards.attachSchema( defaultValue: true, }, + allowsCreator: { + /** + * Does the board allow creator? + */ + type: Boolean, + defaultValue: true, + }, + allowsAssignee: { /** * Does the board allows assignee? @@ -1187,6 +1195,10 @@ Boards.mutations({ return { $set: { allowsSubtasks } }; }, + setAllowsCreator(allowsCreator) { + return { $set: { allowsCreator } }; + }, + setAllowsMembers(allowsMembers) { return { $set: { allowsMembers } }; }, diff --git a/server/publications/cards.js b/server/publications/cards.js index 33314ef30..871af13e6 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -488,6 +488,7 @@ function buildProjection(query) { modifiedAt: 1, labelIds: 1, customFields: 1, + userId: 1, }, sort: { boardId: 1, @@ -658,6 +659,9 @@ function findCards(sessionId, query) { if (card.boardId) boards.push(card.boardId); if (card.swimlaneId) swimlanes.push(card.swimlaneId); if (card.listId) lists.push(card.listId); + if (card.userId) { + users.push(card.userId); + } if (card.members) { card.members.forEach(userId => { users.push(userId); From edd07befe21b4ac941423eae5fe593098e69fdc5 Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Thu, 1 Apr 2021 23:41:32 +0200 Subject: [PATCH 2/6] Add a new search operator `creator` --- client/components/main/globalSearch.js | 2 + config/query-classes.js | 4 +- config/search-const.js | 5 +- i18n/en.i18n.json | 2 + server/publications/cards.js | 67 ++++++++++++-------------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/client/components/main/globalSearch.js b/client/components/main/globalSearch.js index 50bc9ae7e..294ac378f 100644 --- a/client/components/main/globalSearch.js +++ b/client/components/main/globalSearch.js @@ -123,6 +123,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent { operator_member_abbrev: TAPi18n.__('operator-member-abbrev'), operator_assignee: TAPi18n.__('operator-assignee'), operator_assignee_abbrev: TAPi18n.__('operator-assignee-abbrev'), + operator_creator: TAPi18n.__('operator-creator'), operator_due: TAPi18n.__('operator-due'), operator_created: TAPi18n.__('operator-created'), operator_modified: TAPi18n.__('operator-modified'), @@ -167,6 +168,7 @@ class GlobalSearchComponent extends CardSearchPagedComponent { ['\n* ', 'globalSearch-instructions-operator-at'], ['\n* ', 'globalSearch-instructions-operator-member'], ['\n* ', 'globalSearch-instructions-operator-assignee'], + ['\n* ', 'globalSearch-instructions-operator-creator'], ['\n* ', 'globalSearch-instructions-operator-due'], ['\n* ', 'globalSearch-instructions-operator-created'], ['\n* ', 'globalSearch-instructions-operator-modified'], diff --git a/config/query-classes.js b/config/query-classes.js index 2c8a49ee0..3955bcd75 100644 --- a/config/query-classes.js +++ b/config/query-classes.js @@ -2,7 +2,7 @@ import { OPERATOR_ASSIGNEE, OPERATOR_BOARD, OPERATOR_COMMENT, - OPERATOR_CREATED_AT, + OPERATOR_CREATED_AT, OPERATOR_CREATOR, OPERATOR_DUE, OPERATOR_HAS, OPERATOR_LABEL, @@ -107,6 +107,7 @@ export class QueryErrors { [OPERATOR_USER, 'user-username-not-found'], [OPERATOR_ASSIGNEE, 'user-username-not-found'], [OPERATOR_MEMBER, 'user-username-not-found'], + [OPERATOR_CREATOR, 'user-username-not-found'], ]; constructor() { @@ -238,6 +239,7 @@ export class Query { 'operator-member': OPERATOR_MEMBER, 'operator-member-abbrev': OPERATOR_MEMBER, 'operator-assignee': OPERATOR_ASSIGNEE, + 'operator-creator': OPERATOR_CREATOR, 'operator-assignee-abbrev': OPERATOR_ASSIGNEE, 'operator-status': OPERATOR_STATUS, 'operator-due': OPERATOR_DUE, diff --git a/config/search-const.js b/config/search-const.js index 26f8ad00b..5a7f54b6b 100644 --- a/config/search-const.js +++ b/config/search-const.js @@ -1,14 +1,15 @@ export const DEFAULT_LIMIT = 25; -export const OPERATOR_ASSIGNEE = 'assignee'; +export const OPERATOR_ASSIGNEE = 'assignees'; export const OPERATOR_COMMENT = 'comment'; export const OPERATOR_CREATED_AT = 'createdAt'; +export const OPERATOR_CREATOR = 'userId'; export const OPERATOR_DUE = 'dueAt'; export const OPERATOR_BOARD = 'board'; export const OPERATOR_HAS = 'has'; export const OPERATOR_LABEL = 'label'; export const OPERATOR_LIMIT = 'limit'; export const OPERATOR_LIST = 'list'; -export const OPERATOR_MEMBER = 'member'; +export const OPERATOR_MEMBER = 'members'; export const OPERATOR_MODIFIED_AT = 'modifiedAt'; export const OPERATOR_SORT = 'sort'; export const OPERATOR_STATUS = 'status'; diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 916351156..73141e8b1 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -901,6 +901,7 @@ "operator-member-abbrev": "m", "operator-assignee": "assignee", "operator-assignee-abbrev": "a", + "operator-creator": "creator", "operator-status": "status", "operator-due": "due", "operator-created": "created", @@ -952,6 +953,7 @@ "globalSearch-instructions-operator-at": "`__operator_user_abbrev__username` - shorthand for `user:`", "globalSearch-instructions-operator-member": "`__operator_member__:` - cards where ** is a *member*", "globalSearch-instructions-operator-assignee": "`__operator_assignee__:` - cards where ** is an *assignee*", + "globalSearch-instructions-operator-creator": "`__operator_creator__:` - cards where ** is the card's creator", "globalSearch-instructions-operator-due": "`__operator_due__:` - cards which are due up to ** days from now. `__operator_due__:__predicate_overdue__ lists all cards past their due date.", "globalSearch-instructions-operator-created": "`__operator_created__:` - cards which were created ** days ago or less", "globalSearch-instructions-operator-modified": "`__operator_modified__:` - cards which were modified ** days ago or less", diff --git a/server/publications/cards.js b/server/publications/cards.js index 871af13e6..1af29bdb0 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -15,12 +15,15 @@ import { OPERATOR_ASSIGNEE, OPERATOR_BOARD, OPERATOR_COMMENT, + OPERATOR_CREATED_AT, + OPERATOR_CREATOR, OPERATOR_DUE, OPERATOR_HAS, OPERATOR_LABEL, OPERATOR_LIMIT, OPERATOR_LIST, OPERATOR_MEMBER, + OPERATOR_MODIFIED_AT, OPERATOR_SORT, OPERATOR_STATUS, OPERATOR_SWIMLANE, @@ -163,7 +166,7 @@ function buildSelector(queryParams) { if (queryParams.hasOperator(OPERATOR_BOARD)) { const queryBoards = []; - queryParams.hasOperator(OPERATOR_BOARD).forEach(query => { + queryParams.getPredicates(OPERATOR_BOARD).forEach(query => { const boards = Boards.userSearch(userId, { title: new RegExp(escapeForRegex(query), 'i'), }); @@ -240,7 +243,7 @@ function buildSelector(queryParams) { } } - [OPERATOR_DUE, 'createdAt', 'modifiedAt'].forEach(field => { + [OPERATOR_DUE, OPERATOR_CREATED_AT, OPERATOR_MODIFIED_AT].forEach(field => { if (queryParams.hasOperator(field)) { selector[field] = {}; const predicate = queryParams.getPredicate(field); @@ -251,52 +254,42 @@ function buildSelector(queryParams) { const queryUsers = {}; queryUsers[OPERATOR_ASSIGNEE] = []; queryUsers[OPERATOR_MEMBER] = []; + queryUsers[OPERATOR_CREATOR] = []; if (queryParams.hasOperator(OPERATOR_USER)) { + const users = []; queryParams.getPredicates(OPERATOR_USER).forEach(username => { const user = Users.findOne({ username }); if (user) { - queryUsers[OPERATOR_MEMBER].push(user._id); - queryUsers[OPERATOR_ASSIGNEE].push(user._id); + users.push(user._id); } else { errors.addNotFound(OPERATOR_USER, username); } }); - } - - [OPERATOR_MEMBER, OPERATOR_ASSIGNEE].forEach(key => { - if (queryParams.hasOperator(key)) { - queryParams.getPredicates(key).forEach(query => { - const users = Users.find({ - username: query, - }); - if (users.count()) { - users.forEach(user => { - queryUsers[key].push(user._id); - }); - } else { - errors.addNotFound(key, query); - } + if (users.length) { + selector.$and.push({ + $or: [{ members: { $in: users } }, { assignees: { $in: users } }], }); } - }); - - if ( - queryUsers[OPERATOR_MEMBER].length && - queryUsers[OPERATOR_ASSIGNEE].length - ) { - selector.$and.push({ - $or: [ - { members: { $in: queryUsers[OPERATOR_MEMBER] } }, - { assignees: { $in: queryUsers[OPERATOR_ASSIGNEE] } }, - ], - }); - } else if (queryUsers[OPERATOR_MEMBER].length) { - selector.members = { $in: queryUsers[OPERATOR_MEMBER] }; - } else if (queryUsers[OPERATOR_ASSIGNEE].length) { - selector.assignees = { $in: queryUsers[OPERATOR_ASSIGNEE] }; } + [OPERATOR_MEMBER, OPERATOR_ASSIGNEE, OPERATOR_CREATOR].forEach(key => { + if (queryParams.hasOperator(key)) { + const users = []; + queryParams.getPredicates(key).forEach(username => { + const user = Users.findOne({ username }); + if (user) { + users.push(user._id); + } else { + errors.addNotFound(key, username); + } + }); + if (users.length) { + selector[key] = { $in: users }; + } + } + }); + if (queryParams.hasOperator(OPERATOR_LABEL)) { queryParams.getPredicates(OPERATOR_LABEL).forEach(label => { const queryLabels = []; @@ -443,9 +436,9 @@ function buildSelector(queryParams) { } // eslint-disable-next-line no-console - // console.log('selector:', selector); + console.log('selector:', selector); // eslint-disable-next-line no-console - // console.log('selector.$and:', selector.$and); + console.log('selector.$and:', selector.$and); const query = new Query(); query.selector = selector; From e43002d5adf79f2ef85a88e2bd1b8d6a7c2f4a21 Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Fri, 2 Apr 2021 02:15:12 +0200 Subject: [PATCH 3/6] Update `Boards.userBoards()` to only return type 'board' by default --- models/boards.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/models/boards.js b/models/boards.js index 598ae53c3..42b356daa 100644 --- a/models/boards.js +++ b/models/boards.js @@ -1330,8 +1330,11 @@ Boards.userBoards = (userId, archived = false, selector = {}) => { if (typeof archived === 'boolean') { selector.archived = archived; } - selector.$or = [{ permission: 'public' }]; + if (!selector.type) { + selector.type = 'board'; + } + selector.$or = [{ permission: 'public' }]; if (userId) { selector.$or.push({ members: { $elemMatch: { userId, isActive: true } } }); } @@ -1435,17 +1438,15 @@ if (Meteor.isServer) { }, myLabelNames() { let names = []; - Boards.userBoards(Meteor.userId(), false, { type: 'board' }).forEach( - board => { - names = names.concat( - board.labels - .filter(label => !!label.name) - .map(label => { - return label.name; - }), - ); - }, - ); + Boards.userBoards(Meteor.userId()).forEach(board => { + names = names.concat( + board.labels + .filter(label => !!label.name) + .map(label => { + return label.name; + }), + ); + }); return _.uniq(names).sort(); }, myBoardNames() { From 69dc8f304cc0b8b35ed044de60e95730ab19f52b Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Fri, 2 Apr 2021 21:40:52 +0200 Subject: [PATCH 4/6] Only search label names in boards of type 'board' --- models/boards.js | 1 + models/cards.js | 1 + server/publications/cards.js | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/boards.js b/models/boards.js index 42b356daa..40435bfca 100644 --- a/models/boards.js +++ b/models/boards.js @@ -505,6 +505,7 @@ Boards.attachSchema( type: { /** * The type of board + * possible values: board, template-board, template-container */ type: String, defaultValue: 'board', diff --git a/models/cards.js b/models/cards.js index a0aed5c69..71f0e343d 100644 --- a/models/cards.js +++ b/models/cards.js @@ -299,6 +299,7 @@ Cards.attachSchema( type: { /** * type of the card + * possible values: cardType-card, cardType-linkedCard, cardType-linkedBoard */ type: String, defaultValue: 'cardType-card', diff --git a/server/publications/cards.js b/server/publications/cards.js index 1af29bdb0..c8c2497f7 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -294,7 +294,7 @@ function buildSelector(queryParams) { queryParams.getPredicates(OPERATOR_LABEL).forEach(label => { const queryLabels = []; - let boards = Boards.userSearch(userId, { + let boards = Boards.userBoards(userId, null, { labels: { $elemMatch: { color: label.toLowerCase() } }, }); @@ -318,7 +318,7 @@ function buildSelector(queryParams) { const reLabel = new RegExp(escapeForRegex(label), 'i'); // eslint-disable-next-line no-console // console.log('reLabel:', reLabel); - boards = Boards.userSearch(userId, { + boards = Boards.userBoards(userId, null, { labels: { $elemMatch: { name: reLabel } }, }); From 302ba75729102e6fbb848ebefe898a5a7403fb05 Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Sat, 3 Apr 2021 01:19:02 +0200 Subject: [PATCH 5/6] * Fix bug with multiple label predicates * Add new constants --- client/components/main/globalSearch.jade | 3 +- client/lib/cardSearch.js | 2 +- config/const.js | 51 ++++++++++++++++++++ config/query-classes.js | 3 +- models/boards.js | 59 ++++++------------------ models/cards.js | 39 ++++------------ server/publications/cards.js | 18 ++++---- 7 files changed, 88 insertions(+), 87 deletions(-) create mode 100644 config/const.js diff --git a/client/components/main/globalSearch.jade b/client/components/main/globalSearch.jade index bd2493124..9d480c3c0 100644 --- a/client/components/main/globalSearch.jade +++ b/client/components/main/globalSearch.jade @@ -50,8 +50,7 @@ template(name="globalSearch") each msg in errorMessages li.global-search-error-messages = msg - else - +resultsPaged(this) + +resultsPaged(this) else if serverError.get .global-search-page .global-search-help diff --git a/client/lib/cardSearch.js b/client/lib/cardSearch.js index 9d89f2447..4ba9ee017 100644 --- a/client/lib/cardSearch.js +++ b/client/lib/cardSearch.js @@ -72,7 +72,7 @@ export class CardSearchPagedComponent extends BlazeComponent { if (this.queryErrors.length) { // console.log('queryErrors:', this.queryErrorMessages()); this.hasQueryErrors.set(true); - return null; + // return null; } if (cards) { diff --git a/config/const.js b/config/const.js new file mode 100644 index 000000000..0c9c71c7c --- /dev/null +++ b/config/const.js @@ -0,0 +1,51 @@ +export const ALLOWED_BOARD_COLORS = [ + 'belize', + 'nephritis', + 'pomegranate', + 'pumpkin', + 'wisteria', + 'moderatepink', + 'strongcyan', + 'limegreen', + 'midnight', + 'dark', + 'relax', + 'corteza', + 'clearblue', + 'natural', + 'modern', + 'moderndark', +]; +export const ALLOWED_COLORS = [ + 'white', + 'green', + 'yellow', + 'orange', + 'red', + 'purple', + 'blue', + 'sky', + 'lime', + 'pink', + 'black', + 'silver', + 'peachpuff', + 'crimson', + 'plum', + 'darkgreen', + 'slateblue', + 'magenta', + 'gold', + 'navy', + 'gray', + 'saddlebrown', + 'paleturquoise', + 'mistyrose', + 'indigo', +]; +export const TYPE_BOARD = 'board'; +export const TYPE_CARD = 'cardType-card'; +export const TYPE_LINKED_BOARD = 'cardType-linkedBoard'; +export const TYPE_LINKED_CARD = 'cardType-linkedCard'; +export const TYPE_TEMPLATE_BOARD = 'template-board'; +export const TYPE_TEMPLATE_CONTAINER = 'template-container'; diff --git a/config/query-classes.js b/config/query-classes.js index 3955bcd75..48c596617 100644 --- a/config/query-classes.js +++ b/config/query-classes.js @@ -2,7 +2,8 @@ import { OPERATOR_ASSIGNEE, OPERATOR_BOARD, OPERATOR_COMMENT, - OPERATOR_CREATED_AT, OPERATOR_CREATOR, + OPERATOR_CREATED_AT, + OPERATOR_CREATOR, OPERATOR_DUE, OPERATOR_HAS, OPERATOR_LABEL, diff --git a/models/boards.js b/models/boards.js index 40435bfca..b54957fb9 100644 --- a/models/boards.js +++ b/models/boards.js @@ -1,3 +1,11 @@ +import { + ALLOWED_BOARD_COLORS, + ALLOWED_COLORS, + TYPE_BOARD, + TYPE_TEMPLATE_BOARD, + TYPE_TEMPLATE_CONTAINER, +} from '../config/const'; + const escapeForRegex = require('escape-string-regexp'); Boards = new Mongo.Collection('boards'); @@ -144,32 +152,7 @@ Boards.attachSchema( * `saddlebrown`, `paleturquoise`, `mistyrose`, `indigo` */ type: String, - allowedValues: [ - 'green', - 'yellow', - 'orange', - 'red', - 'purple', - 'blue', - 'sky', - 'lime', - 'pink', - 'black', - 'silver', - 'peachpuff', - 'crimson', - 'plum', - 'darkgreen', - 'slateblue', - 'magenta', - 'gold', - 'navy', - 'gray', - 'saddlebrown', - 'paleturquoise', - 'mistyrose', - 'indigo', - ], + allowedValues: ALLOWED_COLORS, }, // XXX We might want to maintain more informations under the member sub- // documents like de-normalized meta-data (the date the member joined the @@ -246,28 +229,11 @@ Boards.attachSchema( * The color of the board. */ type: String, - allowedValues: [ - 'belize', - 'nephritis', - 'pomegranate', - 'pumpkin', - 'wisteria', - 'moderatepink', - 'strongcyan', - 'limegreen', - 'midnight', - 'dark', - 'relax', - 'corteza', - 'clearblue', - 'natural', - 'modern', - 'moderndark', - ], + allowedValues: ALLOWED_BOARD_COLORS, // eslint-disable-next-line consistent-return autoValue() { if (this.isInsert && !this.isSet) { - return Boards.simpleSchema()._schema.color.allowedValues[0]; + return ALLOWED_BOARD_COLORS[0]; } }, }, @@ -508,7 +474,8 @@ Boards.attachSchema( * possible values: board, template-board, template-container */ type: String, - defaultValue: 'board', + defaultValue: TYPE_BOARD, + allowedValues: [TYPE_BOARD, TYPE_TEMPLATE_BOARD, TYPE_TEMPLATE_CONTAINER], }, sort: { /** diff --git a/models/cards.js b/models/cards.js index 71f0e343d..192fa2e3a 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1,3 +1,10 @@ +import { + ALLOWED_COLORS, + TYPE_CARD, + TYPE_LINKED_BOARD, + TYPE_LINKED_CARD, +} from '../config/const'; + Cards = new Mongo.Collection('cards'); // XXX To improve pub/sub performances a card document should include a @@ -77,33 +84,7 @@ Cards.attachSchema( color: { type: String, optional: true, - allowedValues: [ - 'white', - 'green', - 'yellow', - 'orange', - 'red', - 'purple', - 'blue', - 'sky', - 'lime', - 'pink', - 'black', - 'silver', - 'peachpuff', - 'crimson', - 'plum', - 'darkgreen', - 'slateblue', - 'magenta', - 'gold', - 'navy', - 'gray', - 'saddlebrown', - 'paleturquoise', - 'mistyrose', - 'indigo', - ], + allowedValues: ALLOWED_COLORS, }, createdAt: { /** @@ -299,10 +280,10 @@ Cards.attachSchema( type: { /** * type of the card - * possible values: cardType-card, cardType-linkedCard, cardType-linkedBoard */ type: String, - defaultValue: 'cardType-card', + defaultValue: TYPE_CARD, + allowedValues: [TYPE_CARD, TYPE_LINKED_CARD, TYPE_LINKED_BOARD], }, linkedId: { /** diff --git a/server/publications/cards.js b/server/publications/cards.js index c8c2497f7..38395851c 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -102,7 +102,7 @@ function buildSelector(queryParams) { let selector = {}; // eslint-disable-next-line no-console - // console.log('queryParams:', queryParams); + console.log('queryParams:', queryParams); if (queryParams.selector) { selector = queryParams.selector; @@ -291,9 +291,8 @@ function buildSelector(queryParams) { }); if (queryParams.hasOperator(OPERATOR_LABEL)) { + const queryLabels = []; queryParams.getPredicates(OPERATOR_LABEL).forEach(label => { - const queryLabels = []; - let boards = Boards.userBoards(userId, null, { labels: { $elemMatch: { color: label.toLowerCase() } }, }); @@ -339,9 +338,12 @@ function buildSelector(queryParams) { errors.addNotFound(OPERATOR_LABEL, label); } } - - selector.labelIds = { $in: _.uniq(queryLabels) }; }); + if (queryLabels.length) { + // eslint-disable-next-line no-console + // console.log('queryLabels:', queryLabels); + selector.labelIds = { $in: _.uniq(queryLabels) }; + } } if (queryParams.hasOperator(OPERATOR_HAS)) { @@ -597,9 +599,9 @@ function findCards(sessionId, query) { // eslint-disable-next-line no-console // console.log('projection:', projection); let cards; - if (!query.hasErrors()) { - cards = Cards.find(query.selector, query.projection); - } + // if (!query.hasErrors()) { + cards = Cards.find(query.selector, query.projection); + // } // eslint-disable-next-line no-console // console.log('count:', cards.count()); From ed6c6e5a2576ffd3e6137849e9e0214b18d4b514 Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Sat, 3 Apr 2021 18:52:47 +0200 Subject: [PATCH 6/6] Use new colors constants --- models/boards.js | 4 ++-- models/lists.js | 29 +++-------------------------- models/swimlanes.js | 29 +++-------------------------- 3 files changed, 8 insertions(+), 54 deletions(-) diff --git a/models/boards.js b/models/boards.js index b54957fb9..5ed06f4d1 100644 --- a/models/boards.js +++ b/models/boards.js @@ -4,7 +4,7 @@ import { TYPE_BOARD, TYPE_TEMPLATE_BOARD, TYPE_TEMPLATE_CONTAINER, -} from '../config/const'; +} from '/config/const'; const escapeForRegex = require('escape-string-regexp'); Boards = new Mongo.Collection('boards'); @@ -1324,7 +1324,7 @@ Boards.colorMap = () => { }; Boards.labelColors = () => { - return _.clone(Boards.simpleSchema()._schema['labels.$.color'].allowedValues); + return ALLOWED_COLORS; }; if (Meteor.isServer) { diff --git a/models/lists.js b/models/lists.js index 49cda140b..29f71eb01 100644 --- a/models/lists.js +++ b/models/lists.js @@ -1,3 +1,5 @@ +import { ALLOWED_COLORS } from '/config/const'; + Lists = new Mongo.Collection('lists'); /** @@ -144,32 +146,7 @@ Lists.attachSchema( type: String, optional: true, // silver is the default, so it is left out - allowedValues: [ - 'white', - 'green', - 'yellow', - 'orange', - 'red', - 'purple', - 'blue', - 'sky', - 'lime', - 'pink', - 'black', - 'peachpuff', - 'crimson', - 'plum', - 'darkgreen', - 'slateblue', - 'magenta', - 'gold', - 'navy', - 'gray', - 'saddlebrown', - 'paleturquoise', - 'mistyrose', - 'indigo', - ], + allowedValues: ALLOWED_COLORS, }, type: { /** diff --git a/models/swimlanes.js b/models/swimlanes.js index 8cb0c8e9c..1c803cdc9 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -1,3 +1,5 @@ +import { ALLOWED_COLORS } from '/config/const'; + Swimlanes = new Mongo.Collection('swimlanes'); /** @@ -68,32 +70,7 @@ Swimlanes.attachSchema( type: String, optional: true, // silver is the default, so it is left out - allowedValues: [ - 'white', - 'green', - 'yellow', - 'orange', - 'red', - 'purple', - 'blue', - 'sky', - 'lime', - 'pink', - 'black', - 'peachpuff', - 'crimson', - 'plum', - 'darkgreen', - 'slateblue', - 'magenta', - 'gold', - 'navy', - 'gray', - 'saddlebrown', - 'paleturquoise', - 'mistyrose', - 'indigo', - ], + allowedValues: ALLOWED_COLORS, }, updatedAt: { /**