summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-12-17 02:50:10 -0800
committerSteve Manuel <nilslice@gmail.com>2016-12-17 02:50:10 -0800
commit31c53a3c73815918515af8692021e3c29ef63d65 (patch)
treea081eea155980e8358c5834990d908e2c0dcfe84
parentcf6227c71b9c2354fc0c0e4e93b5808acd616104 (diff)
testing reference input type
-rw-r--r--addons/reference/reference.go43
1 files changed, 3 insertions, 40 deletions
diff --git a/addons/reference/reference.go b/addons/reference/reference.go
index 2681146..3865e71 100644
--- a/addons/reference/reference.go
+++ b/addons/reference/reference.go
@@ -10,11 +10,11 @@ import (
"github.com/bosssauce/ponzu/system/db"
)
-// New returns the []byte of a <select> HTML element plus internal <options> with a label.
+// 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 New(fieldName string, p interface{}, attrs map[string]string, contentType, fmtString string) []byte {
+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)
@@ -40,7 +40,7 @@ func New(fieldName string, p interface{}, attrs map[string]string, contentType,
// make sure it is an Identifiable
item, ok := t.(content.Identifiable)
if !ok {
- log.Println("Cannot use type", contentType, "as reference as it does not implement content.Identifiable")
+ log.Println("Cannot use type", contentType, "as a reference since it does not implement content.Identifiable")
return nil
}
@@ -49,42 +49,5 @@ func New(fieldName string, p interface{}, attrs map[string]string, contentType,
options[k] = v
}
- options[""] = contentType + "Content loading..."
-
return editor.Select(fieldName, p, attrs, options)
}
-
-/*
-<script>
- // fmtString = "{name} - ( Age: {age} | Power: {power} )"
- // $(function() {
- // var API = '/api/contents?type=` + contentType + `';
- // var select = $('select[name="` + name + `"]);
-
- // $.getJSON(API, function(resp, status) {
- // if (status !== '200' || status !== '304') {
- // console.log('Error loading Reference for', '` + contentType + `')
- // return
- // }
-
- // var data = resp.data,
- // options = [],
- // re = /{(.*?)}/g,
- // tmpl = '` + fmtString + `'
- // tags = tmpl.match(re),
- // keys = [];
-
- // // get keys from tags ({x} -> x)
- // for (var i = 0; i < tags.length; i++) {
- // var key = tags[i].slice(1, tags[i].length-1);
- // keys.push(key);
- // }
-
- // // create options as objects of "?type=<contentType>&id=<id>":displayName
- // for (var i = 0; i < data.length; i++) {
-
- // }
- // });
- // });
- </script>
-*/