From 4249bf0e0be86677a78c294faabb6e25c498b120 Mon Sep 17 00:00:00 2001
From: NazarMykhalkevych Upload File
Uploaded files will automatically be archived in this registration. They will also be added to a
related project that will be created for this registration.
File input is not implemented yet.
+{{ progress() }} %
+- You may attach up to 5 file(s) to this question. Files cannot total over 5GB in size. + {{ 'shared.files.limitText' | translate }}
- Uploaded files will automatically be archived in this registration. They will also be added to a - related project that will be created for this registration. + {{ 'shared.files.description' | translate }}
{{ option }}
+ @switch (question.fieldType) { + @case (FieldType.Text) { +{{ stepsData()[question.responseKey!] }}
+ } + @case (FieldType.Checkbox) { + @for (option of stepsData()[question.responseKey!]; track option) { +{{ option }}
+ } + } + @case (FieldType.File) { + @if (stepsData()[question.responseKey!].length) { +{{ 'common.labels.noFiles' | translate }}
+ } + } + @default { +{{ stepsData()[question.responseKey!] }}
} - } @else { -{{ stepsData()[question.responseKey!] }}
} } @else { @if (question.fieldType === FieldType.File) { diff --git a/src/app/features/registries/mappers/files.mapper.ts b/src/app/features/registries/mappers/files.mapper.ts new file mode 100644 index 000000000..bde6bd742 --- /dev/null +++ b/src/app/features/registries/mappers/files.mapper.ts @@ -0,0 +1,17 @@ +import { FilePayloadJsonApi, OsfFile } from '@osf/shared/models'; + +export class FilesMapper { + static toFilePayload(file: OsfFile): FilePayloadJsonApi { + return { + file_id: file.id, + file_name: file.name, + file_urls: { + html: file.links.html, + download: file.links.download, + }, + file_hashes: { + sha256: file.extra?.hashes?.sha256 || '', + }, + }; + } +} diff --git a/src/app/features/registries/mappers/page-schema.mapper.ts b/src/app/features/registries/mappers/page-schema.mapper.ts index cd399808c..3a60c6add 100644 --- a/src/app/features/registries/mappers/page-schema.mapper.ts +++ b/src/app/features/registries/mappers/page-schema.mapper.ts @@ -126,6 +126,7 @@ export class PageSchemaMapper { case BlockType.FileInput: if (currentQuestion) { currentQuestion.fieldType = FieldType.File; + currentQuestion.required = item.attributes.required; currentQuestion.responseKey = item.attributes.registration_response_key || undefined; } break; diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index bc237bc4a..077d0a08c 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -36,7 +36,6 @@ export class FilesHandlers { getProjectFiles(ctx: StateContext{{ 'project.files.dropText' | translate }}
+