Add support for clicking label names and board titles

This commit is contained in:
John R. Supplee 2021-01-21 01:48:24 +02:00
parent 52f920db12
commit 61c691a267
4 changed files with 82 additions and 11 deletions

View file

@ -32,15 +32,28 @@ template(name="globalSearch")
+resultCard(card)
else
.global-search-instructions
h2 Label Colors
.palette-colors: each label in labelColors
span.card-label.palette-color.js-palette-color(class="card-label-{{label.color}}")
= label.name
h2 Boards
.lists-wrapper
each title in myBoardNames.get
span.card-label.list-title.js-board-title
= title
h2 Lists
.lists-wrapper
each title in myLists.get
span.card-label.list-title.js-list-title
= title
h2 Label Colors
.palette-colors: each label in labelColors
span.card-label.palette-color.js-label-color(class="card-label-{{label.color}}")
= label.name
if myLabelNames.get.length
h2 Label Names
.lists-wrapper
each name in myLabelNames.get
span.card-label.list-title.js-label-name
= name
+viewer
= searchInstructions
template(name="globalSearchViewChangePopup")
if currentUser

View file

@ -43,6 +43,8 @@ BlazeComponent.extendComponent({
this.resultsHeading = new ReactiveVar('');
this.searchLink = new ReactiveVar(null);
this.myLists = new ReactiveVar([]);
this.myLabelNames = new ReactiveVar([]);
this.myBoardNames = new ReactiveVar([]);
this.queryParams = null;
this.parsingErrors = [];
this.resultsCount = 0;
@ -63,6 +65,18 @@ BlazeComponent.extendComponent({
}
});
Meteor.call('myLabelNames', (err, data) => {
if (!err) {
this.myLabelNames.set(data);
}
});
Meteor.call('myBoardNames', (err, data) => {
if (!err) {
this.myBoardNames.set(data);
}
});
Meteor.subscribe('setting');
if (Session.get('globalQuery')) {
this.searchAllBoards(Session.get('globalQuery'));
@ -119,11 +133,13 @@ BlazeComponent.extendComponent({
messages.push({ tag: 'list-title-not-found', value: list });
});
this.queryErrors.notFound.labels.forEach(label => {
const color = TAPi18n.__(`color-${label}`);
if (color) {
const color = Object.entries(this.colorMap)
.filter(value => value[1] === label)
.map(value => value[0]);
if (color.length) {
messages.push({
tag: 'label-color-not-found',
value: color,
value: color[0],
});
} else {
messages.push({ tag: 'label-not-found', value: label });
@ -378,14 +394,36 @@ BlazeComponent.extendComponent({
evt.preventDefault();
this.searchAllBoards(evt.target.searchQuery.value);
},
'click .js-palette-color'(evt) {
'click .js-label-color'(evt) {
evt.preventDefault();
this.query.set(
`${this.query.get()} label:"${evt.currentTarget.textContent}"`,
`${this.query.get()} ${TAPi18n.__('operator-label')}:"${
evt.currentTarget.textContent
}"`,
);
},
'click .js-board-title'(evt) {
evt.preventDefault();
this.query.set(
`${this.query.get()} ${TAPi18n.__('operator-board')}:"${
evt.currentTarget.textContent
}"`,
);
},
'click .js-list-title'(evt) {
evt.preventDefault();
this.query.set(
`${this.query.get()} list:"${evt.currentTarget.textContent}"`,
`${this.query.get()} ${TAPi18n.__('operator-list')}:"${
evt.currentTarget.textContent
}"`,
);
},
'click .js-label-name'(evt) {
evt.preventDefault();
this.query.set(
`${this.query.get()} ${TAPi18n.__('operator-label')}:"${
evt.currentTarget.textContent
}"`,
);
},
},

View file

@ -1324,6 +1324,26 @@ if (Meteor.isServer) {
},
});
},
myLabelNames() {
let names = [];
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() {
return _.uniq(
Boards.userBoards(Meteor.userId()).map(board => {
return board.title;
}),
).sort();
},
});
Meteor.methods({

View file

@ -374,7 +374,7 @@ Meteor.methods({
.map(list => {
return list.title;
}),
);
).sort();
},
});