Merge pull request #3597 from jrsupplee/search

Global Search Updates
This commit is contained in:
Lauri Ojansivu 2021-02-24 15:55:46 +02:00 committed by GitHub
commit 4f9b4059a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 119 additions and 18 deletions

View file

@ -222,6 +222,7 @@ BlazeComponent.extendComponent({
'operator-created': 'createdAt',
'operator-modified': 'modifiedAt',
'operator-comment': 'comments',
'operator-has': 'has',
};
const predicates = {
@ -238,12 +239,19 @@ BlazeComponent.extendComponent({
'predicate-archived': 'archived',
'predicate-all': 'all',
'predicate-ended': 'ended',
'predicate-public': 'public',
'predicate-private': 'private',
},
sorts: {
'predicate-due': 'dueAt',
'predicate-created': 'createdAt',
'predicate-modified': 'modifiedAt',
},
has: {
'predicate-description': 'description',
'predicate-checklist': 'checklist',
'predicate-attachment': 'attachment',
},
};
const predicateTranslations = {};
Object.entries(predicates).forEach(([category, catPreds]) => {
@ -276,6 +284,7 @@ BlazeComponent.extendComponent({
createdAt: null,
modifiedAt: null,
comments: [],
has: [],
};
let text = '';
@ -296,6 +305,7 @@ BlazeComponent.extendComponent({
} else {
op = m.groups.abbrev.toLowerCase();
}
// eslint-disable-next-line no-prototype-builtins
if (operatorMap.hasOwnProperty(op)) {
let value = m.groups.value;
if (operatorMap[op] === 'labels') {
@ -353,6 +363,15 @@ BlazeComponent.extendComponent({
} else {
value = predicateTranslations.status[value];
}
} else if (operatorMap[op] === 'has') {
if (!predicateTranslations.has[value]) {
this.parsingErrors.push({
tag: 'operator-has-invalid',
value,
});
} else {
value = predicateTranslations.has[value];
}
}
if (Array.isArray(params[operatorMap[op]])) {
params[operatorMap[op]].push(value);
@ -511,6 +530,7 @@ BlazeComponent.extendComponent({
operator_created: TAPi18n.__('operator-created'),
operator_modified: TAPi18n.__('operator-modified'),
operator_status: TAPi18n.__('operator-status'),
operator_has: TAPi18n.__('operator-has'),
predicate_overdue: TAPi18n.__('predicate-overdue'),
predicate_archived: TAPi18n.__('predicate-archived'),
predicate_all: TAPi18n.__('predicate-all'),
@ -519,6 +539,11 @@ BlazeComponent.extendComponent({
predicate_month: TAPi18n.__('predicate-month'),
predicate_quarter: TAPi18n.__('predicate-quarter'),
predicate_year: TAPi18n.__('predicate-year'),
predicate_attachment: TAPi18n.__('predicate-attachment'),
predicate_description: TAPi18n.__('predicate-description'),
predicate_checklist: TAPi18n.__('predicate-checklist'),
predicate_public: TAPi18n.__('predicate-public'),
predicate_private: TAPi18n.__('predicate-private'),
};
text = `# ${TAPi18n.__('globalSearch-instructions-heading')}`;
@ -574,9 +599,19 @@ BlazeComponent.extendComponent({
'globalSearch-instructions-status-archived',
tags,
)}`;
text += `\n* ${TAPi18n.__(
'globalSearch-instructions-status-public',
tags,
)}`;
text += `\n* ${TAPi18n.__(
'globalSearch-instructions-status-private',
tags,
)}`;
text += `\n* ${TAPi18n.__('globalSearch-instructions-status-all', tags)}`;
text += `\n* ${TAPi18n.__('globalSearch-instructions-status-ended', tags)}`;
text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-has', tags)}`;
text += `\n## ${TAPi18n.__('heading-notes')}`;
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-1', tags)}`;
text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-2', tags)}`;