}
}
+function templateFromId(id) {
+ return _.template($(id).html());
+}
+
HTMLView = Marionette.ItemView.extend({
render: function() {
this.$el.append(this.options.html);
} else {
$(this.successBoxId).show();
$(this.successBoxId).html(_.template($(this.successTemplate).html())(result));
+ var that=this;
$(this.successCloseButtonId).unbind().bind('click', function() {
- $(this.successBoxId).hide();
+ $(that.successBoxId).hide();
});
}
},
} else {
$(this.errorBoxId).show();
$(this.errorBoxId).html(_.template($(this.errorTemplate).html())(result));
+ var that=this;
$(this.errorCloseButtonId).unbind().bind('click', function() {
- $(this.errorBoxId).hide();
+ $(that.errorBoxId).hide();
});
}
},
// We were passed the logMessageId of an informational message,
// and the caller wants us to replace that message with our own.
// i.e. replace an informational message with a success or an error.
- console.log(result["infoMsgId"]);
- console.log($("."+result["infoMsgId"]));
$("#"+result["infoMsgId"]).replaceWith(newRow);
} else {
// Create a brand new log message rather than replacing one.
},
hideLinkedItems: function(result) {
- index=0;
+ var index=0;
while (index<4) {\r
this["linkedObjs" + (index+1)].empty();\r
index = index + 1;\r
}\r
},\r
\r
- listViewShower: function(listViewName, regionName) {\r
+ listViewShower: function(listViewName, collection_name, regionName, title) {\r
var app=this;\r
return function() {\r
app[regionName].show(new app[listViewName]);\r
app.hideLinkedItems();\r
+ $("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));\r
+ $("#detail").show();\r
+ $("#tabs").hide();\r
}\r
},\r
\r
- detailShower: function(detailName, collection_name, regionName) {\r
+ detailShower: function(detailName, collection_name, regionName, title) {\r
var app=this;\r
showModelId = function(model_id) {\r
showModel = function(model) {\r
- console.log(app);\r
detailViewClass = app[detailName];\r
detailView = new detailViewClass({model: model});\r
app[regionName].show(detailView);\r
detailView.showLinkedItems();\r
}\r
\r
+ $("#contentTitle").html(templateFromId("#xos-title-detail")({"title": title}));\r
+\r
collection = xos[collection_name];\r
model = collection.get(model_id);\r
if (model == undefined) {\r
this.dirty = false;\r
},
+ tabClick: function(tabId, regionName) {
+ region = this.app[regionName];\r
+ if (this.currentTabRegion != undefined) {\r
+ this.currentTabRegion.$el.hide();\r
+ }\r
+ if (this.currentTabId != undefined) {\r
+ $(this.currentTabId).removeClass('active');\r
+ }\r
+ this.currentTabRegion = region;\r
+ this.currentTabRegion.$el.show();\r
+\r
+ this.currentTabId = tabId;\r
+ $(tabId).addClass('active');\r
+ },
+
+ showTabs: function(tabs) {
+ template = templateFromId("#xos-tabs-template", {tabs: tabs});
+ $("#tabs").html(template(tabs));
+ var that = this;
+
+ _.each(tabs, function(tab) {
+ var regionName = tab["region"];
+ var tabId = '#xos-nav-'+regionName;
+ $(tabId).bind('click', function() { that.tabClick(tabId, regionName); });
+ });
+
+ $("#tabs").show();
+ },
+
showLinkedItems: function() {
- index=0;\r
+ tabs=[];
+
+ tabs.push({name: "details", region: "detail"});
+
+ var index=0;
for (relatedName in this.model.collection.relatedCollections) {\r
relatedField = this.model.collection.relatedCollections[relatedName];\r
+ regionName = "linkedObjs" + (index+1);\r
\r
relatedListViewClassName = relatedName + "ListView";\r
- if (this.app[relatedListViewClassName] == undefined) {\r
- console.log("warning: " + relatedListViewClassName + " not found");\r
- }\r
+ assert(this.app[relatedListViewClassName] != undefined, relatedListViewClassName + " not found");\r
relatedListViewClass = this.app[relatedListViewClassName].extend({collection: xos[relatedName].filterBy(relatedField,this.model.id)});\r
- this.app["linkedObjs" + (index+1)].show(new relatedListViewClass());\r
+ this.app[regionName].show(new relatedListViewClass());\r
+ this.app[regionName].$el.hide();\r
+ tabs.push({name: relatedName, region: regionName});\r
index = index + 1;\r
}\r
\r
+ console.log(index);\r
+\r
while (index<4) {\r
this.app["linkedObjs" + (index+1)].empty();\r
index = index + 1;\r
}\r
- },
-});
+\r
+ this.showTabs(tabs);\r
+ this.tabClick('#xos-nav-detail', 'detail');\r
+ },\r
+\r
+});\r
/* XOSItemView
This is for items that will be displayed as table rows.