diff options
| -rw-r--r-- | app/node_modules/okschema/index.js | 3 | ||||
| -rw-r--r-- | examples/db.json | 43 | ||||
| -rw-r--r-- | examples/index.js | 11 | ||||
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | themes/okadmin/templates/index.liquid | 30 | ||||
| -rw-r--r-- | themes/okadmin/templates/partials/inputs.liquid | 16 |
6 files changed, 41 insertions, 64 deletions
diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 0048fc5..39845ea 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -30,7 +30,8 @@ var types = { parent: {type: 'string'}, assertValid: function(spec, value) { value = value || ''; - if (spec.options.indexOf(value.trim()) === -1) { + if ( (spec.options.length && spec.options.indexOf(value.trim()) === -1) || + (! spec.options.length && Object.keys(spec.options).indexOf(value.trim()) === -1)) { throw [{ constraint: 'enum', actual: value, diff --git a/examples/db.json b/examples/db.json index d037d2b..ed60f22 100644 --- a/examples/db.json +++ b/examples/db.json @@ -122,7 +122,7 @@ "title": "About Us", "body": "Just a small bakery", "id": "about", - "__index": "1", + "__index": 1, "links": [], "dateCreated": "" }, @@ -284,44 +284,5 @@ "dateCreated": "Fri, 02 Sep 2016 16:41:10 GMT" } ], - "flour": [ - { - "id": "test", - "title": "Test", - "image": { - "uri": "", - "caption": "", - "width": "", - "height": "" - }, - "images": [ - { - "uri": "https://ltho.s3.amazonaws.com/okcms-example/07ad6a70-8a49-11e6-80c3-41900948e24c.png", - "width": "463", - "height": "606", - "label": "1", - "caption": "2", - "code": "3" - }, - { - "uri": "https://ltho.s3.amazonaws.com/okcms-example/07ad1c50-8a49-11e6-80c3-41900948e24c.png", - "width": "515", - "height": "441", - "label": "13", - "caption": "23", - "code": "33" - }, - { - "uri": "https://ltho.s3.amazonaws.com/okcms-example/07aa3620-8a49-11e6-80c3-41900948e24c.png", - "width": "566", - "height": "329", - "label": "14", - "caption": "25", - "code": "36" - } - ], - "__index": 0, - "dateCreated": "Tue, 04 Oct 2016 15:41:52 GMT" - } - ] + "flour": [] }
\ No newline at end of file diff --git a/examples/index.js b/examples/index.js index 92db7c0..8918043 100644 --- a/examples/index.js +++ b/examples/index.js @@ -36,13 +36,22 @@ var app = okcms.createApp({ id: {type: 'string'}, title: {type: 'string'}, body: {type: 'text'}, - links: {type: 'link-list'}, + links: {type: 'link-list', textLabel: "A", linkLabel: "B"}, }, bread: { type: {type: 'string', id: true}, title: {type: 'string'}, description: {type: 'text'}, color: {type: 'enum', options: ["red","blue","green"]}, + rating: {type: 'enum', options: { + "e": "Everyone", + "ec": "Early Childhood", + "e10": "Everyone 10+", + "t": "Teen", + "m": "Mature", + "ao": "Adults Only", + "rp": "Rating Pending", + }}, video: {type: 'video'}, images: {type: 'gallery'} }, diff --git a/package.json b/package.json index 7d0647a..66f4a41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okcms", - "version": "0.2.2", + "version": "0.2.4", "description": "The dopest CMS on the planet.", "main": "app/index.js", "scripts": { diff --git a/themes/okadmin/templates/index.liquid b/themes/okadmin/templates/index.liquid index c5754dc..d47eb2e 100644 --- a/themes/okadmin/templates/index.liquid +++ b/themes/okadmin/templates/index.liquid @@ -49,19 +49,23 @@ {% endfor %} {% endfor %} {% else %} - <ol class="resource-list"> - {% for data in resource.data %} - <a href="{{resource.type}}/{{data.id}}/" {% if data.disabled %}class="disabled"{% endif %}> - {% if resource.display == 'image' %} - <div class="image" style="background-image:url('{{data.title}}')"></div> - {% else %} - {{data.title}} - {% endif %} - <input class="resource-input" type="hidden" name="{{resource.type}}[{{forloop.index0}}]" - value='{{data | stringify | escape_once}}'> - </a> - {% endfor %} - </ol> + {% assign resourceJSON = resource.data[0] | stringify %} + {% if resourceJSON != "[]" %} + <ol class="resource-list"> + {% for data in resource.data %} + <a href="{{resource.type}}/{{data.id}}/" {% if data.disabled %}class="disabled"{% endif %}> + {% if resource.display == 'image' %} + <div class="image" style="background-image:url('{{data.title}}')"></div> + {% else %} + {{data.title}} + {% endif %} + <input class="resource-input" type="hidden" name="{{resource.type}}[{{forloop.index0}}]" + value='{{data | stringify | escape_once}}'> + </a> + {% endfor %} + </ol> + {% endif %} + {% endif %} <footer> <nav> <a class="btn cancel-btn" href="#">cancel</a> diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 55afb51..60466de 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -21,7 +21,11 @@ <select name="{{name}}"> {% for option in spec.options %} - <option value="{{option}}" {% if option == spec.value %}selected{% endif %}>{{option | capitalize}}</option> + {% if option.length == 2 %} + <option value="{{option[0]}}" {% if option[0] == spec.value %}selected{% endif %}>{{option[1] | capitalize}}</option> + {% else %} + <option value="{{option}}" {% if option == spec.value %}selected{% endif %}>{{option | capitalize}}</option> + {% endif %} {% endfor %} </select> {% elsif type == 'video' %} @@ -94,13 +98,11 @@ name="{{name}}[{{forloop.index0}}][text]" value="{{link.text | escape}}" type="text" - placeholder="Link text" class="link-input link-text"> <input name="{{name}}[{{forloop.index0}}][uri]" value="{{link.uri | escape}}" type="text" - placeholder="URL" class="link-input link-uri"> <button class="remove-link-btn btn"> - @@ -112,10 +114,10 @@ <div class="handle"></div> <input type="text" class="link-input-new link-text" - placeholder="Link text"> + placeholder="{% if spec.textLabel %}{{ spec.textLabel }}{% else %}Link text{% endif %}"> <input type="text" class="link-input-new link-uri" - placeholder="http://www.example.com"> + placeholder="{% if spec.linkLabel %}{{ spec.linkLabel }}{% else %}http://www.example.com{% endif %}"> <button class="add-link-btn btn">+</button> <script type="text/html" class="link-template"> @@ -125,13 +127,13 @@ name="{{name}}[][text]" value="" type="text" - placeholder="Link text" + placeholder="{% if spec.textLabel %}{{ spec.textLabel }}{% else %}Link text{% endif %}" class="link-input link-text"> <input name="{{name}}[][uri]" value="" type="text" - placeholder="URL" + placeholder="{% if spec.linkLabel %}{{ spec.linkLabel }}{% else %}http://www.example.com{% endif %}" class="link-input link-uri"> <button class="remove-link-btn btn"> - |
