mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Comment - Reference in new issue (#14366)
* Implemented "Reference in new issue" * Fixed menu style on "pulls/x/files" because "button" has a style. * Added context menu for PR file comments. * Use only a single modal for every comment. * Use current repository as default. Added search filter. * Added suggested changes. * Fixed assignment. Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		@@ -932,6 +932,27 @@ async function initRepository() {
 | 
			
		||||
      event.preventDefault();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Reference issue
 | 
			
		||||
    $(document).on('click', '.reference-issue', function (event) {
 | 
			
		||||
      const $this = $(this);
 | 
			
		||||
 | 
			
		||||
      $this.closest('.dropdown').find('.menu').toggle('visible');
 | 
			
		||||
 | 
			
		||||
      const content = $(`#comment-${$this.data('target')}`).text();
 | 
			
		||||
      const subject = content.split('\n', 1)[0].slice(0, 255);
 | 
			
		||||
 | 
			
		||||
      const poster = $this.data('poster');
 | 
			
		||||
      const reference = $this.data('reference');
 | 
			
		||||
 | 
			
		||||
      const $modal = $($this.data('modal'));
 | 
			
		||||
      $modal.find('input[name="title"').val(subject);
 | 
			
		||||
      $modal.find('textarea[name="content"]').val(`${content}\n\n_Originally posted by @${poster} in ${reference}_`);
 | 
			
		||||
 | 
			
		||||
      $modal.modal('show');
 | 
			
		||||
 | 
			
		||||
      event.preventDefault();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Edit issue or comment content
 | 
			
		||||
    $(document).on('click', '.edit-content', async function (event) {
 | 
			
		||||
      $(this).closest('.dropdown').find('.menu').toggle('visible');
 | 
			
		||||
@@ -2337,6 +2358,31 @@ function initTemplateSearch() {
 | 
			
		||||
  changeOwner();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function initIssueReferenceRepositorySearch() {
 | 
			
		||||
  $('.issue_reference_repository_search')
 | 
			
		||||
    .dropdown({
 | 
			
		||||
      apiSettings: {
 | 
			
		||||
        url: `${AppSubUrl}/api/v1/repos/search?q={query}&limit=20`,
 | 
			
		||||
        onResponse(response) {
 | 
			
		||||
          const filteredResponse = {success: true, results: []};
 | 
			
		||||
          $.each(response.data, (_r, repo) => {
 | 
			
		||||
            filteredResponse.results.push({
 | 
			
		||||
              name: htmlEscape(repo.full_name),
 | 
			
		||||
              value: repo.full_name
 | 
			
		||||
            });
 | 
			
		||||
          });
 | 
			
		||||
          return filteredResponse;
 | 
			
		||||
        },
 | 
			
		||||
        cache: false,
 | 
			
		||||
      },
 | 
			
		||||
      onChange(_value, _text, $choice) {
 | 
			
		||||
        const $form = $choice.closest('form');
 | 
			
		||||
        $form.attr('action', `${AppSubUrl}/${_text}/issues/new`);
 | 
			
		||||
      },
 | 
			
		||||
      fullTextSearch: true
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).ready(async () => {
 | 
			
		||||
  // Show exact time
 | 
			
		||||
  $('.time-since').each(function () {
 | 
			
		||||
@@ -2553,6 +2599,7 @@ $(document).ready(async () => {
 | 
			
		||||
  initPullRequestReview();
 | 
			
		||||
  initRepoStatusChecker();
 | 
			
		||||
  initTemplateSearch();
 | 
			
		||||
  initIssueReferenceRepositorySearch();
 | 
			
		||||
  initContextPopups();
 | 
			
		||||
  initTableSort();
 | 
			
		||||
  initNotificationsTable();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user