From 1d67e906a3ea0114426600f64ea5fab160672c8d Mon Sep 17 00:00:00 2001 From: Katrin Yordanova Date: Tue, 28 Mar 2023 17:16:32 +0300 Subject: [PATCH] Apply preview styles from file page block to module field --- .../ModuleFields/Configurator/File.vue | 113 +++++++----------- .../PageBlocks/FileConfigurator.vue | 8 +- lib/js/src/compose/types/module-field/file.ts | 30 ++--- locale/en/corteza-webapp-compose/field.yaml | 1 + 4 files changed, 58 insertions(+), 94 deletions(-) diff --git a/client/web/compose/src/components/ModuleFields/Configurator/File.vue b/client/web/compose/src/components/ModuleFields/Configurator/File.vue index 5aec75e43..9a70c1291 100644 --- a/client/web/compose/src/components/ModuleFields/Configurator/File.vue +++ b/client/web/compose/src/components/ModuleFields/Configurator/File.vue @@ -54,6 +54,8 @@ {{ $t('kind.file.view.previewStyle') }} + {{ $t('kind.file.view.description' ) }} + - - - + @@ -84,17 +80,11 @@ > - - - + @@ -104,17 +94,11 @@ > - - - + @@ -124,17 +108,11 @@ > - - - + @@ -144,31 +122,10 @@ > - - - - - - - - @@ -179,17 +136,27 @@ > - - - + + + + + + + diff --git a/client/web/compose/src/components/PageBlocks/FileConfigurator.vue b/client/web/compose/src/components/PageBlocks/FileConfigurator.vue index c5c2d7467..ce3818ec2 100644 --- a/client/web/compose/src/components/PageBlocks/FileConfigurator.vue +++ b/client/web/compose/src/components/PageBlocks/FileConfigurator.vue @@ -58,6 +58,8 @@ {{ $t('kind.file.view.previewStyle') }} + {{ $t('kind.file.view.description' ) }} + @@ -90,7 +91,6 @@ @@ -107,7 +107,6 @@ @@ -124,7 +123,6 @@ @@ -141,7 +139,6 @@ @@ -158,7 +155,6 @@ diff --git a/lib/js/src/compose/types/module-field/file.ts b/lib/js/src/compose/types/module-field/file.ts index d57166ec5..29759a7ba 100644 --- a/lib/js/src/compose/types/module-field/file.ts +++ b/lib/js/src/compose/types/module-field/file.ts @@ -22,12 +22,12 @@ interface FileOptions extends Options { inline: boolean; hideFileName: boolean; mimetypes?: string; - height?: number; - width?: number; - maxHeight?: number; - maxWidth?: number; - borderRadius?: number; - margin?: number; + height?: string; + width?: string; + maxHeight?: string; + maxWidth?: string; + borderRadius?: string; + margin?: string; backgroundColor?: string; } @@ -40,13 +40,13 @@ const defaults = (): Readonly => Object.freeze({ inline: true, hideFileName: false, mimetypes: '', - height: undefined, - width: undefined, - maxHeight: undefined, - maxWidth: undefined, - borderRadius: undefined, - margin: undefined, - backgroundColor: undefined, + height: '', + width: '', + maxHeight: '', + maxWidth: '', + borderRadius: '', + margin: 'auto', + backgroundColor: '', }) export class ModuleFieldFile extends ModuleField { @@ -63,9 +63,9 @@ export class ModuleFieldFile extends ModuleField { if (!o) return super.applyOptions(o) - Apply(this.options, o, Number, 'maxSize', 'height', 'width', 'maxHeight', 'maxWidth', 'borderRadius', 'margin') + Apply(this.options, o, Number, 'maxSize') Apply(this.options, o, Boolean, 'allowImages', 'allowDocuments', 'inline', 'hideFileName') - Apply(this.options, o, String, 'mimetypes', 'backgroundColor') + Apply(this.options, o, String, 'mimetypes', 'height', 'width', 'maxHeight', 'maxWidth', 'borderRadius', 'margin', 'backgroundColor') ApplyWhitelisted(this.options, o, modes, 'mode') } } diff --git a/locale/en/corteza-webapp-compose/field.yaml b/locale/en/corteza-webapp-compose/field.yaml index 06072d89e..952143d6c 100644 --- a/locale/en/corteza-webapp-compose/field.yaml +++ b/locale/en/corteza-webapp-compose/field.yaml @@ -50,6 +50,7 @@ kind: px: px enableDownload: Enable download clickToView: Click to view file + description: 'Add unit after value to set it. For example: 50px or 50%' number: exampleFormat: Format exampleInput: Input