diff options
-rw-r--r-- | apps/files/lib/Controller/TemplateController.php | 3 | ||||
-rw-r--r-- | apps/files/lib/ResponseDefinitions.php | 6 | ||||
-rw-r--r-- | apps/files/openapi.json | 8 | ||||
-rw-r--r-- | apps/files/src/components/TemplateFiller.vue | 2 | ||||
-rw-r--r-- | lib/public/Files/Template/BeforeGetTemplatesEvent.php | 6 | ||||
-rw-r--r-- | lib/public/Files/Template/Field.php | 20 | ||||
-rw-r--r-- | lib/public/Files/Template/ITemplateManager.php | 4 |
7 files changed, 28 insertions, 21 deletions
diff --git a/apps/files/lib/Controller/TemplateController.php b/apps/files/lib/Controller/TemplateController.php index f4770cb5623..bdc4fd7f8a0 100644 --- a/apps/files/lib/Controller/TemplateController.php +++ b/apps/files/lib/Controller/TemplateController.php @@ -21,6 +21,7 @@ use OCP\IRequest; /** * @psalm-import-type FilesTemplateFile from ResponseDefinitions * @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions + * @psalm-import-type FilesTemplateField from ResponseDefinitions */ class TemplateController extends OCSController { protected $templateManager; @@ -51,7 +52,7 @@ class TemplateController extends OCSController { * @param string $filePath Path of the file * @param string $templatePath Name of the template * @param string $templateType Type of the template - * @param array $templateFields Fields of the template + * @param FilesTemplateField[] $templateFields Fields of the template * * @return DataResponse<Http::STATUS_OK, FilesTemplateFile, array{}> * @throws OCSForbiddenException Creating template is not allowed diff --git a/apps/files/lib/ResponseDefinitions.php b/apps/files/lib/ResponseDefinitions.php index 01b20a34cac..50893af7b11 100644 --- a/apps/files/lib/ResponseDefinitions.php +++ b/apps/files/lib/ResponseDefinitions.php @@ -32,6 +32,12 @@ namespace OCA\Files; * ratio: ?float, * actionLabel: string, * } + * + * @psalm-type FilesTemplateField = array{ + * index: string, + * content: string, + * type: string, + * } */ class ResponseDefinitions { } diff --git a/apps/files/openapi.json b/apps/files/openapi.json index 6fff32e4854..e93c4d2807a 100644 --- a/apps/files/openapi.json +++ b/apps/files/openapi.json @@ -1060,6 +1060,14 @@ "type": "string", "default": "user", "description": "Type of the template" + }, + "templateFields": { + "type": "array", + "default": [], + "description": "Fields of the template", + "items": { + "$ref": "#/components/schemas/TemplateField" + } } } } diff --git a/apps/files/src/components/TemplateFiller.vue b/apps/files/src/components/TemplateFiller.vue index 082cf982d82..926bcdd4dfd 100644 --- a/apps/files/src/components/TemplateFiller.vue +++ b/apps/files/src/components/TemplateFiller.vue @@ -19,7 +19,7 @@ </div> <div class="template-field-modal__buttons"> - <NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields...')" /> + <NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields…')" /> <NcButton aria-label="Submit button" type="primary" @click="submit"> diff --git a/lib/public/Files/Template/BeforeGetTemplatesEvent.php b/lib/public/Files/Template/BeforeGetTemplatesEvent.php index c4e23c17c7c..006163c5f7f 100644 --- a/lib/public/Files/Template/BeforeGetTemplatesEvent.php +++ b/lib/public/Files/Template/BeforeGetTemplatesEvent.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /** * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -18,7 +20,7 @@ class BeforeGetTemplatesEvent extends Event { /** * @param array<Template> $templates - * + * * @since 30.0.0 */ public function __construct(array $templates) { @@ -29,7 +31,7 @@ class BeforeGetTemplatesEvent extends Event { /** * @return array<Template> - * + * * @since 30.0.0 */ public function getTemplates(): array { diff --git a/lib/public/Files/Template/Field.php b/lib/public/Files/Template/Field.php index 49c6a033e5c..ce0ed3176d9 100644 --- a/lib/public/Files/Template/Field.php +++ b/lib/public/Files/Template/Field.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /** * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -19,32 +21,18 @@ class Field implements \JsonSerializable { private ?string $tag; /** - * @param string $index - * @param string $content - * @param FieldType $type - * @param ?string $alias - * @param ?int $id - * @param ?string $tag - * * @since 30.0.0 */ - public function __construct($index, $content, $type, $alias = null, $id = null, $tag = null) { + 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; - - if ($type instanceof FieldType) { - $this->type = $type; - } else { - $this->type = FieldType::tryFrom($type) ?? throw new InvalidFieldTypeException(); - } } /** - * @return array - * * @since 30.0.0 */ public function jsonSerialize(): array { diff --git a/lib/public/Files/Template/ITemplateManager.php b/lib/public/Files/Template/ITemplateManager.php index 5adcc0ded25..94e0db935e7 100644 --- a/lib/public/Files/Template/ITemplateManager.php +++ b/lib/public/Files/Template/ITemplateManager.php @@ -67,9 +67,11 @@ interface ITemplateManager { /** * @param string $filePath * @param string $templateId + * @param string $templateType + * @param array $templateFields Since 30.0.0 * @return array * @throws GenericFileException * @since 21.0.0 */ - public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user'): array; + public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user', array $templateFields = []): array; } |