From 32e98857bdba0930489da1e537efe61cb9d70a1b Mon Sep 17 00:00:00 2001
From: DeNic0la <57986114+DeNic0la@users.noreply.github.com>
Date: Sun, 30 Jun 2024 07:20:21 +0200
Subject: [PATCH 1/3] allow pasting Activities using paste command
---
.../program/DialogActivityCreate.vue | 51 ++++++++++++++++---
.../components/program/ScheduleEntries.vue | 13 +----
2 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/frontend/src/components/program/DialogActivityCreate.vue b/frontend/src/components/program/DialogActivityCreate.vue
index 6337553d60..e600558195 100644
--- a/frontend/src/components/program/DialogActivityCreate.vue
+++ b/frontend/src/components/program/DialogActivityCreate.vue
@@ -189,6 +189,18 @@ export default {
watch: {
showDialog: function (showDialog) {
if (showDialog) {
+ if (!this.scheduleEntry.start) {
+ this.scheduleEntry.start = this.$date
+ .utc(this.period.start)
+ .add(8, 'hour')
+ .format()
+ }
+ if (!this.scheduleEntry.end) {
+ this.scheduleEntry.end = this.$date
+ .utc(this.period.start)
+ .add(9, 'hour')
+ .format()
+ }
this.refreshCopyActivitySource()
this.setEntityData({
title: this.entityData?.title,
@@ -249,6 +261,10 @@ export default {
},
mounted() {
this.api.href(this.api.get(), 'activities').then((url) => (this.entityUri = url))
+ window.addEventListener('paste', this.pasteHandler)
+ },
+ beforeUnmount() {
+ window.removeEventListener('paste', this.pasteHandler)
},
methods: {
refreshCopyActivitySource() {
@@ -276,18 +292,23 @@ export default {
}
)
},
+ isActivitySource(value) {
+ if (value?.startsWith(window.location.origin)) {
+ const url = value.substring(window.location.origin.length)
+ const match = router.matcher.match(url)
+ return match.name === 'activity'
+ }
+ return false
+ },
async getCopyActivitySource(url) {
- if (url?.startsWith(window.location.origin)) {
+ if (this.isActivitySource(url)) {
url = url.substring(window.location.origin.length)
const match = router.matcher.match(url)
+ const scheduleEntry = await this.api
+ .get()
+ .scheduleEntries({ id: match.params['scheduleEntryId'] })
- if (match.name === 'activity') {
- const scheduleEntry = await this.api
- .get()
- .scheduleEntries({ id: match.params['scheduleEntryId'] })
-
- return await scheduleEntry.activity()
- }
+ return await scheduleEntry.activity()
}
return null
},
@@ -295,6 +316,20 @@ export default {
await navigator.clipboard.writeText('')
this.refreshCopyActivitySource()
},
+ /// Handles the Paste event which still can be used if the user doesnt grant permission
+ async pasteHandler(event) {
+ const url = (event.clipboardData || window.clipboardData).getData('text')
+ if (!this.isActivitySource(url) || this.copyActivitySourceUrlShowPopover) return
+ if (this.copyActivitySource == null) {
+ const copyActivitySource = await this.getCopyActivitySource(url)
+ this.copyActivitySource = await copyActivitySource?._meta.load
+ }
+ if (this.copyActivitySource != null) {
+ this.showDialog = true // on paste make sure this dialog opens
+ this.copyContent = true
+ event.preventDefault()
+ }
+ },
cancelCreate() {
this.close()
},
diff --git a/frontend/src/components/program/ScheduleEntries.vue b/frontend/src/components/program/ScheduleEntries.vue
index 8991da5cb3..361a9fd1ff 100644
--- a/frontend/src/components/program/ScheduleEntries.vue
+++ b/frontend/src/components/program/ScheduleEntries.vue
@@ -24,7 +24,7 @@
right
class="fab--bottom_nav float-right"
color="red"
- @click.stop="createNewActivity()"
+ @click.stop="showActivityCreateDialog()"
>
mdi-plus
@@ -77,17 +77,6 @@ export default {
},
methods: {
- createNewActivity() {
- this.newScheduleEntry.start = this.$date
- .utc(this.period.start)
- .add(8, 'hour')
- .format()
- this.newScheduleEntry.end = this.$date
- .utc(this.period.start)
- .add(9, 'hour')
- .format()
- this.showActivityCreateDialog()
- },
showActivityCreateDialog() {
this.$refs.dialogActivityCreate.showDialog = true
},
From c693a48bf5ff06c3928fc995dd2b38f13371e513 Mon Sep 17 00:00:00 2001
From: Pirmin Mattmann
Date: Tue, 6 Aug 2024 20:01:28 +0200
Subject: [PATCH 2/3] Update DialogActivityCreate.vue
change local variable-name
---
frontend/src/components/program/DialogActivityCreate.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/src/components/program/DialogActivityCreate.vue b/frontend/src/components/program/DialogActivityCreate.vue
index e600558195..db814040e6 100644
--- a/frontend/src/components/program/DialogActivityCreate.vue
+++ b/frontend/src/components/program/DialogActivityCreate.vue
@@ -277,8 +277,8 @@ export default {
navigator.clipboard
.readText()
.then(async (url) => {
- const copyActivitySource = await this.getCopyActivitySource(url)
- this.copyActivitySource = await copyActivitySource?._meta.load
+ const activitySource = await this.getCopyActivitySource(url)
+ this.copyActivitySource = await activitySource?._meta.load
})
.catch(() => {
this.clipboardPermission = 'unaccessable'
From c1f1c404424dfe797b1070f2fd54c898758ee1be Mon Sep 17 00:00:00 2001
From: Pirmin Mattmann
Date: Tue, 6 Aug 2024 20:03:09 +0200
Subject: [PATCH 3/3] Update DialogActivityCreate.vue
change local varibale name
---
frontend/src/components/program/DialogActivityCreate.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/src/components/program/DialogActivityCreate.vue b/frontend/src/components/program/DialogActivityCreate.vue
index db814040e6..d88ab68698 100644
--- a/frontend/src/components/program/DialogActivityCreate.vue
+++ b/frontend/src/components/program/DialogActivityCreate.vue
@@ -321,8 +321,8 @@ export default {
const url = (event.clipboardData || window.clipboardData).getData('text')
if (!this.isActivitySource(url) || this.copyActivitySourceUrlShowPopover) return
if (this.copyActivitySource == null) {
- const copyActivitySource = await this.getCopyActivitySource(url)
- this.copyActivitySource = await copyActivitySource?._meta.load
+ const activitySource = await this.getCopyActivitySource(url)
+ this.copyActivitySource = await activitySource?._meta.load
}
if (this.copyActivitySource != null) {
this.showDialog = true // on paste make sure this dialog opens