From 14094a0f9082e1eaf22d1864a52e21c69c965f3d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Sep 2016 12:40:37 -0400 Subject: show sort/+ buttons on groupby elements if resource is empty --- examples/db.json | 9 +++++++++ examples/index.js | 22 ++++++++++++++++++++++ themes/okadmin/templates/index.liquid | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) 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 @@

{{name | capitalize}}

- {% 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] %} -- cgit v1.2.3-70-g09d2