diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-17 03:17:30 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-17 03:17:30 -0800 |
commit | 01c856d7d7fbb10998e7e07f75958cf28f3f32d6 (patch) | |
tree | 3350d9eb3a6d8ae23e1a77a3a86f0fec10e233e7 /addons | |
parent | 31c53a3c73815918515af8692021e3c29ef63d65 (diff) |
testing fix for import cycle issue
Diffstat (limited to 'addons')
-rw-r--r-- | addons/reference/reference.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/addons/reference/reference.go b/addons/reference/reference.go deleted file mode 100644 index 3865e71..0000000 --- a/addons/reference/reference.go +++ /dev/null @@ -1,53 +0,0 @@ -package reference - -import ( - "encoding/json" - "fmt" - "log" - - "github.com/bosssauce/ponzu/content" - "github.com/bosssauce/ponzu/management/editor" - "github.com/bosssauce/ponzu/system/db" -) - -// Select returns the []byte of a <select> HTML element plus internal <options> with a label. -// 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) - - // // 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") - - for i := range jj { - err := json.Unmarshal(jj[i], t) - 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() - options[k] = v - } - - return editor.Select(fieldName, p, attrs, options) -} |