diff --git a/kernel/api/av.go b/kernel/api/av.go index ca9d3858e..88953e6b3 100644 --- a/kernel/api/av.go +++ b/kernel/api/av.go @@ -27,7 +27,7 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -func getAttributeViewSelectOptions(c *gin.Context) { +func getAttributeViewKeysByAvID(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) @@ -36,8 +36,7 @@ func getAttributeViewSelectOptions(c *gin.Context) { return } avID := arg["avID"].(string) - keyID := arg["keyID"].(string) - ret.Data = model.GetAttributeViewSelectOptions(avID, keyID) + ret.Data = model.GetAttributeViewKeysByAvID(avID) } func getMirrorDatabaseBlocks(c *gin.Context) { diff --git a/kernel/api/router.go b/kernel/api/router.go index 6de7dd863..45f2148e1 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -423,7 +423,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/av/getAttributeViewPrimaryKeyValues", model.CheckAuth, model.CheckReadonly, getAttributeViewPrimaryKeyValues) ginServer.Handle("POST", "/api/av/setDatabaseBlockView", model.CheckAuth, model.CheckReadonly, setDatabaseBlockView) ginServer.Handle("POST", "/api/av/getMirrorDatabaseBlocks", model.CheckAuth, model.CheckReadonly, getMirrorDatabaseBlocks) - ginServer.Handle("POST", "/api/av/getAttributeViewSelectOptions", model.CheckAuth, model.CheckReadonly, getAttributeViewSelectOptions) + ginServer.Handle("POST", "/api/av/getAttributeViewKeysByAvID", model.CheckAuth, model.CheckReadonly, getAttributeViewKeysByAvID) ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT) ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index edfcee6f0..c5eb0e05d 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -41,8 +41,8 @@ import ( "github.com/xrash/smetrics" ) -func GetAttributeViewSelectOptions(avID string, keyID string) (ret []*av.SelectOption) { - ret = []*av.SelectOption{} +func GetAttributeViewKeysByAvID(avID string) (ret []*av.Key) { + ret = []*av.Key{} attrView, err := av.ParseAttributeView(avID) if nil != err { @@ -50,17 +50,9 @@ func GetAttributeViewSelectOptions(avID string, keyID string) (ret []*av.SelectO return } - key, _ := attrView.GetKey(keyID) - if nil == key { - return - } - - if av.KeyTypeSelect != key.Type && av.KeyTypeMSelect != key.Type { - return - } - - if 0 < len(key.Options) { - ret = key.Options + for _, keyValues := range attrView.KeyValues { + key := keyValues.Key + ret = append(ret, key) } return ret }