feat(search): add suggestion to edit page

This commit is contained in:
alistair3149 2023-08-29 19:37:17 -07:00
parent 969f4f0d3d
commit 3d31d08021
No known key found for this signature in database
GPG key ID: 16076C01E5C88864
4 changed files with 15 additions and 3 deletions

View file

@ -30,6 +30,7 @@
"citizen-search-fulltext-empty": "Search for text within pages",
"citizen-search-mediasearch-empty": "Search for media",
"citizen-search-editpage": "Edit or create page",
"citizen-search-empty-desc": "Type to start searching",
"citizen-search-noresults-title": "Uh oh! No results for $1",
"citizen-search-noresults-desc": "Maybe try the options above?",

View file

@ -35,6 +35,7 @@
"citizen-search-fulltext-empty": "Helper text for Fulltext search",
"citizen-search-mediasearch-empty": "Helper text for MediaSearch",
"citizen-search-editpage": "Helper text for edit and create page suggestion",
"citizen-search-empty-desc": "Helper text in the search suggestion when there are no search query",
"citizen-search-noresults-title": "Title in the search suggestion when there are no search results",
"citizen-search-noresults-desc": "Description in the search suggestion when there are no search results",

View file

@ -455,16 +455,25 @@ function updateTypeaheadItems() {
// Fulltext search
itemGroupData.items.push( {
// id: 'fulltext',
link: `${config.wgScriptPath}/index.php?title=Special:Search&fulltext=1&search=`,
link: `${config.wgScriptPath}/index.php?title=Special:Search&fulltext=1&search=${searchQuery.valueHtml}`,
icon: 'articleSearch',
msg: 'citizen-search-fulltext-empty'
} );
// Edit/create page
// TODO: Check if user has right, and whether the page exists
itemGroupData.items.push( {
// id: 'editpage',
link: `${config.wgScriptPath}/index.php?title=${searchQuery.valueHtml}&action=edit`,
icon: 'edit',
msg: 'citizen-search-editpage'
} );
// MediaSearch
if ( config.isMediaSearchExtensionEnabled ) {
itemGroupData.items.push( {
// id: 'mediasearch',
link: `${config.wgScriptPath}/index.php?title=Special:MediaSearch&type=image&search=`,
link: `${config.wgScriptPath}/index.php?title=Special:MediaSearch&type=image&search=${searchQuery.valueHtml}`,
icon: 'imageGallery',
msg: 'citizen-search-mediasearch-empty'
} );
@ -482,7 +491,7 @@ function updateTypeaheadItems() {
itemGroupData.items.forEach( ( item, index ) => {
const toolEl = document.getElementById( `citizen-typeahead-tool-${index}` );
htmlHelper.updateItemElement( toolEl, {
link: `${item.link}${searchQuery.valueHtml}`,
link: item.link,
title: searchQuery.value,
/* eslint-disable-next-line mediawiki/msg-doc */
label: mw.message( item.msg )

View file

@ -172,6 +172,7 @@
"messages": [
"citizen-search-fulltext",
"citizen-search-fulltext-empty",
"citizen-search-editpage",
"citizen-search-mediasearch",
"citizen-search-mediasearch-empty",
"citizen-search-empty-desc",