debian-mirror-gitlab/app/assets/javascripts/ide/components/commit_sidebar/radio_group.vue

91 lines
1.8 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2018-10-15 14:42:47 +05:30
import { mapActions, mapState, mapGetters } from 'vuex';
import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
2018-05-09 12:01:36 +05:30
2018-10-15 14:42:47 +05:30
export default {
directives: {
tooltip,
},
props: {
value: {
type: String,
required: true,
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
label: {
type: String,
required: false,
default: null,
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
checked: {
type: Boolean,
required: false,
default: false,
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
showInput: {
type: Boolean,
required: false,
default: false,
2018-05-09 12:01:36 +05:30
},
2018-10-15 14:42:47 +05:30
disabled: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapState('commit', ['commitAction']),
...mapGetters('commit', ['newBranchName']),
tooltipTitle() {
return this.disabled
? __('This option is disabled while you still have unstaged changes')
: '';
},
},
methods: {
...mapActions('commit', ['updateCommitAction', 'updateBranchName']),
},
};
2018-05-09 12:01:36 +05:30
</script>
<template>
<fieldset>
2018-10-15 14:42:47 +05:30
<label
v-tooltip
:title="tooltipTitle"
:class="{
'is-disabled': disabled
}"
>
2018-05-09 12:01:36 +05:30
<input
type="radio"
name="commit-action"
:value="value"
@change="updateCommitAction($event.target.value)"
2018-10-15 14:42:47 +05:30
:checked="commitAction === value"
:disabled="disabled"
2018-05-09 12:01:36 +05:30
/>
<span class="prepend-left-10">
<span
2018-10-15 14:42:47 +05:30
v-if="label"
class="ide-radio-label"
2018-05-09 12:01:36 +05:30
>
2018-10-15 14:42:47 +05:30
{{ label }}
2018-05-09 12:01:36 +05:30
</span>
2018-10-15 14:42:47 +05:30
<slot v-else></slot>
2018-05-09 12:01:36 +05:30
</span>
</label>
<div
v-if="commitAction === value && showInput"
class="ide-commit-new-branch"
>
<input
type="text"
2018-10-15 14:42:47 +05:30
class="form-control monospace"
2018-05-09 12:01:36 +05:30
:placeholder="newBranchName"
@input="updateBranchName($event.target.value)"
/>
</div>
</fieldset>
</template>