From 6394add9d69c6ce9e418eb74aff6b588da00dbf0 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 22 Nov 2013 21:47:03 +0000 Subject: [PATCH] Bugfix handle model and collection separately issue #1533 - replaces templateModel which was a weird hybrid with progressModel and progressCollection --- core/client/models/base.js | 19 ++++++++++++++++++- core/client/models/post.js | 2 +- core/client/models/settings.js | 2 +- core/client/models/tag.js | 2 +- core/client/models/themes.js | 2 +- core/client/models/uploadModal.js | 2 +- core/client/models/user.js | 2 +- core/client/models/widget.js | 4 ++-- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/core/client/models/base.js b/core/client/models/base.js index 2c523581de..1ef04e7f2a 100644 --- a/core/client/models/base.js +++ b/core/client/models/base.js @@ -4,7 +4,24 @@ "use strict"; NProgress.configure({ showSpinner: false }); - Ghost.TemplateModel = Backbone.Model.extend({ + Ghost.ProgressModel = Backbone.Model.extend({ + + // Adds in a call to start a loading bar + // This is sets up a success function which completes the loading bar + fetch : function (options) { + options = options || {}; + + NProgress.start(); + + options.success = function () { + NProgress.done(); + }; + + return Backbone.Model.prototype.fetch.call(this, options); + } + }); + + Ghost.ProgressCollection = Backbone.Collection.extend({ // Adds in a call to start a loading bar // This is sets up a success function which completes the loading bar diff --git a/core/client/models/post.js b/core/client/models/post.js index 8e5c72feec..c84b58f233 100644 --- a/core/client/models/post.js +++ b/core/client/models/post.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - Ghost.Models.Post = Ghost.TemplateModel.extend({ + Ghost.Models.Post = Ghost.ProgressModel.extend({ defaults: { status: 'draft' diff --git a/core/client/models/settings.js b/core/client/models/settings.js index 6d7ff2fd8d..738cda7500 100644 --- a/core/client/models/settings.js +++ b/core/client/models/settings.js @@ -2,7 +2,7 @@ (function () { 'use strict'; //id:0 is used to issue PUT requests - Ghost.Models.Settings = Ghost.TemplateModel.extend({ + Ghost.Models.Settings = Ghost.ProgressModel.extend({ url: Ghost.settings.apiRoot + '/settings/?type=blog,theme', id: '0' }); diff --git a/core/client/models/tag.js b/core/client/models/tag.js index 70cd9020e2..d903c67075 100644 --- a/core/client/models/tag.js +++ b/core/client/models/tag.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - Ghost.Collections.Tags = Ghost.TemplateModel.extend({ + Ghost.Collections.Tags = Ghost.ProgressCollection.extend({ url: Ghost.settings.apiRoot + '/tags/' }); }()); diff --git a/core/client/models/themes.js b/core/client/models/themes.js index 03ebc3ecad..5e82d77201 100644 --- a/core/client/models/themes.js +++ b/core/client/models/themes.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - Ghost.Models.Themes = Ghost.TemplateModel.extend({ + Ghost.Models.Themes = Backbone.Model.extend({ url: Ghost.settings.apiRoot + '/themes' }); diff --git a/core/client/models/uploadModal.js b/core/client/models/uploadModal.js index a18bf30544..52fcec1a67 100644 --- a/core/client/models/uploadModal.js +++ b/core/client/models/uploadModal.js @@ -1,7 +1,7 @@ /*global Ghost, Backbone, $ */ (function () { 'use strict'; - Ghost.Models.uploadModal = Ghost.TemplateModel.extend({ + Ghost.Models.uploadModal = Backbone.Model.extend({ options: { close: true, diff --git a/core/client/models/user.js b/core/client/models/user.js index 4ad165a8f3..d90a91a49f 100644 --- a/core/client/models/user.js +++ b/core/client/models/user.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - Ghost.Models.User = Ghost.TemplateModel.extend({ + Ghost.Models.User = Ghost.ProgressModel.extend({ url: Ghost.settings.apiRoot + '/users/me/' }); diff --git a/core/client/models/widget.js b/core/client/models/widget.js index 23306e5abc..65d5a53101 100644 --- a/core/client/models/widget.js +++ b/core/client/models/widget.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - Ghost.Models.Widget = Ghost.TemplateModel.extend({ + Ghost.Models.Widget = Ghost.ProgressModel.extend({ defaults: { title: '', @@ -35,7 +35,7 @@ } }); - Ghost.Collections.Widgets = Backbone.Collection.extend({ + Ghost.Collections.Widgets = Ghost.ProgressCollection.extend({ // url: Ghost.settings.apiRoot + '/widgets/', // What will this be? model: Ghost.Models.Widget });