diff --git a/apps/files_sharing/src/additionalScripts.js b/apps/files_sharing/src/additionalScripts.js index 081519cc64..94c0f232ce 100644 --- a/apps/files_sharing/src/additionalScripts.js +++ b/apps/files_sharing/src/additionalScripts.js @@ -1,4 +1,4 @@ -__webpack_public_path__ = OC.linkTo('files_sharing', 'js/'); +__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/'); __webpack_nonce__ = btoa(OC.requestToken); import './share' diff --git a/apps/files_sharing/src/collaborationresources.js b/apps/files_sharing/src/collaborationresources.js index 0b42b66e0a..ce53d0cd93 100644 --- a/apps/files_sharing/src/collaborationresources.js +++ b/apps/files_sharing/src/collaborationresources.js @@ -25,7 +25,10 @@ import Vuex from 'vuex'; import { PopoverMenu } from 'nextcloud-vue'; import ClickOutside from 'vue-click-outside'; import { VTooltip } from 'v-tooltip'; -import { CollectionStore as Store } from './collectionstore'; +import { CollectionStoreModule } from 'nextcloud-vue-collections'; + +const Store = () => new Vuex.Store(CollectionStoreModule); + Vue.prototype.t = t; diff --git a/apps/files_sharing/src/collectionservice.js b/apps/files_sharing/src/collectionservice.js deleted file mode 100644 index d494280ffb..0000000000 --- a/apps/files_sharing/src/collectionservice.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * @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 axios from 'nextcloud-axios'; - -class CollectionService { - constructor() { - this.http = axios; - this.baseUrl = OC.linkToOCS('collaboration/resources', 2); - } - - listCollection(collectionId) { - return this.http.get(`${this.baseUrl}collections/${collectionId}`); - } - - renameCollection(collectionId, collectionName) { - const resourceBase = OC.linkToOCS('collaboration/resources/collections', 2); - return this.http.put(`${resourceBase}${collectionId}?format=json`, { - collectionName - }).then(result => { - return result.data.ocs.data; - }); - } - - getCollectionsByResource(resourceType, resourceId) { - const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`, 2); - return this.http.get(`${resourceBase}${resourceId}?format=json`) - .then(result => { - return result.data.ocs.data; - }) - .catch(error => { - console.error(error); - return Promise.reject(error); - }); - } - - createCollection(resourceType, resourceId, name) { - const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`, 2); - return this.http.post(`${resourceBase}${resourceId}?format=json`, { - name: name - }) - .then((response) => { - return response.data.ocs.data; - }) - .catch(error => { - console.error(error); - return Promise.reject(error); - }); - } - - addResource(collectionId, resourceType, resourceId) { - resourceId = '' + resourceId; - const resourceBase = OC.linkToOCS('collaboration/resources/collections', 2); - return this.http.post(`${resourceBase}${collectionId}?format=json`, { - resourceType, - resourceId - }).then((response) => { - return response.data.ocs.data; - }); - } - - removeResource(collectionId, resourceType, resourceId) { - return this.http.delete(`${this.baseUrl}/collections/${collectionId}`, { params: { resourceType, resourceId } } ) - .then((response) => { - return response.data.ocs.data; - }); - } - - search(query) { - const searchBase = OC.linkToOCS('collaboration/resources/collections/search', 2); - return this.http.get(`${searchBase}%25${query}%25?format=json`) - .then((response) => { - return response.data.ocs.data; - }); - } - -} - -const service = new CollectionService(); - -export default service; diff --git a/apps/files_sharing/src/collectionstore.js b/apps/files_sharing/src/collectionstore.js deleted file mode 100644 index 7931ef4de6..0000000000 --- a/apps/files_sharing/src/collectionstore.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * @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 Vuex from 'vuex'; -import Vue from 'vue'; -import service from './collectionservice'; - -const CollectionStoreModule = { - state: { - collections: [] - }, - mutations: { - addCollections (state, collections) { - state.collections = collections; - }, - addCollection (state, collection) { - state.collections.push(collection); - }, - removeCollection (state, collectionId) { - state.collections = state.collections.filter(item => item.id !== collectionId); - }, - updateCollection(state, collection) { - let index = state.collections.findIndex((_item) => _item.id === collection.id); - if (index !== -1) { - Vue.set(state.collections, index, collection); - } else { - state.collections.push(collection); - } - } - }, - getters: { - collectionsByResource(state) { - return (resourceType, resourceId) => { - return state.collections.filter((collection) => { - return typeof collection.resources.find((resource) => resource && resource.id === ''+resourceId && resource.type === resourceType) !== 'undefined'; - }); - }; - }, - getSearchResults(state) { - return (term) => { - return state.collections.filter((collection) => collection.name.contains(term)); - }; - } - }, - actions: { - fetchCollectionsByResource(context, {resourceType, resourceId}) { - return service.getCollectionsByResource(resourceType, resourceId).then((collections) => { - context.commit('addCollections', collections); - return collections; - }); - }, - createCollection(context, {baseResourceType, baseResourceId, resourceType, resourceId, name}) { - return service.createCollection(baseResourceType, baseResourceId, name).then((collection) => { - context.commit('addCollection', collection); - context.dispatch('addResourceToCollection', { - collectionId: collection.id, - resourceType, resourceId - }); - }); - }, - renameCollection(context, {collectionId, name}) { - return service.renameCollection(collectionId, name).then((collection) => { - context.commit('updateCollection', collection); - return collection; - }); - }, - addResourceToCollection(context, {collectionId, resourceType, resourceId}) { - return service.addResource(collectionId, resourceType, resourceId).then((collection) => { - context.commit('updateCollection', collection); - return collection; - }); - }, - removeResource(context, {collectionId, resourceType, resourceId}) { - return service.removeResource(collectionId, resourceType, resourceId).then((collection) => { - if (collection.resources.length > 0) { - context.commit('updateCollection', collection); - } else { - context.commit('removeCollection', collectionId); - } - }); - }, - search(context, query) { - return service.search(query); - } - } -}; - -const CollectionStore = () => new Vuex.Store(CollectionStoreModule); - -export { CollectionStoreModule, CollectionStore }; diff --git a/apps/files_sharing/src/components/CollectionList.vue b/apps/files_sharing/src/components/CollectionList.vue deleted file mode 100644 index afadafec87..0000000000 --- a/apps/files_sharing/src/components/CollectionList.vue +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - diff --git a/apps/files_sharing/src/components/CollectionListItem.vue b/apps/files_sharing/src/components/CollectionListItem.vue deleted file mode 100644 index e6b307bfd8..0000000000 --- a/apps/files_sharing/src/components/CollectionListItem.vue +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - diff --git a/apps/files_sharing/src/files_sharing.js b/apps/files_sharing/src/files_sharing.js index 631dc3a832..0bf695a72c 100644 --- a/apps/files_sharing/src/files_sharing.js +++ b/apps/files_sharing/src/files_sharing.js @@ -1,5 +1,5 @@ __webpack_nonce__ = btoa(OC.requestToken); -__webpack_public_path__ = OC.linkTo('files_sharing', 'js/'); +__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/'); import '../js/app'; import '../js/sharedfilelist'; diff --git a/apps/files_sharing/src/views/CollaborationView.vue b/apps/files_sharing/src/views/CollaborationView.vue index e90f7c9d74..1c1cdd7c3e 100644 --- a/apps/files_sharing/src/views/CollaborationView.vue +++ b/apps/files_sharing/src/views/CollaborationView.vue @@ -25,7 +25,7 @@