Skip to content

Commit 9a7814c

Browse files
authoredAug 24, 2023
Merge pull request #59 from kintone-labs/v0.6.0
SSR-3727 v0.6.0 Release
2 parents 11fd1b0 + 2853b28 commit 9a7814c

File tree

2 files changed

+65
-40
lines changed

2 files changed

+65
-40
lines changed
 

‎app.go

+45-40
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
const (
2727
NAME = "go-kintone"
28-
VERSION = "0.4.2"
28+
VERSION = "0.6.0"
2929
DEFAULT_TIMEOUT = time.Second * 600 // Default value for App.Timeout
3030
)
3131

@@ -982,49 +982,51 @@ func (app *App) DeleteComment(recordId uint64, commentId uint64) error {
982982

983983
// FieldInfo is the meta data structure of a field.
984984
type FieldInfo struct {
985-
Label string `json:"label"` // Label string
986-
Code string `json:"code"` // Unique field code
987-
Type string `json:"type"` // Field type. One of FT_* constant.
988-
NoLabel bool `json:"noLabel"` // true to hide the label
989-
Required bool `json:"required"` // true if this field must be filled
990-
Unique bool `json:"unique"` // true if field values must be unique
991-
MaxValue interface{} `json:"maxValue"` // nil or numeric string
992-
MinValue interface{} `json:"minValue"` // nil or numeric string
993-
MaxLength interface{} `json:"maxLength"` // nil or numeric string
994-
MinLength interface{} `json:"minLength"` // nil or numeric string
995-
Default interface{} `json:"defaultValue"` // anything
996-
DefaultTime interface{} `json:"defaultExpression"` // nil or "NOW"
997-
Options []string `json:"options"` // list of selectable values
998-
Expression string `json:"expression"` // to calculate values
999-
Separator bool `json:"digit"` // true to use thousand separator
1000-
Medium string `json:"protocol"` // "WEB", "CALL", or "MAIL"
1001-
Format string `json:"format"` // "NUMBER", "NUMBER_DIGIT", "DATETIME", "DATE", "TIME", "HOUR_MINUTE", "DAY_HOUR_MINUTE"
1002-
Fields []FieldInfo `json:"fields"` // Field list of this subtable
1003-
Index int `json:"index"`
985+
Label string `json:"label"` // Label string
986+
Code string `json:"code"` // Unique field code
987+
Type string `json:"type"` // Field type. One of FT_* constant.
988+
NoLabel bool `json:"noLabel"` // true to hide the label
989+
Required bool `json:"required"` // true if this field must be filled
990+
Unique bool `json:"unique"` // true if field values must be unique
991+
MaxValue interface{} `json:"maxValue"` // nil or numeric string
992+
MinValue interface{} `json:"minValue"` // nil or numeric string
993+
MaxLength interface{} `json:"maxLength"` // nil or numeric string
994+
MinLength interface{} `json:"minLength"` // nil or numeric string
995+
Default interface{} `json:"defaultValue"` // anything
996+
DefaultTime interface{} `json:"defaultExpression"` // nil or "NOW"
997+
Options []string `json:"options"` // list of selectable values
998+
Expression string `json:"expression"` // to calculate values
999+
Separator bool `json:"digit"` // true to use thousand separator
1000+
Medium string `json:"protocol"` // "WEB", "CALL", or "MAIL"
1001+
Format string `json:"format"` // "NUMBER", "NUMBER_DIGIT", "DATETIME", "DATE", "TIME", "HOUR_MINUTE", "DAY_HOUR_MINUTE"
1002+
Fields []FieldInfo `json:"fields"` // Field list of this subtable
1003+
Index int `json:"index"`
1004+
Lookup *map[string]interface{} `json:"lookup,omitempty"` // lookup
10041005
}
10051006

10061007
// Work around code to handle "true"/"false" strings as booleans...
10071008
func (fi *FieldInfo) UnmarshalJSON(data []byte) error {
10081009
var t struct {
1009-
Label string `json:"label"`
1010-
Code string `json:"code"`
1011-
Type string `json:"type"`
1012-
NoLabel string `json:"noLabel"`
1013-
Required string `json:"required"`
1014-
Unique string `json:"unique"`
1015-
MaxValue interface{} `json:"maxValue"`
1016-
MinValue interface{} `json:"minValue"`
1017-
MaxLength interface{} `json:"maxLength"`
1018-
MinLength interface{} `json:"minLength"`
1019-
Default interface{} `json:"defaultValue"`
1020-
DefaultTime interface{} `json:"defaultExpression"`
1021-
Options []string `json:"options"`
1022-
Expression string `json:"expression"`
1023-
Separator string `json:"digit"`
1024-
Medium string `json:"protocol"`
1025-
Format string `json:"format"`
1026-
Fields []FieldInfo `json:"fields"`
1027-
Index int `json:"index"`
1010+
Label string `json:"label"`
1011+
Code string `json:"code"`
1012+
Type string `json:"type"`
1013+
NoLabel string `json:"noLabel"`
1014+
Required string `json:"required"`
1015+
Unique string `json:"unique"`
1016+
MaxValue interface{} `json:"maxValue"`
1017+
MinValue interface{} `json:"minValue"`
1018+
MaxLength interface{} `json:"maxLength"`
1019+
MinLength interface{} `json:"minLength"`
1020+
Default interface{} `json:"defaultValue"`
1021+
DefaultTime interface{} `json:"defaultExpression"`
1022+
Options []string `json:"options"`
1023+
Expression string `json:"expression"`
1024+
Separator string `json:"digit"`
1025+
Medium string `json:"protocol"`
1026+
Format string `json:"format"`
1027+
Fields []FieldInfo `json:"fields"`
1028+
Index int `json:"index"`
1029+
Lookup *map[string]interface{} `json:"lookup,omitempty"`
10281030
}
10291031
err := json.Unmarshal(data, &t)
10301032
if err != nil {
@@ -1038,7 +1040,7 @@ func (fi *FieldInfo) UnmarshalJSON(data []byte) error {
10381040
t.MaxValue, t.MinValue, t.MaxLength, t.MinLength,
10391041
t.Default, t.DefaultTime, t.Options, t.Expression,
10401042
(t.Separator == "true"),
1041-
t.Medium, t.Format, t.Fields, t.Index,
1043+
t.Medium, t.Format, t.Fields, t.Index, t.Lookup,
10421044
}
10431045
return nil
10441046
}
@@ -1098,6 +1100,9 @@ func decodeFieldInfo(t AppFormFields, ret map[string]*FieldInfo) {
10981100
sb = append(sb, *ret[z])
10991101
}
11001102
fi.Fields = sb
1103+
case "lookup":
1104+
result, _ := (w).(map[string]interface{})
1105+
fi.Lookup = &result
11011106
default:
11021107
break
11031108
}

‎app_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,23 @@ func TestGetProcess(t *testing.T) {
496496
t.Error("TestGetProcess failed: ", err)
497497
}
498498
}
499+
500+
func TestLookupFieldInFieldInfo(t *testing.T) {
501+
app := newApp()
502+
countLookup := 0
503+
fi, err := app.Fields()
504+
if err != nil {
505+
t.Error("Fields failed", err)
506+
}
507+
for _, f := range fi {
508+
if f.Lookup != nil {countLookup++}
509+
}
510+
511+
if countLookup > 0 {
512+
fmt.Printf("\nApp have %v Lookup field\n", countLookup);
513+
}
514+
515+
if countLookup == 0 {
516+
fmt.Printf("\nApp have no Lookup field\n");
517+
}
518+
}

0 commit comments

Comments
 (0)
Please sign in to comment.