2017-08-03 11:20:23 -04:00
|
|
|
<script>
|
2017-10-26 06:14:31 -04:00
|
|
|
import { mapGetters, mapActions, mapState } from 'vuex';
|
2017-12-11 13:43:28 -05:00
|
|
|
import modal from '../../vue_shared/components/modal.vue';
|
2017-08-02 15:39:50 -04:00
|
|
|
|
2017-08-03 11:20:23 -04:00
|
|
|
export default {
|
2017-10-26 06:14:31 -04:00
|
|
|
components: {
|
2017-12-11 13:43:28 -05:00
|
|
|
modal,
|
2017-10-17 06:03:12 -04:00
|
|
|
},
|
2017-08-02 15:39:50 -04:00
|
|
|
computed: {
|
2017-10-26 06:14:31 -04:00
|
|
|
...mapState([
|
|
|
|
'editMode',
|
|
|
|
'discardPopupOpen',
|
|
|
|
]),
|
|
|
|
...mapGetters([
|
|
|
|
'canEditFile',
|
|
|
|
]),
|
2017-08-02 15:39:50 -04:00
|
|
|
buttonLabel() {
|
2017-08-03 11:20:23 -04:00
|
|
|
return this.editMode ? this.__('Cancel edit') : this.__('Edit');
|
2017-08-02 15:39:50 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2017-10-26 06:14:31 -04:00
|
|
|
...mapActions([
|
|
|
|
'toggleEditMode',
|
|
|
|
'closeDiscardPopup',
|
|
|
|
]),
|
2017-08-15 14:16:42 -04:00
|
|
|
},
|
2017-08-04 08:13:32 -04:00
|
|
|
};
|
2017-08-03 11:20:23 -04:00
|
|
|
</script>
|
2017-08-02 15:39:50 -04:00
|
|
|
|
2017-08-03 11:20:23 -04:00
|
|
|
<template>
|
2017-10-26 12:36:27 -04:00
|
|
|
<div class="editable-mode">
|
2017-10-26 06:14:31 -04:00
|
|
|
<button
|
|
|
|
v-if="canEditFile"
|
|
|
|
class="btn btn-default"
|
|
|
|
type="button"
|
|
|
|
@click.prevent="toggleEditMode()">
|
|
|
|
<i
|
|
|
|
v-if="!editMode"
|
|
|
|
class="fa fa-pencil"
|
|
|
|
aria-hidden="true">
|
|
|
|
</i>
|
|
|
|
<span>
|
|
|
|
{{buttonLabel}}
|
|
|
|
</span>
|
|
|
|
</button>
|
2017-12-11 13:43:28 -05:00
|
|
|
<modal
|
2017-10-26 06:14:31 -04:00
|
|
|
v-if="discardPopupOpen"
|
|
|
|
class="text-left"
|
|
|
|
:primary-button-label="__('Discard changes')"
|
|
|
|
kind="warning"
|
|
|
|
:title="__('Are you sure?')"
|
|
|
|
:text="__('Are you sure you want to discard your changes?')"
|
2018-01-03 04:21:17 -05:00
|
|
|
@cancel="closeDiscardPopup"
|
2017-10-26 06:14:31 -04:00
|
|
|
@submit="toggleEditMode(true)"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-08-03 11:20:23 -04:00
|
|
|
</template>
|