Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
99915931
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
99915931
编写于
8月 01, 2016
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved data holding into models
上级
da64959b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
169 addition
and
85 deletion
+169
-85
app/assets/javascripts/boards/boards_bundle.js.es6
app/assets/javascripts/boards/boards_bundle.js.es6
+3
-2
app/assets/javascripts/boards/components/board.js.es6
app/assets/javascripts/boards/components/board.js.es6
+1
-1
app/assets/javascripts/boards/components/board_delete.js.es6
app/assets/javascripts/boards/components/board_delete.js.es6
+1
-1
app/assets/javascripts/boards/components/board_list.js.es6
app/assets/javascripts/boards/components/board_list.js.es6
+5
-5
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
...ts/javascripts/boards/components/new_list_dropdown.js.es6
+32
-0
app/assets/javascripts/boards/models/issue.js.es6
app/assets/javascripts/boards/models/issue.js.es6
+35
-0
app/assets/javascripts/boards/models/label.js.es6
app/assets/javascripts/boards/models/label.js.es6
+7
-0
app/assets/javascripts/boards/models/list.js.es6
app/assets/javascripts/boards/models/list.js.es6
+49
-0
app/assets/javascripts/boards/stores/boards_store.js.es6
app/assets/javascripts/boards/stores/boards_store.js.es6
+35
-75
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-1
未找到文件。
app/assets/javascripts/boards/boards_bundle.js.es6
浏览文件 @
99915931
//= require vue
//= require vue-resource
//= require Sortable
//= require_tree ./models
//= require_tree ./stores
//= require_tree ./services
//= require_tree ./components
...
...
@@ -16,8 +17,8 @@ $(function () {
ready: function () {
service.all()
.then((resp) => {
resp.
data
.forEach((board) => {
BoardsStore.
state.lists.push
(board);
resp.
json()
.forEach((board) => {
BoardsStore.
new
(board);
});
});
}
...
...
app/assets/javascripts/boards/components/board.js.es6
浏览文件 @
99915931
...
...
@@ -27,7 +27,7 @@
fallbackClass: 'is-dragging',
ghostClass: 'is-ghost',
onUpdate: function (e) {
BoardsStore.move
Board
(e.oldIndex + 1, e.newIndex + 1);
BoardsStore.move
List
(e.oldIndex + 1, e.newIndex + 1);
}
});
},
...
...
app/assets/javascripts/boards/components/board_delete.js.es6
浏览文件 @
99915931
...
...
@@ -8,7 +8,7 @@
$(this.$el).tooltip('destroy');
if (confirm('Are you sure you want to delete this list?')) {
BoardsStore.remove
Board
(this.boardId);
BoardsStore.remove
List
(this.boardId);
}
}
}
...
...
app/assets/javascripts/boards/components/board_list.js.es6
浏览文件 @
99915931
...
...
@@ -62,13 +62,13 @@
fallbackClass: 'is-dragging',
ghostClass: 'is-ghost',
onAdd: (e) => {
let from
Board
Id = e.from.getAttribute('data-board');
from
BoardId = parseInt(fromBoardId) || fromBoard
Id;
let to
Board
Id = e.to.getAttribute('data-board');
to
BoardId = parseInt(toBoardId) || toBoard
Id;
let from
List
Id = e.from.getAttribute('data-board');
from
ListId = parseInt(fromListId) || fromList
Id;
let to
List
Id = e.to.getAttribute('data-board');
to
ListId = parseInt(toListId) || toList
Id;
const issueId = parseInt(e.item.getAttribute('data-issue'));
BoardsStore.moveCardTo
Board(fromBoardId, toBoard
Id, issueId, e.newIndex);
BoardsStore.moveCardTo
List(fromListId, toList
Id, issueId, e.newIndex);
},
onUpdate: (e) => {
console.log(e.newIndex, e.oldIndex);
...
...
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
0 → 100644
浏览文件 @
99915931
$(() => {
$('.js-new-board-list').each(function () {
const $this = $(this);
$this.glDropdown({
data: function(term, callback) {
$.ajax({
url: $this.attr('data-labels')
}).then((resp) => {
callback(resp);
});
},
renderRow: (label) => {
const $li = $('<li />'),
$a = $('<a />', {
text: label.title,
href: '#'
}),
$labelColor = $('<span />', {
class: 'dropdown-label-box',
style: `background-color: ${label.color}`
});
return $li.append($a.prepend($labelColor));
},
selectable: true,
clicked: (label, $el, e) => {
e.preventDefault();
}
});
});
});
app/assets/javascripts/boards/models/issue.js.es6
0 → 100644
浏览文件 @
99915931
class Issue {
constructor (obj) {
this.id = obj.id;
this.title = obj.title;
this.labels = [];
obj.labels.forEach((label) => {
this.labels.push(new Label(label));
});
}
addLabel (label) {
if (label) {
const hasLabel = this.findLabel(label);
if (!hasLabel) {
this.labels.push(new Label(label));
}
}
}
findLabel (findLabel) {
return _.find(this.labels, (label) => {
return label.title === findLabel.title;
});
}
removeLabel (removeLabel) {
if (removeLabel) {
this.labels = _.reject(this.labels, (label) => {
return removeLabel.title === label.title;
});
}
}
}
app/assets/javascripts/boards/models/label.js.es6
0 → 100644
浏览文件 @
99915931
class Label {
constructor (obj) {
this.title = obj.title;
this.backgroundColor = obj.backgroundColor;
this.textColor = obj.textColor;
}
}
app/assets/javascripts/boards/models/list.js.es6
0 → 100644
浏览文件 @
99915931
class List {
constructor (obj) {
this.id = obj.id;
this.index = obj.index;
this.search = obj.search || false;
this.title = obj.title;
if (obj.label) {
this.label = new Label(obj.label);
}
if (obj.issues) {
this.issues = [];
obj.issues.forEach((issue) => {
this.issues.push(new Issue(issue));
});
}
}
addIssue (issue, index) {
this.issues.splice(index, 0, issue);
issue.addLabel(this.label);
}
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;
});
}
}
app/assets/javascripts/boards/stores/boards_store.js.es6
浏览文件 @
99915931
...
...
@@ -9,103 +9,63 @@
milestone: {},
}
},
removeBoard: (id) => {
BoardsStore.state.lists = _.reject(BoardsStore.state.lists, (board) => {
return board.id === id;
new: function (board) {
const list = new List(board);
this.state.lists.push(list);
},
removeList: function (id) {
this.state.lists = _.reject(this.state.lists, (list) => {
return list.id === id;
});
},
move
Board: (oldIndex, newIndex) =>
{
const
boardFrom = _.find(BoardsStore.state.lists, (board
) => {
return
board
.index === oldIndex;
move
List: function (oldIndex, newIndex)
{
const
listFrom = _.find(this.state.lists, (list
) => {
return
list
.index === oldIndex;
});
service.updateBoard(
board
From.id, newIndex);
service.updateBoard(
list
From.id, newIndex);
const
boardTo = _.find(BoardsStore.state.lists, (board
) => {
return
board
.index === newIndex;
const
listTo = _.find(this.state.lists, (list
) => {
return
list
.index === newIndex;
});
board
From.index = newIndex;
if (newIndex >
board
To.index) {
board
To.index--;
list
From.index = newIndex;
if (newIndex >
list
To.index) {
list
To.index--;
} else {
board
To.index++;
list
To.index++;
}
},
moveCardToBoard: (boardFromId, boardToId, issueId, toIndex) => {
const boardFrom = _.find(BoardsStore.state.lists, (board) => {
return board.id === boardFromId;
});
const boardTo = _.find(BoardsStore.state.lists, (board) => {
return board.id === boardToId;
});
let issue = _.find(boardFrom.issues, (issue) => {
return issue.id === issueId;
moveCardToList: function (listFromId, listToId, issueId, toIndex) {
const listFrom = _.find(this.state.lists, (list) => {
return list.id === listFromId;
});
const issueTo = _.find(boardTo.issues, (issue) => {
return issue.id === issueId;
});
const issueBoards = BoardsStore.getBoardsForIssue(issue);
// Remove the issue from old board
boardFrom.issues = _.reject(boardFrom.issues, (issue) => {
return issue.id === issueId;
const listTo = _.find(this.state.lists, (list) => {
return list.id === listToId;
});
const issueTo = listTo.findIssue(issueId);
let issue = listFrom.findIssue(issueId);
const issueLists = this.getListsForIssue(issue);
listFrom.removeIssue(issue);
// Add to new boards issues if it doesn't already exist
if (issueTo) {
issue = issueTo;
issue.removeLabel(listFrom.label);
} else {
boardTo.issues.splice(toIndex, 0, issue
);
listTo.addIssue(issue, toIndex
);
}
if (
boardTo.id === 'done' && board
From.id !== 'backlog') {
BoardsStore.removeIssueFromBoards(issue, issueBoards);
issue.labels = _.reject(issue.labels, (label) => {
return label.title === boardFrom.title
;
if (
listTo.id === 'done' && list
From.id !== 'backlog') {
issueLists.forEach((list) => {
issue.removeLabel(list.label);
list.removeIssue(issue)
;
});
} else {
if (boardTo.label) {
if (boardFrom.id !== 'backlog') {
BoardsStore.removeIssueFromBoard(issue, boardFrom);
}
foundLabel = _.find(issue.labels, (label) => {
return label.title === boardTo.title;
});
if (!foundLabel) {
issue.labels.push(boardTo.label);
}
}
}
},
removeIssueFromBoards: (issue, boards) => {
const boardLabels = _.map(boards, (board) => {
return board.title;
});
boards.issues = _.each(boards, (board) => {
board.issues = _.reject(board.issues, (boardIssue) => {
return issue.id === boardIssue.id;
});
});
issue.labels = _.reject(issue.labels, (label) => {
return boardLabels.indexOf(label.title) !== -1;
});
},
removeIssueFromBoard: (issue, board) => {
issue.labels = _.reject(issue.labels, (label) => {
return label.title === board.title;
});
},
getBoardsForIssue: (issue) => {
return _.filter(BoardsStore.state.lists, (board) => {
const foundIssue = _.find(board.issues, (boardIssue) => {
return issue.id === boardIssue.id;
});
return foundIssue;
getListsForIssue: function (issue) {
return _.filter(this.state.lists, (list) => {
return list.findIssue(issue.id);
});
},
clearDone: () => {
...
...
app/views/shared/issuable/_filter.html.haml
浏览文件 @
99915931
...
...
@@ -31,7 +31,7 @@
=
render
'shared/sort_dropdown'
-
else
.dropdown
%button
.btn.btn-create
{
type:
"button"
,
data:
{
toggle:
"dropdown"
}
}
%button
.btn.btn-create
.js-new-board-list
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
labels:
labels_filter_path
}
}
Create new list
.dropdown-menu.dropdown-menu-paging.dropdown-menu-align-right.dropdown-menu-issues-board-new
=
dropdown_title
(
"Create a new list"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录