2021-01-10 21:52:25 +02:00
|
|
|
const subManager = new SubsManager();
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
|
|
|
events() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-due-cards-view-change': Popup.open('globalSearchViewChange'),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
}).register('globalSearchHeaderBar');
|
|
|
|
|
|
|
|
Template.globalSearch.helpers({
|
|
|
|
userId() {
|
|
|
|
return Meteor.userId();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
|
|
|
events() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-due-cards-view-me'() {
|
|
|
|
Utils.setDueCardsView('me');
|
|
|
|
Popup.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
'click .js-due-cards-view-all'() {
|
|
|
|
Utils.setDueCardsView('all');
|
|
|
|
Popup.close();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
}).register('globalSearchViewChangePopup');
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
|
|
|
onCreated() {
|
2021-01-10 22:58:29 +02:00
|
|
|
this.searching = new ReactiveVar(false);
|
|
|
|
this.hasResults = new ReactiveVar(false);
|
2021-01-17 16:01:42 +02:00
|
|
|
this.hasQueryErrors = new ReactiveVar(false);
|
2021-01-10 21:52:25 +02:00
|
|
|
this.query = new ReactiveVar('');
|
2021-01-17 16:01:42 +02:00
|
|
|
this.resultsHeading = new ReactiveVar('');
|
2021-01-17 21:04:05 +02:00
|
|
|
this.searchLink = new ReactiveVar(null);
|
2021-01-20 21:52:27 +02:00
|
|
|
this.myLists = new ReactiveVar([]);
|
2021-01-21 01:48:24 +02:00
|
|
|
this.myLabelNames = new ReactiveVar([]);
|
|
|
|
this.myBoardNames = new ReactiveVar([]);
|
2021-01-24 15:38:44 +02:00
|
|
|
this.results = new ReactiveVar([]);
|
2021-01-12 00:48:43 +02:00
|
|
|
this.queryParams = null;
|
2021-01-17 16:01:42 +02:00
|
|
|
this.parsingErrors = [];
|
|
|
|
this.resultsCount = 0;
|
|
|
|
this.totalHits = 0;
|
|
|
|
this.queryErrors = null;
|
2021-01-20 12:52:49 +02:00
|
|
|
this.colorMap = null;
|
2021-01-20 21:52:27 +02:00
|
|
|
|
|
|
|
Meteor.call('myLists', (err, data) => {
|
|
|
|
if (!err) {
|
|
|
|
this.myLists.set(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-01-21 01:48:24 +02:00
|
|
|
Meteor.call('myLabelNames', (err, data) => {
|
|
|
|
if (!err) {
|
|
|
|
this.myLabelNames.set(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Meteor.call('myBoardNames', (err, data) => {
|
|
|
|
if (!err) {
|
|
|
|
this.myBoardNames.set(data);
|
|
|
|
}
|
|
|
|
});
|
2021-01-25 00:07:50 +02:00
|
|
|
},
|
2021-01-21 01:48:24 +02:00
|
|
|
|
2021-01-25 00:07:50 +02:00
|
|
|
onRendered() {
|
2021-01-10 21:52:25 +02:00
|
|
|
Meteor.subscribe('setting');
|
2021-01-25 15:39:36 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
if (Session.get('globalQuery')) {
|
|
|
|
this.searchAllBoards(Session.get('globalQuery'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
resetSearch() {
|
|
|
|
this.searching.set(false);
|
2021-01-24 15:38:44 +02:00
|
|
|
this.results.set([]);
|
2021-01-17 16:01:42 +02:00
|
|
|
this.hasResults.set(false);
|
|
|
|
this.hasQueryErrors.set(false);
|
|
|
|
this.resultsHeading.set('');
|
|
|
|
this.parsingErrors = [];
|
|
|
|
this.resultsCount = 0;
|
|
|
|
this.totalHits = 0;
|
|
|
|
this.queryErrors = null;
|
2021-01-10 21:52:25 +02:00
|
|
|
},
|
|
|
|
|
2021-01-24 15:38:44 +02:00
|
|
|
getResults() {
|
2021-01-17 16:01:42 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2021-01-17 21:43:56 +02:00
|
|
|
// console.log('getting results');
|
2021-01-12 00:48:43 +02:00
|
|
|
if (this.queryParams) {
|
2021-01-24 12:28:36 +02:00
|
|
|
const sessionData = SessionData.findOne({
|
|
|
|
userId: Meteor.userId(),
|
|
|
|
sessionId: SessionData.getSessionId(),
|
|
|
|
});
|
2021-01-24 15:38:44 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2021-01-25 15:39:36 +02:00
|
|
|
// console.log('session data:', sessionData);
|
2021-01-24 15:38:44 +02:00
|
|
|
|
2021-01-24 02:32:37 +02:00
|
|
|
const cards = Cards.find({ _id: { $in: sessionData.cards } });
|
2021-01-25 15:39:36 +02:00
|
|
|
this.queryErrors = sessionData.errors;
|
2021-01-24 02:32:37 +02:00
|
|
|
if (this.queryErrors.length) {
|
2021-01-17 16:01:42 +02:00
|
|
|
this.hasQueryErrors.set(true);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-01-24 02:32:37 +02:00
|
|
|
if (cards) {
|
2021-01-17 16:01:42 +02:00
|
|
|
this.totalHits = sessionData.totalHits;
|
2021-01-24 02:32:37 +02:00
|
|
|
this.resultsCount = cards.count();
|
2021-01-17 16:01:42 +02:00
|
|
|
this.resultsHeading.set(this.getResultsHeading());
|
2021-01-24 15:38:44 +02:00
|
|
|
this.results.set(cards);
|
2021-01-17 16:01:42 +02:00
|
|
|
}
|
2021-01-12 00:48:43 +02:00
|
|
|
}
|
2021-01-17 16:01:42 +02:00
|
|
|
this.resultsCount = 0;
|
2021-01-24 15:38:44 +02:00
|
|
|
return null;
|
2021-01-10 22:58:29 +02:00
|
|
|
},
|
|
|
|
|
2021-01-13 01:14:49 +02:00
|
|
|
errorMessages() {
|
2021-01-25 15:39:36 +02:00
|
|
|
if (this.parsingErrors.length) {
|
|
|
|
return this.parsingErrorMessages();
|
|
|
|
}
|
|
|
|
return this.queryErrorMessages();
|
|
|
|
},
|
|
|
|
|
|
|
|
parsingErrorMessages() {
|
2021-01-13 01:14:49 +02:00
|
|
|
const messages = [];
|
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
if (this.parsingErrors.length) {
|
|
|
|
this.parsingErrors.forEach(err => {
|
2021-01-24 02:32:37 +02:00
|
|
|
messages.push(TAPi18n.__(err.tag, err.value));
|
2021-01-17 16:01:42 +02:00
|
|
|
});
|
|
|
|
}
|
2021-01-13 01:14:49 +02:00
|
|
|
|
|
|
|
return messages;
|
|
|
|
},
|
|
|
|
|
2021-01-25 15:39:36 +02:00
|
|
|
queryErrorMessages() {
|
|
|
|
messages = [];
|
|
|
|
|
|
|
|
this.queryErrors.forEach(err => {
|
|
|
|
let value = err.color ? TAPi18n.__(`color-${err.value}`) : err.value;
|
|
|
|
if (!value) {
|
|
|
|
value = err.value;
|
|
|
|
}
|
|
|
|
messages.push(TAPi18n.__(err.tag, value));
|
|
|
|
});
|
|
|
|
|
|
|
|
return messages;
|
|
|
|
},
|
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
searchAllBoards(query) {
|
2021-01-20 12:52:49 +02:00
|
|
|
query = query.trim();
|
2021-01-24 15:38:44 +02:00
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log('query:', query);
|
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
this.query.set(query);
|
|
|
|
|
|
|
|
this.resetSearch();
|
|
|
|
|
|
|
|
if (!query) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-20 12:52:49 +02:00
|
|
|
this.searching.set(true);
|
|
|
|
|
2021-01-26 18:39:09 +02:00
|
|
|
const reOperator1 = /^((?<operator>[\p{Letter}\p{Mark}]+):|(?<abbrev>[#@]))(?<value>[\p{Letter}\p{Mark}]+)(\s+|$)/iu;
|
|
|
|
const reOperator2 = /^((?<operator>[\p{Letter}\p{Mark}]+):|(?<abbrev>[#@]))(?<quote>["']*)(?<value>.*?)\k<quote>(\s+|$)/iu;
|
2021-01-25 19:01:07 +02:00
|
|
|
const reText = /^(?<text>\S+)(\s+|$)/u;
|
|
|
|
const reQuotedText = /^(?<quote>["'])(?<text>[\w\p{L}]+)\k<quote>(\s+|$)/u;
|
2021-01-17 16:01:42 +02:00
|
|
|
|
2021-01-22 23:07:38 +02:00
|
|
|
const operators = {
|
|
|
|
'operator-board': 'boards',
|
|
|
|
'operator-board-abbrev': 'boards',
|
|
|
|
'operator-swimlane': 'swimlanes',
|
|
|
|
'operator-swimlane-abbrev': 'swimlanes',
|
|
|
|
'operator-list': 'lists',
|
|
|
|
'operator-list-abbrev': 'lists',
|
|
|
|
'operator-label': 'labels',
|
|
|
|
'operator-label-abbrev': 'labels',
|
|
|
|
'operator-user': 'users',
|
|
|
|
'operator-user-abbrev': 'users',
|
|
|
|
'operator-member': 'members',
|
|
|
|
'operator-member-abbrev': 'members',
|
|
|
|
'operator-assignee': 'assignees',
|
|
|
|
'operator-assignee-abbrev': 'assignees',
|
2021-01-26 18:39:09 +02:00
|
|
|
'operator-status': 'status',
|
2021-01-22 23:07:38 +02:00
|
|
|
'operator-due': 'dueAt',
|
|
|
|
'operator-created': 'createdAt',
|
|
|
|
'operator-modified': 'modifiedAt',
|
2021-01-23 18:04:26 +02:00
|
|
|
'operator-comment': 'comments',
|
2021-01-22 23:07:38 +02:00
|
|
|
};
|
|
|
|
|
2021-01-25 19:01:07 +02:00
|
|
|
const predicates = {
|
|
|
|
due: {
|
|
|
|
'predicate-overdue': 'overdue',
|
|
|
|
},
|
2021-01-26 18:39:09 +02:00
|
|
|
durations: {
|
2021-01-25 19:01:07 +02:00
|
|
|
'predicate-week': 'week',
|
|
|
|
'predicate-month': 'month',
|
|
|
|
'predicate-quarter': 'quarter',
|
|
|
|
'predicate-year': 'year',
|
|
|
|
},
|
2021-01-26 18:39:09 +02:00
|
|
|
status: {
|
2021-01-25 19:01:07 +02:00
|
|
|
'predicate-archived': 'archived',
|
2021-01-26 18:39:09 +02:00
|
|
|
'predicate-all': 'all',
|
|
|
|
'predicate-ended': 'ended',
|
|
|
|
},
|
|
|
|
sorts: {
|
|
|
|
'predicate-due': 'dueAt',
|
|
|
|
'predicate-created': 'createdAt',
|
|
|
|
'predicate-modified': 'modifiedAt',
|
2021-01-25 19:01:07 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
const predicateTranslations = {};
|
2021-01-26 18:39:09 +02:00
|
|
|
Object.entries(predicates).forEach(([category, catPreds]) => {
|
2021-01-25 19:01:07 +02:00
|
|
|
predicateTranslations[category] = {};
|
2021-01-26 18:39:09 +02:00
|
|
|
Object.entries(catPreds).forEach(([tag, value]) => {
|
2021-01-25 19:01:07 +02:00
|
|
|
predicateTranslations[category][TAPi18n.__(tag)] = value;
|
|
|
|
});
|
|
|
|
});
|
2021-01-26 18:39:09 +02:00
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// console.log('predicateTranslations:', predicateTranslations);
|
2021-01-25 19:01:07 +02:00
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
const operatorMap = {};
|
2021-01-23 01:35:28 +02:00
|
|
|
Object.entries(operators).forEach(([key, value]) => {
|
|
|
|
operatorMap[TAPi18n.__(key).toLowerCase()] = value;
|
|
|
|
});
|
2021-01-17 16:01:42 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2021-01-24 15:38:44 +02:00
|
|
|
// console.log('operatorMap:', operatorMap);
|
2021-01-25 15:39:36 +02:00
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
const params = {
|
|
|
|
boards: [],
|
|
|
|
swimlanes: [],
|
|
|
|
lists: [],
|
|
|
|
users: [],
|
|
|
|
members: [],
|
|
|
|
assignees: [],
|
|
|
|
labels: [],
|
2021-01-26 18:39:09 +02:00
|
|
|
status: [],
|
2021-01-21 18:11:09 +02:00
|
|
|
dueAt: null,
|
|
|
|
createdAt: null,
|
|
|
|
modifiedAt: null,
|
2021-01-23 18:04:26 +02:00
|
|
|
comments: [],
|
2021-01-17 16:01:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
let text = '';
|
|
|
|
while (query) {
|
|
|
|
m = query.match(reOperator1);
|
|
|
|
if (!m) {
|
|
|
|
m = query.match(reOperator2);
|
|
|
|
if (m) {
|
|
|
|
query = query.replace(reOperator2, '');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
query = query.replace(reOperator1, '');
|
|
|
|
}
|
|
|
|
if (m) {
|
|
|
|
let op;
|
|
|
|
if (m.groups.operator) {
|
|
|
|
op = m.groups.operator.toLowerCase();
|
|
|
|
} else {
|
|
|
|
op = m.groups.abbrev;
|
|
|
|
}
|
2021-01-23 01:35:28 +02:00
|
|
|
if (operatorMap.hasOwnProperty(op)) {
|
2021-01-18 17:17:44 +02:00
|
|
|
let value = m.groups.value;
|
|
|
|
if (operatorMap[op] === 'labels') {
|
2021-01-20 12:52:49 +02:00
|
|
|
if (value in this.colorMap) {
|
|
|
|
value = this.colorMap[value];
|
2021-01-18 17:17:44 +02:00
|
|
|
}
|
2021-01-21 18:11:09 +02:00
|
|
|
} else if (
|
|
|
|
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
|
|
|
|
) {
|
2021-01-22 00:37:16 +02:00
|
|
|
let days = parseInt(value, 10);
|
|
|
|
let duration = null;
|
2021-01-21 18:11:09 +02:00
|
|
|
if (isNaN(days)) {
|
2021-01-26 18:39:09 +02:00
|
|
|
if (predicateTranslations.durations[value]) {
|
|
|
|
duration = predicateTranslations.durations[value];
|
2021-01-22 00:37:16 +02:00
|
|
|
value = moment();
|
2021-01-25 19:01:07 +02:00
|
|
|
} else if (predicateTranslations.due[value] === 'overdue') {
|
2021-01-22 00:37:16 +02:00
|
|
|
value = moment();
|
|
|
|
duration = 'days';
|
|
|
|
days = 0;
|
2021-01-21 18:11:09 +02:00
|
|
|
} else {
|
|
|
|
this.parsingErrors.push({
|
|
|
|
tag: 'operator-number-expected',
|
|
|
|
value: { operator: op, value },
|
|
|
|
});
|
|
|
|
value = null;
|
|
|
|
}
|
|
|
|
} else {
|
2021-01-22 00:37:16 +02:00
|
|
|
value = moment();
|
|
|
|
}
|
|
|
|
if (value) {
|
|
|
|
if (operatorMap[op] === 'dueAt') {
|
|
|
|
value = value.add(days, duration ? duration : 'days').format();
|
|
|
|
} else {
|
|
|
|
value = value
|
|
|
|
.subtract(days, duration ? duration : 'days')
|
|
|
|
.format();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (operatorMap[op] === 'sort') {
|
2021-01-26 18:39:09 +02:00
|
|
|
if (!predicateTranslations.sorts[value]) {
|
2021-01-22 00:37:16 +02:00
|
|
|
this.parsingErrors.push({
|
|
|
|
tag: 'operator-sort-invalid',
|
|
|
|
value,
|
|
|
|
});
|
2021-01-26 18:39:09 +02:00
|
|
|
} else {
|
|
|
|
value = predicateTranslations.sorts[value];
|
|
|
|
}
|
|
|
|
} else if (operatorMap[op] === 'status') {
|
|
|
|
if (!predicateTranslations.status[value]) {
|
|
|
|
this.parsingErrors.push({
|
|
|
|
tag: 'operator-status-invalid',
|
|
|
|
value,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
value = predicateTranslations.status[value];
|
2021-01-21 18:11:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Array.isArray(params[operatorMap[op]])) {
|
|
|
|
params[operatorMap[op]].push(value);
|
|
|
|
} else {
|
|
|
|
params[operatorMap[op]] = value;
|
2021-01-18 17:17:44 +02:00
|
|
|
}
|
2021-01-17 16:01:42 +02:00
|
|
|
} else {
|
|
|
|
this.parsingErrors.push({
|
|
|
|
tag: 'operator-unknown-error',
|
|
|
|
value: op,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = query.match(reQuotedText);
|
|
|
|
if (!m) {
|
|
|
|
m = query.match(reText);
|
|
|
|
if (m) {
|
|
|
|
query = query.replace(reText, '');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
query = query.replace(reQuotedText, '');
|
|
|
|
}
|
|
|
|
if (m) {
|
|
|
|
text += (text ? ' ' : '') + m.groups.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// console.log('text:', text);
|
|
|
|
params.text = text;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
2021-01-25 15:39:36 +02:00
|
|
|
// console.log('params:', params);
|
2021-01-17 16:01:42 +02:00
|
|
|
|
|
|
|
this.queryParams = params;
|
|
|
|
|
2021-01-24 15:38:44 +02:00
|
|
|
if (this.parsingErrors.length) {
|
|
|
|
this.searching.set(false);
|
2021-01-25 15:39:36 +02:00
|
|
|
this.queryErrors = this.parsingErrorMessages();
|
2021-01-26 18:39:09 +02:00
|
|
|
this.hasResults.set(true);
|
2021-01-24 15:38:44 +02:00
|
|
|
this.hasQueryErrors.set(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-17 16:01:42 +02:00
|
|
|
this.autorun(() => {
|
2021-01-26 18:39:09 +02:00
|
|
|
const handle = Meteor.subscribe(
|
2021-01-24 12:28:36 +02:00
|
|
|
'globalSearch',
|
|
|
|
SessionData.getSessionId(),
|
|
|
|
params,
|
|
|
|
);
|
2021-01-17 16:01:42 +02:00
|
|
|
Tracker.nonreactive(() => {
|
|
|
|
Tracker.autorun(() => {
|
|
|
|
if (handle.ready()) {
|
2021-01-24 15:38:44 +02:00
|
|
|
this.getResults();
|
2021-01-17 16:01:42 +02:00
|
|
|
this.searching.set(false);
|
|
|
|
this.hasResults.set(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getResultsHeading() {
|
|
|
|
if (this.resultsCount === 0) {
|
2021-01-16 19:50:11 +02:00
|
|
|
return TAPi18n.__('no-cards-found');
|
2021-01-17 16:01:42 +02:00
|
|
|
} else if (this.resultsCount === 1) {
|
2021-01-16 19:50:11 +02:00
|
|
|
return TAPi18n.__('one-card-found');
|
2021-01-17 16:01:42 +02:00
|
|
|
} else if (this.resultsCount === this.totalHits) {
|
|
|
|
return TAPi18n.__('n-cards-found', this.resultsCount);
|
2021-01-16 19:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TAPi18n.__('n-n-of-n-cards-found', {
|
|
|
|
start: 1,
|
2021-01-17 16:01:42 +02:00
|
|
|
end: this.resultsCount,
|
|
|
|
total: this.totalHits,
|
2021-01-16 19:50:11 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-17 21:04:05 +02:00
|
|
|
getSearchHref() {
|
|
|
|
const baseUrl = window.location.href.replace(/([?#].*$|\s*$)/, '');
|
|
|
|
return `${baseUrl}?q=${encodeURIComponent(this.query.get())}`;
|
|
|
|
},
|
|
|
|
|
2021-01-17 00:05:45 +02:00
|
|
|
searchInstructions() {
|
|
|
|
tags = {
|
|
|
|
operator_board: TAPi18n.__('operator-board'),
|
|
|
|
operator_list: TAPi18n.__('operator-list'),
|
|
|
|
operator_swimlane: TAPi18n.__('operator-swimlane'),
|
2021-01-26 18:39:09 +02:00
|
|
|
operator_comment: TAPi18n.__('operator-comment'),
|
2021-01-17 00:05:45 +02:00
|
|
|
operator_label: TAPi18n.__('operator-label'),
|
|
|
|
operator_label_abbrev: TAPi18n.__('operator-label-abbrev'),
|
|
|
|
operator_user: TAPi18n.__('operator-user'),
|
|
|
|
operator_user_abbrev: TAPi18n.__('operator-user-abbrev'),
|
2021-01-17 16:01:42 +02:00
|
|
|
operator_member: TAPi18n.__('operator-member'),
|
|
|
|
operator_member_abbrev: TAPi18n.__('operator-member-abbrev'),
|
|
|
|
operator_assignee: TAPi18n.__('operator-assignee'),
|
|
|
|
operator_assignee_abbrev: TAPi18n.__('operator-assignee-abbrev'),
|
2021-01-26 18:39:09 +02:00
|
|
|
operator_due: TAPi18n.__('operator-due'),
|
|
|
|
operator_created: TAPi18n.__('operator-created'),
|
|
|
|
operator_modified: TAPi18n.__('operator-modified'),
|
|
|
|
operator_status: TAPi18n.__('operator-status'),
|
|
|
|
predicate_overdue: TAPi18n.__('predicate-overdue'),
|
|
|
|
predicate_archived: TAPi18n.__('predicate-archived'),
|
|
|
|
predicate_all: TAPi18n.__('predicate-all'),
|
|
|
|
predicate_ended: TAPi18n.__('predicate-ended'),
|
|
|
|
predicate_week: TAPi18n.__('predicate-week'),
|
|
|
|
predicate_month: TAPi18n.__('predicate-month'),
|
|
|
|
predicate_quarter: TAPi18n.__('predicate-quarter'),
|
|
|
|
predicate_year: TAPi18n.__('predicate-year'),
|
2021-01-17 00:05:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
text = `# ${TAPi18n.__('globalSearch-instructions-heading')}`;
|
|
|
|
text += `\n${TAPi18n.__('globalSearch-instructions-description', tags)}`;
|
|
|
|
text += `\n${TAPi18n.__('globalSearch-instructions-operators', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-board',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-list',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-swimlane',
|
|
|
|
tags,
|
|
|
|
)}`;
|
2021-01-26 18:39:09 +02:00
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-comment',
|
|
|
|
tags,
|
|
|
|
)}`;
|
2021-01-17 00:05:45 +02:00
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-label',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-hash',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-user',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-at', tags)}`;
|
2021-01-17 16:01:42 +02:00
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-member',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-assignee',
|
|
|
|
tags,
|
|
|
|
)}`;
|
2021-01-26 18:39:09 +02:00
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-due', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-created',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-operator-modified',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__(
|
|
|
|
'globalSearch-instructions-status-archived',
|
|
|
|
tags,
|
|
|
|
)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-status-all', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-status-ended', tags)}`;
|
2021-01-17 00:05:45 +02:00
|
|
|
|
|
|
|
text += `\n## ${TAPi18n.__('heading-notes')}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-1', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-2', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-3', tags)}`;
|
2021-01-26 18:39:09 +02:00
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-3-2', tags)}`;
|
2021-01-17 00:05:45 +02:00
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-4', tags)}`;
|
|
|
|
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-5', tags)}`;
|
|
|
|
|
|
|
|
return text;
|
|
|
|
},
|
|
|
|
|
2021-01-20 13:15:10 +02:00
|
|
|
labelColors() {
|
|
|
|
return Boards.simpleSchema()._schema['labels.$.color'].allowedValues.map(
|
|
|
|
color => {
|
|
|
|
return { color, name: TAPi18n.__(`color-${color}`) };
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2021-01-10 21:52:25 +02:00
|
|
|
events() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'submit .js-search-query-form'(evt) {
|
|
|
|
evt.preventDefault();
|
2021-01-17 16:01:42 +02:00
|
|
|
this.searchAllBoards(evt.target.searchQuery.value);
|
2021-01-10 21:52:25 +02:00
|
|
|
},
|
2021-01-21 01:48:24 +02:00
|
|
|
'click .js-label-color'(evt) {
|
|
|
|
evt.preventDefault();
|
2021-01-25 01:35:44 +02:00
|
|
|
const input = document.getElementById('global-search-input');
|
2021-01-21 01:48:24 +02:00
|
|
|
this.query.set(
|
2021-01-25 01:35:44 +02:00
|
|
|
`${input.value} ${TAPi18n.__('operator-label')}:"${
|
2021-01-21 01:48:24 +02:00
|
|
|
evt.currentTarget.textContent
|
|
|
|
}"`,
|
|
|
|
);
|
2021-01-21 11:55:58 +02:00
|
|
|
document.getElementById('global-search-input').focus();
|
2021-01-21 01:48:24 +02:00
|
|
|
},
|
|
|
|
'click .js-board-title'(evt) {
|
|
|
|
evt.preventDefault();
|
2021-01-25 01:35:44 +02:00
|
|
|
const input = document.getElementById('global-search-input');
|
2021-01-20 13:15:10 +02:00
|
|
|
this.query.set(
|
2021-01-25 01:35:44 +02:00
|
|
|
`${input.value} ${TAPi18n.__('operator-board')}:"${
|
2021-01-21 01:48:24 +02:00
|
|
|
evt.currentTarget.textContent
|
|
|
|
}"`,
|
2021-01-20 13:15:10 +02:00
|
|
|
);
|
2021-01-21 11:55:58 +02:00
|
|
|
document.getElementById('global-search-input').focus();
|
2021-01-20 13:15:10 +02:00
|
|
|
},
|
2021-01-20 21:52:27 +02:00
|
|
|
'click .js-list-title'(evt) {
|
2021-01-21 01:48:24 +02:00
|
|
|
evt.preventDefault();
|
2021-01-25 01:35:44 +02:00
|
|
|
const input = document.getElementById('global-search-input');
|
2021-01-21 01:48:24 +02:00
|
|
|
this.query.set(
|
2021-01-25 01:35:44 +02:00
|
|
|
`${input.value} ${TAPi18n.__('operator-list')}:"${
|
2021-01-21 01:48:24 +02:00
|
|
|
evt.currentTarget.textContent
|
|
|
|
}"`,
|
|
|
|
);
|
2021-01-21 11:55:58 +02:00
|
|
|
document.getElementById('global-search-input').focus();
|
2021-01-21 01:48:24 +02:00
|
|
|
},
|
|
|
|
'click .js-label-name'(evt) {
|
|
|
|
evt.preventDefault();
|
2021-01-25 01:35:44 +02:00
|
|
|
const input = document.getElementById('global-search-input');
|
2021-01-20 21:52:27 +02:00
|
|
|
this.query.set(
|
2021-01-25 01:35:44 +02:00
|
|
|
`${input.value} ${TAPi18n.__('operator-label')}:"${
|
2021-01-21 01:48:24 +02:00
|
|
|
evt.currentTarget.textContent
|
|
|
|
}"`,
|
2021-01-20 21:52:27 +02:00
|
|
|
);
|
2021-01-21 11:55:58 +02:00
|
|
|
document.getElementById('global-search-input').focus();
|
2021-01-20 21:52:27 +02:00
|
|
|
},
|
2021-01-10 21:52:25 +02:00
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
}).register('globalSearch');
|