debian-mirror-gitlab/app/assets/javascripts/sidebar/components/status/status_dropdown.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.4 KiB
Vue
Raw Normal View History

2021-09-30 23:02:18 +05:30
<script>
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { __ } from '~/locale';
2023-03-04 22:38:38 +05:30
import { statusDropdownOptions } from '../../constants';
2021-09-30 23:02:18 +05:30
export default {
components: {
GlDropdown,
GlDropdownItem,
},
data() {
return {
status: null,
};
},
computed: {
dropdownText() {
return this.status?.text ?? this.$options.i18n.defaultDropdownText;
},
selectedValue() {
return this.status?.value;
},
},
methods: {
onDropdownItemClick(statusOption) {
// clear status if the currently checked status is clicked again
if (this.status?.value === statusOption.value) {
this.status = null;
} else {
this.status = statusOption;
}
},
},
i18n: {
dropdownTitle: __('Change status'),
defaultDropdownText: __('Select status'),
},
2022-11-25 23:54:43 +05:30
statusDropdownOptions,
2021-09-30 23:02:18 +05:30
};
</script>
<template>
<div>
<input type="hidden" name="update[state_event]" :value="selectedValue" />
<gl-dropdown :text="dropdownText" :title="$options.i18n.dropdownTitle" class="gl-w-full">
<gl-dropdown-item
2022-11-25 23:54:43 +05:30
v-for="statusOption in $options.statusDropdownOptions"
2021-09-30 23:02:18 +05:30
:key="statusOption.value"
:is-checked="selectedValue === statusOption.value"
is-check-item
:title="statusOption.text"
@click="onDropdownItemClick(statusOption)"
>
{{ statusOption.text }}
</gl-dropdown-item>
</gl-dropdown>
</div>
</template>