Add workaround for "share grid link" on insecure sites
This commit is contained in:
parent
c18367739f
commit
8d880fc9dd
|
@ -315,6 +315,12 @@
|
|||
</template>
|
||||
|
||||
</b-table>
|
||||
|
||||
## dummy input field needed for sharing links on *insecure* sites
|
||||
% if request.scheme == 'http':
|
||||
<b-input v-model="shareLink" ref="shareLink" v-show="shareLink"></b-input>
|
||||
% endif
|
||||
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -349,6 +355,11 @@
|
|||
filters: ${json.dumps(filters_data if grid.filterable else None)|n},
|
||||
filtersSequence: ${json.dumps(filters_sequence if grid.filterable else None)|n},
|
||||
selectedFilter: null,
|
||||
|
||||
## dummy input value needed for sharing links on *insecure* sites
|
||||
% if request.scheme == 'http':
|
||||
shareLink: null,
|
||||
% endif
|
||||
}
|
||||
|
||||
let ${grid.component_studly} = {
|
||||
|
@ -382,7 +393,27 @@
|
|||
methods: {
|
||||
|
||||
copyDirectLink() {
|
||||
|
||||
if (navigator.clipboard) {
|
||||
// this is the way forward, but requires HTTPS
|
||||
navigator.clipboard.writeText(this.directLink)
|
||||
|
||||
} else {
|
||||
// use deprecated 'copy' command, but this just
|
||||
// tells the browser to copy currently-selected
|
||||
// text..which means we first must "add" some text
|
||||
// to screen, and auto-select that, before copying
|
||||
// to clipboard
|
||||
this.shareLink = this.directLink
|
||||
this.$nextTick(() => {
|
||||
let input = this.$refs.shareLink.$el.firstChild
|
||||
input.select()
|
||||
document.execCommand('copy')
|
||||
// re-hide the dummy input
|
||||
this.shareLink = null
|
||||
})
|
||||
}
|
||||
|
||||
this.$buefy.toast.open({
|
||||
message: "Link was copied to clipboard",
|
||||
type: 'is-info',
|
||||
|
|
Loading…
Reference in a new issue