BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b29a8e3c
Commit
b29a8e3c
authored
Mar 17, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'boards-blank-state-template-in-js' into 'master'
Issue boards blank state template in JS file See merge request !9959
parents
357db226
de93054e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
172 additions
and
62 deletions
+172
-62
board.js
app/assets/javascripts/boards/components/board.js
+3
-2
board_blank_state.js
...assets/javascripts/boards/components/board_blank_state.js
+75
-44
_blank_state.html.haml
app/views/projects/boards/components/_blank_state.html.haml
+0
-15
_board.html.haml
app/views/projects/boards/components/_board.html.haml
+1
-1
board_blank_state_spec.js
spec/javascripts/boards/board_blank_state_spec.js
+93
-0
No files found.
app/assets/javascripts/boards/components/board.js
View file @
b29a8e3c
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
/* global Vue */
/* global Vue */
/* global Sortable */
/* global Sortable */
require
(
'./board_blank_state'
);
import
boardBlankState
from
'./board_blank_state'
;
require
(
'./board_delete'
);
require
(
'./board_delete'
);
require
(
'./board_list'
);
require
(
'./board_list'
);
...
@@ -17,7 +18,7 @@ require('./board_list');
...
@@ -17,7 +18,7 @@ require('./board_list');
components
:
{
components
:
{
'board-list'
:
gl
.
issueBoards
.
BoardList
,
'board-list'
:
gl
.
issueBoards
.
BoardList
,
'board-delete'
:
gl
.
issueBoards
.
BoardDelete
,
'board-delete'
:
gl
.
issueBoards
.
BoardDelete
,
'board-blank-state'
:
gl
.
issueBoards
.
BoardBlankState
boardBlankState
,
},
},
props
:
{
props
:
{
list
:
Object
,
list
:
Object
,
...
...
app/assets/javascripts/boards/components/board_blank_state.js
View file @
b29a8e3c
/* eslint-disable space-before-function-paren, comma-dangle */
/* global Vue */
/* global ListLabel */
/* global ListLabel */
/* global Cookies */
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
(()
=>
{
export
default
{
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
template
:
`
<div class="board-blank-state">
<p>
Add the following default lists to your Issue Board with one click:
</p>
<ul class="board-blank-state-list">
<li v-for="label in predefinedLabels">
<span
class="label-color"
:style="{ backgroundColor: label.color }">
</span>
{{ label.title }}
</li>
</ul>
<p>
Starting out with the default set of lists will get you right on the way to making the most of your board.
</p>
<button
class="btn btn-create btn-inverted btn-block"
type="button"
@click.stop="addDefaultLists">
Add default lists
</button>
<button
class="btn btn-default btn-block"
type="button"
@click.stop="clearBlankState">
Nevermind, I'll use my own
</button>
</div>
`
,
data
()
{
return
{
predefinedLabels
:
[
new
ListLabel
({
title
:
'To Do'
,
color
:
'#F0AD4E'
}),
new
ListLabel
({
title
:
'Doing'
,
color
:
'#5CB85C'
}),
],
};
},
methods
:
{
addDefaultLists
()
{
this
.
clearBlankState
();
window
.
gl
=
window
.
gl
||
{};
this
.
predefinedLabels
.
forEach
((
label
,
i
)
=>
{
window
.
gl
.
issueBoards
=
window
.
gl
.
issueBoards
||
{};
Store
.
addList
({
title
:
label
.
title
,
gl
.
issueBoards
.
BoardBlankState
=
Vue
.
extend
({
position
:
i
,
data
()
{
list_type
:
'label'
,
return
{
label
:
{
predefinedLabels
:
[
new
ListLabel
({
title
:
'To Do'
,
color
:
'#F0AD4E'
}),
new
ListLabel
({
title
:
'Doing'
,
color
:
'#5CB85C'
})
]
};
},
methods
:
{
addDefaultLists
()
{
this
.
clearBlankState
();
this
.
predefinedLabels
.
forEach
((
label
,
i
)
=>
{
Store
.
addList
({
title
:
label
.
title
,
title
:
label
.
title
,
position
:
i
,
color
:
label
.
color
,
list_type
:
'label'
,
},
label
:
{
title
:
label
.
title
,
color
:
label
.
color
}
});
});
});
});
Store
.
state
.
lists
=
_
.
sortBy
(
Store
.
state
.
lists
,
'position'
);
Store
.
state
.
lists
=
_
.
sortBy
(
Store
.
state
.
lists
,
'position'
);
// Save the labels
// Save the labels
gl
.
boardService
.
generateDefaultLists
()
gl
.
boardService
.
generateDefaultLists
()
.
then
((
resp
)
=>
{
.
then
((
resp
)
=>
{
resp
.
json
().
forEach
((
listObj
)
=>
{
resp
.
json
().
forEach
((
listObj
)
=>
{
const
list
=
Store
.
findList
(
'title'
,
listObj
.
title
);
const
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
:
Store
.
removeBlankState
.
bind
(
Store
)
.
catch
(()
=>
{
}
Store
.
removeList
(
undefined
,
'label'
);
});
Cookies
.
remove
(
'issue_board_welcome_hidden'
,
{
})();
path
:
''
,
});
Store
.
addBlankState
();
});
},
clearBlankState
:
Store
.
removeBlankState
.
bind
(
Store
),
},
};
app/views/projects/boards/components/_blank_state.html.haml
deleted
100644 → 0
View file @
357db226
%board-blank-state
{
"inline-template"
=>
true
,
"v-if"
=>
'list.id == "blank"'
}
.board-blank-state
%p
Add the following default lists to your Issue Board with one click:
%ul
.board-blank-state-list
%li
{
"v-for"
=>
"label in predefinedLabels"
}
%span
.label-color
{
":style"
=>
"{ backgroundColor: label.color } "
}
{{ label.title }}
%p
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.stop"
=>
"addDefaultLists"
}
Add default lists
%button
.btn.btn-default.btn-block
{
type:
"button"
,
"@click.stop"
=>
"clearBlankState"
}
Nevermind, I'll use my own
app/views/projects/boards/components/_board.html.haml
View file @
b29a8e3c
...
@@ -32,4 +32,4 @@
...
@@ -32,4 +32,4 @@
":root-path"
=>
"rootPath"
,
":root-path"
=>
"rootPath"
,
"ref"
=>
"board-list"
}
"ref"
=>
"board-list"
}
-
if
can?
(
current_user
,
:admin_list
,
@project
)
-
if
can?
(
current_user
,
:admin_list
,
@project
)
=
render
"projects/boards/components/blank_state"
%board-blank-state
{
"v-if"
=>
'list.id == "blank"'
}
spec/javascripts/boards/board_blank_state_spec.js
0 → 100644
View file @
b29a8e3c
/* global BoardService */
import
Vue
from
'vue'
;
import
'~/boards/stores/boards_store'
;
import
boardBlankState
from
'~/boards/components/board_blank_state'
;
import
'./mock_data'
;
describe
(
'Boards blank state'
,
()
=>
{
let
vm
;
let
fail
=
false
;
beforeEach
((
done
)
=>
{
const
Comp
=
Vue
.
extend
(
boardBlankState
);
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
boardService
=
new
BoardService
(
'/test/issue-boards/board'
,
''
,
'1'
);
spyOn
(
gl
.
boardService
,
'generateDefaultLists'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
if
(
fail
)
{
reject
();
}
else
{
resolve
({
json
()
{
return
[{
id
:
1
,
title
:
'To Do'
,
label
:
{
id
:
1
},
},
{
id
:
2
,
title
:
'Doing'
,
label
:
{
id
:
2
},
}];
},
});
}
}));
vm
=
new
Comp
();
setTimeout
(()
=>
{
vm
.
$mount
();
done
();
});
});
it
(
'renders pre-defined labels'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'.board-blank-state-list li'
).
length
,
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'.board-blank-state-list li'
)[
0
].
textContent
.
trim
(),
).
toEqual
(
'To Do'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'.board-blank-state-list li'
)[
1
].
textContent
.
trim
(),
).
toEqual
(
'Doing'
);
});
it
(
'clears blank state'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'.btn-default'
).
click
();
setTimeout
(()
=>
{
expect
(
gl
.
issueBoards
.
BoardsStore
.
welcomeIsHidden
()).
toBeTruthy
();
done
();
});
});
it
(
'creates pre-defined labels'
,
(
done
)
=>
{
vm
.
$el
.
querySelector
(
'.btn-create'
).
click
();
setTimeout
(()
=>
{
expect
(
gl
.
issueBoards
.
BoardsStore
.
state
.
lists
.
length
).
toBe
(
2
);
expect
(
gl
.
issueBoards
.
BoardsStore
.
state
.
lists
[
0
].
title
).
toEqual
(
'To Do'
);
expect
(
gl
.
issueBoards
.
BoardsStore
.
state
.
lists
[
1
].
title
).
toEqual
(
'Doing'
);
done
();
});
});
it
(
'resets the store if request fails'
,
(
done
)
=>
{
fail
=
true
;
vm
.
$el
.
querySelector
(
'.btn-create'
).
click
();
setTimeout
(()
=>
{
expect
(
gl
.
issueBoards
.
BoardsStore
.
welcomeIsHidden
()).
toBeFalsy
();
expect
(
gl
.
issueBoards
.
BoardsStore
.
state
.
lists
.
length
).
toBe
(
1
);
done
();
});
});
});
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