add ability to force route
diff --git a/planetstack/core/xoslib/static/js/xosAdminSite.js b/planetstack/core/xoslib/static/js/xosAdminSite.js
index 8ea8a44..02d23aa 100644
--- a/planetstack/core/xoslib/static/js/xosAdminSite.js
+++ b/planetstack/core/xoslib/static/js/xosAdminSite.js
@@ -27,13 +27,14 @@
});
XOSAdminApp.navigate = function(what, modelName, modelId) {
+ console.log("XOSAsminApp.navigate");
collection_name = modelName + "s";
if (what=="list") {
XOSAdminApp.Router.navigate(collection_name, {trigger: true})
} else if (what=="detail") {
XOSAdminApp.Router.navigate(collection_name + "/" + modelId, {trigger: true})
} else if (what=="add") {
- XOSAdminApp.Router.navigate("add" + firstCharUpper(modelName), {trigger: true})
+ XOSAdminApp.Router.navigate("add" + firstCharUpper(modelName), {trigger: true, force: true})
}
}
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 3bfd8fd..5ebc006 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -39,6 +39,13 @@
this.navigate("#"+prevPage, {trigger: false, replace: true} );
}
},
+
+ navigate: function(href, options) {
+ if (options.force) {
+ Marionette.AppRouter.prototype.navigate.call(this, "nowhere", {trigger: false, replace: true});
+ }
+ Marionette.AppRouter.prototype.navigate.call(this, href, options);
+ },
});
@@ -107,6 +114,9 @@
}
},
+ hideTabs: function() { $("#tabs").hide(); },
+ showTabs: function() { $("#tabs").show(); },
+
createListHandler: function(listViewName, collection_name, regionName, title) {
var app=this;
return function() {
@@ -115,7 +125,7 @@
app.hideLinkedItems();
$("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));
$("#detail").show();
- $("#tabs").hide();
+ app.hideTabs();
listButtons = new XOSListButtonView({linkedView: listView});
app["rightButtonPanel"].show(listButtons);
@@ -125,12 +135,18 @@
createAddHandler: function(detailName, collection_name, regionName, title) {
var app=this;
return function() {
+ console.log("addHandler");
+
+ app.hideLinkedItems();
+ app.hideTabs();
+
model = new xos[collection_name].model();
detailViewClass = app[detailName];
detailView = new detailViewClass({model: model, collection:xos[collection_name]});
app[regionName].show(detailView);
- $("#xos-detail-button-box").show();
- $("#xos-listview-button-box").hide();
+
+ detailButtons = new XOSDetailButtonView({linkedView: detailView});
+ app["rightButtonPanel"].show(detailButtons);
}
},
@@ -138,14 +154,9 @@
var app=this;
return function(parent_modelName, parent_fieldName, parent_id) {
app.Router.showPreviousURL();
- console.log("acs");
- console.log(parent_modelName);
- console.log(parent_fieldName);
- console.log(parent_id);
model = new xos[collection_name].model();
model.attributes[parent_fieldName] = parent_id;
model.readOnlyFields.push(parent_fieldName);
- console.log(model);
detailViewClass = app[addChildName];
var detailView = new detailViewClass({model: model, collection:xos[collection_name]});
detailView.dialog = $("xos-addchild-dialog");
@@ -158,7 +169,7 @@
"Save" : function() {
var addDialog = this;
detailView.synchronous = true;
- detailView.afterSave = function() { console.log("afterSave"); $(addDialog).dialog("close"); }
+ detailView.afterSave = function() { console.log("addChild afterSave"); $(addDialog).dialog("close"); }
detailView.save();
//$(this).dialog("close");
@@ -198,8 +209,6 @@
detailView = new detailViewClass({model: model});
app[regionName].show(detailView);
detailView.showLinkedItems();
- //$("#xos-detail-button-box").show();
- //$("#xos-listview-button-box").hide();
detailButtons = new XOSDetailButtonView({linkedView: detailView});
app["rightButtonPanel"].show(detailButtons);
@@ -445,6 +454,7 @@
e.preventDefault();
var that=this;
this.afterSave = function() {
+ console.log("addAnother afterSave");
that.app.navigate("add", that.model.modelName);
}
this.save();
@@ -736,7 +746,6 @@
result = '<select name="' + variable + '"' + readOnly + '>' +
idToOptions(selectedId, collectionName, fieldName) +
'</select>';
- console.log(result);
return result;
}