Skip to content

Commit 7fda109

Browse files
authored
Drag-and-drop improvements for projects and issue pins (#29875)
1. Add "grabbing" cursor while dragging items: ![](https://github.com/go-gitea/gitea/assets/115237/c60845ff-7544-4215-aeaa-408e8c4ef03a) 2. Make project board only drag via their header, not via their whole body. ![](https://github.com/go-gitea/gitea/assets/115237/62c27f3d-993a-481d-9cc3-b6226b4c5d61) 3. Fix some cursor problems in projects 4. Move shared options into `createSortable`.
1 parent b08c7af commit 7fda109

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

templates/projects/view.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<div class="board {{if .CanWriteProjects}}sortable{{end}}">
6868
{{range .Columns}}
6969
<div class="ui segment project-column" style="background: {{.Color}} !important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}">
70-
<div class="project-column-header">
70+
<div class="project-column-header{{if $canWriteProject}} tw-cursor-grab{{end}}">
7171
<div class="ui large label project-column-title tw-py-1">
7272
<div class="ui small circular grey label project-column-issue-count">
7373
{{.NumIssues ctx}}
@@ -156,7 +156,7 @@
156156

157157
<div class="divider"></div>
158158

159-
<div class="ui cards{{if $canWriteProject}} tw-cursor-grab{{end}}" data-url="{{$.Link}}/{{.ID}}" data-project="{{$.Project.ID}}" data-board="{{.ID}}" id="board_{{.ID}}">
159+
<div class="ui cards" data-url="{{$.Link}}/{{.ID}}" data-project="{{$.Project.ID}}" data-board="{{.ID}}" id="board_{{.ID}}">
160160
{{range (index $.IssuesMap .ID)}}
161161
<div class="issue-card gt-word-break {{if $canWriteProject}}tw-cursor-grab{{end}}" data-issue="{{.ID}}">
162162
{{template "repo/issue/card" (dict "Issue" . "Page" $)}}

web_src/css/features/projects.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
overflow: visible;
2020
display: flex;
2121
flex-direction: column;
22+
cursor: default;
2223
}
2324

2425
.project-column-header {
@@ -46,6 +47,7 @@
4647
.project-column-title {
4748
background: none !important;
4849
line-height: 1.25 !important;
50+
cursor: inherit;
4951
}
5052

5153
.project-column > .cards {
@@ -92,6 +94,7 @@
9294
}
9395

9496
.card-ghost {
97+
border-color: var(--color-secondary-dark-4) !important;
9598
border-style: dashed !important;
9699
background: none !important;
97100
}

web_src/css/repo/issue-card.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
font-size: 14px;
2020
margin-left: 4px;
2121
}
22+
23+
.issue-card.sortable-chosen .issue-card-title {
24+
cursor: inherit;
25+
}

web_src/js/features/repo-issue-list.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ async function initIssuePinSort() {
188188

189189
createSortable(pinDiv, {
190190
group: 'shared',
191-
animation: 150,
192-
ghostClass: 'card-ghost',
193191
onEnd: pinMoveEnd,
194192
});
195193
}

web_src/js/features/repo-projects.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ async function initRepoProjectSortable() {
5858
createSortable(mainBoard, {
5959
group: 'project-column',
6060
draggable: '.project-column',
61-
animation: 150,
62-
ghostClass: 'card-ghost',
61+
handle: '.project-column-header',
6362
delayOnTouchOnly: true,
6463
delay: 500,
6564
onSort: async () => {
@@ -86,8 +85,6 @@ async function initRepoProjectSortable() {
8685
const boardCardList = boardColumn.getElementsByClassName('cards')[0];
8786
createSortable(boardCardList, {
8887
group: 'shared',
89-
animation: 150,
90-
ghostClass: 'card-ghost',
9188
onAdd: moveIssue,
9289
onUpdate: moveIssue,
9390
delayOnTouchOnly: true,

web_src/js/modules/sortable.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
export async function createSortable(...args) {
1+
export async function createSortable(el, opts = {}) {
22
const {Sortable} = await import(/* webpackChunkName: "sortablejs" */'sortablejs');
3-
return new Sortable(...args);
3+
4+
return new Sortable(el, {
5+
animation: 150,
6+
ghostClass: 'card-ghost',
7+
onChoose: (e) => {
8+
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
9+
handle.classList.add('tw-cursor-grabbing');
10+
opts.onChoose?.(e);
11+
},
12+
onUnchoose: (e) => {
13+
const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
14+
handle.classList.remove('tw-cursor-grabbing');
15+
opts.onUnchoose?.(e);
16+
},
17+
...opts,
18+
});
419
}

0 commit comments

Comments
 (0)