parent
82eca44581
commit
ebe6f4cad7
7 changed files with 96 additions and 117 deletions
|
@ -246,9 +246,9 @@ export function initRepoBranchTagSelector(selector) {
|
|||
export default sfc; // activate IDE's Vue plugin
|
||||
</script>
|
||||
<template>
|
||||
<div class="ui dropdown custom">
|
||||
<button class="branch-dropdown-button gt-ellipsis ui basic small compact button tw-flex tw-m-0" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
|
||||
<span class="text tw-flex tw-items-center tw-mr-1 gt-ellipsis">
|
||||
<div class="ui dropdown custom branch-selector-dropdown">
|
||||
<div class="ui button branch-dropdown-button" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
|
||||
<span class="flex-text-block gt-ellipsis">
|
||||
<template v-if="release">{{ textReleaseCompare }}</template>
|
||||
<template v-else>
|
||||
<svg-icon v-if="isViewTag" name="octicon-tag"/>
|
||||
|
@ -257,7 +257,7 @@ export default sfc; // activate IDE's Vue plugin
|
|||
</template>
|
||||
</span>
|
||||
<svg-icon name="octicon-triangle-down" :size="14" class-name="dropdown icon"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="menu transition" :class="{visible: menuVisible}" v-show="menuVisible" v-cloak>
|
||||
<div class="ui icon search input">
|
||||
<i class="icon"><svg-icon name="octicon-filter" :size="16"/></i>
|
||||
|
@ -317,43 +317,3 @@ export default sfc; // activate IDE's Vue plugin
|
|||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.branch-tag-tab {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.branch-tag-item {
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
border: 1px solid transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.branch-tag-item.active {
|
||||
border-color: var(--color-secondary);
|
||||
background: var(--color-menu);
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
.branch-tag-divider {
|
||||
margin-top: -1px !important;
|
||||
border-top: 1px solid var(--color-secondary);
|
||||
}
|
||||
|
||||
.scrolling.menu {
|
||||
border-top: none !important;
|
||||
}
|
||||
|
||||
.menu .item .rss-icon {
|
||||
display: none; /* only show RSS icon on hover */
|
||||
}
|
||||
|
||||
.menu .item:hover .rss-icon {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.scrolling.menu .loading-indicator {
|
||||
height: 4em;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -19,7 +19,7 @@ import {initCompReactionSelector} from './comp/ReactionSelector.js';
|
|||
import {initRepoSettingBranches} from './repo-settings.js';
|
||||
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.js';
|
||||
import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
|
||||
import {hideElem, showElem} from '../utils/dom.js';
|
||||
import {hideElem, queryElemChildren, showElem} from '../utils/dom.js';
|
||||
import {POST} from '../modules/fetch.js';
|
||||
import {initRepoIssueCommentEdit} from './repo-issue-edit.js';
|
||||
|
||||
|
@ -56,16 +56,19 @@ export function initRepoCommentForm() {
|
|||
}
|
||||
|
||||
function initBranchSelector() {
|
||||
const $selectBranch = $('.ui.select-branch');
|
||||
const elSelectBranch = document.querySelector('.ui.dropdown.select-branch');
|
||||
const isForNewIssue = elSelectBranch.getAttribute('data-for-new-issue') === 'true';
|
||||
|
||||
const $selectBranch = $(elSelectBranch);
|
||||
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
||||
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
||||
$branchMenu.find('.item:not(.no-select)').on('click', async function () {
|
||||
const selectedValue = $(this).data('id');
|
||||
$branchMenu.find('.item:not(.no-select)').on('click', async function (e) {
|
||||
e.preventDefault();
|
||||
const selectedValue = $(this).data('id'); // eg: "refs/heads/my-branch"
|
||||
const editMode = $('#editing_mode').val();
|
||||
$($(this).data('id-selector')).val(selectedValue);
|
||||
if ($isNewIssue) {
|
||||
$selectBranch.find('.ui .branch-name').text($(this).data('name'));
|
||||
return;
|
||||
if (isForNewIssue) {
|
||||
elSelectBranch.querySelector('.text-branch-name').textContent = this.getAttribute('data-name');
|
||||
return; // only update UI&form, do not send request/reload
|
||||
}
|
||||
|
||||
if (editMode === 'true') {
|
||||
|
@ -84,9 +87,9 @@ export function initRepoCommentForm() {
|
|||
});
|
||||
$selectBranch.find('.reference.column').on('click', function () {
|
||||
hideElem($selectBranch.find('.scrolling.reference-list-menu'));
|
||||
$selectBranch.find('.reference .text').removeClass('black');
|
||||
showElem($($(this).data('target')));
|
||||
$(this).find('.text').addClass('black');
|
||||
showElem(this.getAttribute('data-target'));
|
||||
queryElemChildren(this.parentNode, '.branch-tag-item', (el) => el.classList.remove('active'));
|
||||
this.classList.add('active');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue