summaryrefslogtreecommitdiffstats
path: root/src/mixins
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-02-26 15:37:35 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-05-30 10:28:56 +0200
commitd6030761c32d047b2208376a99d75b72c7c57987 (patch)
tree3f8e6bddfaa2f1cb18f81d621979faff78123bd0 /src/mixins
parent9acea39cb94222c8d6e4a6c0f7d8dbac5055d1f4 (diff)
Circles listing base
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/mixins')
-rw-r--r--src/mixins/CopyToClipboardMixin.js65
-rw-r--r--src/mixins/RouterMixin.js35
2 files changed, 100 insertions, 0 deletions
diff --git a/src/mixins/CopyToClipboardMixin.js b/src/mixins/CopyToClipboardMixin.js
new file mode 100644
index 00000000..54e76536
--- /dev/null
+++ b/src/mixins/CopyToClipboardMixin.js
@@ -0,0 +1,65 @@
+/**
+ * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import { showError, showSuccess } from '@nextcloud/dialogs'
+import Vue from 'vue'
+import VueClipboard from 'vue-clipboard2'
+
+Vue.use(VueClipboard)
+
+export default {
+ data() {
+ return {
+ copied: false,
+ copyLoading: false,
+ copySuccess: false,
+ }
+ },
+
+ methods: {
+ async copyToClipboard(url) {
+ // change to loading status
+ this.copyLoading = true
+
+ // copy link to clipboard
+ try {
+ await this.$copyText(url)
+ this.copySuccess = true
+ this.copied = true
+
+ // Notify success
+ showSuccess(t('contacts', 'Link copied to the clipboard'))
+ } catch (error) {
+ this.copySuccess = false
+ this.copied = true
+ showError(t('contacts', 'Could not copy link to the clipboard.'))
+ } finally {
+ this.copyLoading = false
+ setTimeout(() => {
+ // stop loading status regardless of outcome
+ this.copied = false
+ this.copySuccess = false
+ }, 2000)
+ }
+ },
+ },
+}
diff --git a/src/mixins/RouterMixin.js b/src/mixins/RouterMixin.js
new file mode 100644
index 00000000..b836ae6c
--- /dev/null
+++ b/src/mixins/RouterMixin.js
@@ -0,0 +1,35 @@
+/**
+ * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+export default {
+ computed: {
+ // router variables
+ selectedContact() {
+ return this.$route.params.selectedContact
+ },
+ selectedGroup() {
+ return this.$route.params.selectedGroup
+ },
+ selectedCircle() {
+ return this.$route.params.selectedCircle
+ },
+ },
+}