2023-07-06 22:05:03 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<button class="ml-2 btn"
|
|
|
|
id="share-button"
|
|
|
|
type="button"
|
|
|
|
:class="shareClass"
|
|
|
|
:title="shareValue"
|
|
|
|
@click="openModal">
|
|
|
|
<span class="sn-icon sn-icon-shared"></span>
|
|
|
|
<span class="text-sm">
|
|
|
|
{{ shareValue }}
|
|
|
|
</span>
|
|
|
|
</button>
|
2023-09-12 20:11:34 +08:00
|
|
|
<div ref="modal">
|
|
|
|
<shareModalContainer :shared="share"
|
|
|
|
:open="visibleShareModal"
|
|
|
|
:shareableLinkUrl="shareableLinkUrl"
|
|
|
|
:characterLimit="255"
|
|
|
|
@enable="enableShare"
|
|
|
|
@disable="disableShare"
|
2023-11-15 22:55:48 +08:00
|
|
|
:canShare="canShare"
|
2023-09-12 20:11:34 +08:00
|
|
|
@close="closeModal"/>
|
|
|
|
</div>
|
2023-07-06 22:05:03 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-01-04 23:34:36 +08:00
|
|
|
import shareModalContainer from './components/shareable_link_modal.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ShareLinkContainer',
|
|
|
|
components: { shareModalContainer },
|
|
|
|
props: {
|
|
|
|
shared: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
shareableLinkUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
2023-07-06 22:05:03 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
canShare: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
share: false,
|
|
|
|
visibleShareModal: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.share = this.shared;
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
shareClass() {
|
|
|
|
return this.share ? 'btn-shared' : 'btn-secondary';
|
2023-07-06 22:05:03 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
shareValue() {
|
|
|
|
return this.i18n.t(this.share ? 'my_modules.shareable_links.shared' : 'my_modules.shareable_links.share');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
// move modal to body to avoid z-index issues
|
|
|
|
$('body').append($(this.$refs.modal));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
enableShare() {
|
|
|
|
this.share = true;
|
2023-07-06 22:05:03 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
disableShare() {
|
|
|
|
this.share = false;
|
2023-07-06 22:05:03 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
openModal() {
|
|
|
|
this.visibleShareModal = true;
|
2023-09-12 20:11:34 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
closeModal() {
|
|
|
|
this.visibleShareModal = false;
|
2023-07-06 22:05:03 +08:00
|
|
|
}
|
2024-01-04 23:34:36 +08:00
|
|
|
}
|
|
|
|
};
|
2023-07-06 22:05:03 +08:00
|
|
|
</script>
|