summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-02 18:38:12 +0100
committerJules Laplace <julescarbon@gmail.com>2021-03-02 18:38:30 +0100
commiteed359e2b6d35fe444353f115237d41d6acad9dc (patch)
tree5e90cb767cf7e87555890318e7f103d9e78cf568
parentee364381107827718c90fa359055be8e525fe386 (diff)
improving display options to the admin view
-rw-r--r--Readme.md25
-rw-r--r--app/node_modules/okadminview/index.js3
-rw-r--r--examples/db.json51
-rw-r--r--examples/index.js14
-rw-r--r--themes/okadmin/templates/index.liquid3
-rw-r--r--themes/okadmin/templates/partials/inputs.liquid8
6 files changed, 102 insertions, 2 deletions
diff --git a/Readme.md b/Readme.md
index 9d146e0..8fa5a0d 100644
--- a/Readme.md
+++ b/Readme.md
@@ -73,6 +73,31 @@ Valid datatypes include:
- double-captioned-image-list
- meta
+### Notes
+
+- ALL records should have a title. this is used to generate the ID.
+- add an `alias` attribute to retitle fields in the admin view
+- foreign keys: list `key` attribute pointing at the other table
+
+### Dashboard resources
+
+```
+ dashboard: {
+ resources: {
+ flour: {
+ display: "image",
+ },
+ bread: {
+ title: "type",
+ subtitle: "title",
+ },
+ artwork: {
+ groupBy: "artist",
+ },
+ },
+ },
+```
+
## Local S3
If you don't want to use S3 and you have enough disk space locally, you can just write them locally. Supply these options to the S3 service configuration (pathss with trailing slash!).
diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js
index 6d441bd..709e630 100644
--- a/app/node_modules/okadminview/index.js
+++ b/app/node_modules/okadminview/index.js
@@ -378,6 +378,7 @@ function fetchIndexTemplateData(meta, queries, dashboardConfig) {
descending: descending,
display: dashConf.display,
title: dashConf.title || "title",
+ subtitle: dashConf.subtitle || null,
}
}
return acc
@@ -448,7 +449,7 @@ function fetchForeignKeyOptions(resource) {
function fillOptions(results) {
return Q.promise(function(resolve, reject) {
spec[field].options = results.map(function(result) {
- return result.id
+ return [result.id, result.title]
})
resolve()
})
diff --git a/examples/db.json b/examples/db.json
index 11204e7..a0a7eb3 100644
--- a/examples/db.json
+++ b/examples/db.json
@@ -340,5 +340,56 @@
"__index": 0,
"dateCreated": "Tue, 23 Feb 2021 19:30:32 GMT"
}
+ ],
+ "artist": [
+ {
+ "id": "alexandra-leykauf",
+ "title": "Alexandra Leykauf",
+ "__index": 0,
+ "dateCreated": "Tue, 02 Mar 2021 17:26:21 GMT"
+ },
+ {
+ "id": "dragutin-banic",
+ "title": "Dragutin Banic",
+ "__index": 1,
+ "dateCreated": "Tue, 02 Mar 2021 17:31:53 GMT"
+ }
+ ],
+ "artwork": [
+ {
+ "id": "sample-1",
+ "title": "Sample 1",
+ "artist": "alexandra-leykauf",
+ "__index": 1,
+ "dateCreated": "Tue, 02 Mar 2021 17:31:33 GMT"
+ },
+ {
+ "id": "sample-2",
+ "title": "Sample 2",
+ "artist": "alexandra-leykauf",
+ "__index": 0,
+ "dateCreated": "Tue, 02 Mar 2021 17:31:37 GMT"
+ },
+ {
+ "id": "sample-3",
+ "title": "Sample 3",
+ "artist": "alexandra-leykauf",
+ "__index": 2,
+ "dateCreated": "Tue, 02 Mar 2021 17:31:39 GMT"
+ },
+ {
+ "id": "dragutin-s-dream",
+ "title": "Dragutin's Dream",
+ "artist": "dragutin-banic",
+ "__index": 4,
+ "dateCreated": "Tue, 02 Mar 2021 17:32:02 GMT"
+ },
+ {
+ "id": "dragutin-s-nightmare",
+ "title": "Dragutin's Nightmare",
+ "artist": "dragutin-banic",
+ "__index": 3,
+ "dateCreated": "Tue, 02 Mar 2021 17:32:08 GMT"
+ }
]
} \ No newline at end of file
diff --git a/examples/index.js b/examples/index.js
index 57bd600..a2a1a18 100644
--- a/examples/index.js
+++ b/examples/index.js
@@ -29,6 +29,9 @@ var app = okcms
bread: {
title: "type",
},
+ artwork: {
+ groupBy: "artist",
+ },
},
},
},
@@ -77,6 +80,15 @@ var app = okcms
title: { type: "string" },
file: { type: "file" },
},
+ artist: {
+ id: { type: "string", hidden: true },
+ title: { type: "string", alias: "Artist Name" },
+ },
+ artwork: {
+ id: { type: "string", hidden: true },
+ title: { type: "string" },
+ artist: { type: "foreign-key", key: "artist" },
+ },
},
resources: [
@@ -86,6 +98,8 @@ var app = okcms
{ type: "test" },
{ type: "flour" },
{ type: "filez" },
+ { type: "artist" },
+ { type: "artwork" },
],
services: {
diff --git a/themes/okadmin/templates/index.liquid b/themes/okadmin/templates/index.liquid
index 5d7975d..48322a9 100644
--- a/themes/okadmin/templates/index.liquid
+++ b/themes/okadmin/templates/index.liquid
@@ -59,6 +59,9 @@
<div class="image" style="background-image:url('{{data.image.uri}}')"></div>
{% else %}
{{ data[resource.title] }}
+ {% if resource.subtitle %}
+ - {{ data[resource.subtitle] }}
+ {% endif %}
{% endif %}
<input class="resource-input" type="hidden" name="{{resource.type}}[{{forloop.index0}}]"
value='{{data | stringify | escape_once}}'>
diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid
index 15dae0f..46d0091 100644
--- a/themes/okadmin/templates/partials/inputs.liquid
+++ b/themes/okadmin/templates/partials/inputs.liquid
@@ -5,7 +5,13 @@
<div class="property {{type}} {% if spec.hidden %}hidden{% endif %}"
data-name="{{name}}">
- <label for="{{name}}">{{name | capitalize}}</label>
+ <label for="{{name}}">
+ {% if spec.alias %}
+ {{spec.alias | capitalize}}
+ {% else %}
+ {{name | capitalize}}
+ {% endif %}
+ </label>
{% if type == 'string' %}
<input