Skip to content

Commit 8fbb688

Browse files
committed
Allow tag creation without a target, falling back to case tags.
1 parent 4fd545b commit 8fbb688

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

dto/tag_dto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func AdaptTagDto(t models.Tag) APITag {
2727
}
2828

2929
type CreateTagBody struct {
30-
Target string `json:"target" binding:"required,oneof=case object"`
30+
Target string `json:"target" binding:"omitempty,oneof=case object"`
3131
Name string `json:"name" binding:"required"`
3232
Color string `json:"color" binding:"required,hexcolor"`
3333
}

usecases/tag_usecase.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func (usecase *TagUseCase) CreateTag(ctx context.Context, attributes models.Crea
5252
return models.Tag{}, err
5353
}
5454

55+
if attributes.Target == models.TagTargetUnknown {
56+
attributes.Target = models.TagTargetCase
57+
}
58+
5559
tag, err := executor_factory.TransactionReturnValue(ctx,
5660
usecase.transactionFactory, func(tx repositories.Transaction) (models.Tag, error) {
5761
newTagId := uuid.NewString()

0 commit comments

Comments
 (0)