// SiYuan - Refactor your thinking // Copyright (c) 2020-present, b3log.org // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package api import ( "net/http" "github.com/88250/gulu" "github.com/gin-gonic/gin" "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/util" ) func renderAttributeView(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) arg, ok := util.JsonArg(c, ret) if !ok { return } id := arg["id"].(string) nodeID := arg["nodeID"].(string) view, attrView, err := model.RenderAttributeView(id, nodeID) if nil != err { ret.Code = -1 ret.Msg = err.Error() return } var views []map[string]interface{} for _, v := range attrView.Views { view := map[string]interface{}{ "id": v.ID, "name": v.Name, "type": v.LayoutType, } views = append(views, view) } ret.Data = map[string]interface{}{ "name": attrView.Name, "id": attrView.ID, "viewType": view.GetType(), "viewID": view.GetID(), "views": views, "view": view, } } func getAttributeViewKeys(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) arg, ok := util.JsonArg(c, ret) if !ok { return } id := arg["id"].(string) blockAttributeViewKeys := model.GetBlockAttributeViewKeys(id) ret.Data = blockAttributeViewKeys } func setAttributeViewBlockAttr(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) arg, ok := util.JsonArg(c, ret) if !ok { return } avID := arg["avID"].(string) keyID := arg["keyID"].(string) rowID := arg["rowID"].(string) cellID := arg["cellID"].(string) value := arg["value"].(interface{}) blockAttributeViewKeys := model.UpdateAttributeViewCell(avID, keyID, rowID, cellID, value) util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID}) ret.Data = blockAttributeViewKeys }