mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
* Fix bug with multiple label predicates
* Add new constants
This commit is contained in:
parent
69dc8f304c
commit
302ba75729
7 changed files with 88 additions and 87 deletions
|
@ -50,8 +50,7 @@ template(name="globalSearch")
|
||||||
each msg in errorMessages
|
each msg in errorMessages
|
||||||
li.global-search-error-messages
|
li.global-search-error-messages
|
||||||
= msg
|
= msg
|
||||||
else
|
+resultsPaged(this)
|
||||||
+resultsPaged(this)
|
|
||||||
else if serverError.get
|
else if serverError.get
|
||||||
.global-search-page
|
.global-search-page
|
||||||
.global-search-help
|
.global-search-help
|
||||||
|
|
|
@ -72,7 +72,7 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
||||||
if (this.queryErrors.length) {
|
if (this.queryErrors.length) {
|
||||||
// console.log('queryErrors:', this.queryErrorMessages());
|
// console.log('queryErrors:', this.queryErrorMessages());
|
||||||
this.hasQueryErrors.set(true);
|
this.hasQueryErrors.set(true);
|
||||||
return null;
|
// return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cards) {
|
if (cards) {
|
||||||
|
|
51
config/const.js
Normal file
51
config/const.js
Normal 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';
|
|
@ -2,7 +2,8 @@ import {
|
||||||
OPERATOR_ASSIGNEE,
|
OPERATOR_ASSIGNEE,
|
||||||
OPERATOR_BOARD,
|
OPERATOR_BOARD,
|
||||||
OPERATOR_COMMENT,
|
OPERATOR_COMMENT,
|
||||||
OPERATOR_CREATED_AT, OPERATOR_CREATOR,
|
OPERATOR_CREATED_AT,
|
||||||
|
OPERATOR_CREATOR,
|
||||||
OPERATOR_DUE,
|
OPERATOR_DUE,
|
||||||
OPERATOR_HAS,
|
OPERATOR_HAS,
|
||||||
OPERATOR_LABEL,
|
OPERATOR_LABEL,
|
||||||
|
|
|
@ -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');
|
const escapeForRegex = require('escape-string-regexp');
|
||||||
Boards = new Mongo.Collection('boards');
|
Boards = new Mongo.Collection('boards');
|
||||||
|
|
||||||
|
@ -144,32 +152,7 @@ Boards.attachSchema(
|
||||||
* `saddlebrown`, `paleturquoise`, `mistyrose`, `indigo`
|
* `saddlebrown`, `paleturquoise`, `mistyrose`, `indigo`
|
||||||
*/
|
*/
|
||||||
type: String,
|
type: String,
|
||||||
allowedValues: [
|
allowedValues: ALLOWED_COLORS,
|
||||||
'green',
|
|
||||||
'yellow',
|
|
||||||
'orange',
|
|
||||||
'red',
|
|
||||||
'purple',
|
|
||||||
'blue',
|
|
||||||
'sky',
|
|
||||||
'lime',
|
|
||||||
'pink',
|
|
||||||
'black',
|
|
||||||
'silver',
|
|
||||||
'peachpuff',
|
|
||||||
'crimson',
|
|
||||||
'plum',
|
|
||||||
'darkgreen',
|
|
||||||
'slateblue',
|
|
||||||
'magenta',
|
|
||||||
'gold',
|
|
||||||
'navy',
|
|
||||||
'gray',
|
|
||||||
'saddlebrown',
|
|
||||||
'paleturquoise',
|
|
||||||
'mistyrose',
|
|
||||||
'indigo',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
// XXX We might want to maintain more informations under the member sub-
|
// XXX We might want to maintain more informations under the member sub-
|
||||||
// documents like de-normalized meta-data (the date the member joined the
|
// documents like de-normalized meta-data (the date the member joined the
|
||||||
|
@ -246,28 +229,11 @@ Boards.attachSchema(
|
||||||
* The color of the board.
|
* The color of the board.
|
||||||
*/
|
*/
|
||||||
type: String,
|
type: String,
|
||||||
allowedValues: [
|
allowedValues: ALLOWED_BOARD_COLORS,
|
||||||
'belize',
|
|
||||||
'nephritis',
|
|
||||||
'pomegranate',
|
|
||||||
'pumpkin',
|
|
||||||
'wisteria',
|
|
||||||
'moderatepink',
|
|
||||||
'strongcyan',
|
|
||||||
'limegreen',
|
|
||||||
'midnight',
|
|
||||||
'dark',
|
|
||||||
'relax',
|
|
||||||
'corteza',
|
|
||||||
'clearblue',
|
|
||||||
'natural',
|
|
||||||
'modern',
|
|
||||||
'moderndark',
|
|
||||||
],
|
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
autoValue() {
|
autoValue() {
|
||||||
if (this.isInsert && !this.isSet) {
|
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
|
* possible values: board, template-board, template-container
|
||||||
*/
|
*/
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'board',
|
defaultValue: TYPE_BOARD,
|
||||||
|
allowedValues: [TYPE_BOARD, TYPE_TEMPLATE_BOARD, TYPE_TEMPLATE_CONTAINER],
|
||||||
},
|
},
|
||||||
sort: {
|
sort: {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
import {
|
||||||
|
ALLOWED_COLORS,
|
||||||
|
TYPE_CARD,
|
||||||
|
TYPE_LINKED_BOARD,
|
||||||
|
TYPE_LINKED_CARD,
|
||||||
|
} from '../config/const';
|
||||||
|
|
||||||
Cards = new Mongo.Collection('cards');
|
Cards = new Mongo.Collection('cards');
|
||||||
|
|
||||||
// XXX To improve pub/sub performances a card document should include a
|
// XXX To improve pub/sub performances a card document should include a
|
||||||
|
@ -77,33 +84,7 @@ Cards.attachSchema(
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
allowedValues: [
|
allowedValues: 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',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
/**
|
/**
|
||||||
|
@ -299,10 +280,10 @@ Cards.attachSchema(
|
||||||
type: {
|
type: {
|
||||||
/**
|
/**
|
||||||
* type of the card
|
* type of the card
|
||||||
* possible values: cardType-card, cardType-linkedCard, cardType-linkedBoard
|
|
||||||
*/
|
*/
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'cardType-card',
|
defaultValue: TYPE_CARD,
|
||||||
|
allowedValues: [TYPE_CARD, TYPE_LINKED_CARD, TYPE_LINKED_BOARD],
|
||||||
},
|
},
|
||||||
linkedId: {
|
linkedId: {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -102,7 +102,7 @@ function buildSelector(queryParams) {
|
||||||
let selector = {};
|
let selector = {};
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('queryParams:', queryParams);
|
console.log('queryParams:', queryParams);
|
||||||
|
|
||||||
if (queryParams.selector) {
|
if (queryParams.selector) {
|
||||||
selector = queryParams.selector;
|
selector = queryParams.selector;
|
||||||
|
@ -291,9 +291,8 @@ function buildSelector(queryParams) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (queryParams.hasOperator(OPERATOR_LABEL)) {
|
if (queryParams.hasOperator(OPERATOR_LABEL)) {
|
||||||
|
const queryLabels = [];
|
||||||
queryParams.getPredicates(OPERATOR_LABEL).forEach(label => {
|
queryParams.getPredicates(OPERATOR_LABEL).forEach(label => {
|
||||||
const queryLabels = [];
|
|
||||||
|
|
||||||
let boards = Boards.userBoards(userId, null, {
|
let boards = Boards.userBoards(userId, null, {
|
||||||
labels: { $elemMatch: { color: label.toLowerCase() } },
|
labels: { $elemMatch: { color: label.toLowerCase() } },
|
||||||
});
|
});
|
||||||
|
@ -339,9 +338,12 @@ function buildSelector(queryParams) {
|
||||||
errors.addNotFound(OPERATOR_LABEL, label);
|
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)) {
|
if (queryParams.hasOperator(OPERATOR_HAS)) {
|
||||||
|
@ -597,9 +599,9 @@ function findCards(sessionId, query) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('projection:', projection);
|
// console.log('projection:', projection);
|
||||||
let cards;
|
let cards;
|
||||||
if (!query.hasErrors()) {
|
// if (!query.hasErrors()) {
|
||||||
cards = Cards.find(query.selector, query.projection);
|
cards = Cards.find(query.selector, query.projection);
|
||||||
}
|
// }
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('count:', cards.count());
|
// console.log('count:', cards.count());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue