diff --git a/app/assets/javascripts/app/models/post.js b/app/assets/javascripts/app/models/post.js index 5ec74b6ffd4d4a7c3914700945c45bdefccad5bc..71123457cf97080ad705370a63acfecbbf88aaed 100644 --- a/app/assets/javascripts/app/models/post.js +++ b/app/assets/javascripts/app/models/post.js @@ -19,6 +19,10 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, this.set({frame_name : new app.models.Post.TemplatePicker(this).getFrameName()}) }, + applicableTemplates: function() { + return new app.models.Post.TemplatePicker(this).applicableTemplates() + }, + interactedAt : function() { return this.timeOf("interacted_at"); }, @@ -59,12 +63,7 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, headlineLimit : 118, frameMoods : [ - // "Day", - // "Night", "Wallpaper", - // "Newspaper", - - // NEW SHIT "Vanilla", "Typist", "Fridge" diff --git a/app/assets/javascripts/app/models/post/template_picker.js b/app/assets/javascripts/app/models/post/template_picker.js index c4a46bb844def5cd0159023721687dbd8fa80f5b..faaa424a5d7262c20bdcadae44745c8d74924b15 100644 --- a/app/assets/javascripts/app/models/post/template_picker.js +++ b/app/assets/javascripts/app/models/post/template_picker.js @@ -25,5 +25,11 @@ _.extend(app.models.Post.TemplatePicker.prototype, { isWallpaper : function(){ return this.model.get("photos").length == 1 + }, + + applicableTemplates : function(){ + /* don't show the wallpaper option if there is no image */ + var moods = app.models.Post.frameMoods; + return (!this.isWallpaper() ? _.without(moods, "Wallpaper") : moods) } }); \ No newline at end of file diff --git a/app/assets/javascripts/app/pages/framer.js b/app/assets/javascripts/app/pages/framer.js index e22cbda6b7ac07a49a0e79bdbf2ebaeaf07a13a0..2f4bc136f9f7c6f7cee9c67c70c9877d4702b039 100644 --- a/app/assets/javascripts/app/pages/framer.js +++ b/app/assets/javascripts/app/pages/framer.js @@ -67,7 +67,7 @@ app.views.framerContent = app.views.Base.extend({ presenter : function() { var selectedFrame = this.model.get("frame_name") - , templates = app.models.Post.frameMoods; + , templates = this.model.applicableTemplates(); //new app.models.Post.TemplatePicker(this.model).frameMoods; return _.extend(this.defaultPresenter(), { templates : _.map(templates, function(template) { diff --git a/spec/javascripts/app/models/post/template_picker_spec.js b/spec/javascripts/app/models/post/template_picker_spec.js index 56371d7750577fe31bfcb940a2c317094b27ad4f..aca0c74b7dd0e5caa97f5b14966e4da634f1e48e 100644 --- a/spec/javascripts/app/models/post/template_picker_spec.js +++ b/spec/javascripts/app/models/post/template_picker_spec.js @@ -41,4 +41,16 @@ describe("app.models.Post.TemplatePicker", function(){ }) }) }) + + describe("applicableTemplates", function(){ + it("includes wallpaper if isWallpaper is true", function(){ + spyOn(this.templatePicker, "isWallpaper").andReturn(true) + expect(_.include(this.templatePicker.applicableTemplates(), "Wallpaper")).toBeTruthy() + }) + + it("does not include wallpaper if isWallpaper is false", function(){ + spyOn(this.templatePicker, "isWallpaper").andReturn(false) + expect(_.include(this.templatePicker.applicableTemplates(), "Wallpaper")).toBeFalsy() + }) + }) })