aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/index.js
diff options
context:
space:
mode:
authorKN4CK3R <KN4CK3R@users.noreply.github.com>2021-01-21 14:51:17 +0100
committerGitHub <noreply@github.com>2021-01-21 14:51:17 +0100
commit56a89296050096df29d0a653019c194631cc6562 (patch)
tree9082430c3e700d55d5627ce8052d27de6d2bed46 /web_src/js/index.js
parent1c230f69d9951af1174f2956064f18e2d135723d (diff)
downloadgitea-56a89296050096df29d0a653019c194631cc6562.tar.gz
gitea-56a89296050096df29d0a653019c194631cc6562.zip
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>
Diffstat (limited to 'web_src/js/index.js')
-rw-r--r--web_src/js/index.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index f64f9e6ef1..541f32507d 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -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();