+
+ {{ t('deck', 'Creating the new card…') }}
+
+
+ {{ t('deck', '"{card}" was added to "{board}"', { card: pendingTitle, board: selectedBoard.title }) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/helpers/selector.js b/src/helpers/selector.js
new file mode 100644
index 000000000..392a06b4c
--- /dev/null
+++ b/src/helpers/selector.js
@@ -0,0 +1,47 @@
+/*
+ * @copyright Copyright (c) 2021 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ *
+ */
+import Vue from 'vue'
+
+const buildSelector = (selector, propsData = {}) => {
+ return new Promise((resolve, reject) => {
+ const container = document.createElement('div')
+ document.getElementById('body-user').append(container)
+ const View = Vue.extend(selector)
+ const ComponentVM = new View({
+ propsData,
+ }).$mount(container)
+ ComponentVM.$root.$on('close', () => {
+ ComponentVM.$el.remove()
+ ComponentVM.$destroy()
+ reject(new Error('Selection canceled'))
+ })
+ ComponentVM.$root.$on('select', (id) => {
+ ComponentVM.$el.remove()
+ ComponentVM.$destroy()
+ resolve(id)
+ })
+ })
+}
+
+export {
+ buildSelector,
+}
diff --git a/src/init-collections.js b/src/init-collections.js
index 4a1b28505..bcafd6fc1 100644
--- a/src/init-collections.js
+++ b/src/init-collections.js
@@ -26,6 +26,8 @@ import BoardSelector from './BoardSelector'
import CardSelector from './CardSelector'
import './../css/collections.css'
import FileSharingPicker from './views/FileSharingPicker'
+import { buildSelector } from './helpers/selector'
+
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken);
// eslint-disable-next-line
@@ -41,61 +43,16 @@ window.addEventListener('DOMContentLoaded', () => {
} else {
console.error('OCA.Sharing.ShareSearch not ready')
}
-});
-((function(OCP) {
-
- OCP.Collaboration.registerType('deck', {
- action: () => {
- return new Promise((resolve, reject) => {
- const container = document.createElement('div')
- container.id = 'deck-board-select'
- const body = document.getElementById('body-user')
- body.append(container)
- const ComponentVM = new Vue({
- render: h => h(BoardSelector),
- })
- ComponentVM.$mount(container)
- ComponentVM.$root.$on('close', () => {
- ComponentVM.$el.remove()
- ComponentVM.$destroy()
- reject(new Error('Board selection canceled'))
- })
- ComponentVM.$root.$on('select', (id) => {
- resolve(id)
- ComponentVM.$el.remove()
- ComponentVM.$destroy()
- })
- })
- },
+ window.OCP.Collaboration.registerType('deck', {
+ action: () => buildSelector(BoardSelector),
typeString: t('deck', 'Link to a board'),
typeIconClass: 'icon-deck',
})
- OCP.Collaboration.registerType('deck-card', {
- action: () => {
- return new Promise((resolve, reject) => {
- const container = document.createElement('div')
- container.id = 'deck-board-select'
- const body = document.getElementById('body-user')
- body.append(container)
- const ComponentVM = new Vue({
- render: h => h(CardSelector),
- })
- ComponentVM.$mount(container)
- ComponentVM.$root.$on('close', () => {
- ComponentVM.$el.remove()
- ComponentVM.$destroy()
- reject(new Error('Card selection canceled'))
- })
- ComponentVM.$root.$on('select', (id) => {
- resolve(id)
- ComponentVM.$el.remove()
- ComponentVM.$destroy()
- })
- })
- },
+ window.OCP.Collaboration.registerType('deck-card', {
+ action: () => buildSelector(CardSelector),
typeString: t('deck', 'Link to a card'),
typeIconClass: 'icon-deck',
})
-})(window.OCP))
+})
diff --git a/src/init-talk.js b/src/init-talk.js
new file mode 100644
index 000000000..23e812401
--- /dev/null
+++ b/src/init-talk.js
@@ -0,0 +1,62 @@
+/*
+ * @copyright Copyright (c) 2019 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ *
+ */
+
+import Vue from 'vue'
+import { generateUrl } from '@nextcloud/router'
+
+import CardCreateDialog from './CardCreateDialog'
+import { buildSelector } from './helpers/selector'
+import './init-collections'
+
+// eslint-disable-next-line
+__webpack_nonce__ = btoa(OC.requestToken);
+// eslint-disable-next-line
+__webpack_public_path__ = OC.linkTo('deck', 'js/');
+
+Vue.prototype.t = t
+Vue.prototype.n = n
+Vue.prototype.OC = OC
+
+window.addEventListener('DOMContentLoaded', () => {
+ if (!window.OCA?.Talk?.registerMessageAction) {
+ return
+ }
+
+ window.OCA.Talk.registerMessageAction({
+ label: t('deck', 'Create a card'),
+ icon: 'icon-deck',
+ async callback({ message: { message, actorDisplayName }, metadata: { name: conversationName, token: conversationToken } }) {
+ const shortenedMessageCandidate = message.replace(/^(.{255}[^\s]*).*/, '$1')
+ const shortenedMessage = shortenedMessageCandidate === '' ? message.substr(0, 255) : shortenedMessageCandidate
+ try {
+ await buildSelector(CardCreateDialog, {
+ title: shortenedMessage,
+ description: message + '\n\n' + '['
+ + t('deck', 'Message from {author} in {conversationName}', { author: actorDisplayName, conversationName })
+ + '](' + generateUrl('/call/' + conversationToken) + ')',
+ })
+ } catch (e) {
+ console.debug('Card creation dialog was canceled')
+ }
+ },
+ })
+})
diff --git a/webpack.js b/webpack.js
index f65b20653..6a33c437e 100644
--- a/webpack.js
+++ b/webpack.js
@@ -7,6 +7,7 @@ const config = {
collections: path.join(__dirname, 'src', 'init-collections.js'),
dashboard: path.join(__dirname, 'src', 'init-dashboard.js'),
calendar: path.join(__dirname, 'src', 'init-calendar.js'),
+ talk: path.join(__dirname, 'src', 'init-talk.js'),
},
output: {
filename: '[name].js',