From 3f346a970dd0823816a5ad2b0dc2b7749e99845c Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Fri, 10 Apr 2015 22:34:39 -0400 Subject: Hide certain inputs in template --- app/node_modules/okadminview/index.js | 19 ++++++++++--------- themes/okadmin/public/css/main.css | 4 ++++ themes/okadmin/templates/partials/inputs.liquid | 20 +++++++++++++------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js index 1668900..884c4b8 100644 --- a/app/node_modules/okadminview/index.js +++ b/app/node_modules/okadminview/index.js @@ -116,15 +116,11 @@ function OKAdminView(options) { errorHandler(req, res)(new Error('No such resource ' + type)); } else { meta.get().then(function(metadata) { - view.renderResourceNew(req, res, { + var templateData = getResourceTemplateData(metadata, resource, {}); + view.renderResourceNew(req, res, assign(templateData, { success: req.flash('success'), errors: req.flash('errors'), - meta: metadata, - resource: { - type: resource.type, - spec: resource.spec - } - }); + })); }).fail(errorHandler(req, res)); } }); @@ -228,10 +224,15 @@ function getResourceTemplateData(meta, resource, data) { meta = meta || {}; resource = resource || {}; data = data || {}; - // Decorate spec with actual resource values var spec = Object.keys(resource.spec).reduce(function(cache, prop) { var value = data[prop]; - cache[prop].value = value; + var propSpec = cache[prop]; + // Decorate spec with actual resource values + propSpec.value = value; + // Some fields should not be shown to the user + if (propSpec.type === 'meta' || propSpec.static) { + propSpec.hidden = true; + } return cache; }, resource.spec); return { diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index ad940e8..73f9735 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -278,3 +278,7 @@ li.image-element .remove-image:hover { .clear { clear: both; } + +.hidden { + display: none; +} diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 7cede76..99258f3 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -4,24 +4,28 @@ {% assign type = spec.type %}
- + {% if type == 'string' %} {% elsif type == 'text' %} {% elsif type == 'enum' %} {% else %}

Admin template doesn't support '{{type}}' properties!

{% endif %} -- cgit v1.2.3-70-g09d2