Commit 27188763 authored by Phil Hughes's avatar Phil Hughes

Added ability to generate default lists

parent 522d53da
...@@ -20,7 +20,8 @@ $(function () { ...@@ -20,7 +20,8 @@ $(function () {
el: '#board-app', el: '#board-app',
props: { props: {
disabled: Boolean, disabled: Boolean,
endpoint: String endpoint: String,
issueLinkBase: String
}, },
data: { data: {
state: BoardsStore.state, state: BoardsStore.state,
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
const Board = Vue.extend({ const Board = Vue.extend({
props: { props: {
list: Object, list: Object,
disabled: Boolean disabled: Boolean,
issueLinkBase: String
}, },
data: function () { data: function () {
return { return {
......
(function () { (() => {
const BoardBlankState = Vue.extend({ const BoardBlankState = Vue.extend({
data: function () {
return {
predefinedLabels: [
new Label({ title: 'Development', color: '#5CB85C' }),
new Label({ title: 'Testing', color: '#F0AD4E' }),
new Label({ title: 'Production', color: '#FF5F00' }),
new Label({ title: 'Ready', color: '#FF0000' })
]
}
},
methods: { methods: {
addDefaultLists: function () { addDefaultLists: function () {
BoardsStore.removeBlankState();
_.each(this.predefinedLabels, (label, i) => {
BoardsStore.addList({
title: label.title,
position: i,
type: 'label',
label: {
title: label.title,
color: label.color
}
});
});
// Save the labels
gl.boardService
.generateDefaultLists()
.then((resp) => {
const data = resp.json();
_.each(data, (listObj) => {
const list = BoardsStore.findList('title', listObj.title);
list.id = listObj.id;
list.label.id = listObj.label.id;
list.getIssues();
});
});
}, },
clearBlankState: function () { clearBlankState: function () {
BoardsStore.removeBlankState(); BoardsStore.removeBlankState();
......
...@@ -3,7 +3,12 @@ class BoardService { ...@@ -3,7 +3,12 @@ class BoardService {
Vue.http.options.root = root; Vue.http.options.root = root;
this.lists = Vue.resource(`${root}{/id}.json`, {}); this.lists = Vue.resource(`${root}{/id}.json`, {});
this.list = Vue.resource(`${root}/lists{/id}.json`, {}); this.list = Vue.resource(`${root}/lists{/id}.json`, {}, {
generate: {
method: 'POST',
url: `${root}/lists/generate.json`
}
});
this.issue = Vue.resource(`${root}/issues{/id}.json`, {}); this.issue = Vue.resource(`${root}/issues{/id}.json`, {});
this.issues = Vue.resource(`${root}/lists{/id}/issues.json`, {}); this.issues = Vue.resource(`${root}/lists{/id}/issues.json`, {});
} }
...@@ -17,6 +22,12 @@ class BoardService { ...@@ -17,6 +22,12 @@ class BoardService {
return this.lists.get(); return this.lists.get();
} }
generateDefaultLists () {
this.setCSRF();
return this.list.generate({});
}
createList (labelId) { createList (labelId) {
this.setCSRF(); this.setCSRF();
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
}, },
shouldAddBlankState: function () { shouldAddBlankState: function () {
// Decide whether to add the blank state // Decide whether to add the blank state
return !_.find(this.state.lists, function (list) { return !!_.find(this.state.lists, function (list) {
return list.type === 'backlog' || list.type === 'done'; return list.type === 'backlog' || list.type === 'done';
}); });
}, },
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
%p %p
Add the following default lists to your Issue Board with one click: Add the following default lists to your Issue Board with one click:
%ul.board-blank-state-list %ul.board-blank-state-list
%li %li{ "v-for" => "label in predefinedLabels" }
%span.label-color{ style: "background-color: red;" } %span.label-color{ ":style" => "{ backgroundColor: label.color } " }
Development {{ label.title }}
%p %p
Starting out with the default set of lists will get you right on the way to making the most of your board. Starting out with the default set of lists will get you right on the way to making the most of your board.
%button.btn.btn-create.btn-inverted.btn-block{ type: "button", "@click" => "addDefaultLists" } %button.btn.btn-create.btn-inverted.btn-block{ type: "button", "@click" => "addDefaultLists" }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"v-cloak" => true, "v-cloak" => true,
"v-for" => "list in state.lists | orderBy 'position'", "v-for" => "list in state.lists | orderBy 'position'",
":list" => "list", ":list" => "list",
":disabled" => "#{current_user.nil?}" } ":disabled" => "disabled",
":issue-link-base" => "issueLinkBase" }
.board{ ":class" => "{ 'is-draggable': !isPreset }" } .board{ ":class" => "{ 'is-draggable': !isPreset }" }
.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) }" }
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
":issues" => "list.issues", ":issues" => "list.issues",
":loading" => "list.loading", ":loading" => "list.loading",
":disabled" => "disabled", ":disabled" => "disabled",
":issue-link-base" => "'#{namespace_project_issues_path(@project.namespace, @project)}'" } ":issue-link-base" => "issueLinkBase" }
.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, %ul.board-list{ "v-el:list" => true,
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
= render 'shared/issuable/filter', type: :boards = render 'shared/issuable/filter', type: :boards
.boards-list#board-app{ ":endpoint" => "'#{namespace_project_board_path(@project.namespace, @project)}'", .boards-list#board-app{ "v-cloak" => true,
":disabled" => "#{current_user.nil?}" } ":endpoint" => "'#{namespace_project_board_path(@project.namespace, @project)}'",
":disabled" => "#{current_user.nil?}",
":issue-link-base" => "'#{namespace_project_issues_path(@project.namespace, @project)}'" }
.boards-app-loading.text-center{ "v-if" => "loading" } .boards-app-loading.text-center{ "v-if" => "loading" }
= icon("spinner spin") = icon("spinner spin")
= render "projects/boards/components/board" = render "projects/boards/components/board"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment