Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
0b351d55
Commit
0b351d55
authored
Aug 05, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some code around to make it easier to read & work with
parent
db2eabfd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
63 deletions
+55
-63
app/assets/javascripts/boards/boards_bundle.js.es6
app/assets/javascripts/boards/boards_bundle.js.es6
+1
-3
app/assets/javascripts/boards/components/board_list.js.es6
app/assets/javascripts/boards/components/board_list.js.es6
+1
-1
app/assets/javascripts/boards/models/issue.js.es6
app/assets/javascripts/boards/models/issue.js.es6
+7
-1
app/assets/javascripts/boards/models/list.js.es6
app/assets/javascripts/boards/models/list.js.es6
+15
-2
app/assets/javascripts/boards/stores/boards_store.js.es6
app/assets/javascripts/boards/stores/boards_store.js.es6
+27
-49
app/assets/stylesheets/pages/boards.scss
app/assets/stylesheets/pages/boards.scss
+0
-5
app/views/projects/boards/components/_board.html.haml
app/views/projects/boards/components/_board.html.haml
+3
-1
app/views/projects/boards/components/_card.html.haml
app/views/projects/boards/components/_card.html.haml
+1
-1
No files found.
app/assets/javascripts/boards/boards_bundle.js.es6
View file @
0b351d55
...
@@ -20,13 +20,11 @@ $(function () {
...
@@ -20,13 +20,11 @@ $(function () {
const boards = resp.json();
const boards = resp.json();
boards.forEach((board) => {
boards.forEach((board) => {
const list =
new List(board
);
const list =
BoardsStore.new(board, false
);
if (list.type === 'done') {
if (list.type === 'done') {
list.position = 9999999;
list.position = 9999999;
}
}
BoardsStore.state.lists.push(list);
});
});
BoardsStore.addBlankState();
BoardsStore.addBlankState();
...
...
app/assets/javascripts/boards/components/board_list.js.es6
View file @
0b351d55
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
toListId = parseInt(toListId) || toListId;
toListId = parseInt(toListId) || toListId;
const issueId = parseInt(e.item.getAttribute('data-issue'));
const issueId = parseInt(e.item.getAttribute('data-issue'));
BoardsStore.moveCardToList(fromListId, toListId, issueId
, e.newIndex
);
BoardsStore.moveCardToList(fromListId, toListId, issueId);
}
}
});
});
...
...
app/assets/javascripts/boards/models/issue.js.es6
View file @
0b351d55
...
@@ -6,7 +6,7 @@ class Issue {
...
@@ -6,7 +6,7 @@ class Issue {
if (obj.assignee) {
if (obj.assignee) {
this.assignee = new User(obj.assignee);
this.assignee = new User(obj.assignee);
}
}
this.labels = [];
this.labels = [];
obj.labels.forEach((label) => {
obj.labels.forEach((label) => {
...
@@ -37,4 +37,10 @@ class Issue {
...
@@ -37,4 +37,10 @@ class Issue {
});
});
}
}
}
}
getLists () {
return _.filter(BoardsStore.state.lists, (list) => {
return list.findIssue(this.id);
});
}
}
}
app/assets/javascripts/boards/models/list.js.es6
View file @
0b351d55
...
@@ -24,6 +24,17 @@ class List {
...
@@ -24,6 +24,17 @@ class List {
}
}
}
}
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 () {
destroy () {
service.destroyList(this.id);
service.destroyList(this.id);
}
}
...
@@ -36,10 +47,12 @@ class List {
...
@@ -36,10 +47,12 @@ class List {
return this.type === 'backlog';
return this.type === 'backlog';
}
}
addIssue (issue,
index
) {
addIssue (issue,
listFrom
) {
this.issues.
splice(index, 0,
issue);
this.issues.
push(
issue);
issue.addLabel(this.label);
issue.addLabel(this.label);
service.moveIssue(issue.id, listFrom.id, this.id);
}
}
findIssue (id) {
findIssue (id) {
...
...
app/assets/javascripts/boards/stores/boards_store.js.es6
View file @
0b351d55
...
@@ -6,30 +6,23 @@
...
@@ -6,30 +6,23 @@
author: {},
author: {},
assignee: {},
assignee: {},
milestone: {},
milestone: {},
label: []
}
}
},
},
new: function (board) {
new: function (board
, persist = true
) {
const doneList = this.getDoneList(),
const doneList = this.getDoneList(),
list = new List(board);
list = new List(board);
this.state.lists.push(list);
this.state.lists.push(list);
if (list.type !== 'blank') {
if (persist) {
service.createList(list.label.id)
list.save();
.then(function (resp) {
const data = resp.json();
list.id = data.id;
list.type = data.list_type;
list.position = data.position;
});
this.removeBlankState();
this.removeBlankState();
this.addBlankState();
this.addBlankState();
}
}
},
addBlankState: function () {
const doneList = this.getDoneList();
return list;
},
shouldAddBlankState: function () {
// Decide whether to add the blank state
// Decide whether to add the blank state
let addBlankState = true;
let addBlankState = true;
...
@@ -39,6 +32,11 @@
...
@@ -39,6 +32,11 @@
return;
return;
}
}
});
});
return addBlankState;
},
addBlankState: function () {
const doneList = this.getDoneList(),
addBlankState = this.shouldAddBlankState();
if (addBlankState) {
if (addBlankState) {
this.new({
this.new({
...
@@ -46,21 +44,17 @@
...
@@ -46,21 +44,17 @@
list_type: 'blank',
list_type: 'blank',
title: 'Welcome to your Issue Board!',
title: 'Welcome to your Issue Board!',
position: 0
position: 0
});
}
, false
);
}
}
},
},
removeBlankState: function () {
removeBlankState: function () {
this.removeList('blank');
this.removeList('blank');
},
},
getDoneList: function () {
getDoneList: function () {
return _.find(this.state.lists, (list) => {
return this.findList('type', 'done');
return list.type === 'done';
});
},
},
removeList: function (id) {
removeList: function (id) {
const list = _.find(this.state.lists, (list) => {
const list = this.findList('id', id);
return list.id === id;
});
if (id !== 'blank') {
if (id !== 'blank') {
list.destroy();
list.destroy();
...
@@ -75,13 +69,8 @@
...
@@ -75,13 +69,8 @@
}
}
},
},
moveList: function (oldIndex, newIndex) {
moveList: function (oldIndex, newIndex) {
const listFrom = _.find(this.state.lists, (list) => {
const listFrom = this.findList('position', oldIndex),
return list.position === oldIndex;
istTo = this.findList('position', newIndex);
});
const listTo = _.find(this.state.lists, (list) => {
return list.position === newIndex;
});
listFrom.position = newIndex;
listFrom.position = newIndex;
if (newIndex > listTo.position) {
if (newIndex > listTo.position) {
...
@@ -92,42 +81,31 @@
...
@@ -92,42 +81,31 @@
listFrom.update();
listFrom.update();
},
},
moveCardToList: function (listFromId, listToId, issueId, toIndex) {
moveCardToList: function (listFromId, listToId, issueId) {
const listFrom = _.find(this.state.lists, (list) => {
const listFrom = this.findList('id', listFromId),
return list.id === listFromId;
listTo = this.findList('id', listToId),
});
issueTo = listTo.findIssue(issueId);
const listTo = _.find(this.state.lists, (list) => {
return list.id === listToId;
});
const issueTo = listTo.findIssue(issueId);
let issue = listFrom.findIssue(issueId);
let issue = listFrom.findIssue(issueId);
const issueLists =
this.getListsForIssue(issue
);
const issueLists =
issue.getLists(
);
listFrom.removeIssue(issue);
listFrom.removeIssue(issue);
// Add to new lists issues if it doesn't already exist
// Add to new lists issues if it doesn't already exist
if (issueTo) {
if (issueTo) {
issue = issueTo;
listTo.removeIssue(issueTo);
issue.removeLabel(listFrom.label);
} else {
} else {
listTo.addIssue(issue,
toIndex
);
listTo.addIssue(issue,
listFrom
);
}
}
if (listTo.id === 'done' && listFrom.id !== 'backlog') {
if (listTo.id === 'done' && listFrom.id !== 'backlog') {
issueLists.forEach((list) => {
issueLists.forEach((list) => {
issue.removeLabel(list.label);
list.removeIssue(issue);
list.removeIssue(issue);
});
});
}
}
service.moveIssue(issue.id, listFrom.id, listTo.id);
},
},
getListsForIssue: function (issue
) {
findList: function (key, val
) {
return _.fi
lter
(this.state.lists, (list) => {
return _.fi
nd
(this.state.lists, (list) => {
return list
.findIssue(issue.id)
;
return list
[key] === val
;
});
});
},
clearDone: function () {
Vue.set(BoardsStore.state, 'done', {});
}
}
};
};
}(window));
}(window));
app/assets/stylesheets/pages/boards.scss
View file @
0b351d55
...
@@ -237,8 +237,3 @@
...
@@ -237,8 +237,3 @@
margin-right
:
8px
;
margin-right
:
8px
;
font-weight
:
500
;
font-weight
:
500
;
}
}
.card-avatar
{
margin-top
:
-2px
;
border-radius
:
50%
;
}
app/views/projects/boards/components/_board.html.haml
View file @
0b351d55
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
":issue-link-base"
=>
"'#{namespace_project_issues_path(@project.namespace, @project)}'"
}
":issue-link-base"
=>
"'#{namespace_project_issues_path(@project.namespace, @project)}'"
}
.board-list-loading.text-center
{
"v-if"
=>
"loading"
}
.board-list-loading.text-center
{
"v-if"
=>
"loading"
}
=
icon
(
"spinner spin"
)
=
icon
(
"spinner spin"
)
%ul
.board-list
{
"v-el:list"
=>
true
,
":data-board"
=>
"boardId"
}
%ul
.board-list
{
"v-el:list"
=>
true
,
"v-show"
=>
"!loading"
,
":data-board"
=>
"boardId"
}
=
render
"projects/boards/components/card"
=
render
"projects/boards/components/card"
=
render
"projects/boards/components/blank_state"
=
render
"projects/boards/components/blank_state"
app/views/projects/boards/components/_card.html.haml
View file @
0b351d55
...
@@ -9,4 +9,4 @@
...
@@ -9,4 +9,4 @@
%span
.label.color-label
{
"v-for"
=>
"label in issue.labels"
,
":style"
=>
"{ backgroundColor: label.color, color: label.textColor }"
}
%span
.label.color-label
{
"v-for"
=>
"label in issue.labels"
,
":style"
=>
"{ backgroundColor: label.color, color: label.textColor }"
}
{{ label.title }}
{{ label.title }}
%a
{
":href"
=>
"'/u/' + issue.assignee.username"
,
":title"
=>
"issue.assignee.name"
,
"v-if"
=>
"issue.assignee"
}
%a
{
":href"
=>
"'/u/' + issue.assignee.username"
,
":title"
=>
"issue.assignee.name"
,
"v-if"
=>
"issue.assignee"
}
%img
.
card-avatar
{
":src"
=>
"issue.assignee.avatar"
,
width:
20
,
height:
20
}
%img
.
avatar.avatar-inline.s20
{
":src"
=>
"issue.assignee.avatar"
,
width:
20
,
height:
20
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment