Fixed syncing messages in schema view to always show a message when syncing.

This commit is contained in:
Jeff Cross
2011-12-03 11:07:47 -07:00
parent 3dc95ed4f3
commit e6bb14d883
4 changed files with 17 additions and 13 deletions

View File

@@ -3,11 +3,12 @@ window.SchemaModel = Backbone.Model.extend({
return "/settings/"+this.get("_id")+'?method=put';
},
sync: function (method, model) {
var _self = this;
if (model.get('groups')) model.unset('groups', {silent: true});
d(this.url(), model, function onSync(response) {
console.log('onSync in SchemaModel');
_self.trigger('change', response);
});
},
idAttribute: '_id'
});

View File

@@ -1,4 +1,5 @@
var Router = Backbone.Router.extend({
currentView: '',
initialize: function() {
// prevent caching
$.ajaxSetup({ cache: false });
@@ -31,7 +32,7 @@ var Router = Backbone.Router.extend({
},
plugin: function(name, tabId) {
var model = app.get("plugins").getByPluginName(name);
var view = new PluginView({
this.currentView = new PluginView({
model: model
});
var _breadcrumbHTML = '<a href="/dashboard">'+app.get('name')+'</a>';
@@ -39,8 +40,8 @@ var Router = Backbone.Router.extend({
if (tabId) _breadcrumbHTML += ' &raquo; <a href="/dashboard/#/plugins/'+tabId+'">'+model.getObjectById(tabId).get('name')+'</a>';
$('#bread > h4').empty().append(_breadcrumbHTML);
if (typeof tabId !== "undefined" && tabId !== '') view.tabId = tabId;
view.render();
if (tabId && tabId !== '') this.currentView.tabId = tabId;
this.currentView.render();
}
});

View File

@@ -11,7 +11,7 @@ window.PluginView = Backbone.View.extend({
// if its the models plugin
if(this.model.get('plugin') === 'models') {
var tabContent = _self.addTab('overview', 'models-overview');
var tabContent = _self.addTab('overview', '');
tabContent
.append('<input id="model-name" type="text"" placeholder="Model Name" />')
.append(
@@ -24,8 +24,7 @@ window.PluginView = Backbone.View.extend({
window.location.reload();
});
})
)
;
);
}
this.model.get("objects").each(function(obj){

View File

@@ -26,14 +26,17 @@ window.SchemaView = Backbone.View.extend({
$(".save-changes", this.el).html("Save All Schema Changes").removeClass("white").addClass("blue");
},
schemaChange: function (msg) {
if (msg.get("errors")) {
this.showAlert('error', JSON.stringify(msg.get('errors')));
}
else if (msg.get("description")) {
this.showAlert('success', "Schema saved successfully.");
console.log(JSON.stringify(msg));
if (!msg.description) {
if (msg.errors) {
this.showAlert('error', JSON.stringify(msg.get('errors')));
}
else {
this.showAlert('error', 'The schema wasn\'t saved but no error messages were received. Make sure the server is online.');
}
}
else {
this.showAlert('warning', "Couldn't determine if schema was saved.");
this.showAlert('success', "Schema saved successfully.");
}
},
initialize: function () {