Skip to content

Commit 6cce6a8

Browse files
committed
show issue details in projects/view
1 parent 008248b commit 6cce6a8

File tree

7 files changed

+156
-18
lines changed

7 files changed

+156
-18
lines changed

models/project_board.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ func (b *ProjectBoard) LoadProjectIssues() ([]*ProjectIssue, error) {
202202
}
203203
var projectIssuesDB []*ProjectIssue
204204
var projectIssues []*ProjectIssue
205-
err := x.Table("project_issue").Where("project_board_id = ?", boardID).
205+
err := x.Table("project_issue").Where("project_board_id = ? and project_id =?",
206+
boardID, b.ProjectID).
206207
OrderBy("priority").Find(&projectIssuesDB)
207208
for _, projectIssue := range projectIssuesDB {
208209
if issue, err := getIssueByID(x, projectIssue.IssueID); err != nil {

routers/repo/issue.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848

4949
issueTemplateKey = "IssueTemplate"
5050
issueTemplateTitleKey = "IssueTemplateTitle"
51+
tplSidebar = "repo/issue/view_content/sidebar"
5152
)
5253

5354
var (
@@ -1486,7 +1487,14 @@ func ViewIssue(ctx *context.Context) {
14861487
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin)
14871488
ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
14881489
ctx.Data["RefEndName"] = git.RefEndName(issue.Ref)
1489-
ctx.HTML(200, tplIssueView)
1490+
1491+
if ctx.Params(":sidebar") == "true" {
1492+
ctx.Data["Sidebar"] = true
1493+
ctx.HTML(200, tplSidebar)
1494+
} else {
1495+
ctx.Data["Sidebar"] = false
1496+
ctx.HTML(200, tplIssueView)
1497+
}
14901498
}
14911499

14921500
// GetActionIssue will return the issue which is used in the context.

routers/routes/macaron.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
772772
m.Group("", func() {
773773
m.Get("/^:type(issues|pulls)$", repo.Issues)
774774
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
775+
m.Get("/^:type(issues|pulls)$/:index/sidebar/:sidebar", repo.ViewIssue)
775776
m.Get("/labels/", reqRepoIssuesOrPullsReader, repo.RetrieveLabels, repo.Labels)
776777
m.Get("/milestones", reqRepoIssuesOrPullsReader, repo.Milestones)
777778
}, context.RepoRef())

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<div class="four wide column">
22
<div class="ui segment metas">
3+
{{if eq .Sidebar true}}
4+
<h3>#{{.Issue.ID}} {{.Issue.Title}}</h3>
5+
{{end}}
36
{{template "repo/issue/branch_selector_field" .}}
47

58
{{if .Issue.IsPull }}
@@ -567,7 +570,7 @@
567570
</div>
568571

569572
<form class="ui form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}{{ if .Issue.IsLocked }}/unlock{{ else }}/lock{{ end }}"
570-
method="post">
573+
method="post" id="lock-form">
571574
{{.CsrfTokenHtml}}
572575

573576
{{ if not .Issue.IsLocked }}
@@ -576,7 +579,7 @@
576579
</div>
577580

578581
<div class="field">
579-
<div class="ui fluid dropdown selection" tabindex="0">
582+
<div class="ui fluid dropdown selection" tabindex="0" id="lock-dropdown">
580583

581584
<select name="reason">
582585
<option value=""> </option>

templates/repo/projects/view.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<div class="ui container fluid padded" id="project-board">
7171

7272
<div class="board" id="board-container" data-url="{{.RepoLink}}/projects/{{$.Project.ID}}">
73+
<div class="ui segment ignore-elements hide" id="current-card-details"></div>
7374
{{ range $board := .Boards }}
7475

7576
<div class="ui segment board-column {{if eq .ID 0}}ignore-elements{{end}}"
@@ -145,6 +146,7 @@
145146

146147
<!-- start issue card -->
147148
<div class="card board-card"
149+
data-issueid="{{.Issue.ID}}"
148150
data-id="{{.ID}}" data-priority="{{.Priority}}">
149151
<div class="content">
150152
<div class="header">
@@ -154,7 +156,7 @@
154156
{{else}}{{svg "octicon-issue-opened"}}
155157
{{end}}
156158
</span>
157-
<a class="project-board-title" href="{{$.RepoLink}}/issues/{{.IssueID}}">#{{.IssueID}} {{.Issue.Title}}</a>
159+
<a class="project-board-title" href="{{$.RepoLink}}/{{if .Issue.IsPull}}pulls{{else}}issues{{end}}/{{.IssueID}}" data-url="{{$.RepoLink}}/{{if .Issue.IsPull}}pulls{{else}}issues{{end}}/{{.IssueID}}/sidebar/true">#{{.IssueID}} {{.Issue.Title}}</a>
158160
</div>
159161
<div class="meta">
160162
{{ if .Issue.MilestoneID }}

web_src/js/index.js

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ function updateIssuesMeta(url, action, issueIds, elementId) {
185185
id: elementId,
186186
},
187187
success: resolve
188+
}).done(data => {
189+
console.log('done', data);
190+
console.log(url, action, issueIds, elementId, isAdd);
191+
let projectID = $('[data-project]').data('project');
192+
193+
if (projectID === elementId) {
194+
console.log('same project, don\'t remove!');
195+
} else {
196+
$(`.board-card[data-issueid=${elementId}]`).remove();
197+
console.log('different project, please remove!');
198+
}
188199
});
189200
}));
190201
}
@@ -334,7 +345,76 @@ async function uploadFile(file) {
334345
}
335346

336347
function reload() {
337-
window.location.reload();
348+
if ($("#current-card-details").length > 0) {
349+
reloadIssuesActions();
350+
} else {
351+
window.location.reload();
352+
}
353+
}
354+
355+
function reloadIssuesActions(data) {
356+
if ($('#current-card-details').length === 0) {
357+
window.location.reload();
358+
}
359+
if (!data || !data.url) {
360+
data = $('body').data();
361+
if (!data.url) {
362+
data.url = window.location.href + '/sidebar/true';
363+
}
364+
} else {
365+
$('body').data('url', data.url);
366+
}
367+
fetch(data.url, {
368+
method: 'GET',
369+
headers: { 'X-Csrf-Token': csrf, 'Content-Type': 'text/html' }
370+
})
371+
.then(function(res) {
372+
return res.text();
373+
})
374+
375+
.then(function(html) {
376+
$('#current-card-details').html(html);
377+
$('#current-card-details').removeClass('hide');
378+
initCommentForm(true);
379+
initIssueList();
380+
initAjaxForms('#subscribe-repo');
381+
initAjaxForms('#toggle_stopwatch_form');
382+
initAjaxForms('#cancel_stopwatch_form');
383+
initAjaxForms('#add_time_manual_form');
384+
initAjaxForms('#addDependencyForm');
385+
initAjaxForms('#lock-form');
386+
initAjaxForms('#removeDependencyForm');
387+
$('#lock-dropdown').dropdown('show');
388+
$('#lock').modal('hide');
389+
$('.show-modal.button').on('click', function() {
390+
$($(this).data('modal')).modal('show');
391+
});
392+
});
393+
}
394+
395+
//subscribe-repo
396+
//toggle_stopwatch_form"
397+
//cancel_stopwatch_form"
398+
//add_time_manual_form
399+
//addDependencyForm
400+
function initAjaxForms(formId) {
401+
$(formId).submit(function(e) {
402+
e.preventDefault(); // avoid to execute the actual submit of the form.
403+
404+
var form = $(this);
405+
var url = form.attr("action");
406+
407+
$.ajax({
408+
type: "POST",
409+
url: url,
410+
data: form.serialize(), // serializes the form's elements.
411+
success: function(data) {
412+
$("#lock").modal("hide");
413+
$("#lock").remove();
414+
reloadIssuesActions();
415+
}
416+
});
417+
});
338418
}
339419

340420
function initImagePaste(target) {
@@ -368,15 +448,19 @@ function initSimpleMDEImagePaste(simplemde, files) {
368448

369449
let autoSimpleMDE;
370450

371-
function initCommentForm() {
372-
if ($('.comment.form').length === 0) {
373-
return;
374-
}
451+
function initCommentForm(skipCommentForm) {
452+
if (!skipCommentForm) {
453+
if ($('.comment.form').length === 0) {
454+
return;
455+
}
375456

376-
autoSimpleMDE = setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)'));
457+
autoSimpleMDE = setCommentSimpleMDE(
458+
$('.comment.form textarea:not(.review-textarea)')
459+
);
460+
initCommentPreviewTab($('.comment.form'));
461+
initImagePaste($('.comment.form textarea'));
462+
}
377463
initBranchSelector();
378-
initCommentPreviewTab($('.comment.form'));
379-
initImagePaste($('.comment.form textarea'));
380464

381465
// Listsubmit
382466
function initListSubmits(selector, outerSelector) {
@@ -400,7 +484,7 @@ function initCommentForm() {
400484
);
401485
promises.push(promise);
402486
});
403-
Promise.all(promises).then(reload);
487+
Promise.all(promises).then(reloadIssuesActions);
404488
}
405489
});
406490

@@ -493,10 +577,12 @@ function initCommentForm() {
493577
}
494578

495579
// Init labels and assignees
496-
initListSubmits('select-label', 'labels');
497-
initListSubmits('select-assignees', 'assignees');
498-
initListSubmits('select-assignees-modify', 'assignees');
499-
initListSubmits('select-reviewers-modify', 'assignees');
580+
initListSubmits("select-label", "labels");
581+
initListSubmits("select-milestone", "milestone");
582+
initListSubmits("select-project", "project");
583+
initListSubmits("select-assignees", "assignees");
584+
initListSubmits("select-assignees-modify", "assignees");
585+
initListSubmits("select-reviewers-modify", "assignees");
500586

501587
function selectItem(select_id, input_id) {
502588
const $menu = $(`${select_id} .menu`);
@@ -739,6 +825,12 @@ function initArchiveLinks() {
739825
}
740826

741827
async function initRepository() {
828+
$('body').keyup(e => {
829+
if (e.keyCode === 27) {
830+
$('#current-card-details').hide();
831+
}
832+
});
833+
742834
if ($('.repository').length === 0) {
743835
return;
744836
}
@@ -2310,6 +2402,15 @@ function initTemplateSearch() {
23102402
}
23112403

23122404
$(document).ready(async () => {
2405+
// Show issue or pr in board sidebar
2406+
$('.draggable-cards [data-url]').on("click", e => {
2407+
e.preventDefault();
2408+
let data = $(e.currentTarget).data();
2409+
$('#current-card-details').css('visibility', 'visible');
2410+
$('#current-card-details').show();
2411+
reloadIssuesActions(data);
2412+
});
2413+
23132414
// Show exact time
23142415
$('.time-since').each(function () {
23152416
$(this)

web_src/less/_repository.less

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,3 +3356,25 @@ td.blob-excerpt {
33563356
.migrate .cards .card {
33573357
text-align: center;
33583358
}
3359+
3360+
#current-card-details {
3361+
visibility: hidden;
3362+
position: absolute;
3363+
right: 0px;
3364+
background-color: #fff;
3365+
width: 200px;
3366+
overflow-y: scroll;
3367+
white-space: normal;
3368+
white-space: initial;
3369+
z-index: 100;
3370+
width: 280px;
3371+
margin: 0 0.5rem !important;
3372+
padding: 0.5rem !important;
3373+
width: 320px;
3374+
height: 60vh;
3375+
overflow-y: scroll;
3376+
flex: 0 0 auto;
3377+
overflow: scroll;
3378+
display: flex;
3379+
flex-direction: column;
3380+
}

0 commit comments

Comments
 (0)