Set operation mode according to the mime type value
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
15b64c6abb
commit
0cdcdb305e
|
@ -81,7 +81,11 @@ export default {
|
||||||
},
|
},
|
||||||
operators() {
|
operators() {
|
||||||
if (!this.currentOption) { return [] }
|
if (!this.currentOption) { return [] }
|
||||||
return this.checks[this.currentOption.class].operators
|
const operators = this.checks[this.currentOption.class].operators
|
||||||
|
if (typeof operators === 'function') {
|
||||||
|
return operators(this.check)
|
||||||
|
}
|
||||||
|
return operators
|
||||||
},
|
},
|
||||||
currentComponent() {
|
currentComponent() {
|
||||||
if (!this.currentOption) { return [] }
|
if (!this.currentOption) { return [] }
|
||||||
|
@ -118,7 +122,8 @@ export default {
|
||||||
return this.valid
|
return this.valid
|
||||||
},
|
},
|
||||||
updateCheck() {
|
updateCheck() {
|
||||||
if (this.check.class !== this.currentOption.class) {
|
const matchingOperator = this.operators.findIndex((operator) => this.check.operator === operator.operator)
|
||||||
|
if (this.check.class !== this.currentOption.class || matchingOperator === -1) {
|
||||||
this.currentOperator = this.operators[0]
|
this.currentOperator = this.operators[0]
|
||||||
}
|
}
|
||||||
this.check.class = this.currentOption.class
|
this.check.class = this.currentOption.class
|
||||||
|
|
|
@ -120,7 +120,6 @@ export default {
|
||||||
return result !== null
|
return result !== null
|
||||||
},
|
},
|
||||||
setValue(value) {
|
setValue(value) {
|
||||||
// TODO: check if value requires a regex and set the check operator according to that
|
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
this.newValue = value.pattern
|
this.newValue = value.pattern
|
||||||
this.$emit('input', this.newValue)
|
this.$emit('input', this.newValue)
|
||||||
|
|
|
@ -24,16 +24,24 @@ import { stringValidator, validateIPv4, validateIPv6 } from './../../helpers/val
|
||||||
import FileMimeType from './FileMimeType'
|
import FileMimeType from './FileMimeType'
|
||||||
import FileSystemTag from './FileSystemTag'
|
import FileSystemTag from './FileSystemTag'
|
||||||
|
|
||||||
|
const stringOrRegexOperators = (check) => {
|
||||||
|
if (check.value.startsWith('/')) {
|
||||||
|
return [
|
||||||
|
{ operator: 'matches', name: t('workflowengine', 'matches') },
|
||||||
|
{ operator: '!matches', name: t('workflowengine', 'does not match') },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{ operator: 'is', name: t('workflowengine', 'is') },
|
||||||
|
{ operator: '!is', name: t('workflowengine', 'is not') },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const FileChecks = [
|
const FileChecks = [
|
||||||
{
|
{
|
||||||
class: 'OCA\\WorkflowEngine\\Check\\FileName',
|
class: 'OCA\\WorkflowEngine\\Check\\FileName',
|
||||||
name: t('workflowengine', 'File name'),
|
name: t('workflowengine', 'File name'),
|
||||||
operators: [
|
operators: stringOrRegexOperators,
|
||||||
{ operator: 'is', name: t('workflowengine', 'is') },
|
|
||||||
{ operator: '!is', name: t('workflowengine', 'is not') },
|
|
||||||
{ operator: 'matches', name: t('workflowengine', 'matches') },
|
|
||||||
{ operator: '!matches', name: t('workflowengine', 'does not match') },
|
|
||||||
],
|
|
||||||
placeholder: (check) => {
|
placeholder: (check) => {
|
||||||
if (check.operator === 'matches' || check.operator === '!matches') {
|
if (check.operator === 'matches' || check.operator === '!matches') {
|
||||||
return '/^dummy-.+$/i'
|
return '/^dummy-.+$/i'
|
||||||
|
@ -46,12 +54,7 @@ const FileChecks = [
|
||||||
{
|
{
|
||||||
class: 'OCA\\WorkflowEngine\\Check\\FileMimeType',
|
class: 'OCA\\WorkflowEngine\\Check\\FileMimeType',
|
||||||
name: t('workflowengine', 'File MIME type'),
|
name: t('workflowengine', 'File MIME type'),
|
||||||
operators: [
|
operators: stringOrRegexOperators,
|
||||||
{ operator: 'is', name: t('workflowengine', 'is') },
|
|
||||||
{ operator: '!is', name: t('workflowengine', 'is not') },
|
|
||||||
{ operator: 'matches', name: t('workflowengine', 'matches') },
|
|
||||||
{ operator: '!matches', name: t('workflowengine', 'does not match') },
|
|
||||||
],
|
|
||||||
component: FileMimeType,
|
component: FileMimeType,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue