diff --git a/frontend/src/modules/scaffold/backboneFormsOverrides.js b/frontend/src/modules/scaffold/backboneFormsOverrides.js index bf18e15b68..522930be80 100644 --- a/frontend/src/modules/scaffold/backboneFormsOverrides.js +++ b/frontend/src/modules/scaffold/backboneFormsOverrides.js @@ -94,6 +94,33 @@ define(function(require) { return parts.join('
'); }; + Backbone.Form.editors.List.prototype.removeItem = function(item) { + //Confirm delete + var confirmMsg = this.schema.confirmDelete; + + var remove = _.bind(function(isConfirmed) { + if (isConfirmed === false) return; + + var index = _.indexOf(this.items, item); + + this.items[index].remove(); + this.items.splice(index, 1); + + if (item.addEventTriggered) { + this.trigger('remove', this, item.editor); + this.trigger('change', this); + } + + if (!this.items.length && !this.Editor.isAsync) this.addItem(); + }, this); + + if (confirmMsg) { + window.confirm({ title: confirmMsg, type: 'warning', callback: remove }); + } else { + remove(); + } + }; + // Used to setValue with defaults Backbone.Form.editors.Base.prototype.setValue = function(value) { diff --git a/lib/bowermanager.js b/lib/bowermanager.js index a96fd1090a..f2bf976ce6 100644 --- a/lib/bowermanager.js +++ b/lib/bowermanager.js @@ -125,7 +125,7 @@ BowerManager.prototype.installPlugin = function(pluginName, pluginVersion, callb if (err) { return callback(err); } - installHelpers.getLatestFrameworkVersion(function(error, frameworkVersion) { + installHelpers.getInstalledFrameworkVersion(function(error, frameworkVersion) { if (error) { return callback(error); } diff --git a/lib/installHelpers.js b/lib/installHelpers.js index 71e7ef008a..cdcb9d43b5 100644 --- a/lib/installHelpers.js +++ b/lib/installHelpers.js @@ -166,10 +166,10 @@ function getUpdateData(callback) { return callback(error); } var updateData = {}; - if(semver.lt(results[0].adapt_authoring, results[1].adapt_authoring)) { + if(results[1].adapt_authoring && semver.lt(results[0].adapt_authoring, results[1].adapt_authoring)) { updateData.adapt_authoring = results[1].adapt_authoring; } - if(semver.lt(results[0].adapt_framework, results[1].adapt_framework)) { + if(results[1].adapt_framework && semver.lt(results[0].adapt_framework, results[1].adapt_framework)) { updateData.adapt_framework = results[1].adapt_framework; } if(_.isEmpty(updateData)) { @@ -205,17 +205,20 @@ function checkLatestAdaptRepoVersion(repoName, versionLimit, callback) { }, done); }; var _requestHandler = function(error, response, body) { - // we've exceeded the API limit - if(response.statusCode === 403 && response.headers['x-ratelimit-remaining'] === '0') { - var reqsReset = new Date(response.headers['x-ratelimit-reset']*1000); - error = `You have exceeded GitHub's request limit of ${response.headers['x-ratelimit-limit']} requests per hour. Please wait until at least ${reqsReset.toTimeString()} before trying again.`; - } - else if (response.statusCode !== 200) { - error = 'GitubAPI did not respond with a 200 status code.'; + if(response) { + // we've exceeded the API limit + if(response.statusCode === 403 && response.headers['x-ratelimit-remaining'] === '0') { + var reqsReset = new Date(response.headers['x-ratelimit-reset']*1000); + error = `You have exceeded GitHub's request limit of ${response.headers['x-ratelimit-limit']} requests per hour. Please wait until at least ${reqsReset.toTimeString()} before trying again.`; + } + else if(response.statusCode !== 200) { + error = 'GitubAPI did not respond with a 200 status code.'; + } } - + // exit, but just log the error if (error) { - return callback(`Couldn't check latest version of ${repoName}\n${error}`); + log(`Couldn't check latest version of ${repoName}\n${error}`); + return callback(); } nextPage = parseLinkHeader(response.headers.link).next; try { @@ -287,8 +290,8 @@ function installFramework(opts, callback) { } if(!opts.revision) { return getLatestFrameworkVersion(function(error, version) { - if(error) return callback(error); - opts.revision = version; + // NOTE we default to the master branch + opts.revision = version || 'master'; installFramework(opts, callback); }); }