Skip to content

Commit

Permalink
Add support for project datatype in custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
oveaurs committed Oct 6, 2022
1 parent 3ac9347 commit 341a9bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/jira/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ func constructCustomFields(fields map[string]string, data *createRequest) {
switch configured.Schema.DataType {
case customFieldFormatOption:
data.Fields.M.customFields[configured.Key] = customFieldTypeOption{Value: val}
case customFieldFormatProject:
data.Fields.M.customFields[configured.Key] = customFieldTypeProject{Value: val}
case customFieldFormatArray:
pieces := strings.Split(strings.TrimSpace(val), ",")
if configured.Schema.Items == customFieldFormatOption {
Expand Down
15 changes: 12 additions & 3 deletions pkg/jira/customfield.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package jira

const (
customFieldFormatOption = "option"
customFieldFormatArray = "array"
customFieldFormatNumber = "number"
customFieldFormatOption = "option"
customFieldFormatArray = "array"
customFieldFormatNumber = "number"
customFieldFormatProject = "project"
)

type customField map[string]interface{}
Expand All @@ -30,3 +31,11 @@ type customFieldTypeOptionAddRemove struct {
Add *customFieldTypeOption `json:"add,omitempty"`
Remove *customFieldTypeOption `json:"remove,omitempty"`
}

type customFieldTypeProject struct {
Value string `json:"key"`
}

type customFieldTypeProjectSet struct {
Set customFieldTypeProject `json:"set"`
}
2 changes: 2 additions & 0 deletions pkg/jira/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ func constructCustomFieldsForEdit(fields map[string]string, data *editRequest) {
switch configured.Schema.DataType {
case customFieldFormatOption:
data.Update.M.customFields[configured.Key] = []customFieldTypeOptionSet{{Set: customFieldTypeOption{Value: val}}}
case customFieldFormatProject:
data.Update.M.customFields[configured.Key] = []customFieldTypeProjectSet{{Set: customFieldTypeProject{Value: val}}}
case customFieldFormatArray:
pieces := strings.Split(strings.TrimSpace(val), ",")
if configured.Schema.Items == customFieldFormatOption {
Expand Down

0 comments on commit 341a9bd

Please sign in to comment.