summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Fridman <fridman@mail.sfsu.edu>2015-06-19 15:29:19 -0400
committerSean Fridman <fridman@mail.sfsu.edu>2015-06-19 15:30:59 -0400
commit27abfdd15714895894565124bcc660b9d6774494 (patch)
tree920db8ec4972e0b8aa24b184d4be986033b2452b
parent5f002254c523bb9651e627c2fbd7d9cd9b021568 (diff)
Add 'flag' data type
-rw-r--r--app/node_modules/okschema/index.js4
-rw-r--r--package.json2
-rw-r--r--themes/okadmin/public/js/app.js11
-rw-r--r--themes/okadmin/templates/partials/inputs.liquid13
4 files changed, 28 insertions, 2 deletions
diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js
index 67f6e42..89b59cc 100644
--- a/app/node_modules/okschema/index.js
+++ b/app/node_modules/okschema/index.js
@@ -69,6 +69,10 @@ var types = {
'date': {
parent: 'string',
assertValid: function(spec, value) {}
+ },
+ 'flag': {
+ parent: 'string',
+ assertValid: function(spec, value) {}
}
}
diff --git a/package.json b/package.json
index a8a602f..50ec3e6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "okcms",
- "version": "0.1.0",
+ "version": "0.1.10",
"description": "great",
"main": "app/index.js",
"scripts": {
diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js
index d58cb2a..4be0afc 100644
--- a/themes/okadmin/public/js/app.js
+++ b/themes/okadmin/public/js/app.js
@@ -181,6 +181,17 @@ var OKAdmin = function(){
$(el).append(normalizedInput)
})
+ // Modify flags checkboxes such that unchecked ones return "false"
+ // instead of nothing
+ $('.property .flag').each(function(i, el) {
+ var input = el.querySelector('input')
+ var checked = !!input.checked
+ if (!checked) {
+ $(input).attr('value', 'false')
+ input.checked = true
+ }
+ })
+
$("ol").each(function(){
$("li", this).each(function(index){
$(this).find("input,textarea").each(function(){
diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid
index e766558..9c1a26b 100644
--- a/themes/okadmin/templates/partials/inputs.liquid
+++ b/themes/okadmin/templates/partials/inputs.liquid
@@ -51,7 +51,7 @@
</div>
</div>
- {% elsif type =='date' %}
+ {% elsif type == 'date' %}
<div class="date">
<input name="{{name}}"
@@ -62,6 +62,17 @@
>
</div>
+ {% elsif type == 'flag' %}
+
+ <div class="flag">
+ <input name="{{name}}"
+ type="checkbox"
+ {% if spec.value == 'true' %}
+ checked="true"
+ {% endif %}
+ value="true">
+ </div>
+
{% elsif type == 'tag-list' %}
<div class="tag-list">
<input name="{{name}}"