Commit 50b326a0 authored by Kushal Pandya's avatar Kushal Pandya Committed by Jarka Kadlecová

[ci skip] Add todo button in Epic sidebar

parent 9e41a571
<script>
import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue';
import LoadingIcon from '~/vue_shared/components/loading_icon.vue';
const MARK_TEXT = __('Mark todo as done');
const TODO_TEXT = __('Add todo');
export default {
directives: {
tooltip,
},
components: {
Icon,
LoadingIcon,
},
props: {
issuableId: {
type: Number,
required: true,
},
issuableType: {
type: String,
required: true,
},
isAddTodo: {
type: Boolean,
required: false,
default: true,
},
collapsed: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
isButtonTypeAddTodo: this.isAddTodo,
isActionActive: false,
};
},
computed: {
buttonClasses() {
return this.collapsed ?
'btn-blank btn-todo sidebar-collapsed-icon dont-change-state' :
'btn btn-default btn-todo issuable-header-btn float-right';
},
buttonLabel() {
return this.isButtonTypeAddTodo ? MARK_TEXT : TODO_TEXT;
},
collapsedButtonIconClasses() {
return this.isButtonTypeAddTodo ? 'todo-undone' : '';
},
collapsedButtonIcon() {
return this.isButtonTypeAddTodo ? 'check-circle' : 'plus-square';
},
},
};
</script>
<template>
<button
v-tooltip
:class="buttonClasses"
:title="buttonLabel"
:aria-label="buttonLabel"
:data-issuable-id="issuableId"
:data-issuable-type="issuableType"
type="button"
data-container="body"
data-placement="left"
data-boundary="viewport"
>
<icon
v-if="collapsed"
:css-classes="collapsedButtonIconClasses"
:name="collapsedButtonIcon"
/>
<span
v-else
class="issuable-todo-inner"
>
{{ buttonLabel }}
</span>
<loading-icon
v-if="isActionActive"
:inline="true"
/>
</button>
</template>
...@@ -12,6 +12,11 @@ export default { ...@@ -12,6 +12,11 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
cssClasses: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
tooltipLabel() { tooltipLabel() {
...@@ -30,10 +35,12 @@ export default { ...@@ -30,10 +35,12 @@ export default {
<button <button
v-tooltip v-tooltip
:title="tooltipLabel" :title="tooltipLabel"
:class="cssClasses"
type="button" type="button"
class="btn btn-blank gutter-toggle btn-sidebar-action" class="btn btn-blank gutter-toggle btn-sidebar-action"
data-container="body" data-container="body"
data-placement="left" data-placement="left"
data-boundary="viewport"
@click="toggle" @click="toggle"
> >
<i <i
......
...@@ -462,6 +462,7 @@ ...@@ -462,6 +462,7 @@
.todo-undone { .todo-undone {
color: $gl-link-color; color: $gl-link-color;
fill: $gl-link-color;
} }
.author { .author {
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
relatedIssuesRoot, relatedIssuesRoot,
}, },
props: { props: {
epicId: {
type: Number,
required: true,
},
endpoint: { endpoint: {
type: String, type: String,
required: true, required: true,
...@@ -170,6 +174,7 @@ ...@@ -170,6 +174,7 @@
/> />
</div> </div>
<epic-sidebar <epic-sidebar
:epic-id="epicId"
:endpoint="endpoint" :endpoint="endpoint"
:editable="canUpdate" :editable="canUpdate"
:initial-start-date="startDate" :initial-start-date="startDate"
......
...@@ -9,6 +9,7 @@ export default () => { ...@@ -9,6 +9,7 @@ export default () => {
const props = Object.assign({}, initialData, metaData, el.dataset); const props = Object.assign({}, initialData, metaData, el.dataset);
// Convert backend casing to match frontend style guide // Convert backend casing to match frontend style guide
props.epicId = props.epic_id;
props.startDate = props.start_date; props.startDate = props.start_date;
props.endDate = props.end_date; props.endDate = props.end_date;
......
...@@ -4,6 +4,7 @@ module EpicsHelper ...@@ -4,6 +4,7 @@ module EpicsHelper
group = epic.group group = epic.group
epic_meta = { epic_meta = {
epic_id: epic.id,
created: epic.created_at, created: epic.created_at,
author: { author: {
name: author.name, name: author.name,
......
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