blob: 6482eda828caf0f8675fbd2baa6fbf5c11bd5ff5 (
plain)
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
|
class List {
constructor (obj) {
this.id = obj.id;
this.position = obj.position;
this.title = obj.title;
this.type = obj.list_type;
this.issues = [];
if (obj.label) {
this.label = new Label(obj.label);
}
if (this.type !== 'blank') {
this.loading = true;
service.getIssuesForList(this.id)
.then((resp) => {
const data = resp.json();
this.loading = false;
data.forEach((issue) => {
this.issues.push(new Issue(issue));
});
});
}
}
save () {
service.createList(this.label.id)
.then((resp) => {
const data = resp.json();
this.id = data.id;
this.type = data.list_type;
this.position = data.position;
});
}
destroy () {
service.destroyList(this.id);
}
update () {
service.updateList(this);
}
canSearch () {
return this.type === 'backlog';
}
addIssue (issue, listFrom) {
this.issues.push(issue);
issue.addLabel(this.label);
service.moveIssue(issue.id, listFrom.id, this.id);
}
findIssue (id) {
return _.find(this.issues, (issue) => {
return issue.id === id;
});
}
removeIssue (removeIssue, listLabels) {
this.issues = _.reject(this.issues, (issue) => {
const matchesRemove = removeIssue.id === issue.id;
if (matchesRemove) {
if (typeof listLabels !== 'undefined') {
listLabels.forEach((listLabel) => {
issue.removeLabel(listLabel);
});
} else {
issue.removeLabel(this.label);
}
}
return matchesRemove;
});
}
}
|