Skip to content

Commit

Permalink
Moved more code to update.go for work package resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pfohl committed Jun 29, 2023
1 parent e4acd5c commit 3422867
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 0 additions & 16 deletions components/resources/work_packages/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ import (
"github.com/opf/openproject-cli/models"
)

type UpdateOption int

const (
UpdateAction UpdateOption = iota
UpdateAttach
UpdateSubject
UpdateType
)

var patchableUpdates = []UpdateOption{UpdateSubject, UpdateType}

var patchMap = map[UpdateOption]func(patch, workPackage *dtos.WorkPackageDto, input string) (string, error){
UpdateType: typePatch,
UpdateSubject: subjectPatch,
}

type FilterOption int

const (
Expand Down
16 changes: 16 additions & 0 deletions components/resources/work_packages/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ import (
"github.com/opf/openproject-cli/models"
)

type UpdateOption int

const (
UpdateAction UpdateOption = iota
UpdateAttach
UpdateSubject
UpdateType
)

var patchableUpdates = []UpdateOption{UpdateSubject, UpdateType}

var patchMap = map[UpdateOption]func(patch, workPackage *dtos.WorkPackageDto, input string) (string, error){
UpdateType: typePatch,
UpdateSubject: subjectPatch,
}

func Update(id uint64, options map[UpdateOption]string) (*models.WorkPackage, error) {
workPackage, err := fetch(id)
if err != nil {
Expand Down

0 comments on commit 3422867

Please sign in to comment.