From c8eab703d468439a5b04dcfdeaf72db3eae4f966 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Thu, 9 Apr 2015 16:46:10 -0400 Subject: css and stuff --- themes/okadmin/public/css/main.css | 3 +++ 1 file changed, 3 insertions(+) (limited to 'themes/okadmin/public/css/main.css') diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index a1e20a0..a01a85c 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -46,6 +46,9 @@ a:visited { color: rgba(0, 0, 0, 0.25); line-height: 50px; } +.admin-header .breadcrumb b { + color: #333; +} .admin-header .site-link { float: right; -- cgit v1.2.3-70-g09d2 From d96e081e9ee7f96a268c3beaf2f8d11d6146927b Mon Sep 17 00:00:00 2001 From: julie lala Date: Thu, 9 Apr 2015 16:49:00 -0400 Subject: little things --- themes/okadmin/public/css/main.css | 4 ++-- themes/okadmin/public/js/app.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index a01a85c..d2a4418 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -41,7 +41,7 @@ a:visited { } .admin-header .breadcrumb { - margin-left: 1em; + margin-left: 0.5em; font-size: 2em; color: rgba(0, 0, 0, 0.25); line-height: 50px; @@ -107,7 +107,7 @@ h2 { .main.resource { float: left; margin-top: 2em; - width: 80%; + width: 85%; } .main.resource > * { diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 170b2ab..352507f 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -12,7 +12,7 @@ var OKAdmin = function(){ var url = $(this).val() $(this).val("") add_image(url) - })}) + })) // clone and populate template function add_image(url){ @@ -46,7 +46,7 @@ var OKAdmin = function(){ $el.parent().find(".video-title").val( media.title ) $el.parent().find(".video-thumb").val( media.thumbnail ) }) - }})) + })) // fix post indexing in list-driven inputs $("form").submit(function(){ @@ -64,6 +64,7 @@ var OKAdmin = function(){ e.preventDefault() } } +} $(function(){ window.app = new OKAdmin () -- cgit v1.2.3-70-g09d2 From 7b7ac014579bafdb16e91a98f995f4fa7f55b4f1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 9 Apr 2015 17:17:00 -0400 Subject: alert when deleting posts --- site/db.json | 20 ++++++++++++++++++++ themes/okadmin/public/css/main.css | 5 +++++ themes/okadmin/public/js/app.js | 9 +++++++++ themes/okadmin/templates/resource.liquid | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/site/db.json b/site/db.json index 8107c6d..07085d4 100644 --- a/site/db.json +++ b/site/db.json @@ -28,6 +28,26 @@ "caption": "CURABITUR BLANDIT TEMPUS PORTTITOR 4" } ] + }, + { + "id": "TEST", + "title": "", + "shortname": "", + "description": "", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "category": "retail", + "images": [ + { + "uri": "https://ltho.s3.amazonaws.com/cb2698ea-9927-4ca9-972b-f227d46d25f3.png", + "caption": "" + } + ] } ], "advertising": [], diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index d2a4418..ad940e8 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -248,10 +248,15 @@ label { li.image-element:hover .remove-image { display: block; } +li.image-element .remove-image:hover { + color: red; +} .remove-image { display: none; } +#delete_form button:hover { color: red } + .template { display: none; } diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 8c85663..441172f 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -59,6 +59,15 @@ var OKAdmin = function(){ }) }) + $("#delete_form").submit(function(e){ + if (confirm("Are you sure you want to delete this record?")) { + return + } + else { + e.preventDefault() + } + }) + function pressEnter(fn){ return function(e){ if (e.keyCode && e.keyCode !== 13) return diff --git a/themes/okadmin/templates/resource.liquid b/themes/okadmin/templates/resource.liquid index 48e3ef2..c321e8a 100644 --- a/themes/okadmin/templates/resource.liquid +++ b/themes/okadmin/templates/resource.liquid @@ -14,7 +14,7 @@
-
+
-- cgit v1.2.3-70-g09d2 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(-) (limited to 'themes/okadmin/public/css/main.css') 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 From 0810b806f7605a75b080ea4a6fc9010c6552095c Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Sat, 11 Apr 2015 01:41:34 -0400 Subject: Implement admin interface resource reordering --- examples/db.json | 63 ++++++++++++++++++++++----- themes/okadmin/public/css/main.css | 65 ++++++++++++++++++++++++---- themes/okadmin/public/js/app.js | 43 +++++++++++++++++- themes/okadmin/templates/index.liquid | 20 ++++++--- themes/okadmin/templates/resource.liquid | 2 +- themes/okadmin/templates/resource_new.liquid | 2 +- 6 files changed, 168 insertions(+), 27 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/examples/db.json b/examples/db.json index 148391a..20d4510 100644 --- a/examples/db.json +++ b/examples/db.json @@ -3,8 +3,8 @@ "bread": [ { "type": "pretzel", - "description": "really a very tasty bread! yup yes", - "color": "green", + "description": "really a very tasty bread!", + "color": "red", "id": "pretzel", "title": "Pretzel Chips", "images": [ @@ -23,7 +23,8 @@ "token": "", "title": "", "thumb": "" - } + }, + "__index": 0 }, { "type": "bagel", @@ -38,31 +39,73 @@ "token": "112498725", "title": "FW14-2H-VIDEO-V4 2", "thumb": "http://i.vimeocdn.com/video/497493142_640.jpg" - } + }, + "__index": 1 }, { "type": "pumpernickel", - "description": "grandma's recipe", + "description": "yup", "id": "pumpernickel", - "title": "Pumpernickel", + "title": "ok", "images": [ { "uri": "cool", "caption": "cool" } - ] + ], + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 2 + }, + { + "type": "cracker", + "title": "", + "description": "once upon a time this noble creature etc", + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 4, + "id": "cracker" + }, + { + "type": "croissant", + "title": "", + "description": "wow just wow", + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 3, + "id": "croissant" } ], "page": [ { "title": "About Us", "body": "Just a small bakery", - "id": "about" + "id": "about", + "__index": 1 }, { - "title": "contact", + "title": "ok...", "body": "2406 Old Rd, San Juan Bautista", - "id": "contact" + "id": "contact", + "__index": 0 } ] } \ No newline at end of file diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 73f9735..3762fd4 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -14,11 +14,12 @@ html, body { background-attachment: scroll; } -ul { +ul, ol { padding: 0; list-style: none; } +.main.index .resource-category button, a { color: #A200FF; text-decoration: none; @@ -26,6 +27,7 @@ a { text-transform: uppercase; } +.main.index .resource-category button:hover, a:hover { border-bottom: 1px solid #A200FF; } @@ -65,7 +67,12 @@ a:visited { border: 2px solid #ddd; } -nav { +.main.index .resource-category.active li:before { + content: "፧"; + margin-right: 1em; +} + +.resource-nav { background: white; width: 10%; margin: 2.5em 1em; @@ -89,21 +96,63 @@ h2 { transform: rotate(-1deg); } -.main.index .resource-category a.add-new { - border-bottom: 3px solid rgba(0, 0, 0, 0); +.main.index .resource-category nav { float: right; - font-size: 1.5em; +} + +.main.index .resource-category.active ol { + cursor: -webkit-grab; + cursor: grab; +} + +.main.index .resource-category.active li a { + pointer-events: none; +} + + /* Makes the button look like a link */ +.main.index .resource-category button { + background: none !important; + height: 1.5em; + border: none; + padding: 0 !important; + font: inherit; + cursor: pointer; +} + +.main.index .resource-category .btn { + border-bottom: 3px solid rgba(0, 0, 0, 0); color: rgba(0, 0, 0, 0.25); + line-height: 20px; } -.main.index .resource-category li { - margin: 1em 0; +.main.index .resource-category .btn { + display: none; +} + +.main.index .resource-category .btn.active { + display: inline; } -.main.index .resource-category a.add-new:hover { +.main.index .resource-category .btn:hover { border-bottom: 3px solid rgba(0, 0, 0, 0.25); } +.main.index .resource-category .btn { + margin-right: 1em; +} + +.main.index .resource-category .btn:last-child { + margin-right: 0; +} +.main.index .resource-category .add-btn { + font-size: 20px; +} + +.main.index .resource-category li { + margin: 1em 0; +} + + .main.resource { float: left; margin-top: 2em; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 4d13bb2..1ab9956 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -50,7 +50,7 @@ var OKAdmin = function(){ })) // fix post indexing in list-driven inputs - $("form").submit(function(){ + $(".main.resource form").submit(function(){ $(".image-element").each(function(index){ $(this).find("input,textarea").each(function(){ var field = $(this).attr("name").replace(/\[[0-9]*\]/, "[" + index + "]") @@ -67,6 +67,47 @@ var OKAdmin = function(){ e.preventDefault() } }) + + $(".resource-category").on("click", ".edit-btn", function(e) { + e.preventDefault(); + var $parent = $(e.delegateTarget); + var $editBtn = $parent.find(".edit-btn"); + var $cancelBtn = $parent.find(".cancel-btn"); + var $saveBtn = $parent.find(".save-btn"); + var $ol = $parent.find("ol"); + var toggles = [$parent, $cancelBtn, $saveBtn, $editBtn]; + + $ol.sortable(); + $ol.disableSelection(); + toggle(); + + $cancelBtn.one("click", function(e) { + $ol.sortable("cancel"); + $ol.enableSelection(); + toggle(); + }); + + $saveBtn.one("click", function(e) { + $ol.sortable(); + toggle(); + }); + + function toggle() { + toggles.forEach(function($el) { + $el.toggleClass('active'); + }) + } + }); + + $(".resource-category").on("submit", "form", function(e) { + var $parent = $(e.delegateTarget); + $parent.find(".resource-input").each(function(index) { + var $input = $(this); + var parsed = JSON.parse($input.val()); + parsed.__index = index; + $input.val(JSON.stringify(parsed)); + }) + }); function pressEnter(fn){ return function(e){ diff --git a/themes/okadmin/templates/index.liquid b/themes/okadmin/templates/index.liquid index 830fb2e..0672613 100644 --- a/themes/okadmin/templates/index.liquid +++ b/themes/okadmin/templates/index.liquid @@ -8,19 +8,27 @@ {% assign resource = pair[1] %}
-
+

{{name | capitalize}}

- +
diff --git a/themes/okadmin/templates/resource.liquid b/themes/okadmin/templates/resource.liquid index 53cd83e..8078778 100644 --- a/themes/okadmin/templates/resource.liquid +++ b/themes/okadmin/templates/resource.liquid @@ -2,7 +2,7 @@ {% include 'partials/flash' %} -
{% elsif type == 'meta' %} -- cgit v1.2.3-70-g09d2 From 7155995136123452b0f13c3e974f624eba59e8c4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 22 Apr 2015 16:02:27 -0400 Subject: input field --- themes/okadmin/public/css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 685e368..747ec34 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -229,7 +229,7 @@ button, input[type=submit] { display: none; } .main.resource form .group.image input, -.main.resource form .group.video input:first-child, +.main.resource form .group.video input[type=text]:first-child, .main.resource form .group.loaded.video input[type=text], .main.resource form .group input:first-child { display: block; -- cgit v1.2.3-70-g09d2 From 3e2d7e98230990ad954b33203e0611358c1fa915 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 27 Apr 2015 14:24:20 -0400 Subject: stubbing in videos --- app/node_modules/okadminview/index.js | 1 + site/index.js | 3 +- site/templates/project.liquid | 5 ++- themes/okadmin/public/css/main.css | 17 +++++--- themes/okadmin/public/js/app.js | 58 ++++++++++++++++++++----- themes/okadmin/public/js/upload.js | 15 ++++++- themes/okadmin/templates/partials/inputs.liquid | 55 +++++++++++++++++++++-- 7 files changed, 130 insertions(+), 24 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js index 82f364d..2a0fcd5 100644 --- a/app/node_modules/okadminview/index.js +++ b/app/node_modules/okadminview/index.js @@ -157,6 +157,7 @@ function OKAdminView(options) { resourceMissingHandler(req, res)() } else { view.renderResource(req, res, assign(data, { + JSON: JSON, success: req.flash('success'), errors: req.flash('errors') })); diff --git a/site/index.js b/site/index.js index 8bb4b4d..a7b207a 100644 --- a/site/index.js +++ b/site/index.js @@ -5,8 +5,7 @@ var projectSchema = { title: {type: 'string'}, menu: {type: 'string'}, description: {type: 'text'}, - video: {type: 'video'}, - images: {type: 'captioned-image-list'}, + images: {type: 'media-list'}, thumbnail: {type: 'image'}, } diff --git a/site/templates/project.liquid b/site/templates/project.liquid index b54722d..3d32c0d 100644 --- a/site/templates/project.liquid +++ b/site/templates/project.liquid @@ -1,7 +1,10 @@
{{project.title}} - +
+ PREVIOUS ASSET + NEXT ASSET +
- +
@@ -49,6 +49,55 @@
+ {% elsif type == 'media-list' %} +
+
+
+ + +
+ +
+ + + + + +
    + {% for image in spec.value %} + {% if image.token %} +
  1. + {{ JSON.stringify(spec.value) }} +
  2. + {% else %} +
  3. + + + {{image.caption}} + +
  4. + {% endif %} + {% endfor %} +
+
{% elsif type == 'captioned-image-list' %}
@@ -56,10 +105,10 @@
- +
- +
    + {% for image in spec.value %} +
  1. + + + + {{image.caption}} + +
  2. + {% endfor %} +
+ {% elsif type == 'meta' %} {% else %} -- cgit v1.2.3-70-g09d2 From e923cb0e5e1efac4fba534aba87f6b6e9d95d3f0 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Tue, 2 Jun 2015 15:55:45 -0400 Subject: Add link-list field type --- themes/okadmin/public/css/main.css | 6 ++++ themes/okadmin/public/js/app.js | 39 ++++++++++++++++++++++++- themes/okadmin/templates/partials/inputs.liquid | 25 +++++++++++++++- 3 files changed, 68 insertions(+), 2 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index e5af10c..094e66b 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -301,6 +301,12 @@ button, input[type=submit] { .main.resource form .video-element input[type=text] { width: 15em; } +.main .link-list .add-link-btn, +.main .link-list .remove-link-btn { + margin: 0; + height: 2em; + line-height: 1em; +} .add-image-button { background: #ddd; clear: left; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 2667ce6..f989c7b 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -99,7 +99,44 @@ var OKAdmin = function(){ $el.parent().find(".video-thumb").val( media.thumbnail ) }) })) - + + // Add a new link to the list + $('.link-list').on('click', '.add-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $list = $delegate.find('.links') + var length = $list.find('input').length + var name = $delegate.parent('.property').data('name') + var $new = $delegate.find('.link-input-new') + var input = document.createElement('input') + var delBtn = document.createElement('button') + var inputName = name + '[' + length + ']' + $(input).attr({ + name: inputName, + type: 'text', + value: $new.val() + }) + $list.append(input) + $(delBtn).addClass('remove-link-btn') + $(delBtn).data('for', inputName) + delBtn.innerHTML = '-' + $list.append(delBtn) + $new.val('') + }) + + // Remove a link from the list + $('.link-list').on('click', '.remove-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $target = $(e.target) + var inputName = $target.data('for') + var $input = $delegate.find('[name="' + inputName + '"]') + $input.remove() + $target.remove() + }) + // fix post indexing in list-driven inputs $(".main.resource form").submit(function(e){ var $id = $("[name=id]"), $title = $("[name=title]"), $menu = $("[name=menu]"), $section = $(".resource.main") diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 25ad197..0d5321b 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -3,7 +3,8 @@ {% assign spec = pair[1] %} {% assign type = spec.type %} -
+
{% if type == 'string' %} @@ -54,6 +55,28 @@
+ {% elsif type == 'link-list' %} + + + {% elsif type == 'media-list' %}
-- cgit v1.2.3-70-g09d2 From bcca89ebfd9ea93356d934edd5218335430746b6 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Tue, 2 Jun 2015 17:29:57 -0400 Subject: Add 'date' field type --- app/node_modules/okschema/index.js | 4 ++++ themes/okadmin/public/css/main.css | 4 ++++ themes/okadmin/public/js/app.js | 19 +++++++++++++++++++ themes/okadmin/templates/partials/inputs.liquid | 17 +++++++++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 0079f51..67f6e42 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -65,6 +65,10 @@ var types = { 'tag-list': { parent: 'string', assertValid: function(spec, value) {} + }, + 'date': { + parent: 'string', + assertValid: function(spec, value) {} } } diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 094e66b..a5fbdeb 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -211,6 +211,10 @@ label { button, input[type=submit] { cursor: pointer; } +.main.resource .date input { + /* date inputs need font family override */ + font-family: "Helvetica", sans-serif; +} .main.resource form .group { display: block; float: left; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index f989c7b..d58cb2a 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -162,6 +162,25 @@ var OKAdmin = function(){ $id.val( slug ) } + // Parse date input + $('.property .date').each(function(i, el) { + var name = $(el).parent('.property').data('name') + var $input = $(el).find('input') + var date = new Date($input.val()) + // Set to middle of day so it is the same date + // for all locales + date.setUTCHours(12) + var dateString = date.toUTCString() + var normalizedInput = document.createElement('input') + $(normalizedInput).attr({ + name: name, + type: 'text', + value: dateString + }) + $input.remove() + $(el).append(normalizedInput) + }) + $("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 0d5321b..e766558 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -50,10 +50,23 @@
+ + {% elsif type =='date' %} + +
+ +
+ {% elsif type == 'tag-list' %}
- +
{% elsif type == 'link-list' %} -- cgit v1.2.3-70-g09d2 From 8898bbe48285c7f9f11760ef420cca43d683d5e0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 28 Mar 2016 13:59:50 -0400 Subject: modify links field to specify text and uri --- app/index.js | 1 + app/node_modules/okdb/index.js | 2 +- app/node_modules/okschema/index.js | 17 +++++++- examples/db.json | 9 +++- examples/index.js | 5 ++- package.json | 2 +- themes/okadmin/public/css/main.css | 8 ++++ themes/okadmin/public/js/app.js | 34 ++++++--------- themes/okadmin/templates/partials/inputs.liquid | 56 +++++++++++++++++++------ 9 files changed, 93 insertions(+), 41 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/app/index.js b/app/index.js index 6a1c74f..06b1591 100644 --- a/app/index.js +++ b/app/index.js @@ -28,6 +28,7 @@ function OKCMS(options) { var app = express(); app.enable('strict routing'); + app.disable('x-powered-by'); var root = this._root = options.root || 'public'; var adminConfig = options.admin || {}; diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js index 4820c8c..ad8d9a7 100644 --- a/app/node_modules/okdb/index.js +++ b/app/node_modules/okdb/index.js @@ -97,7 +97,7 @@ FSDB.prototype.update = function(collection, id, data) { } var result = chain.assign(cloneDeep(data)).value(); - if (result ) { + if (result) { return resolve(cloneDeep(result)); } else { return resolve(null, new Error('Problem updating document')); diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 330ad6b..82aa13f 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -63,8 +63,21 @@ var types = { assertValid: function(spec, value) {} }, 'tag-list': { - parent: 'string', - assertValid: function(spec, value) {} + parent: [{ + uri: { type: 'string' }, + text: { type: 'string' } + }], + assertValid: function(spec, value) { + var message; + var actual; + if (!value || !value.length) { + throw [{ + message: 'Not an array', + expected: JSON.stringify(this.parent), + actual: value + }]; + } + } }, 'date': { parent: 'string', diff --git a/examples/db.json b/examples/db.json index 20d4510..4319237 100644 --- a/examples/db.json +++ b/examples/db.json @@ -99,7 +99,14 @@ "title": "About Us", "body": "Just a small bakery", "id": "about", - "__index": 1 + "__index": "1", + "links": [ + { + "text": "asdf2", + "uri": "asdf" + } + ], + "dateCreated": "" }, { "title": "ok...", diff --git a/examples/index.js b/examples/index.js index 3e9f509..bf51dfc 100644 --- a/examples/index.js +++ b/examples/index.js @@ -10,7 +10,8 @@ var app = okcms.createApp({ page: { id: {type: 'string'}, title: {type: 'string'}, - body: {type: 'text'} + body: {type: 'text'}, + links: {type: 'link-list'}, }, bread: { type: {type: 'string', id: true}, @@ -19,7 +20,7 @@ var app = okcms.createApp({ color: {type: 'enum', options: ["red","blue","green"]}, video: {type: 'video'}, images: {type: 'captioned-image-list'} - } + }, }, resources: [ diff --git a/package.json b/package.json index 192685c..faf3cc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okcms", - "version": "0.1.18", + "version": "0.1.19", "description": "great", "main": "app/index.js", "scripts": { diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index a5fbdeb..9289fdf 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -305,6 +305,14 @@ button, input[type=submit] { .main.resource form .video-element input[type=text] { width: 15em; } +.main.resource form .group input[type=text].link-input, +.main.resource form .group input[type=text].link-input-new { + width: 13.05em; + padding: 0 0 0 0.5em; +} +.main.resource form .links li { + height: auto; +} .main .link-list .add-link-btn, .main .link-list .remove-link-btn { margin: 0; diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index edf9980..17b35d0 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -120,35 +120,25 @@ var OKAdmin = function(){ e.stopPropagation() var $delegate = $(e.delegateTarget) var $list = $delegate.find('.links') - var length = $list.find('input').length - var name = $delegate.parent('.property').data('name') - var $new = $delegate.find('.link-input-new') - var input = document.createElement('input') - var delBtn = document.createElement('button') - var inputName = name + '[' + length + ']' - $(input).attr({ - name: inputName, - type: 'text', - value: $new.val() - }) - $list.append(input) - $(delBtn).addClass('remove-link-btn') - $(delBtn).data('for', inputName) - delBtn.innerHTML = '-' - $list.append(delBtn) - $new.val('') + var $linkText = $delegate.find(".link-input-new.link-text") + var $linkURI = $delegate.find(".link-input-new.link-uri") + + var template = $delegate.find(".link-template").html() + var $el = $(template) + $el.find(".link-text").val( $linkText.val() ) + $el.find(".link-uri").val( $linkURI.val() ) + $list.append($el) + console.log($list, template) + $linkText.val("") + $linkURI.val("") }) // Remove a link from the list $('.link-list').on('click', '.remove-link-btn', function(e) { e.preventDefault() e.stopPropagation() - var $delegate = $(e.delegateTarget) var $target = $(e.target) - var inputName = $target.data('for') - var $input = $delegate.find('[name="' + inputName + '"]') - $input.remove() - $target.remove() + $target.closest("li").remove() }) // fix post indexing in list-driven inputs diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index c6efc68..55d5fb8 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -79,26 +79,58 @@ value="{{spec.value}}" placeholder="Enter a comma separated list of tags.">
- {% elsif type == 'link-list' %} + {% elsif type == 'link-list' %} {% elsif type == 'media-list' %} -- cgit v1.2.3-70-g09d2 From 49fe25c8e884c14ab3258d22240a62f0b57da490 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 28 Mar 2016 16:15:46 -0400 Subject: make links sortable --- examples/db.json | 33 ++++++++++++------------- themes/okadmin/public/css/main.css | 9 ++++++- themes/okadmin/public/js/app.js | 19 ++++++++++---- themes/okadmin/templates/partials/inputs.liquid | 19 ++++++++------ 4 files changed, 49 insertions(+), 31 deletions(-) (limited to 'themes/okadmin/public/css/main.css') diff --git a/examples/db.json b/examples/db.json index 5e10d60..9ab7233 100644 --- a/examples/db.json +++ b/examples/db.json @@ -92,22 +92,6 @@ }, "__index": 3, "id": "croissant" - }, - { - "type": "Test", - "title": "Testing", - "description": "", - "color": "red", - "video": { - "url": "", - "type": "", - "token": "", - "title": "", - "thumb": "" - }, - "__index": "5", - "dateCreated": "Mon, 28 Mar 2016 18:49:32 GMT", - "images": [] } ], "page": [ @@ -123,7 +107,22 @@ "title": "ok...", "body": "2406 Old Rd, San Juan Bautista", "id": "contact", - "__index": 0 + "__index": "0", + "links": [ + { + "text": "US Bread Board", + "uri": "http://bread.com/" + }, + { + "text": "National Council on Grain", + "uri": "http://grain.org/" + }, + { + "text": "USDA", + "uri": "http://usda.gov/" + } + ], + "dateCreated": "" } ] } \ No newline at end of file diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 9289fdf..df0ca43 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -310,8 +310,15 @@ button, input[type=submit] { width: 13.05em; padding: 0 0 0 0.5em; } +.handle { + display: block; + width: 1em; + height: 2em; + background: #ddd; + float: left; +} .main.resource form .links li { - height: auto; + height: 2em; } .main .link-list .add-link-btn, .main .link-list .remove-link-btn { diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 17b35d0..da398eb 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -91,7 +91,7 @@ var OKAdmin = function(){ }) // make the region sortable with drag-and-drop - $(".media-list ol, .image-list ol").sortable() + $(".media-list ol, .image-list ol, .link-list .links").sortable() $(".media-list ol, .image-list ol").disableSelection() // populate a video field with info from our url parser @@ -115,20 +115,22 @@ var OKAdmin = function(){ })) // Add a new link to the list - $('.link-list').on('click', '.add-link-btn', function(e) { - e.preventDefault() - e.stopPropagation() + $('.link-list').on('click', '.add-link-btn', function addNewLink (e) { + e.preventDefault && e.preventDefault() + e.stopPropagation && e.stopPropagation() var $delegate = $(e.delegateTarget) var $list = $delegate.find('.links') + var linkCount = $list.find("li").length + var $linkText = $delegate.find(".link-input-new.link-text") var $linkURI = $delegate.find(".link-input-new.link-uri") var template = $delegate.find(".link-template").html() + template = template.replace(/\[\]/g, "[" + linkCount + "]") var $el = $(template) $el.find(".link-text").val( $linkText.val() ) $el.find(".link-uri").val( $linkURI.val() ) $list.append($el) - console.log($list, template) $linkText.val("") $linkURI.val("") }) @@ -195,6 +197,13 @@ var OKAdmin = function(){ input.checked = true } }) + + $(".link-list").each(function(){ + var $inputs = $(this).find(".link-input-new") + if ($inputs.eq(0).val() && $inputs.eq(1).val()) { + $(this).find(".add-link-btn").trigger("click") + } + }) $("ol").each(function(){ $("li", this).each(function(index){ diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 55d5fb8..4acb435 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -82,17 +82,18 @@ {% elsif type == 'link-list' %} {% elsif type == 'image' %}
@@ -47,8 +47,8 @@
- - {{spec.value.caption}} + + {{spec.value.caption | escape}}
@@ -78,7 +78,7 @@ {% elsif type == 'tag-list' %}
@@ -90,13 +90,13 @@
@@ -142,8 +142,8 @@
- - + +
@@ -177,6 +177,23 @@ + +