diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-09-02 12:40:37 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-09-02 12:40:37 -0400 |
| commit | 14094a0f9082e1eaf22d1864a52e21c69c965f3d (patch) | |
| tree | 945d64312c5b1b4a1cb89dd98120bd1beb52412e | |
| parent | ef64682b40be479ecff91c19d406fff10f9cc688 (diff) | |
show sort/+ buttons on groupby elements if resource is empty
| -rw-r--r-- | examples/db.json | 9 | ||||
| -rw-r--r-- | examples/index.js | 22 | ||||
| -rw-r--r-- | themes/okadmin/templates/index.liquid | 4 |
3 files changed, 34 insertions, 1 deletions
diff --git a/examples/db.json b/examples/db.json index 454db14..74f460f 100644 --- a/examples/db.json +++ b/examples/db.json @@ -246,5 +246,14 @@ "__index": 0, "dateCreated": "Thu, 21 Apr 2016 21:52:44 GMT" } + ], + "card": [], + "stack": [ + { + "id": "demo", + "title": "Demo", + "__index": 0, + "dateCreated": "Fri, 02 Sep 2016 16:20:27 GMT" + } ] }
\ No newline at end of file diff --git a/examples/index.js b/examples/index.js index 711246a..f1fabfa 100644 --- a/examples/index.js +++ b/examples/index.js @@ -10,6 +10,17 @@ var app = okcms.createApp({ debug: !isProduction, production: isProduction, + admin: { + dashboard: { + resources: { + card: { + groupBy: 'stack', + descending: true + } + } + }, + }, + schemas: { page: { id: {type: 'string'}, @@ -35,6 +46,15 @@ var app = okcms.createApp({ id: {type: 'string', hidden: true}, title: {type: 'string'}, image: {type: 'image'}, + }, + card: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, + stack: {type: 'foreign-key', key: 'stack'}, + }, + stack: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, } }, @@ -44,6 +64,8 @@ var app = okcms.createApp({ { type: 'bread' }, { type: 'test' }, { type: 'flour' }, + { type: 'card' }, + { type: 'stack' }, ], services: { diff --git a/themes/okadmin/templates/index.liquid b/themes/okadmin/templates/index.liquid index c8c4aa5..ebb1bde 100644 --- a/themes/okadmin/templates/index.liquid +++ b/themes/okadmin/templates/index.liquid @@ -9,13 +9,15 @@ <section class="resource-category root {% if resource.groupBy %} grouped {% endif %} + {% if resource.descending %} descending {% endif %} {{name}}"> <form action="{{resource.type}}/__batch__/" method="POST"> <header> <h2>{{name | capitalize}}</h2> </header> <input type="hidden" name="_method" value="PUT"> - {% if resource.groupBy %} + {% assign resourceJSON = resource.data[0][resource.groupBy] | stringify %} + {% if resource.groupBy and resourceJSON != "{}" %} {% assign i = 0 %} {% for item in resource.data %} {% for pair in item[resource.groupBy] %} |
