mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Global search fixes
* Fix error with infinite loop if whitespace on front of query * Translate color to user's language if not found
This commit is contained in:
parent
f0c9740c13
commit
5553277a1e
2 changed files with 44 additions and 32 deletions
|
|
@ -47,6 +47,14 @@ BlazeComponent.extendComponent({
|
||||||
this.resultsCount = 0;
|
this.resultsCount = 0;
|
||||||
this.totalHits = 0;
|
this.totalHits = 0;
|
||||||
this.queryErrors = null;
|
this.queryErrors = null;
|
||||||
|
this.colorMap = null;
|
||||||
|
// this.colorMap = {};
|
||||||
|
// for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
||||||
|
// .allowedValues) {
|
||||||
|
// this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
||||||
|
// }
|
||||||
|
// // eslint-disable-next-line no-console
|
||||||
|
// console.log('colorMap:', this.colorMap);
|
||||||
Meteor.subscribe('setting');
|
Meteor.subscribe('setting');
|
||||||
if (Session.get('globalQuery')) {
|
if (Session.get('globalQuery')) {
|
||||||
this.searchAllBoards(Session.get('globalQuery'));
|
this.searchAllBoards(Session.get('globalQuery'));
|
||||||
|
|
@ -103,7 +111,15 @@ BlazeComponent.extendComponent({
|
||||||
messages.push({ tag: 'list-title-not-found', value: list });
|
messages.push({ tag: 'list-title-not-found', value: list });
|
||||||
});
|
});
|
||||||
this.queryErrors.notFound.labels.forEach(label => {
|
this.queryErrors.notFound.labels.forEach(label => {
|
||||||
|
const color = TAPi18n.__(`color-${label}`);
|
||||||
|
if (color) {
|
||||||
|
messages.push({
|
||||||
|
tag: 'label-color-not-found',
|
||||||
|
value: color,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
messages.push({ tag: 'label-not-found', value: label });
|
messages.push({ tag: 'label-not-found', value: label });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.queryErrors.notFound.users.forEach(user => {
|
this.queryErrors.notFound.users.forEach(user => {
|
||||||
messages.push({ tag: 'user-username-not-found', value: user });
|
messages.push({ tag: 'user-username-not-found', value: user });
|
||||||
|
|
@ -126,6 +142,7 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
searchAllBoards(query) {
|
searchAllBoards(query) {
|
||||||
|
query = query.trim();
|
||||||
this.query.set(query);
|
this.query.set(query);
|
||||||
|
|
||||||
this.resetSearch();
|
this.resetSearch();
|
||||||
|
|
@ -134,43 +151,24 @@ BlazeComponent.extendComponent({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.searching.set(true);
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('query:', query);
|
// console.log('query:', query);
|
||||||
|
|
||||||
|
this.searching.set(true);
|
||||||
|
|
||||||
|
if (!this.colorMap) {
|
||||||
|
this.colorMap = {};
|
||||||
|
for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
||||||
|
.allowedValues) {
|
||||||
|
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const reOperator1 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<value>\w+)(\s+|$)/;
|
const reOperator1 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<value>\w+)(\s+|$)/;
|
||||||
const reOperator2 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
const reOperator2 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
|
||||||
const reText = /^(?<text>\S+)(\s+|$)/;
|
const reText = /^(?<text>\S+)(\s+|$)/;
|
||||||
const reQuotedText = /^(?<quote>["'])(?<text>\w+)\k<quote>(\s+|$)/;
|
const reQuotedText = /^(?<quote>["'])(?<text>\w+)\k<quote>(\s+|$)/;
|
||||||
|
|
||||||
const colorMap = {};
|
|
||||||
colorMap[TAPi18n.__('color-black')] = 'black';
|
|
||||||
colorMap[TAPi18n.__('color-blue')] = 'blue';
|
|
||||||
colorMap[TAPi18n.__('color-crimson')] = 'crimson';
|
|
||||||
colorMap[TAPi18n.__('color-darkgreen')] = 'darkgreen';
|
|
||||||
colorMap[TAPi18n.__('color-gold')] = 'gold';
|
|
||||||
colorMap[TAPi18n.__('color-gray')] = 'gray';
|
|
||||||
colorMap[TAPi18n.__('color-green')] = 'green';
|
|
||||||
colorMap[TAPi18n.__('color-indigo')] = 'indigo';
|
|
||||||
colorMap[TAPi18n.__('color-lime')] = 'lime';
|
|
||||||
colorMap[TAPi18n.__('color-magenta')] = 'magenta';
|
|
||||||
colorMap[TAPi18n.__('color-mistyrose')] = 'mistyrose';
|
|
||||||
colorMap[TAPi18n.__('color-navy')] = 'navy';
|
|
||||||
colorMap[TAPi18n.__('color-orange')] = 'orange';
|
|
||||||
colorMap[TAPi18n.__('color-paleturquoise')] = 'paleturquoise';
|
|
||||||
colorMap[TAPi18n.__('color-peachpuff')] = 'peachpuff';
|
|
||||||
colorMap[TAPi18n.__('color-pink')] = 'pink';
|
|
||||||
colorMap[TAPi18n.__('color-plum')] = 'plum';
|
|
||||||
colorMap[TAPi18n.__('color-purple')] = 'purple';
|
|
||||||
colorMap[TAPi18n.__('color-red')] = 'red';
|
|
||||||
colorMap[TAPi18n.__('color-saddlebrown')] = 'saddlebrown';
|
|
||||||
colorMap[TAPi18n.__('color-silver')] = 'silver';
|
|
||||||
colorMap[TAPi18n.__('color-sky')] = 'sky';
|
|
||||||
colorMap[TAPi18n.__('color-slateblue')] = 'slateblue';
|
|
||||||
colorMap[TAPi18n.__('color-white')] = 'white';
|
|
||||||
colorMap[TAPi18n.__('color-yellow')] = 'yellow';
|
|
||||||
|
|
||||||
const operatorMap = {};
|
const operatorMap = {};
|
||||||
operatorMap[TAPi18n.__('operator-board')] = 'boards';
|
operatorMap[TAPi18n.__('operator-board')] = 'boards';
|
||||||
operatorMap[TAPi18n.__('operator-board-abbrev')] = 'boards';
|
operatorMap[TAPi18n.__('operator-board-abbrev')] = 'boards';
|
||||||
|
|
@ -222,8 +220,8 @@ BlazeComponent.extendComponent({
|
||||||
if (op in operatorMap) {
|
if (op in operatorMap) {
|
||||||
let value = m.groups.value;
|
let value = m.groups.value;
|
||||||
if (operatorMap[op] === 'labels') {
|
if (operatorMap[op] === 'labels') {
|
||||||
if (value in colorMap) {
|
if (value in this.colorMap) {
|
||||||
value = colorMap[value];
|
value = this.colorMap[value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params[operatorMap[op]].push(value);
|
params[operatorMap[op]].push(value);
|
||||||
|
|
@ -357,6 +355,14 @@ BlazeComponent.extendComponent({
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
labelColors() {
|
||||||
|
return Boards.simpleSchema()._schema['labels.$.color'].allowedValues.map(
|
||||||
|
color => {
|
||||||
|
return { color, name: TAPi18n.__(`color-${color}`) };
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|
@ -364,6 +370,11 @@ BlazeComponent.extendComponent({
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
this.searchAllBoards(evt.target.searchQuery.value);
|
this.searchAllBoards(evt.target.searchQuery.value);
|
||||||
},
|
},
|
||||||
|
'click .js-palette-color'(evt) {
|
||||||
|
this.query.set(
|
||||||
|
`${this.query.get()} label:"${evt.currentTarget.textContent}"`,
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -873,6 +873,7 @@
|
||||||
"swimlane-title-not-found": "Swimlane '%s' not found.",
|
"swimlane-title-not-found": "Swimlane '%s' not found.",
|
||||||
"list-title-not-found": "List '%s' not found.",
|
"list-title-not-found": "List '%s' not found.",
|
||||||
"label-not-found": "Label '%s' not found.",
|
"label-not-found": "Label '%s' not found.",
|
||||||
|
"label-color-not-found": "Label color %s not found.",
|
||||||
"user-username-not-found": "Username '%s' not found.",
|
"user-username-not-found": "Username '%s' not found.",
|
||||||
"globalSearch-title": "Search All Boards",
|
"globalSearch-title": "Search All Boards",
|
||||||
"no-cards-found": "No Cards Found",
|
"no-cards-found": "No Cards Found",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue