From 46bf96ee2921ea1de326ed08879b510ae53c24ac Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Oct 2022 16:58:13 +0200 Subject: [PATCH] Use @nextcloud/vue MultiselectTags component Signed-off-by: Joas Schilling --- .../src/components/Checks/FileSystemTag.vue | 7 +- .../Checks/MultiselectTag/MultiselectTag.vue | 130 ------------------ .../components/Checks/MultiselectTag/api.js | 115 ---------------- .../components/Checks/MultiselectTag/index.js | 27 ---- 4 files changed, 3 insertions(+), 276 deletions(-) delete mode 100644 apps/workflowengine/src/components/Checks/MultiselectTag/MultiselectTag.vue delete mode 100644 apps/workflowengine/src/components/Checks/MultiselectTag/api.js delete mode 100644 apps/workflowengine/src/components/Checks/MultiselectTag/index.js diff --git a/apps/workflowengine/src/components/Checks/FileSystemTag.vue b/apps/workflowengine/src/components/Checks/FileSystemTag.vue index 828423736a4..1c99be3816d 100644 --- a/apps/workflowengine/src/components/Checks/FileSystemTag.vue +++ b/apps/workflowengine/src/components/Checks/FileSystemTag.vue @@ -21,19 +21,18 @@ --> diff --git a/apps/workflowengine/src/components/Checks/MultiselectTag/api.js b/apps/workflowengine/src/components/Checks/MultiselectTag/api.js deleted file mode 100644 index be32917bca7..00000000000 --- a/apps/workflowengine/src/components/Checks/MultiselectTag/api.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @copyright Copyright (c) 2019 Julius Härtl - * - * @author Christoph Wurst - * @author John Molakvoæ - * @author Julius Härtl - * @author Roeland Jago Douma - * - * @license AGPL-3.0-or-later - * - * 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' -import { generateRemoteUrl } from '@nextcloud/router' - -const xmlToJson = (xml) => { - let obj = {} - - if (xml.nodeType === 1) { - if (xml.attributes.length > 0) { - obj['@attributes'] = {} - for (let j = 0; j < xml.attributes.length; j++) { - const attribute = xml.attributes.item(j) - obj['@attributes'][attribute.nodeName] = attribute.nodeValue - } - } - } else if (xml.nodeType === 3) { - obj = xml.nodeValue - } - - if (xml.hasChildNodes()) { - for (let i = 0; i < xml.childNodes.length; i++) { - const item = xml.childNodes.item(i) - const nodeName = item.nodeName - if (typeof (obj[nodeName]) === 'undefined') { - obj[nodeName] = xmlToJson(item) - } else { - if (typeof obj[nodeName].push === 'undefined') { - const old = obj[nodeName] - obj[nodeName] = [] - obj[nodeName].push(old) - } - obj[nodeName].push(xmlToJson(item)) - } - } - } - return obj -} - -const parseXml = (xml) => { - let dom = null - try { - dom = (new DOMParser()).parseFromString(xml, 'text/xml') - } catch (e) { - console.error('Failed to parse xml document', e) - } - return dom -} - -const xmlToTagList = (xml) => { - const json = xmlToJson(parseXml(xml)) - const list = json['d:multistatus']['d:response'] - const result = [] - for (const index in list) { - const tag = list[index]['d:propstat'] - - if (tag['d:status']['#text'] !== 'HTTP/1.1 200 OK') { - continue - } - result.push({ - id: tag['d:prop']['oc:id']['#text'], - displayName: tag['d:prop']['oc:display-name']['#text'], - canAssign: tag['d:prop']['oc:can-assign']['#text'] === 'true', - userAssignable: tag['d:prop']['oc:user-assignable']['#text'] === 'true', - userVisible: tag['d:prop']['oc:user-visible']['#text'] === 'true', - }) - } - return result -} - -const searchTags = function() { - return axios({ - method: 'PROPFIND', - url: generateRemoteUrl('dav') + '/systemtags/', - data: ` - - - - - - - - - `, - }).then((response) => { - return xmlToTagList(response.data) - }) -} - -export { - searchTags, -} diff --git a/apps/workflowengine/src/components/Checks/MultiselectTag/index.js b/apps/workflowengine/src/components/Checks/MultiselectTag/index.js deleted file mode 100644 index a7c7e5e87e7..00000000000 --- a/apps/workflowengine/src/components/Checks/MultiselectTag/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @copyright Copyright (c) 2019 Julius Härtl - * - * @author John Molakvoæ - * @author Julius Härtl - * - * @license AGPL-3.0-or-later - * - * 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 MultiselectTag from './MultiselectTag' - -export default MultiselectTag -export { MultiselectTag }