-
Notifications
You must be signed in to change notification settings - Fork 10
add use cases for editing template to TemplatesRepository.ts #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 4 commits
7f37fe1
a6df2e2
5cb432a
4b6149b
b98a2da
70d0228
2c483e5
503f81b
faade42
7a73b1c
fc2acfc
4d88ce6
651c24e
8d8258b
a6e163d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { CustomTerms } from '../../../datasets/domain/models/Dataset' | ||
|
|
||
| export interface UpdateTemplateLicenseTermsDTO { | ||
| name?: string | ||
| customTerms?: CustomTerms | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { TemplateFieldDTO, TemplateInstructionDTO } from './CreateTemplateDTO' | ||
|
|
||
| export interface UpdateTemplateMetadataDTO { | ||
| name?: string | ||
| fields?: TemplateFieldDTO[] | ||
| instructions?: TemplateInstructionDTO[] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { UpdateTemplateLicenseTermsDTO } from '../dtos/UpdateTemplateLicenseTermsDTO' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateLicenseTerms implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
| async execute(templateId: number, payload: UpdateTemplateLicenseTermsDTO): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateLicenseTerms(templateId, payload) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { UpdateTemplateMetadataDTO } from '../dtos/UpdateTemplateMetadataDTO' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateMetadata implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
| async execute( | ||
| templateId: number, | ||
| payload: UpdateTemplateMetadataDTO, | ||
| replace = false | ||
| ): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateMetadata(templateId, payload, replace) | ||
| } | ||
|
ekraffmiller marked this conversation as resolved.
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { TermsOfAccess } from '../../../datasets/domain/models/Dataset' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateTermsOfAccess implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
|
ekraffmiller marked this conversation as resolved.
|
||
| async execute(templateId: number, termsOfAccess: TermsOfAccess): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateTermsOfAccess(templateId, termsOfAccess) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { TermsOfAccess } from '../../../../datasets/domain/models/Dataset' | ||
|
|
||
| export const transformTemplateTermsOfAccessToUpdatePayload = ( | ||
| terms: TermsOfAccess & { termsOfAccess?: string } | ||
| ) => { | ||
| const { | ||
| fileAccessRequest, | ||
| dataAccessPlace, | ||
| originalArchive, | ||
| availabilityStatus, | ||
| contactForAccess, | ||
| sizeOfCollection, | ||
| studyCompletion | ||
| } = terms | ||
|
|
||
| const termsOfAccess = terms.termsOfAccess ?? terms.termsOfAccessForRestrictedFiles | ||
|
|
||
| return { | ||
| customTermsOfAccess: { | ||
| fileAccessRequest, | ||
| termsOfAccess, | ||
| dataAccessPlace, | ||
| originalArchive, | ||
| availabilityStatus, | ||
| contactForAccess, | ||
| sizeOfCollection, | ||
| studyCompletion | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| POSTGRES_VERSION=17 | ||
| DATAVERSE_DB_USER=dataverse | ||
| SOLR_VERSION=9.8.0 | ||
| DATAVERSE_IMAGE_REGISTRY=docker.io | ||
| DATAVERSE_IMAGE_TAG=unstable | ||
| DATAVERSE_IMAGE_REGISTRY=ghcr.io | ||
| DATAVERSE_IMAGE_TAG=11912-edit-template-api | ||
|
||
| DATAVERSE_BOOTSTRAP_TIMEOUT=5m | ||
Uh oh!
There was an error while loading. Please reload this page.