-
Notifications
You must be signed in to change notification settings - Fork 19
/
filesPluginLessThan28.js
78 lines (72 loc) · 1.87 KB
/
filesPluginLessThan28.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (c) 2023 Sagar Gurung <sagar@jankaritech.com>
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
* This script will no longer run when the support for the
* integration app with nextcloud is greater ro equal to version 28
* In that case this file can be removed.
*
*/
import '../bootstrap.js'
import Vue from 'vue'
import LinkMultipleFilesModal from '../views/LinkMultipleFilesModal.vue'
(function() {
if (!OCA.OpenProject) {
/**
* @namespace
*/
OCA.OpenProject = {
requestOnFileChange: false,
}
}
/**
* @namespace
*/
OCA.OpenProject.FilesPlugin = {
ignoreLists: [
'trashbin',
'files.public',
],
attach(fileList) {
if (this.ignoreLists.indexOf(fileList.id) >= 0) {
return
}
fileList.registerMultiSelectFileAction({
name: 'open-project',
displayName: t('integration_openproject', 'Link to work package'),
mime: 'all',
permissions: OC.PERMISSION_READ,
iconClass: 'icon-openproject',
action: (selectedFiles) => { this.signExample(selectedFiles) },
})
},
signExample: (selectedFiles) => {
// store all the file-id in an array and set the file ids
const fileInfos = []
for (const file of selectedFiles) {
const fileInfo = {
id: file.id,
name: file.name,
}
fileInfos.push(fileInfo)
}
OCA.OpenProject.LinkMultipleFilesModalVue.$children[0].setFileInfos(fileInfos)
OCA.OpenProject.LinkMultipleFilesModalVue.$children[0].showModal()
},
}
})()
OC.Plugins.register('OCA.Files.FileList', OCA.OpenProject.FilesPlugin)
const modalId = 'multipleFileLinkModal'
const modalElement = document.createElement('div')
modalElement.id = modalId
document.body.append(modalElement)
OCA.OpenProject.LinkMultipleFilesModalVue = new Vue({
el: modalElement,
render: h => {
return h(LinkMultipleFilesModal)
},
})