debian-mirror-gitlab/app/assets/javascripts/boards/components/board_blank_state.vue

99 lines
2.6 KiB
Vue
Raw Normal View History

2018-10-15 14:42:47 +05:30
<script>
2019-09-30 21:07:59 +05:30
import { __ } from '~/locale';
2019-10-12 21:52:04 +05:30
import ListLabel from '~/boards/models/label';
2017-08-17 22:00:37 +05:30
import Cookies from 'js-cookie';
2018-12-13 13:39:08 +05:30
import boardsStore from '../stores/boards_store';
2017-08-17 22:00:37 +05:30
export default {
data() {
return {
predefinedLabels: [
2019-09-30 21:07:59 +05:30
new ListLabel({ title: __('To Do'), color: '#F0AD4E' }),
new ListLabel({ title: __('Doing'), color: '#5CB85C' }),
2017-08-17 22:00:37 +05:30
],
};
},
methods: {
addDefaultLists() {
this.clearBlankState();
this.predefinedLabels.forEach((label, i) => {
2018-12-13 13:39:08 +05:30
boardsStore.addList({
2017-08-17 22:00:37 +05:30
title: label.title,
position: i,
list_type: 'label',
label: {
title: label.title,
color: label.color,
},
});
});
// Save the labels
2019-10-12 21:52:04 +05:30
boardsStore
2018-12-13 13:39:08 +05:30
.generateDefaultLists()
2018-03-17 18:26:18 +05:30
.then(res => res.data)
2018-12-13 13:39:08 +05:30
.then(data => {
data.forEach(listObj => {
const list = boardsStore.findList('title', listObj.title);
2017-08-17 22:00:37 +05:30
2019-10-12 21:52:04 +05:30
if (!list) {
return;
}
2017-08-17 22:00:37 +05:30
list.id = listObj.id;
list.label.id = listObj.label.id;
2018-12-13 13:39:08 +05:30
list.getIssues().catch(() => {
// TODO: handle request error
});
2017-08-17 22:00:37 +05:30
});
})
.catch(() => {
2018-12-13 13:39:08 +05:30
boardsStore.removeList(undefined, 'label');
2017-08-17 22:00:37 +05:30
Cookies.remove('issue_board_welcome_hidden', {
path: '',
});
2018-12-13 13:39:08 +05:30
boardsStore.addBlankState();
2017-08-17 22:00:37 +05:30
});
},
2018-12-13 13:39:08 +05:30
clearBlankState: boardsStore.removeBlankState.bind(boardsStore),
2017-08-17 22:00:37 +05:30
},
};
2018-10-15 14:42:47 +05:30
</script>
<template>
2019-07-31 22:56:46 +05:30
<div class="board-blank-state p-3">
2019-09-30 21:07:59 +05:30
<p>
{{
s__('BoardBlankState|Add the following default lists to your Issue Board with one click:')
}}
</p>
2019-07-31 22:56:46 +05:30
<ul class="list-unstyled board-blank-state-list">
2019-02-15 15:39:39 +05:30
<li v-for="(label, index) in predefinedLabels" :key="index">
2019-07-31 22:56:46 +05:30
<span
:style="{ backgroundColor: label.color }"
class="label-color position-relative d-inline-block rounded"
2019-10-12 21:52:04 +05:30
></span>
2018-10-15 14:42:47 +05:30
{{ label.title }}
</li>
</ul>
<p>
2019-09-30 21:07:59 +05:30
{{
s__(
'BoardBlankState|Starting out with the default set of lists will get you right on the way to making the most of your board.',
)
}}
2018-10-15 14:42:47 +05:30
</p>
<button
2018-12-05 23:21:45 +05:30
class="btn btn-success btn-inverted btn-block"
2018-10-15 14:42:47 +05:30
type="button"
2019-02-15 15:39:39 +05:30
@click.stop="addDefaultLists"
>
2019-09-30 21:07:59 +05:30
{{ s__('BoardBlankState|Add default lists') }}
2018-10-15 14:42:47 +05:30
</button>
2019-02-15 15:39:39 +05:30
<button class="btn btn-default btn-block" type="button" @click.stop="clearBlankState">
2019-09-30 21:07:59 +05:30
{{ s__("BoardBlankState|Nevermind, I'll use my own") }}
2018-10-15 14:42:47 +05:30
</button>
</div>
</template>