2017-09-10 17:25:29 +05:30
|
|
|
<script>
|
|
|
|
import updateMixin from '../mixins/update';
|
|
|
|
import eventHub from '../event_hub';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [updateMixin],
|
|
|
|
props: {
|
|
|
|
canDestroy: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
formState: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
showDeleteButton: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
deleteLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isSubmitEnabled() {
|
|
|
|
return this.formState.title.trim() !== '';
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
shouldShowDeleteButton() {
|
|
|
|
return this.canDestroy && this.showDeleteButton;
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
closeForm() {
|
|
|
|
eventHub.$emit('close.form');
|
|
|
|
},
|
|
|
|
deleteIssuable() {
|
|
|
|
// eslint-disable-next-line no-alert
|
2018-11-08 19:23:39 +05:30
|
|
|
if (window.confirm('Issue will be removed! Are you sure?')) {
|
2017-09-10 17:25:29 +05:30
|
|
|
this.deleteLoading = true;
|
|
|
|
|
|
|
|
eventHub.$emit('delete.issuable');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="prepend-top-default append-bottom-default clearfix">
|
|
|
|
<button
|
|
|
|
:class="{ disabled: formState.updateLoading || !isSubmitEnabled }"
|
|
|
|
:disabled="formState.updateLoading || !isSubmitEnabled"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="btn btn-save float-left"
|
|
|
|
type="submit"
|
2017-09-10 17:25:29 +05:30
|
|
|
@click.prevent="updateIssuable">
|
|
|
|
Save changes
|
|
|
|
<i
|
2018-11-08 19:23:39 +05:30
|
|
|
v-if="formState.updateLoading"
|
2017-09-10 17:25:29 +05:30
|
|
|
class="fa fa-spinner fa-spin"
|
2018-11-08 19:23:39 +05:30
|
|
|
aria-hidden="true">
|
2017-09-10 17:25:29 +05:30
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
<button
|
2018-11-08 19:23:39 +05:30
|
|
|
class="btn btn-default float-right"
|
2017-09-10 17:25:29 +05:30
|
|
|
type="button"
|
|
|
|
@click="closeForm">
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button
|
2018-03-17 18:26:18 +05:30
|
|
|
v-if="shouldShowDeleteButton"
|
2017-09-10 17:25:29 +05:30
|
|
|
:class="{ disabled: deleteLoading }"
|
|
|
|
:disabled="deleteLoading"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="btn btn-danger float-right append-right-default"
|
|
|
|
type="button"
|
2017-09-10 17:25:29 +05:30
|
|
|
@click="deleteIssuable">
|
|
|
|
Delete
|
|
|
|
<i
|
2018-11-08 19:23:39 +05:30
|
|
|
v-if="deleteLoading"
|
2017-09-10 17:25:29 +05:30
|
|
|
class="fa fa-spinner fa-spin"
|
2018-11-08 19:23:39 +05:30
|
|
|
aria-hidden="true">
|
2017-09-10 17:25:29 +05:30
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|