Moved some code over to underscorejs
This commit is contained in:
parent
1de6467571
commit
ff5fd4eb01
|
@ -35,10 +35,11 @@
|
|||
},
|
||||
},
|
||||
ready: function () {
|
||||
const list = this.list;
|
||||
const options = _.extend({
|
||||
group: 'issues',
|
||||
disabled: this.disabled,
|
||||
onAdd: function (e) {
|
||||
onAdd: (e) => {
|
||||
const fromListId = parseInt(e.from.getAttribute('data-board')),
|
||||
toListId = parseInt(e.to.getAttribute('data-board')),
|
||||
issueId = parseInt(e.item.getAttribute('data-issue'));
|
||||
|
|
|
@ -39,9 +39,7 @@ class Issue {
|
|||
}
|
||||
|
||||
removeLabels (labels) {
|
||||
labels.forEach((label) => {
|
||||
this.removeLabel(label);
|
||||
});
|
||||
_.each(labels, this.removeLabel.bind(this));
|
||||
}
|
||||
|
||||
getLists () {
|
||||
|
|
|
@ -19,7 +19,7 @@ class List {
|
|||
}
|
||||
|
||||
save () {
|
||||
gl.boardService.createList(this.label.id)
|
||||
return gl.boardService.createList(this.label.id)
|
||||
.then((resp) => {
|
||||
const data = resp.json();
|
||||
|
||||
|
@ -27,7 +27,7 @@ class List {
|
|||
this.type = data.list_type;
|
||||
this.position = data.position;
|
||||
|
||||
this.getIssues();
|
||||
return this.getIssues();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class List {
|
|||
}
|
||||
|
||||
createIssues (data) {
|
||||
data.forEach((issue) => {
|
||||
_.each(data, (issue) => {
|
||||
this.issues.push(new Issue(issue));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,12 +12,19 @@
|
|||
};
|
||||
},
|
||||
new: function (board, persist = true) {
|
||||
const doneList = this.getDoneList(),
|
||||
const doneList = this.findList('type', 'done'),
|
||||
backlogList = this.findList('type', 'backlog'),
|
||||
list = new List(board);
|
||||
this.state.lists.push(list);
|
||||
|
||||
if (persist) {
|
||||
list.save();
|
||||
list
|
||||
.save()
|
||||
.then(function () {
|
||||
// Remove any new issues from the backlog
|
||||
// as they will be visible in the new list
|
||||
_.each(list.issues, backlogList.removeIssue.bind(backlogList));
|
||||
});
|
||||
this.removeBlankState();
|
||||
}
|
||||
|
||||
|
@ -29,15 +36,10 @@
|
|||
},
|
||||
shouldAddBlankState: function () {
|
||||
// Decide whether to add the blank state
|
||||
let addBlankState = true;
|
||||
|
||||
this.state.lists.forEach(function (list) {
|
||||
if (list.type !== 'backlog' && list.type !== 'done') {
|
||||
addBlankState = false;
|
||||
return;
|
||||
}
|
||||
let addBlankState = _.find(this.state.lists, function (list) {
|
||||
return list.type === 'backlog' || list.type === 'done';
|
||||
});
|
||||
return addBlankState;
|
||||
return !addBlankState;
|
||||
},
|
||||
addBlankState: function () {
|
||||
const addBlankState = this.shouldAddBlankState();
|
||||
|
@ -65,9 +67,6 @@
|
|||
welcomeIsHidden: function () {
|
||||
return $.cookie('issue_board_welcome_hidden') === 'true';
|
||||
},
|
||||
getDoneList: function () {
|
||||
return this.findList('type', 'done');
|
||||
},
|
||||
removeList: function (id) {
|
||||
const list = this.findList('id', id);
|
||||
|
||||
|
@ -75,7 +74,7 @@
|
|||
|
||||
list.destroy();
|
||||
|
||||
this.state.lists = _.reject(this.state.lists, (list) => {
|
||||
this.state.lists = _.reject(this.state.lists, function (list) {
|
||||
return list.id === id;
|
||||
});
|
||||
|
||||
|
@ -83,7 +82,7 @@
|
|||
},
|
||||
moveList: function (oldIndex, newIndex) {
|
||||
if (oldIndex === newIndex) return;
|
||||
|
||||
|
||||
const listFrom = this.findList('position', oldIndex),
|
||||
listTo = this.findList('position', newIndex);
|
||||
|
||||
|
@ -101,9 +100,9 @@
|
|||
moveCardToList: function (listFromId, listToId, issueId) {
|
||||
const listFrom = this.findList('id', listFromId),
|
||||
listTo = this.findList('id', listToId),
|
||||
issueTo = listTo.findIssue(issueId);
|
||||
let issue = listFrom.findIssue(issueId);
|
||||
const issueLists = issue.getLists(),
|
||||
issueTo = listTo.findIssue(issueId),
|
||||
issue = listFrom.findIssue(issueId),
|
||||
issueLists = issue.getLists(),
|
||||
listLabels = issueLists.map(function (issue) {
|
||||
return issue.label;
|
||||
});
|
||||
|
@ -114,9 +113,7 @@
|
|||
}
|
||||
|
||||
if (listTo.type === 'done' && listFrom.type !== 'backlog') {
|
||||
issueLists.forEach((list) => {
|
||||
list.removeIssue(issue);
|
||||
});
|
||||
_.each(issueLists, list.removeIssue.bind(list));
|
||||
issue.removeLabels(listLabels);
|
||||
} else {
|
||||
listFrom.removeIssue(issue);
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
overflow-x: scroll;
|
||||
|
||||
@media (min-width: $screen-sm-min) {
|
||||
min-height: 470px;
|
||||
max-height: 470px;
|
||||
min-height: 475px;
|
||||
max-height: 475px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue