diff options
author | Steve <nilslice@gmail.com> | 2016-12-06 15:24:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 15:24:36 -0800 |
commit | f39c1519ab382a343c05163f00f38c83bff3583d (patch) | |
tree | 254f75834f2cb787179f7880b0063e667d8ad234 /management/editor/elements.go | |
parent | 5527117e706114c1188afaa10188d96170874047 (diff) | |
parent | 64050ef8065bccdef0aab1748040995c637fe9ed (diff) |
Merge pull request #19 from bosssauce/ponzu-dev
[core] Added account recovery process and content pagination in admin UI
Diffstat (limited to 'management/editor/elements.go')
-rw-r--r-- | management/editor/elements.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/management/editor/elements.go b/management/editor/elements.go index 4a95150..4a8ae55 100644 --- a/management/editor/elements.go +++ b/management/editor/elements.go @@ -341,7 +341,15 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { // get the saved tags if this is already an existing post values := valueFromStructField(fieldName, p) - tags := strings.Split(values, "__ponzu") + var tags []string + if strings.Contains(values, "__ponzu") { + tags = strings.Split(values, "__ponzu") + } + + // case where there is only one tag stored, thus has no separator + if len(values) > 0 && !strings.Contains(values, "__ponzu") { + tags = append(tags, values) + } html := ` <div class="col s12 __ponzu-tags ` + name + `"> @@ -375,7 +383,7 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { var input = $('<input>'); input.attr({ - class: 'tag '+chip.tag, + class: '__ponzu-tag '+chip.tag.split(' ').join('__'), name: '` + name + `.'+String(tags.find('input[type=hidden]').length), value: chip.tag, type: 'hidden' @@ -386,9 +394,7 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { chips.on('chip.delete', function(e, chip) { // convert tag string to class-like selector "some tag" -> ".some.tag" - var sel = '.__ponzu-tag.'+chip.tag.split(' ').join('.'); - console.log(sel); - console.log(chips.parent().find(sel)); + var sel = '.__ponzu-tag.' + chip.tag.split(' ').join('__'); chips.parent().find(sel).remove(); // iterate through all hidden tag inputs to re-name them with the correct ` + name + `.index @@ -404,9 +410,9 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { }); tags.append(input); - return; } + // re-name hidden storage elements in necessary format for (var i = 0; i < hidden.length; i++) { $(hidden[i]).attr('name', '` + name + `.'+String(i)); } |