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
Boxiang Sun
gitlab-ce
Commits
94f5d8a9
Commit
94f5d8a9
authored
Aug 17, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved code readability
parent
c7b0732c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
124 deletions
+57
-124
app/assets/javascripts/boards/components/board.js.es6
app/assets/javascripts/boards/components/board.js.es6
+2
-14
app/assets/javascripts/boards/components/board_blank_state.js.es6
...ts/javascripts/boards/components/board_blank_state.js.es6
+8
-16
app/assets/javascripts/boards/components/board_delete.js.es6
app/assets/javascripts/boards/components/board_delete.js.es6
+1
-2
app/assets/javascripts/boards/components/board_list.js.es6
app/assets/javascripts/boards/components/board_list.js.es6
+15
-28
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
...ts/javascripts/boards/components/new_list_dropdown.js.es6
+5
-6
app/assets/javascripts/boards/models/issue.js.es6
app/assets/javascripts/boards/models/issue.js.es6
+9
-26
app/assets/javascripts/boards/models/list.js.es6
app/assets/javascripts/boards/models/list.js.es6
+6
-12
app/assets/javascripts/boards/services/board_service.js.es6
app/assets/javascripts/boards/services/board_service.js.es6
+6
-15
app/views/projects/boards/components/_board.html.haml
app/views/projects/boards/components/_board.html.haml
+5
-5
No files found.
app/assets/javascripts/boards/components/board.js.es6
View file @
94f5d8a9
...
@@ -27,10 +27,8 @@
...
@@ -27,10 +27,8 @@
},
},
watch: {
watch: {
query () {
query () {
if (this.list.canSearch()) {
this.list.filters = this.getFilterData();
this.list.filters = this.getFilterData();
this.list.getIssues(true);
this.list.getIssues(true);
}
},
},
filters: {
filters: {
handler () {
handler () {
...
@@ -41,12 +39,7 @@
...
@@ -41,12 +39,7 @@
}
}
},
},
methods: {
methods: {
clearSearch () {
this.query = '';
},
getFilterData () {
getFilterData () {
if (!this.list.canSearch()) return this.filters;
const filters = this.filters;
const filters = this.filters;
let queryData = { search: this.query };
let queryData = { search: this.query };
...
@@ -55,11 +48,6 @@
...
@@ -55,11 +48,6 @@
return queryData;
return queryData;
}
}
},
},
computed: {
isPreset () {
return ['backlog', 'done', 'blank'].indexOf(this.list.type) > -1;
}
},
ready () {
ready () {
const options = gl.issueBoards.getBoardSortableDefaultOptions({
const options = gl.issueBoards.getBoardSortableDefaultOptions({
disabled: this.disabled,
disabled: this.disabled,
...
...
app/assets/javascripts/boards/components/board_blank_state.js.es6
View file @
94f5d8a9
...
@@ -17,11 +17,9 @@
...
@@ -17,11 +17,9 @@
},
},
methods: {
methods: {
addDefaultLists () {
addDefaultLists () {
Store.removeBlankState();
this.clearBlankState();
for (let i = 0, labelsLength = this.predefinedLabels.length; i < labelsLength; i++) {
const label = this.predefinedLabels[i];
this.predefinedLabels.forEach((label, i) => {
Store.addList({
Store.addList({
title: label.title,
title: label.title,
position: i,
position: i,
...
@@ -31,27 +29,21 @@
...
@@ -31,27 +29,21 @@
color: label.color
color: label.color
}
}
});
});
}
}
);
// Save the labels
// Save the labels
gl.boardService
gl.boardService.generateDefaultLists()
.generateDefaultLists()
.then((resp) => {
.then((resp) => {
const data = resp.json();
resp.json().forEach((listObj) => {
const list = Store.findList('title', listObj.title);
for (let i = 0, dataLength = data.length; i < dataLength; i++) {
const listObj = data[i],
list = Store.findList('title', listObj.title);
list.id = listObj.id;
list.id = listObj.id;
list.label.id = listObj.label.id;
list.label.id = listObj.label.id;
list.getIssues();
list.getIssues();
}
}
);
});
});
},
},
clearBlankState () {
clearBlankState: Store.removeBlankState.bind(Store)
Store.removeBlankState();
}
}
}
});
});
})();
})();
app/assets/javascripts/boards/components/board_delete.js.es6
View file @
94f5d8a9
...
@@ -7,8 +7,7 @@
...
@@ -7,8 +7,7 @@
list: Object
list: Object
},
},
methods: {
methods: {
deleteBoard (e) {
deleteBoard () {
e.stopImmediatePropagation();
$(this.$el).tooltip('hide');
$(this.$el).tooltip('hide');
if (confirm('Are you sure you want to delete this list?')) {
if (confirm('Are you sure you want to delete this list?')) {
...
...
app/assets/javascripts/boards/components/board_list.js.es6
View file @
94f5d8a9
...
@@ -65,20 +65,10 @@
...
@@ -65,20 +65,10 @@
Store.moving.list = card.list;
Store.moving.list = card.list;
},
},
onAdd: (e) => {
onAdd: (e) => {
const fromList = Store.moving.list,
gl.issueBoards.BoardsStore.moveIssueToList(Store.moving.list, this.list, Store.moving.issue);
issue = Store.moving.issue;
gl.issueBoards.BoardsStore.moveIssueToList(fromList, this.list, issue);
},
},
onRemove (e) {
onRemove: (e) => {
const card = e.item,
this.$refs.issue[e.oldIndex].$destroy(true);
list = Store.moving.list,
issue = Store.moving.issue;
// Remove the new dom element & let vue add the element
card.parentNode.removeChild(card);
list.removeIssue(issue);
}
}
});
});
...
@@ -94,9 +84,6 @@
...
@@ -94,9 +84,6 @@
this.loadNextPage();
this.loadNextPage();
}
}
};
};
},
beforeDestroy () {
this.sortable.destroy();
}
}
});
});
})();
})();
app/assets/javascripts/boards/components/new_list_dropdown.js.es6
View file @
94f5d8a9
...
@@ -8,15 +8,14 @@ $(() => {
...
@@ -8,15 +8,14 @@ $(() => {
$this.glDropdown({
$this.glDropdown({
data(term, callback) {
data(term, callback) {
$.ajax({
$.get($this.attr('data-labels'))
url: $this.attr('data-labels')
.then((resp) => {
}).then((resp) => {
callback(resp);
callback(resp);
});
});
},
},
renderRow (label) {
renderRow (label) {
const active = Store.findList('title', label.title),
const active = Store.findList('title', label.title),
$li = $('<li />'
,
),
$li = $('<li />'),
$a = $('<a />', {
$a = $('<a />', {
class: (active ? `is-active js-board-list-${active.id}` : ''),
class: (active ? `is-active js-board-list-${active.id}` : ''),
text: label.title,
text: label.title,
...
...
app/assets/javascripts/boards/models/issue.js.es6
View file @
94f5d8a9
...
@@ -3,17 +3,15 @@ class ListIssue {
...
@@ -3,17 +3,15 @@ class ListIssue {
this.id = obj.iid;
this.id = obj.iid;
this.title = obj.title;
this.title = obj.title;
this.confidential = obj.confidential;
this.confidential = obj.confidential;
this.labels = [];
if (obj.assignee) {
if (obj.assignee) {
this.assignee = new ListUser(obj.assignee);
this.assignee = new ListUser(obj.assignee);
}
}
this.labels = [];
obj.labels.forEach((label) => {
for (let i = 0, objLabelsLength = obj.labels.length; i < objLabelsLength; i++) {
const label = obj.labels[i];
this.labels.push(new ListLabel(label));
this.labels.push(new ListLabel(label));
}
}
);
this.priority = this.labels.reduce((max, label) => {
this.priority = this.labels.reduce((max, label) => {
return (label.priority < max) ? label.priority : max;
return (label.priority < max) ? label.priority : max;
...
@@ -21,39 +19,24 @@ class ListIssue {
...
@@ -21,39 +19,24 @@ class ListIssue {
}
}
addLabel (label) {
addLabel (label) {
if (label) {
if (!this.findLabel(label)) {
const hasLabel = this.findLabel(label);
if (!hasLabel) {
this.labels.push(new ListLabel(label));
this.labels.push(new ListLabel(label));
}
}
}
}
}
findLabel (findLabel) {
findLabel (findLabel) {
return this.labels.filter((label) => {
return this.labels.filter( label => label.title === findLabel.title )[0];
return label.title === findLabel.title;
})[0];
}
}
removeLabel (removeLabel) {
removeLabel (removeLabel) {
if (removeLabel) {
this.labels = this.labels.filter( label => removeLabel.title !== label.title );
this.labels = this.labels.filter((label) => {
return removeLabel.title !== label.title;
});
}
}
}
removeLabels (labels) {
removeLabels (labels) {
for (let i = 0, labelsLength = labels.length; i < labelsLength; i++) {
labels.forEach(this.removeLabel.bind(this));
const label = labels[i];
this.removeLabel(label);
}
}
}
getLists () {
getLists () {
return gl.issueBoards.BoardsStore.state.lists.filter((list) => {
return gl.issueBoards.BoardsStore.state.lists.filter( list => list.findIssue(this.id) );
return list.findIssue(this.id);
});
}
}
}
}
app/assets/javascripts/boards/models/list.js.es6
View file @
94f5d8a9
...
@@ -5,6 +5,7 @@ class List {
...
@@ -5,6 +5,7 @@ class List {
this.position = obj.position;
this.position = obj.position;
this.title = obj.title;
this.title = obj.title;
this.type = obj.list_type;
this.type = obj.list_type;
this.preset = ['backlog', 'done', 'blank'].indexOf(this.type) > -1;
this.filters = gl.issueBoards.BoardsStore.state.filters;
this.filters = gl.issueBoards.BoardsStore.state.filters;
this.page = 1;
this.page = 1;
this.loading = true;
this.loading = true;
...
@@ -21,9 +22,7 @@ class List {
...
@@ -21,9 +22,7 @@ class List {
}
}
guid() {
guid() {
const s4 = () => {
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
}
}
...
@@ -72,9 +71,7 @@ class List {
...
@@ -72,9 +71,7 @@ class List {
Object.keys(filters).forEach((key) => { data[key] = filters[key]; });
Object.keys(filters).forEach((key) => { data[key] = filters[key]; });
if (this.label) {
if (this.label) {
data.label_name = data.label_name.filter((label) => {
data.label_name = data.label_name.filter( label => label !== this.label.title );
return label !== this.label.title;
});
}
}
if (emptyIssues) {
if (emptyIssues) {
...
@@ -95,10 +92,9 @@ class List {
...
@@ -95,10 +92,9 @@ class List {
}
}
createIssues (data) {
createIssues (data) {
for (let i = 0, dataLength = data.length; i < dataLength; i++) {
data.forEach((issueObj) => {
const issueObj = data[i];
this.issues.push(new ListIssue(issueObj));
this.issues.push(new ListIssue(issueObj));
}
}
);
}
}
addIssue (issue, listFrom) {
addIssue (issue, listFrom) {
...
@@ -110,9 +106,7 @@ class List {
...
@@ -110,9 +106,7 @@ class List {
}
}
findIssue (id) {
findIssue (id) {
return this.issues.filter((issue) => {
return this.issues.filter( issue => issue.id === id )[0];
return issue.id === id;
})[0];
}
}
removeIssue (removeIssue) {
removeIssue (removeIssue) {
...
...
app/assets/javascripts/boards/services/board_service.js.es6
View file @
94f5d8a9
...
@@ -10,36 +10,30 @@ class BoardService {
...
@@ -10,36 +10,30 @@ class BoardService {
});
});
this.issue = Vue.resource(`${root}/issues{/id}`, {});
this.issue = Vue.resource(`${root}/issues{/id}`, {});
this.issues = Vue.resource(`${root}/lists{/id}/issues`, {});
this.issues = Vue.resource(`${root}/lists{/id}/issues`, {});
}
setCSRF () {
Vue.http.interceptors.push((request, next) => {
Vue.http.headers.common['X-CSRF-Token'] = $.rails.csrfToken();
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
next();
});
}
}
all () {
all () {
this.setCSRF();
return this.lists.get();
return this.lists.get();
}
}
generateDefaultLists () {
generateDefaultLists () {
this.setCSRF();
return this.lists.generate({});
return this.lists.generate({});
}
}
createList (labelId) {
createList (label_id) {
this.setCSRF();
return this.lists.save({}, {
return this.lists.save({}, {
list: {
list: {
label_id
: labelId
label_id
}
}
});
});
}
}
updateList (id, position) {
updateList (id, position) {
this.setCSRF();
return this.lists.update({ id }, {
return this.lists.update({ id }, {
list: {
list: {
position
position
...
@@ -48,15 +42,12 @@ class BoardService {
...
@@ -48,15 +42,12 @@ class BoardService {
}
}
destroyList (id) {
destroyList (id) {
this.setCSRF();
return this.lists.delete({ id });
return this.lists.delete({ id });
}
}
getIssuesForList (id, filter = {}) {
getIssuesForList (id, filter = {}) {
let data = { id };
let data = { id };
Object.keys(filter).forEach((key) => { data[key] = filter[key]; });
Object.keys(filter).forEach((key) => { data[key] = filter[key]; });
this.setCSRF();
return this.issues.get(data);
return this.issues.get(data);
}
}
...
...
app/views/projects/boards/components/_board.html.haml
View file @
94f5d8a9
...
@@ -6,26 +6,26 @@
...
@@ -6,26 +6,26 @@
":disabled"
=>
"disabled"
,
":disabled"
=>
"disabled"
,
":issue-link-base"
=>
"issueLinkBase"
,
":issue-link-base"
=>
"issueLinkBase"
,
"track-by"
=>
"_uid"
}
"track-by"
=>
"_uid"
}
.board
{
":class"
=>
"{ 'is-draggable': !
isP
reset }"
,
.board
{
":class"
=>
"{ 'is-draggable': !
list.p
reset }"
,
":data-id"
=>
"list.id"
}
":data-id"
=>
"list.id"
}
.board-inner
.board-inner
%header
.board-header
{
":class"
=>
"{ 'has-border': list.label }"
,
":style"
=>
"{ borderTopColor: (list.label ? list.label.color : null) }"
}
%header
.board-header
{
":class"
=>
"{ 'has-border': list.label }"
,
":style"
=>
"{ borderTopColor: (list.label ? list.label.color : null) }"
}
%h3
.board-title.js-board-handle
{
":class"
=>
"{ 'user-can-drag': (!disabled && !
isP
reset) }"
}
%h3
.board-title.js-board-handle
{
":class"
=>
"{ 'user-can-drag': (!disabled && !
list.p
reset) }"
}
=
icon
(
"align-justify"
,
class:
"board-mobile-handle js-board-drag-handle"
,
"v-if"
=>
"(!disabled && !
isP
reset)"
)
=
icon
(
"align-justify"
,
class:
"board-mobile-handle js-board-drag-handle"
,
"v-if"
=>
"(!disabled && !
list.p
reset)"
)
{{ list.title }}
{{ list.title }}
%span
.pull-right
{
"v-if"
=>
"list.type !== 'blank'"
}
%span
.pull-right
{
"v-if"
=>
"list.type !== 'blank'"
}
{{ list.issues.length }}
{{ list.issues.length }}
-
if
can?
(
current_user
,
:admin_list
,
@project
)
-
if
can?
(
current_user
,
:admin_list
,
@project
)
%board-delete
{
"inline-template"
=>
true
,
%board-delete
{
"inline-template"
=>
true
,
":list"
=>
"list"
,
":list"
=>
"list"
,
"v-if"
=>
"!
isP
reset && list.id"
}
"v-if"
=>
"!
list.p
reset && list.id"
}
%button
.board-delete.has-tooltip.pull-right
{
type:
"button"
,
title:
"Delete list"
,
"aria-label"
=>
"Delete list"
,
data:
{
placement:
"bottom"
},
"@click.stop"
=>
"deleteBoard"
}
%button
.board-delete.has-tooltip.pull-right
{
type:
"button"
,
title:
"Delete list"
,
"aria-label"
=>
"Delete list"
,
data:
{
placement:
"bottom"
},
"@click.stop"
=>
"deleteBoard"
}
=
icon
(
"trash"
)
=
icon
(
"trash"
)
=
icon
(
"spinner spin"
,
class:
"board-header-loading-spinner pull-right"
,
"v-show"
=>
"list.loadingMore"
)
=
icon
(
"spinner spin"
,
class:
"board-header-loading-spinner pull-right"
,
"v-show"
=>
"list.loadingMore"
)
.board-inner-container.board-search-container
{
"v-if"
=>
"list.canSearch()"
}
.board-inner-container.board-search-container
{
"v-if"
=>
"list.canSearch()"
}
%input
.form-control
{
type:
"text"
,
placeholder:
"Search issues"
,
"v-model"
=>
"query"
,
"debounce"
=>
"250"
}
%input
.form-control
{
type:
"text"
,
placeholder:
"Search issues"
,
"v-model"
=>
"query"
,
"debounce"
=>
"250"
}
=
icon
(
"search"
,
class:
"board-search-icon"
,
"v-show"
=>
"!query"
)
=
icon
(
"search"
,
class:
"board-search-icon"
,
"v-show"
=>
"!query"
)
%button
.board-search-clear-btn
{
type:
"button"
,
role:
"button"
,
"aria-label"
=>
"Clear search"
,
"@click"
=>
"
clearSearch
"
,
"v-show"
=>
"query"
}
%button
.board-search-clear-btn
{
type:
"button"
,
role:
"button"
,
"aria-label"
=>
"Clear search"
,
"@click"
=>
"
query = ''
"
,
"v-show"
=>
"query"
}
=
icon
(
"times"
,
class:
"board-search-clear"
)
=
icon
(
"times"
,
class:
"board-search-clear"
)
%board-list
{
"inline-template"
=>
true
,
%board-list
{
"inline-template"
=>
true
,
"v-if"
=>
"list.type !== 'blank'"
,
"v-if"
=>
"list.type !== 'blank'"
,
...
...
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