mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Merge pull request #3459 from jrsupplee/new-search
Search All Boards: Added list of board, list and color names.
This commit is contained in:
commit
1df060b8f6
7 changed files with 198 additions and 9 deletions
|
|
@ -14,7 +14,14 @@ template(name="globalSearch")
|
|||
if currentUser
|
||||
.wrapper
|
||||
form.global-search-instructions.js-search-query-form
|
||||
input.global-search-query-input(type="text" name="searchQuery" placeholder="{{_ 'search-example'}}" value="{{ query.get }}" autofocus dir="auto")
|
||||
input.global-search-query-input(
|
||||
id="global-search-input"
|
||||
type="text"
|
||||
name="searchQuery"
|
||||
placeholder="{{_ 'search-example'}}"
|
||||
value="{{ query.get }}"
|
||||
autofocus dir="auto"
|
||||
)
|
||||
if searching.get
|
||||
+spinner
|
||||
else if hasResults.get
|
||||
|
|
@ -32,6 +39,26 @@ template(name="globalSearch")
|
|||
+resultCard(card)
|
||||
else
|
||||
.global-search-instructions
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ BlazeComponent.extendComponent({
|
|||
this.query = new ReactiveVar('');
|
||||
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;
|
||||
|
|
@ -55,6 +58,25 @@ BlazeComponent.extendComponent({
|
|||
// }
|
||||
// // eslint-disable-next-line no-console
|
||||
// console.log('colorMap:', this.colorMap);
|
||||
|
||||
Meteor.call('myLists', (err, data) => {
|
||||
if (!err) {
|
||||
this.myLists.set(data);
|
||||
}
|
||||
});
|
||||
|
||||
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'));
|
||||
|
|
@ -111,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 });
|
||||
|
|
@ -185,9 +209,12 @@ BlazeComponent.extendComponent({
|
|||
operatorMap[TAPi18n.__('operator-assignee')] = 'assignees';
|
||||
operatorMap[TAPi18n.__('operator-assignee-abbrev')] = 'assignees';
|
||||
operatorMap[TAPi18n.__('operator-is')] = 'is';
|
||||
operatorMap[TAPi18n.__('operator-due')] = 'dueAt';
|
||||
operatorMap[TAPi18n.__('operator-created')] = 'createdAt';
|
||||
operatorMap[TAPi18n.__('operator-modified')] = 'modifiedAt';
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('operatorMap:', operatorMap);
|
||||
console.log('operatorMap:', operatorMap);
|
||||
const params = {
|
||||
boards: [],
|
||||
swimlanes: [],
|
||||
|
|
@ -197,6 +224,9 @@ BlazeComponent.extendComponent({
|
|||
assignees: [],
|
||||
labels: [],
|
||||
is: [],
|
||||
dueAt: null,
|
||||
createdAt: null,
|
||||
modifiedAt: null,
|
||||
};
|
||||
|
||||
let text = '';
|
||||
|
|
@ -223,8 +253,33 @@ BlazeComponent.extendComponent({
|
|||
if (value in this.colorMap) {
|
||||
value = this.colorMap[value];
|
||||
}
|
||||
} else if (
|
||||
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
|
||||
) {
|
||||
const days = parseInt(value, 10);
|
||||
if (isNaN(days)) {
|
||||
if (['day', 'week', 'month', 'quarter', 'year'].includes(value)) {
|
||||
value = moment()
|
||||
.subtract(1, value)
|
||||
.format();
|
||||
} else {
|
||||
this.parsingErrors.push({
|
||||
tag: 'operator-number-expected',
|
||||
value: { operator: op, value },
|
||||
});
|
||||
value = null;
|
||||
}
|
||||
} else {
|
||||
value = moment()
|
||||
.subtract(days, 'days')
|
||||
.format();
|
||||
}
|
||||
}
|
||||
if (Array.isArray(params[operatorMap[op]])) {
|
||||
params[operatorMap[op]].push(value);
|
||||
} else {
|
||||
params[operatorMap[op]] = value;
|
||||
}
|
||||
params[operatorMap[op]].push(value);
|
||||
} else {
|
||||
this.parsingErrors.push({
|
||||
tag: 'operator-unknown-error',
|
||||
|
|
@ -355,6 +410,14 @@ BlazeComponent.extendComponent({
|
|||
return text;
|
||||
},
|
||||
|
||||
labelColors() {
|
||||
return Boards.simpleSchema()._schema['labels.$.color'].allowedValues.map(
|
||||
color => {
|
||||
return { color, name: TAPi18n.__(`color-${color}`) };
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
|
|
@ -362,6 +425,42 @@ BlazeComponent.extendComponent({
|
|||
evt.preventDefault();
|
||||
this.searchAllBoards(evt.target.searchQuery.value);
|
||||
},
|
||||
'click .js-label-color'(evt) {
|
||||
evt.preventDefault();
|
||||
this.query.set(
|
||||
`${this.query.get()} ${TAPi18n.__('operator-label')}:"${
|
||||
evt.currentTarget.textContent
|
||||
}"`,
|
||||
);
|
||||
document.getElementById('global-search-input').focus();
|
||||
},
|
||||
'click .js-board-title'(evt) {
|
||||
evt.preventDefault();
|
||||
this.query.set(
|
||||
`${this.query.get()} ${TAPi18n.__('operator-board')}:"${
|
||||
evt.currentTarget.textContent
|
||||
}"`,
|
||||
);
|
||||
document.getElementById('global-search-input').focus();
|
||||
},
|
||||
'click .js-list-title'(evt) {
|
||||
evt.preventDefault();
|
||||
this.query.set(
|
||||
`${this.query.get()} ${TAPi18n.__('operator-list')}:"${
|
||||
evt.currentTarget.textContent
|
||||
}"`,
|
||||
);
|
||||
document.getElementById('global-search-input').focus();
|
||||
},
|
||||
'click .js-label-name'(evt) {
|
||||
evt.preventDefault();
|
||||
this.query.set(
|
||||
`${this.query.get()} ${TAPi18n.__('operator-label')}:"${
|
||||
evt.currentTarget.textContent
|
||||
}"`,
|
||||
);
|
||||
document.getElementById('global-search-input').focus();
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
|
|
|
|||
|
|
@ -78,6 +78,12 @@
|
|||
margin-left: auto
|
||||
line-height: 150%
|
||||
|
||||
.global-search-instructions h1
|
||||
margin-top: 2rem;
|
||||
|
||||
.global-search-instructions h2
|
||||
margin-top: 1rem;
|
||||
|
||||
.global-search-query-input
|
||||
width: 90% !important
|
||||
margin-right: auto
|
||||
|
|
@ -95,3 +101,6 @@ code
|
|||
background-color: lightgrey
|
||||
padding: 0.1rem !important
|
||||
font-size: 0.7rem !important
|
||||
|
||||
.list-title
|
||||
background-color: darkgray
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue