diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-17 03:30:33 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-17 03:30:33 -0800 |
commit | f680588370706affb2ef98ba2a93d93fb5284683 (patch) | |
tree | 35d8ba1754929d19cd66ad43bd3af20945f87e44 /management/reference/reference.go | |
parent | 755c1d95d5b164952deeb0fadd96f3e3c5888e33 (diff) |
testing simplification of reference input
Diffstat (limited to 'management/reference/reference.go')
-rw-r--r-- | management/reference/reference.go | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/management/reference/reference.go b/management/reference/reference.go index 48446d5..e6d7edd 100644 --- a/management/reference/reference.go +++ b/management/reference/reference.go @@ -5,7 +5,6 @@ import ( "fmt" "log" - "github.com/bosssauce/ponzu/content" "github.com/bosssauce/ponzu/management/editor" "github.com/bosssauce/ponzu/system/db" ) @@ -14,38 +13,21 @@ import ( // IMPORTANT: // The `fieldName` argument will cause a panic if it is not exactly the string // form of the struct field that this editor input is representing -func Select(fieldName string, p interface{}, attrs map[string]string, contentType string) []byte { - ct, ok := content.Types[contentType] - if !ok { - log.Println("Cannot reference an invalid content type:", contentType) - return nil - } - - // get a handle to the underlying interface type for decoding - t := ct() - - fmt.Println(t) - +func Select(fieldName string, p interface{}, attrs map[string]string, contentType, display string) []byte { // decode all content type from db into options map // map["?type=<contentType>&id=<id>"]t.String() options := make(map[string]string) jj := db.ContentAll(contentType + "__sorted") + data := make(map[string]interface{}) for i := range jj { - err := json.Unmarshal(jj[i], t) + err := json.Unmarshal(jj[i], data) if err != nil { log.Println("Error decoding into reference handle:", contentType, err) } - // make sure it is an Identifiable - item, ok := t.(content.Identifiable) - if !ok { - log.Println("Cannot use type", contentType, "as a reference since it does not implement content.Identifiable") - return nil - } - - k := fmt.Sprintf("?type=%s&id=%d", contentType, item.ItemID()) - v := item.String() + k := fmt.Sprintf("?type=%s&id=%d", contentType, data["id"].(int)) + v := data[display].(string) options[k] = v } |