debian-mirror-gitlab/app/assets/javascripts/sidebar/components/todo_toggle/todo.vue

94 lines
2 KiB
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
2019-02-15 15:39:39 +05:30
import { GlLoadingIcon } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
import Icon from '~/vue_shared/components/icon.vue';
2019-09-30 21:07:59 +05:30
const MARK_TEXT = __('Mark as done');
const TODO_TEXT = __('Add a To Do');
2018-11-18 11:00:15 +05:30
export default {
directives: {
tooltip,
},
components: {
Icon,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2018-11-18 11:00:15 +05:30
},
props: {
issuableId: {
type: Number,
required: true,
},
issuableType: {
type: String,
required: true,
},
isTodo: {
type: Boolean,
required: false,
default: true,
},
isActionActive: {
type: Boolean,
required: false,
default: false,
},
collapsed: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
buttonClasses() {
2018-12-13 13:39:08 +05:30
return this.collapsed
? 'btn-blank btn-todo sidebar-collapsed-icon dont-change-state'
: 'btn btn-default btn-todo issuable-header-btn float-right';
2018-11-18 11:00:15 +05:30
},
buttonLabel() {
return this.isTodo ? MARK_TEXT : TODO_TEXT;
},
2019-07-07 11:18:12 +05:30
buttonTooltip() {
return !this.collapsed ? undefined : this.buttonLabel;
},
2018-11-18 11:00:15 +05:30
collapsedButtonIconClasses() {
return this.isTodo ? 'todo-undone' : '';
},
collapsedButtonIcon() {
return this.isTodo ? 'todo-done' : 'todo-add';
},
},
methods: {
handleButtonClick() {
this.$emit('toggleTodo');
},
},
};
</script>
<template>
<button
v-tooltip
:class="buttonClasses"
2019-07-07 11:18:12 +05:30
:title="buttonTooltip"
2018-11-18 11:00:15 +05:30
:aria-label="buttonLabel"
:data-issuable-id="issuableId"
:data-issuable-type="issuableType"
type="button"
data-container="body"
data-placement="left"
data-boundary="viewport"
@click="handleButtonClick"
>
<icon
v-show="collapsed"
:css-classes="collapsedButtonIconClasses"
:name="collapsedButtonIcon"
/>
2019-02-15 15:39:39 +05:30
<span v-show="!collapsed" class="issuable-todo-inner"> {{ buttonLabel }} </span>
<gl-loading-icon v-show="isActionActive" :inline="true" />
2018-11-18 11:00:15 +05:30
</button>
</template>