aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/index.js
diff options
context:
space:
mode:
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();