Skip to content

Commit

Permalink
separate qr dialog to component
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Beichler <[email protected]>
  • Loading branch information
Himmelxd committed May 16, 2024
1 parent 41ab25d commit d5ad0b1
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 25 deletions.
60 changes: 60 additions & 0 deletions src/components/QRDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<div class="qrDialog__content">

Check failure on line 2 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
<h2>{{ title }}</h2>

Check failure on line 3 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
<div>

Check failure on line 4 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
<img :src="uri" :title="text"

Check failure on line 5 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character

Check failure on line 5 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':title' should be on a new line
:alt="t('forms', 'QR code representation of {title}', { title: title })">

Check failure on line 6 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
</div>

Check failure on line 7 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
</div>

Check failure on line 8 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected "\t" character, but found " " character
</template>

<script>
import QRCode from 'qrcode'
export default {
name: 'QrDialog',

Check failure on line 16 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 1 tab but found 4 spaces

Check failure on line 16 in src/components/QRDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Component name `QrDialog` should match file name `QRDialog`
props: {
title: {
type: String,
default: '',
},
text: {
type: String,
default: '',
},
},
data() {
return {
uri: {
type: String,
default: '',
},
}
},
created() {
this.generateQr()
},
methods: {
async generateQr() {
try {
this.uri = await QRCode.toDataURL(this.text)
} catch (err) {
console.error(err)
}
},
},
}
</script>

<style lang="scss">
.qrDialog__content {
margin-bottom: 50px;
text-align: center;
}
</style>
33 changes: 8 additions & 25 deletions src/components/SidebarTabs/SharingSidebarTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@
</div>
</TransitionGroup>

<NcDialog :open.sync="qrDialog.on" closeOnClickOutside="true" @close="qrDialog.on=false">
<div class="qrDialog__content">
<h2>{{ t('forms', 'Share {formTitle}', { formTitle: form.title }) }}</h2>
<div>
<img :src="qrDialog.uri" :title="qrDialog.text" :alt=" t('forms', 'QR code representation of {title}', {title: form.title})">
</div>
</div>
<NcDialog :open.sync="qrDialog" closeOnClickOutside="true" @close="qrDialog=false">

Check warning on line 100 in src/components/SidebarTabs/SharingSidebarTab.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute 'closeOnClickOutside' must be hyphenated
<QRDialog :title="t('forms', 'Share {formTitle}', { formTitle: form.title })"

Check warning on line 101 in src/components/SidebarTabs/SharingSidebarTab.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Require self-closing on Vue.js custom components (<QRDialog>)
:text="qrDialog">
</QRDialog>
</NcDialog>

<!-- Legacy Info, if present -->
Expand Down Expand Up @@ -206,13 +203,13 @@ import IconDelete from 'vue-material-design-icons/Delete.vue'
import IconLinkBoxVariantOutline from 'vue-material-design-icons/LinkBoxVariantOutline.vue'
import IconLinkVariant from 'vue-material-design-icons/LinkVariant.vue'
import IconPlus from 'vue-material-design-icons/Plus.vue'
import QRCode from 'qrcode'

import FormsIcon from '../Icons/FormsIcon.vue'
import IconCopyAll from '../Icons/IconCopyAll.vue'
import SharingSearchDiv from './SharingSearchDiv.vue'
import SharingShareDiv from './SharingShareDiv.vue'
import PermissionTypes from '../../mixins/PermissionTypes.js'
import QRDialog from '../QRDialog.vue'
import ShareTypes from '../../mixins/ShareTypes.js'
import ShareLinkMixin from '../../mixins/ShareLinkMixin.js'
import OcsResponse2Data from '../../utils/OcsResponse2Data.js'
Expand All @@ -235,6 +232,7 @@ export default {
NcActionLink,
NcCheckboxRadioSwitch,
NcDialog,
QRDialog,
SharingSearchDiv,
SharingShareDiv,
},
Expand All @@ -252,11 +250,7 @@ export default {
return {
isLoading: false,
appConfig: loadState(appName, 'appConfig'),
qrDialog: {
on: false,
text: '',
uri: '',
},
qrDialog: false,
}
},

Expand Down Expand Up @@ -417,13 +411,7 @@ export default {
},

async openQrDialog(qrText) {
this.qrDialog.text = qrText
try {
this.qrDialog.uri = await QRCode.toDataURL(this.qrDialog.text)
this.qrDialog.on = true
} catch (err) {
console.error(err)
}
this.qrDialog = qrText
},
},
}
Expand Down Expand Up @@ -489,9 +477,4 @@ export default {
color: var(--color-error)
}
}

.qrDialog__content {
margin-bottom: 50px;
text-align: center;
}
</style>

0 comments on commit d5ad0b1

Please sign in to comment.