Merge pull request #3450 from jrsupplee/search

Global search fixes
This commit is contained in:
Lauri Ojansivu 2021-01-20 17:59:10 +02:00 committed by GitHub
commit 484276b80d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 151 deletions

View file

@ -26,27 +26,7 @@ template(name="dueCards")
.wrapper
.due-cards-dueat-list-wrapper
each card in dueCardsList
.due-cards-card-wrapper
a.minicard-wrapper.card-title(href=card.absoluteUrl)
+minicard(card)
ul.due-cards-context-list
li.due-cards-context(title="{{_ 'board'}}")
+viewer
= card.getBoard.title
li.due-cards-context.due-cards-context-separator
= ' '
| {{_ 'context-separator'}}
= ' '
li.due-cards-context(title="{{_ 'swimlane'}}")
+viewer
= card.getSwimlane.title
li.due-cards-context
= ' '
| {{_ 'context-separator'}}
= ' '
li.due-cards-context(title="{{_ 'list'}}")
+viewer
= card.getList.title
+resultCard(card)
else
+spinner

View file

@ -1,69 +1,4 @@
.due-cards-board-wrapper
border-radius: 8px
//padding: 0.5rem
min-width: 400px
border-width: 8px
border-color: grey
border-style: solid
margin-bottom: 2rem
margin-right: auto
margin-left: auto
.due-cards-board-title
font-size: 1.4rem
font-weight: bold
padding: 0.5rem
background-color: grey
color: white
.due-cards-swimlane-title
font-size: 1.1rem
font-weight: bold
padding: 0.5rem
padding-bottom: 0.4rem
margin-top: 0
margin-bottom: 0.5rem
//border-top: black 1px solid
//border-bottom: black 1px solid
text-align: center
.swimlane-default-color
background-color: lightgrey
.due-cards-list-title
font-weight: bold
font-size: 1.1rem
//padding-bottom: 0
//margin-bottom: 0
text-align: center
margin-bottom: 0.7rem
.due-cards-list-wrapper
margin: 1rem
border-radius: 5px
padding: 1.5rem
padding-top: 0.75rem
display: inline-block
min-width: 250px
max-width: 350px
.due-cards-card-wrapper
margin-top: 0
margin-bottom: 10px
.due-cards-dueat-list-wrapper
max-width: 500px
margin-right: auto
margin-left: auto
.due-cards-field-name
font-weight: bold
.due-cards-context
display: inline-block
.due-cards-context-separator
font-weight: bold
.due-cards-context-list
margin-bottom: 0.7rem

View file

@ -47,6 +47,14 @@ BlazeComponent.extendComponent({
this.resultsCount = 0;
this.totalHits = 0;
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');
if (Session.get('globalQuery')) {
this.searchAllBoards(Session.get('globalQuery'));
@ -103,7 +111,15 @@ BlazeComponent.extendComponent({
messages.push({ tag: 'list-title-not-found', value: list });
});
this.queryErrors.notFound.labels.forEach(label => {
messages.push({ tag: 'label-not-found', value: 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 });
}
});
this.queryErrors.notFound.users.forEach(user => {
messages.push({ tag: 'user-username-not-found', value: user });
@ -126,6 +142,7 @@ BlazeComponent.extendComponent({
},
searchAllBoards(query) {
query = query.trim();
this.query.set(query);
this.resetSearch();
@ -134,43 +151,24 @@ BlazeComponent.extendComponent({
return;
}
this.searching.set(true);
// eslint-disable-next-line no-console
// 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 reOperator2 = /^((?<operator>\w+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/;
const reText = /^(?<text>\S+)(\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 = {};
operatorMap[TAPi18n.__('operator-board')] = 'boards';
operatorMap[TAPi18n.__('operator-board-abbrev')] = 'boards';
@ -222,8 +220,8 @@ BlazeComponent.extendComponent({
if (op in operatorMap) {
let value = m.groups.value;
if (operatorMap[op] === 'labels') {
if (value in colorMap) {
value = colorMap[value];
if (value in this.colorMap) {
value = this.colorMap[value];
}
}
params[operatorMap[op]].push(value);

View file

@ -48,27 +48,7 @@ template(name="myCards")
else
.my-cards-dueat-list-wrapper
each card in myDueCardsList
.my-cards-card-wrapper
a.minicard-wrapper.card-title(href=card.absoluteUrl)
+minicard(card)
ul.my-cards-context-list
li.my-cards-context(title="{{_ 'board'}}")
+viewer
= card.getBoard.title
li.my-cards-context.my-cards-context-separator
= ' '
| {{_ 'context-separator'}}
= ' '
li.my-cards-context(title="{{_ 'swimlane'}}")
+viewer
= card.getSwimlane.title
li.my-cards-context
= ' '
| {{_ 'context-separator'}}
= ' '
li.my-cards-context(title="{{_ 'list'}}")
+viewer
= card.getList.title
+resultCard(card)
else
+spinner

View file

@ -55,15 +55,3 @@
max-width: 500px
margin-right: auto
margin-left: auto
.my-cards-field-name
font-weight: bold
.my-cards-context
display: inline-block
.my-cards-context-separator
font-weight: bold
.my-cards-context-list
margin-bottom: 0.7rem

View file

@ -873,6 +873,7 @@
"swimlane-title-not-found": "Swimlane '%s' not found.",
"list-title-not-found": "List '%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.",
"globalSearch-title": "Search All Boards",
"no-cards-found": "No Cards Found",