0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-06 00:59:45 +02:00

add component for searching for teams to add to a group

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-08-16 16:14:33 -04:00
parent efe8193237
commit da30652db0
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import {fomanticQuery} from '../../modules/fomantic/base.ts';
import {html} from '../../utils/html.ts';
const {appSubUrl} = window.config;
export function initCompSearchTeamBox() {
const searchTeamBox = document.querySelector('#search-team-box');
if (!searchTeamBox) return;
fomanticQuery(searchTeamBox).search({
minCharacters: 2,
apiSettings: {
url: `${appSubUrl}${searchTeamBox.getAttribute('data-search-url')}`,
onResponse(response: {data: any[]}) {
const resultItems = [];
const searchQuery = searchTeamBox.querySelector('input').value;
const searchQueryUppercase = searchQuery.toUpperCase();
for (const item of response.data) {
const resultItem = {
title: item.name,
description: html`${item.description}`,
};
if (searchQueryUppercase === item.name.toUpperCase()) {
resultItems.unshift(resultItem); // add the exact match to the top
} else {
resultItems.push(resultItem);
}
}
return {results: resultItems};
},
},
searchFields: ['login', 'full_name'],
showNoResults: false,
});
}

View File

@ -37,6 +37,7 @@ import {initRepoReleaseNew} from './features/repo-release.ts';
import {initRepoEditor} from './features/repo-editor.ts';
import {initCompSearchUserBox} from './features/comp/SearchUserBox.ts';
import {initInstall} from './features/install.ts';
import {initCompSearchTeamBox} from './features/comp/SearchTeamBox.ts'
import {initCompWebHookEditor} from './features/comp/WebHookEditor.ts';
import {initRepoBranchButton} from './features/repo-branch.ts';
import {initCommonOrganization} from './features/common-organization.ts';
@ -93,6 +94,7 @@ const initPerformanceTracer = callInitFunctions([
initCompSearchUserBox,
initCompWebHookEditor,
initCompSearchTeamBox,
initInstall,