From e6ea889e6ec80b26aa74aca9971e646aef7cc10e Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Tue, 3 Sep 2024 09:31:59 +0200 Subject: [PATCH 1/8] TASK: Add FileSize and FileExtension Validator --- .../NodeTypes.FormElements.FileUpload.yaml | 1 + Configuration/NodeTypes.Mixin.File.yaml | 10 +++++ .../NodeTypes.Validator.FileExtension.yaml | 45 +++++++++++++++++++ .../NodeTypes.Validator.FileSize.yaml | 25 +++++++++++ .../Validators/FileExtensionValidator.fusion | 7 +++ .../Validators/FileSizeValidator.fusion | 8 ++++ 6 files changed, 96 insertions(+) create mode 100644 Configuration/NodeTypes.Mixin.File.yaml create mode 100644 Configuration/NodeTypes.Validator.FileExtension.yaml create mode 100644 Configuration/NodeTypes.Validator.FileSize.yaml create mode 100644 Resources/Private/Fusion/Validators/FileExtensionValidator.fusion create mode 100644 Resources/Private/Fusion/Validators/FileSizeValidator.fusion diff --git a/Configuration/NodeTypes.FormElements.FileUpload.yaml b/Configuration/NodeTypes.FormElements.FileUpload.yaml index 40bee68..91a8ec6 100644 --- a/Configuration/NodeTypes.FormElements.FileUpload.yaml +++ b/Configuration/NodeTypes.FormElements.FileUpload.yaml @@ -2,6 +2,7 @@ superTypes: 'Neos.Form.Builder:FormElement': true 'Neos.Form.Builder:DefaultValueMixin': false + 'Neos.Form.Builder:FileValidatorsMixin': true postprocessors: 'Neos.Form.Builder:ResourceCollectionsPostprocessor': postprocessor: 'Neos\Form\Builder\NodeType\ResourceCollectionsPostprocessor' diff --git a/Configuration/NodeTypes.Mixin.File.yaml b/Configuration/NodeTypes.Mixin.File.yaml new file mode 100644 index 0000000..4ba01be --- /dev/null +++ b/Configuration/NodeTypes.Mixin.File.yaml @@ -0,0 +1,10 @@ +'Neos.Form.Builder:FileMixin': + abstract: true + superTypes: + 'Neos.Form.Builder:ValidatorsMixin': true + childNodes: + 'validators': + constraints: + nodeTypes: + 'Neos.Form.Builder:FileSizeValidator': true + 'Neos.Form.Builder:FileTypeValidator': true diff --git a/Configuration/NodeTypes.Validator.FileExtension.yaml b/Configuration/NodeTypes.Validator.FileExtension.yaml new file mode 100644 index 0000000..0c580fe --- /dev/null +++ b/Configuration/NodeTypes.Validator.FileExtension.yaml @@ -0,0 +1,45 @@ +'Neos.Form.Builder:FileExtensionValidator': + superTypes: + 'Neos.Form.Builder:AbstractValidator': true + ui: + label: 'File Type Validator' + icon: 'icon-sort-numeric-asc' + inspector: + groups: + 'validator': + icon: 'icon-sort-numeric-asc' + properties: + 'allowedExtensions': + type: array + ui: + label: i18n + reloadIfChanged: true + inspector: + group: 'validator' + editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' + editorOptions: + values: + 'pdf': + label: '.pdf' + icon: 'icon-file-pdf-o' + 'xls': + label: '.xls' + icon: 'icon-file-excel-o' + 'xlsx': + label: '.xlsx' + icon: 'icon-file-excel-o' + 'doc': + label: '.doc' + icon: 'icon-file-text' + 'docx': + label: '.docx' + icon: 'icon-file-text' + 'odt': + label: '.odt' + icon: 'icon-file-text' + 'csv': + label: '.csv' + icon: 'icon-file-text' + 'zip': + label: '.zip' + icon: 'icon-file-text' \ No newline at end of file diff --git a/Configuration/NodeTypes.Validator.FileSize.yaml b/Configuration/NodeTypes.Validator.FileSize.yaml new file mode 100644 index 0000000..ee3300e --- /dev/null +++ b/Configuration/NodeTypes.Validator.FileSize.yaml @@ -0,0 +1,25 @@ +'Neos.Form.Builder:FileSizeValidator': + superTypes: + 'Neos.Form.Builder:AbstractValidator': true + ui: + label: 'File size range Validator' + icon: 'icon-sort-numeric-asc' + inspector: + groups: + 'validator': + icon: 'icon-sort-numeric-asc' + properties: + 'minimum': + type: integer + defaultValue: 0 + ui: + label: i18n + inspector: + group: 'validator' + 'maximum': + type: integer + defaultValue: 100 + ui: + label: i18n + inspector: + group: 'validator' diff --git a/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion b/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion new file mode 100644 index 0000000..f73c311 --- /dev/null +++ b/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion @@ -0,0 +1,7 @@ +# See Neos\Flow\Validation\Validator\FileTypeValidator +prototype(Neos.Form.Builder:FileExtensionValidator.Definition) < prototype(Neos.Form.Builder:Validator.Definition) { + formElementType = 'Neos.Flow:FileExtension' + options { + allowedExtensions = Neos.Fusion:DataStructure + } +} \ No newline at end of file diff --git a/Resources/Private/Fusion/Validators/FileSizeValidator.fusion b/Resources/Private/Fusion/Validators/FileSizeValidator.fusion new file mode 100644 index 0000000..b5e38c2 --- /dev/null +++ b/Resources/Private/Fusion/Validators/FileSizeValidator.fusion @@ -0,0 +1,8 @@ +# See Neos\Flow\Validation\Validator\FileSizeValidator +prototype(Neos.Form.Builder:FileSizeValidator.Definition) < prototype(Neos.Form.Builder:Validator.Definition) { + formElementType = 'Neos.Flow:FileSize' + options { + minimum = 0 + maximum = 10000000 + } +} \ No newline at end of file From af5d18014a75f1883b29cb3efdd43bb02e14d636 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Tue, 3 Sep 2024 10:54:11 +0200 Subject: [PATCH 2/8] TASK: Add translation files --- .../NodeTypes.Validator.FileExtension.yaml | 4 ++-- .../da/NodeTypes/FileExtensionValidator.xlf | 11 +++++++++++ .../da/NodeTypes/FileSizeValidator.xlf | 15 +++++++++++++++ .../de/NodeTypes/FileExtensionValidator.xlf | 13 +++++++++++++ .../de/NodeTypes/FileSizeValidator.xlf | 13 +++++++++++++ .../en/NodeTypes/FileExtensionValidator.xlf | 10 ++++++++++ .../en/NodeTypes/FileSizeValidator.xlf | 13 +++++++++++++ 7 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 Resources/Private/Translations/da/NodeTypes/FileExtensionValidator.xlf create mode 100644 Resources/Private/Translations/da/NodeTypes/FileSizeValidator.xlf create mode 100644 Resources/Private/Translations/de/NodeTypes/FileExtensionValidator.xlf create mode 100644 Resources/Private/Translations/de/NodeTypes/FileSizeValidator.xlf create mode 100644 Resources/Private/Translations/en/NodeTypes/FileExtensionValidator.xlf create mode 100644 Resources/Private/Translations/en/NodeTypes/FileSizeValidator.xlf diff --git a/Configuration/NodeTypes.Validator.FileExtension.yaml b/Configuration/NodeTypes.Validator.FileExtension.yaml index 0c580fe..36bfe2f 100644 --- a/Configuration/NodeTypes.Validator.FileExtension.yaml +++ b/Configuration/NodeTypes.Validator.FileExtension.yaml @@ -2,8 +2,8 @@ superTypes: 'Neos.Form.Builder:AbstractValidator': true ui: - label: 'File Type Validator' - icon: 'icon-sort-numeric-asc' + label: 'File Extension Validator' + icon: 'file-archive' inspector: groups: 'validator': diff --git a/Resources/Private/Translations/da/NodeTypes/FileExtensionValidator.xlf b/Resources/Private/Translations/da/NodeTypes/FileExtensionValidator.xlf new file mode 100644 index 0000000..6db51a8 --- /dev/null +++ b/Resources/Private/Translations/da/NodeTypes/FileExtensionValidator.xlf @@ -0,0 +1,11 @@ + + + + + + Allowed file types + Tilladte filtyper + + + + diff --git a/Resources/Private/Translations/da/NodeTypes/FileSizeValidator.xlf b/Resources/Private/Translations/da/NodeTypes/FileSizeValidator.xlf new file mode 100644 index 0000000..508d2bb --- /dev/null +++ b/Resources/Private/Translations/da/NodeTypes/FileSizeValidator.xlf @@ -0,0 +1,15 @@ + + + + + + Minimum value + Mindste værdi i bytes + + + Maximum value + Højeste værdi i bytes + + + + diff --git a/Resources/Private/Translations/de/NodeTypes/FileExtensionValidator.xlf b/Resources/Private/Translations/de/NodeTypes/FileExtensionValidator.xlf new file mode 100644 index 0000000..b78efe3 --- /dev/null +++ b/Resources/Private/Translations/de/NodeTypes/FileExtensionValidator.xlf @@ -0,0 +1,13 @@ + + + + + + Allowed file types + Erlaubte Dateitypen + + Target Resource Collection + Ziel "Resource Collection" + + + diff --git a/Resources/Private/Translations/de/NodeTypes/FileSizeValidator.xlf b/Resources/Private/Translations/de/NodeTypes/FileSizeValidator.xlf new file mode 100644 index 0000000..e1b9e30 --- /dev/null +++ b/Resources/Private/Translations/de/NodeTypes/FileSizeValidator.xlf @@ -0,0 +1,13 @@ + + + + + + Minimum value + Mindestwert in Bytes + + Maximum value + Maximalwert in Bytes + + + diff --git a/Resources/Private/Translations/en/NodeTypes/FileExtensionValidator.xlf b/Resources/Private/Translations/en/NodeTypes/FileExtensionValidator.xlf new file mode 100644 index 0000000..3a9da01 --- /dev/null +++ b/Resources/Private/Translations/en/NodeTypes/FileExtensionValidator.xlf @@ -0,0 +1,10 @@ + + + + + + Allowed file types + + + + diff --git a/Resources/Private/Translations/en/NodeTypes/FileSizeValidator.xlf b/Resources/Private/Translations/en/NodeTypes/FileSizeValidator.xlf new file mode 100644 index 0000000..fed98e5 --- /dev/null +++ b/Resources/Private/Translations/en/NodeTypes/FileSizeValidator.xlf @@ -0,0 +1,13 @@ + + + + + + Minimum value in bytes + + + Maximum value in bytes + + + + From ce786d4fe002a604b0359c0a8a84de4a9c62be68 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Wed, 4 Sep 2024 17:59:56 +0200 Subject: [PATCH 3/8] TASK: Add examples for allowedExtensions --- .../Fusion/Validators/FileExtensionValidator.fusion | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion b/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion index f73c311..8ffdaa9 100644 --- a/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion +++ b/Resources/Private/Fusion/Validators/FileExtensionValidator.fusion @@ -2,6 +2,15 @@ prototype(Neos.Form.Builder:FileExtensionValidator.Definition) < prototype(Neos.Form.Builder:Validator.Definition) { formElementType = 'Neos.Flow:FileExtension' options { - allowedExtensions = Neos.Fusion:DataStructure + allowedExtensions = Neos.Fusion:DataStructure { + pdf = 'pdf' + xls = 'xls' + xlsx = 'xlsx' + doc = 'doc' + docx = 'docx' + odt = 'odt' + csv = 'csv' + zip = 'zip' + } } } \ No newline at end of file From 8df0f4bec88528c0c86415ac70064a1a1b2b7803 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Thu, 5 Sep 2024 09:25:18 +0200 Subject: [PATCH 4/8] TASK: Reduce double code --- .../NodeTypes.FormElements.FileUpload.yaml | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/Configuration/NodeTypes.FormElements.FileUpload.yaml b/Configuration/NodeTypes.FormElements.FileUpload.yaml index 91a8ec6..5e690f7 100644 --- a/Configuration/NodeTypes.FormElements.FileUpload.yaml +++ b/Configuration/NodeTypes.FormElements.FileUpload.yaml @@ -15,37 +15,6 @@ 'formElement': icon: 'icon-upload' properties: - 'allowedExtensions': - type: array - ui: - label: i18n - reloadIfChanged: true - inspector: - group: 'formElement' - editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' - editorOptions: - values: - 'pdf': - label: '.pdf' - icon: 'icon-file-pdf-o' - 'xls': - label: '.xls' - icon: 'icon-file-excel-o' - 'xlsx': - label: '.xlsx' - icon: 'icon-file-excel-o' - 'doc': - label: '.doc' - icon: 'icon-file-text' - 'docx': - label: '.docx' - icon: 'icon-file-text' - 'odt': - label: '.odt' - icon: 'icon-file-text' - 'csv': - label: '.csv' - icon: 'icon-file-text' 'resourceCollection': type: string ui: From 10ae5d031f69931511b4a37fa4d0ae826d050e08 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Thu, 5 Sep 2024 09:39:51 +0200 Subject: [PATCH 5/8] TASK: Update icons --- Configuration/NodeTypes.Validator.FileExtension.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/NodeTypes.Validator.FileExtension.yaml b/Configuration/NodeTypes.Validator.FileExtension.yaml index 36bfe2f..aa9f1f8 100644 --- a/Configuration/NodeTypes.Validator.FileExtension.yaml +++ b/Configuration/NodeTypes.Validator.FileExtension.yaml @@ -3,11 +3,11 @@ 'Neos.Form.Builder:AbstractValidator': true ui: label: 'File Extension Validator' - icon: 'file-archive' + icon: 'icon-file-archive' inspector: groups: 'validator': - icon: 'icon-sort-numeric-asc' + icon: 'icon-filter' properties: 'allowedExtensions': type: array From a016ce07700e4b9a0eb79d6e08b66dfd41f246e3 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Thu, 5 Sep 2024 09:46:13 +0200 Subject: [PATCH 6/8] TASK: Update Icons for FileSizeValidator --- Configuration/NodeTypes.Validator.FileSize.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/NodeTypes.Validator.FileSize.yaml b/Configuration/NodeTypes.Validator.FileSize.yaml index ee3300e..1b1aa00 100644 --- a/Configuration/NodeTypes.Validator.FileSize.yaml +++ b/Configuration/NodeTypes.Validator.FileSize.yaml @@ -3,11 +3,11 @@ 'Neos.Form.Builder:AbstractValidator': true ui: label: 'File size range Validator' - icon: 'icon-sort-numeric-asc' + icon: 'icon-arrows-alt-h' inspector: groups: 'validator': - icon: 'icon-sort-numeric-asc' + icon: 'icon-filter' properties: 'minimum': type: integer From 62bea460c1b24b7a483437cd844828ec21589603 Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Thu, 5 Sep 2024 09:49:07 +0200 Subject: [PATCH 7/8] TASK: Add Mixin --- Configuration/NodeTypes.Mixin.FileValidators.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Configuration/NodeTypes.Mixin.FileValidators.yaml diff --git a/Configuration/NodeTypes.Mixin.FileValidators.yaml b/Configuration/NodeTypes.Mixin.FileValidators.yaml new file mode 100644 index 0000000..d3e7b50 --- /dev/null +++ b/Configuration/NodeTypes.Mixin.FileValidators.yaml @@ -0,0 +1,10 @@ +'Neos.Form.Builder:FileValidatorsMixin': + abstract: true + superTypes: + 'Neos.Form.Builder:ValidatorsMixin': true + childNodes: + 'validators': + constraints: + nodeTypes: + 'Neos.Form.Builder:FileSizeValidator': true + 'Neos.Form.Builder:FileExtensionValidator': true From 218750d06e437be84a2bacfa89c77126f3d34b2e Mon Sep 17 00:00:00 2001 From: Schuppel1 Date: Thu, 5 Sep 2024 09:53:28 +0200 Subject: [PATCH 8/8] Typo --- Configuration/NodeTypes.Validator.FileExtension.yaml | 2 +- Configuration/NodeTypes.Validator.FileSize.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/NodeTypes.Validator.FileExtension.yaml b/Configuration/NodeTypes.Validator.FileExtension.yaml index aa9f1f8..e013eac 100644 --- a/Configuration/NodeTypes.Validator.FileExtension.yaml +++ b/Configuration/NodeTypes.Validator.FileExtension.yaml @@ -2,7 +2,7 @@ superTypes: 'Neos.Form.Builder:AbstractValidator': true ui: - label: 'File Extension Validator' + label: 'File-Extension Validator' icon: 'icon-file-archive' inspector: groups: diff --git a/Configuration/NodeTypes.Validator.FileSize.yaml b/Configuration/NodeTypes.Validator.FileSize.yaml index 1b1aa00..fe35fdc 100644 --- a/Configuration/NodeTypes.Validator.FileSize.yaml +++ b/Configuration/NodeTypes.Validator.FileSize.yaml @@ -2,7 +2,7 @@ superTypes: 'Neos.Form.Builder:AbstractValidator': true ui: - label: 'File size range Validator' + label: 'File-Size range Validator' icon: 'icon-arrows-alt-h' inspector: groups: