-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40765b5
commit ef736b7
Showing
5 changed files
with
31 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,44 @@ | ||
import $ from 'jquery'; | ||
import {hideElem, showElem} from '../utils/dom.ts'; | ||
import {queryElems, toggleElem} from '../utils/dom.ts'; | ||
import {fomanticQuery} from '../modules/fomantic/base.ts'; | ||
|
||
const {appSubUrl} = window.config; | ||
|
||
export function initOrgTeamSettings() { | ||
// Change team access mode | ||
$('.organization.new.team input[name=permission]').on('change', () => { | ||
const val = $('input[name=permission]:checked', '.organization.new.team').val(); | ||
if (val === 'admin') { | ||
hideElem('.organization.new.team .team-units'); | ||
} else { | ||
showElem('.organization.new.team .team-units'); | ||
} | ||
}); | ||
function initOrgTeamSettings() { | ||
// on the page "page-content organization new team" | ||
const pageContent = document.querySelector('.page-content.organization.new.team'); | ||
if (!pageContent) return; | ||
queryElems(pageContent, 'input[name=permission]', (el) => el.addEventListener('change', () => { | ||
// Change team access mode | ||
const val = pageContent.querySelector<HTMLInputElement>('input[name=permission]:checked')?.value; | ||
toggleElem(pageContent.querySelectorAll('.team-units'), val !== 'admin'); | ||
})); | ||
} | ||
|
||
export function initOrgTeamSearchRepoBox() { | ||
const $searchRepoBox = $('#search-repo-box'); | ||
function initOrgTeamSearchRepoBox() { | ||
// on the page "page-content organization teams" | ||
const $searchRepoBox = fomanticQuery('#search-repo-box'); | ||
$searchRepoBox.search({ | ||
minCharacters: 2, | ||
apiSettings: { | ||
url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`, | ||
onResponse(response) { | ||
const items = []; | ||
$.each(response.data, (_i, item) => { | ||
for (const item of response.data) { | ||
items.push({ | ||
title: item.repository.full_name.split('/')[1], | ||
description: item.repository.full_name, | ||
}); | ||
}); | ||
|
||
} | ||
return {results: items}; | ||
}, | ||
}, | ||
searchFields: ['full_name'], | ||
showNoResults: false, | ||
}); | ||
} | ||
|
||
export function initOrgTeam() { | ||
if (!document.querySelector('.page-content.organization')) return; | ||
initOrgTeamSettings(); | ||
initOrgTeamSearchRepoBox(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters