* Fix bug with multiple label predicates

* Add new constants
This commit is contained in:
John R. Supplee 2021-04-03 01:19:02 +02:00
parent 69dc8f304c
commit 302ba75729
7 changed files with 88 additions and 87 deletions

View file

@ -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

View file

@ -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) {

51
config/const.js Normal file
View file

@ -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';

View file

@ -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,

View file

@ -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: {
/**

View file

@ -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: {
/**

View file

@ -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());