1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
const {csrf} = window.config;
export default async function initProject() {
if (!window.config || !window.config.PageIsProjects) {
return;
}
const {Sortable} = await import(/* webpackChunkName: "sortable" */'sortablejs');
const boardColumns = document.getElementsByClassName('board-column');
for (const column of boardColumns) {
new Sortable(
column.getElementsByClassName('board')[0],
{
group: 'shared',
animation: 150,
onAdd: (e) => {
$.ajax(`${e.to.dataset.url}/${e.item.dataset.issue}`, {
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
},
contentType: 'application/json',
type: 'POST',
error: () => {
e.from.insertBefore(e.item, e.from.children[e.oldIndex]);
},
});
},
}
);
}
$('.edit-project-board').each(function () {
const projectTitleLabel = $(this).closest('.board-column-header').find('.board-label');
const projectTitleInput = $(this).find(
'.content > .form > .field > .project-board-title'
);
$(this)
.find('.content > .form > .actions > .red')
.on('click', function (e) {
e.preventDefault();
$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: projectTitleInput.val()}),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
},
contentType: 'application/json',
method: 'PUT',
}).done(() => {
projectTitleLabel.text(projectTitleInput.val());
projectTitleInput.closest('form').removeClass('dirty');
$('.ui.modal').modal('hide');
});
});
});
$('.delete-project-board').each(function () {
$(this).click(function (e) {
e.preventDefault();
$.ajax({
url: $(this).data('url'),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
},
contentType: 'application/json',
method: 'DELETE',
}).done(() => {
setTimeout(window.location.reload(true), 2000);
});
});
});
$('#new_board_submit').click(function (e) {
e.preventDefault();
const boardTitle = $('#new_board');
$.ajax({
url: $(this).data('url'),
data: JSON.stringify({title: boardTitle.val()}),
headers: {
'X-Csrf-Token': csrf,
'X-Remote': true,
},
contentType: 'application/json',
method: 'POST',
}).done(() => {
boardTitle.closest('form').removeClass('dirty');
setTimeout(window.location.reload(true), 2000);
});
});
}
|