2017-07-20 11:20:48 -04:00
|
|
|
<script>
|
2017-10-26 06:14:31 -04:00
|
|
|
import { mapActions } from 'vuex';
|
2017-06-30 17:44:48 -04:00
|
|
|
|
2017-10-26 06:14:31 -04:00
|
|
|
export default {
|
2017-06-30 17:44:48 -04:00
|
|
|
props: {
|
2017-07-20 11:37:52 -04:00
|
|
|
tab: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-06-30 17:44:48 -04:00
|
|
|
},
|
|
|
|
|
2017-07-17 09:15:35 -04:00
|
|
|
computed: {
|
2017-08-10 15:17:38 -04:00
|
|
|
closeLabel() {
|
2017-10-26 11:44:26 -04:00
|
|
|
if (this.tab.changed || this.tab.tempFile) {
|
2017-08-10 15:17:38 -04:00
|
|
|
return `${this.tab.name} changed`;
|
|
|
|
}
|
|
|
|
return `Close ${this.tab.name}`;
|
|
|
|
},
|
2017-07-17 09:15:35 -04:00
|
|
|
changedClass() {
|
|
|
|
const tabChangedObj = {
|
2017-10-12 05:55:11 -04:00
|
|
|
'fa-times close-icon': !this.tab.changed && !this.tab.tempFile,
|
|
|
|
'fa-circle unsaved-icon': this.tab.changed || this.tab.tempFile,
|
2017-07-17 09:15:35 -04:00
|
|
|
};
|
2017-07-17 09:44:19 -04:00
|
|
|
return tabChangedObj;
|
|
|
|
},
|
2017-07-17 09:15:35 -04:00
|
|
|
},
|
|
|
|
|
2017-06-30 17:44:48 -04:00
|
|
|
methods: {
|
2017-10-26 06:14:31 -04:00
|
|
|
...mapActions([
|
|
|
|
'closeFile',
|
|
|
|
]),
|
2017-12-21 10:05:47 -05:00
|
|
|
clickFile(tab) {
|
|
|
|
this.$router.push(`/project${tab.url}`);
|
|
|
|
},
|
2017-07-14 21:54:51 -04:00
|
|
|
},
|
2017-06-30 17:44:48 -04:00
|
|
|
};
|
2017-07-20 11:20:48 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2017-10-13 05:08:10 -04:00
|
|
|
<li
|
2017-12-21 10:05:47 -05:00
|
|
|
@click="clickFile(tab)"
|
2017-10-13 05:08:10 -04:00
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="button"
|
2017-11-23 12:16:01 -05:00
|
|
|
class="multi-file-tab-close"
|
2017-10-26 11:44:26 -04:00
|
|
|
@click.stop.prevent="closeFile({ file: tab })"
|
2017-11-23 12:16:01 -05:00
|
|
|
:aria-label="closeLabel"
|
|
|
|
:class="{
|
|
|
|
'modified': tab.changed,
|
|
|
|
}"
|
|
|
|
:disabled="tab.changed"
|
|
|
|
>
|
2017-10-13 05:08:10 -04:00
|
|
|
<i
|
|
|
|
class="fa"
|
|
|
|
:class="changedClass"
|
2017-11-23 12:16:01 -05:00
|
|
|
aria-hidden="true"
|
|
|
|
>
|
2017-10-13 05:08:10 -04:00
|
|
|
</i>
|
|
|
|
</button>
|
2017-07-20 11:20:48 -04:00
|
|
|
|
2017-11-23 12:16:01 -05:00
|
|
|
<div
|
|
|
|
class="multi-file-tab"
|
|
|
|
:class="{active : tab.active }"
|
2017-10-13 05:08:10 -04:00
|
|
|
:title="tab.url"
|
2017-11-23 12:16:01 -05:00
|
|
|
>
|
|
|
|
{{ tab.name }}
|
|
|
|
</div>
|
2017-10-13 05:08:10 -04:00
|
|
|
</li>
|
2017-07-20 11:20:48 -04:00
|
|
|
</template>
|