diff --git a/apps/files/src/components/TemplateFiller.vue b/apps/files/src/components/TemplateFiller.vue index 926bcdd4dfd24..a52928ebc1a9e 100644 --- a/apps/files/src/components/TemplateFiller.vue +++ b/apps/files/src/components/TemplateFiller.vue @@ -9,11 +9,8 @@

{{ t('files', 'Fill template fields') }}

-
- +
@@ -29,11 +26,12 @@ - + + diff --git a/apps/files/src/components/TemplateFiller/TemplateTextField.vue b/apps/files/src/components/TemplateFiller/TemplateRichTextField.vue similarity index 91% rename from apps/files/src/components/TemplateFiller/TemplateTextField.vue rename to apps/files/src/components/TemplateFiller/TemplateRichTextField.vue index b58e17971c790..e794abd7e163c 100644 --- a/apps/files/src/components/TemplateFiller/TemplateTextField.vue +++ b/apps/files/src/components/TemplateFiller/TemplateRichTextField.vue @@ -15,7 +15,7 @@ :label="fieldLabel" :label-outside="true" :placeholder="field.content" - @input="$emit('input', [value, field.index])" /> + @input="$emit('input', [field.index, 'content', value])" /> @@ -24,7 +24,7 @@ import { defineComponent } from 'vue' import { NcTextField } from '@nextcloud/vue' export default defineComponent({ - name: 'TemplateTextField', + name: 'TemplateRichTextField', components: { NcTextField, diff --git a/lib/public/Files/Template/Field.php b/lib/public/Files/Template/Field.php index 9a847d29ce0c8..6f26a464597d3 100644 --- a/lib/public/Files/Template/Field.php +++ b/lib/public/Files/Template/Field.php @@ -13,36 +13,39 @@ * @since 30.0.0 */ class Field implements \JsonSerializable { - private string $index; - private string $content; - private FieldType $type; - private ?string $alias; - private ?int $id; - private ?string $tag; + public ?string $content = null; + public ?string $alias = null; + public ?string $tag = null; + public ?int $id = null; + public ?bool $checked = null; /** * @since 30.0.0 */ - public function __construct(string $index, string $content, FieldType $type, ?string $alias = null, ?int $id = null, ?string $tag = null) { - $this->index = $index; - $this->alias = $alias; - $this->type = $type; - $this->id = $id; - $this->tag = $tag; - $this->content = $content; + public function __construct( + private string $index, + private FieldType $type + ) { } /** * @since 30.0.0 */ public function jsonSerialize(): array { - return [ - 'index' => $this->index, - 'content' => $this->content, - 'type' => $this->type->value, - 'alias' => $this->alias, - 'id' => $this->id, - 'tag' => $this->tag, - ]; + $jsonProperties = []; + + foreach (get_object_vars($this) as $propertyName => $propertyValue) { + if (is_null($propertyValue)) { + continue; + } + + if ($propertyValue instanceof FieldType) { + $propertyValue = $propertyValue->value; + } + + array_push($jsonProperties, [$propertyName => $propertyValue]); + } + + return array_merge([], ...$jsonProperties); } }