code.gitea.io/gitea@v1.21.7/web_src/js/features/org-team.js (about)

     1  import $ from 'jquery';
     2  import {hideElem, showElem} from '../utils/dom.js';
     3  
     4  const {appSubUrl} = window.config;
     5  
     6  export function initOrgTeamSettings() {
     7    // Change team access mode
     8    $('.organization.new.team input[name=permission]').on('change', () => {
     9      const val = $('input[name=permission]:checked', '.organization.new.team').val();
    10      if (val === 'admin') {
    11        hideElem($('.organization.new.team .team-units'));
    12      } else {
    13        showElem($('.organization.new.team .team-units'));
    14      }
    15    });
    16  }
    17  
    18  
    19  export function initOrgTeamSearchRepoBox() {
    20    const $searchRepoBox = $('#search-repo-box');
    21    $searchRepoBox.search({
    22      minCharacters: 2,
    23      apiSettings: {
    24        url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
    25        onResponse(response) {
    26          const items = [];
    27          $.each(response.data, (_i, item) => {
    28            items.push({
    29              title: item.repository.full_name.split('/')[1],
    30              description: item.repository.full_name
    31            });
    32          });
    33  
    34          return {results: items};
    35        }
    36      },
    37      searchFields: ['full_name'],
    38      showNoResults: false
    39    });
    40  }