From e72f58b000efbca5efa74098dbfa7f2f7418bcc0 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Thu, 10 Oct 2019 15:32:55 +0200 Subject: Fix bugs with check plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../src/components/Checks/FileMimeType.vue | 23 +++++++++++++--- .../src/components/Checks/RequestTime.vue | 31 +++++++++++++--------- apps/workflowengine/src/components/Checks/file.js | 2 +- apps/workflowengine/src/helpers/validators.js | 9 +++++++ 4 files changed, 48 insertions(+), 17 deletions(-) (limited to 'apps/workflowengine/src') diff --git a/apps/workflowengine/src/components/Checks/FileMimeType.vue b/apps/workflowengine/src/components/Checks/FileMimeType.vue index 2f2487c9adf..862c4a42011 100644 --- a/apps/workflowengine/src/components/Checks/FileMimeType.vue +++ b/apps/workflowengine/src/components/Checks/FileMimeType.vue @@ -32,17 +32,20 @@ :tagging="false" @input="setValue"> @@ -68,12 +71,12 @@ export default { pattern: '/image\\/.*/' }, { - icon: 'icon-category-office', + iconUrl: OC.imagePath('core', 'filetypes/x-office-document'), label: t('workflowengine', 'Office documents'), pattern: '/(vnd\\.(ms-|openxmlformats-).*))$/' }, { - icon: 'icon-filetype-file', + iconUrl: OC.imagePath('core', 'filetypes/application-pdf'), label: t('workflowengine', 'PDF documents'), pattern: 'application/pdf' } @@ -130,3 +133,15 @@ export default { } } + diff --git a/apps/workflowengine/src/components/Checks/RequestTime.vue b/apps/workflowengine/src/components/Checks/RequestTime.vue index 1d7950f64f8..cd702ecae82 100644 --- a/apps/workflowengine/src/components/Checks/RequestTime.vue +++ b/apps/workflowengine/src/components/Checks/RequestTime.vue @@ -4,12 +4,13 @@ +

{{ t('workflowengine', 'Please enter a valid time span')}}

@@ -30,7 +31,7 @@ export default { props: { value: { type: String, - default: '1 MB' + default: '' } }, data() { @@ -46,15 +47,16 @@ export default { }, methods: { updateInternalValue(value) { - var data = JSON.parse(value) - var startTime = data[0].split(' ', 2)[0] - var endTime = data[1].split(' ', 2)[0] - var timezone = data[0].split(' ', 2)[1] - this.newValue = { - startTime: startTime, - endTime: endTime, - timezone: timezone - } + try { + const data = JSON.parse(value) + if (data.length === 2) { + this.newValue = { + startTime: data[0].split(' ', 2)[0], + endTime: data[1].split(' ', 2)[0], + timezone: data[0].split(' ', 2)[1] + } + } + } catch (e) {} }, validate() { return this.newValue.startTime && this.newValue.startTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null @@ -90,10 +92,15 @@ export default { width: 50%; margin: 0; margin-bottom: 5px; + &.timeslot--start { margin-right: 5px; width: calc(50% - 5px); } } + + .invalid-hint { + color: var(--color-text-maxcontrast); + } } diff --git a/apps/workflowengine/src/components/Checks/file.js b/apps/workflowengine/src/components/Checks/file.js index 76f998da007..0cc49c2d4c1 100644 --- a/apps/workflowengine/src/components/Checks/file.js +++ b/apps/workflowengine/src/components/Checks/file.js @@ -65,7 +65,7 @@ const FileChecks = [ { operator: 'greater', name: t('workflowengine', 'greater') } ], placeholder: (check) => '5 MB', - validate: (check) => check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null + validate: (check) => check.value ? check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null : false }, { diff --git a/apps/workflowengine/src/helpers/validators.js b/apps/workflowengine/src/helpers/validators.js index 837b20ad44c..4936b9200f7 100644 --- a/apps/workflowengine/src/helpers/validators.js +++ b/apps/workflowengine/src/helpers/validators.js @@ -24,16 +24,25 @@ const regexIPv4 = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9] const regexIPv6 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/ const validateRegex = function(string) { + if (!string) { + return false + } const result = regexRegex.exec(string) return result !== null } const validateIPv4 = function(string) { + if (!string) { + return false + } const result = regexIPv4.exec(string) return result !== null } const validateIPv6 = function(string) { + if (!string) { + return false + } const result = regexIPv6.exec(string) return result !== null } -- cgit v1.2.3