From ddd65eb1c4d0b2dd39d455b82b073da5095ef2b0 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 20 Jan 2014 23:42:22 +0200 Subject: [PATCH] fix #83 --- example/classic/models/tests.js | 2 +- generated/templates.js | 3 ++- test/common.js | 1 + test/test-mongoose.js | 2 +- views/model.jade | 3 ++- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/classic/models/tests.js b/example/classic/models/tests.js index 2845ed9..23127af 100644 --- a/example/classic/models/tests.js +++ b/example/classic/models/tests.js @@ -69,7 +69,7 @@ schema.methods.toString = function () {return this.string_req}; schema.formage = { filters: ['ref', 'string_req'], - list: ['embeded.name1', 'ref', 'filepicker', 'filepicker_picture', 'filepicker_aviary', 'swizzle'], + list: ['embeded.name1', 'ref', 'filepicker', 'filepicker_picture', 'filepicker_aviary', 'swizzle', 'date'], subCollections: [{label: 'Sub Tests', model: 'pages', field:'ref'}], list_populate: ['ref'] }; diff --git a/generated/templates.js b/generated/templates.js index af5e7fc..6c371a8 100644 --- a/generated/templates.js +++ b/generated/templates.js @@ -209,6 +209,7 @@ var cloudinary_url = value_url && value.url.split('/upload/')[0] + '/upload/c_fi var geomery = value && value.geometry && value.geometry.lat + ',' + value.geometry.lng; var maps_url = geomery && 'https://maps.google.com/?q=' + geomery; var filename = value && value.filename; +var date_string = value && value.toISOString ? value.toISOString().split('T')[0] : ''; switch (type){ case 'Picture': buf.push(""); @@ -243,7 +244,7 @@ buf.push.apply(buf, jade.indent); buf.push("
"); break; case 'Date': -buf.push("" + (jade.escape(null == (jade.interp = value.toISOString().split('T')[0]) ? "" : jade.interp)) + ""); +buf.push("" + (jade.escape(null == (jade.interp = date_string) ? "" : jade.interp)) + ""); break; default: buf.push("" + (jade.escape(null == (jade.interp = value) ? "" : jade.interp)) + ""); diff --git a/test/common.js b/test/common.js index 7698ecd..0122265 100644 --- a/test/common.js +++ b/test/common.js @@ -57,6 +57,7 @@ global.mockFind = function mockFindFactory(arr) { populate: function mockLimit() { return this; }, skip: function mockLimit() { return this; }, limit: function mockLimit() { return this; }, + sort: function mockLimit() { return this; }, exec: function mockExec(cb) { var p = new Promise(cb); p.fulfill(arr); diff --git a/test/test-mongoose.js b/test/test-mongoose.js index 128fbda..ead26d2 100644 --- a/test/test-mongoose.js +++ b/test/test-mongoose.js @@ -556,7 +556,7 @@ describe("high level REST requests on mongoose", function () { }); - it.skip("view model page 2", function (done) { + it("view model page 2", function (done) { var Tests = this.registry.models['Tests'].model; var old_Tests_find = Tests.find; Tests.find = mockFind([new Tests()]); diff --git a/views/model.jade b/views/model.jade index 7c3a2da..d0184a4 100644 --- a/views/model.jade +++ b/views/model.jade @@ -6,6 +6,7 @@ mixin fielddesc(value, type, document_url) - var geomery = value && value.geometry && value.geometry.lat + ',' + value.geometry.lng; - var maps_url = geomery && 'https://maps.google.com/?q=' + geomery; - var filename = value && value.filename; + - var date_string = value && value.toISOString ? value.toISOString().split('T')[0] : ''; case type when 'Picture' a(href=value_url, target='_blank'): img(src=cloudinary_url) @@ -32,7 +33,7 @@ mixin fielddesc(value, type, document_url) i(class=(value ? 'icon-ok' : 'icon-remove')) when 'Date' - a(href=document_url): =value.toISOString().split('T')[0] + a(href=document_url): =date_string default a(href=document_url): =value