2020-08-25 09:10:42 +00:00
|
|
|
<script>
|
|
|
|
import { GlButton } from '@gitlab/ui';
|
2021-08-16 12:09:17 +00:00
|
|
|
import { todoLabel, updateGlobalTodoCount } from './utils';
|
2020-08-25 09:10:42 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlButton,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
isTodo: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
buttonLabel() {
|
2021-07-15 06:09:39 +00:00
|
|
|
return todoLabel(this.isTodo);
|
2020-08-25 09:10:42 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-30 09:08:07 +00:00
|
|
|
methods: {
|
|
|
|
incrementGlobalTodoCount() {
|
2021-08-16 12:09:17 +00:00
|
|
|
updateGlobalTodoCount(1);
|
2021-06-30 09:08:07 +00:00
|
|
|
},
|
|
|
|
decrementGlobalTodoCount() {
|
2021-08-16 12:09:17 +00:00
|
|
|
updateGlobalTodoCount(-1);
|
2021-06-30 09:08:07 +00:00
|
|
|
},
|
|
|
|
onToggle(event) {
|
|
|
|
if (this.isTodo) {
|
|
|
|
this.decrementGlobalTodoCount();
|
|
|
|
} else {
|
|
|
|
this.incrementGlobalTodoCount();
|
|
|
|
}
|
|
|
|
this.$emit('click', event);
|
|
|
|
},
|
|
|
|
},
|
2020-08-25 09:10:42 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-06-30 09:08:07 +00:00
|
|
|
<gl-button v-bind="$attrs" :aria-label="buttonLabel" @click="onToggle($event)">
|
2020-08-25 09:10:42 +00:00
|
|
|
{{ buttonLabel }}
|
|
|
|
</gl-button>
|
|
|
|
</template>
|