template: "#xos-sliceselector-option",
tagName: "option",
attributes: function() {
- console.log("XXX");
- console.log(this.options.selectedID);
- console.log(this.model.get("id"));
if (this.options.selectedID == this.model.get("id")) {
return { value: this.model.get("id"), selected: 1 };
} else {
template: "#xos-sliceselector-select",
childViewContainer: "select",
childView: SliceSelectorOption,
+ caption: "Slice",
events: {"change select": "onSliceChanged"},
sliceChanged: function(id) {
console.log("sliceChanged " + id);
},
+
+ templateHelpers: function() { return {caption: this.options.caption || this.caption }; },
});
FilteredCompositeView = Marionette.CompositeView.extend( {
Marionette.AppRouter.prototype.navigate.call(this, href, options);
},
});\r
-
-Backbone.Syphon.InputReaders.register('select', function(el) {
+\r
+// XXX - We import backbone multiple times (BAD!) since the import happens\r
+// inside of the view's html. The second time it's imported (developer\r
+// view), it wipes out Backbone.Syphon. So, save it as Backbone_Syphon for\r
+// now.\r
+Backbone_Syphon = Backbone.Syphon\r
+Backbone_Syphon.InputReaders.register('select', function(el) {\r
// Modify syphon so that if a select has "syphonall" in the class, then
// the value of every option will be returned, regardless of whether of
// not it is selected.
that.destroyModel(model);
if (afterDelete=="list") {
that.navigate("list", modelName);
+ } else if (afterDelete) {
+ afterDelete();
}
});
},
*/
initialize: function() {
- this.on("saveSuccess", this.onAfterSave);
+ this.on("saveSuccess", this.onSaveSuccess);
this.synchronous = false;
},
});
},
+ saveSuccess: function(e) {
+ // always called after a save succeeds
+ },
+
afterSave: function(e) {
+ // if this.synchronous, then called after the save succeeds
+ // if !this.synchronous, then called after save is initiated
},
- onAfterSave: function(e) {
- this.afterSave(e);
+ onSaveSuccess: function(e) {
+ this.saveSuccess(e);
+ if (this.synchronous) {
+ this.afterSave(e);
+ }
},
inputChanged: function(e) {
submitLeaveClicked: function(e) {
console.log("saveLeave");
e.preventDefault();
+ if (this.options.noSubmitButton || this.noSubmitButton) {
+ return;
+ }
var that=this;
this.afterSave = function() {
that.app.navigate("list", that.model.modelName);
save: function() {
this.app.hideError();
- var data = Backbone.Syphon.serialize(this);
+ var data = Backbone_Syphon.serialize(this);
var that = this;
var isNew = !this.model.id;
this.model.save(data, {error: function(model, result, xhr) { that.app.saveError(model,result,xhr,infoMsgId);},
success: function(model, result, xhr) { that.app.saveSuccess(model,result,xhr,infoMsgId);
- if (that.synchronous) {
- that.trigger("saveSuccess");
- }
+ that.trigger("saveSuccess");
}});
this.dirty = false;
addFields: this.model.addFields,
listFields: this.model.listFields,
detailFields: this.options.detailFields || this.detailFields || this.model.detailFields,
+ fieldDisplayNames: this.options.fieldDisplayNames || this.fieldDisplayNames || this.model.fieldDisplayNames || {},
foreignFields: this.model.foreignFields,
detailLinkFields: this.model.detailLinkFields,
inputType: this.model.inputType,
render: function() {
var view = this;
+ var fieldDisplayNames = view.options.fieldDisplayNames || view.fieldDisplayNames || {};
view.columnsByIndex = [];
view.columnsByFieldName = {};
inputType = view.options.inputType || view.inputType || {};
mRender = undefined;
mSearchText = undefined;
- sTitle = fieldNameToHumanReadable(fieldName);
+ sTitle = fieldName in fieldDisplayNames ? fieldDisplayNames[fieldName] : fieldNameToHumanReadable(fieldName);
bSortable = true;
if (fieldName=="backend_status") {
mRender = function(x,y,z) { return xosBackendStatusIconTemplate(z); };
var foreignCollection = view.collection.foreignFields[fieldName];
mSearchText = function(x) { return idToName(x, foreignCollection, "humanReadableName"); };
} else if (inputType[fieldName] == "spinner") {
- mRender = function(x,y,z) { return xosDataTableSpinnerTemplate( {value: x, collectionName: view.collection.collectionName, fieldName: fieldName, id: z.id} ); };
+ mRender = function(x,y,z) { return xosDataTableSpinnerTemplate( {value: x, collectionName: view.collection.collectionName, fieldName: fieldName, id: z.id, app: view.app} ); };
}
if ($.inArray(fieldName, view.collection.detailLinkFields)>=0) {
var collectionName = view.collection.collectionName;
"bJQueryUI": true,
"bStateSave": true,
"bServerSide": true,
+ "bFilter": ! (view.options.disableFilter || view.disableFilter),
+ "bPaginate": ! (view.options.disablePaginate || view.disablePaginate),
"aoColumns": view.columnsByIndex,
fnServerData: function(sSource, aoData, fnCallback, settings) {
aaData.sort(function(a,b) { return compareColumns(sortCols, sortDirs, a, b); });\r
\r
// slice it for pagination\r
- aaData = aaData.slice(iDisplayStart, iDisplayStart+iDisplayLength);\r
+ if (iDisplayLength >= 0) {\r
+ aaData = aaData.slice(iDisplayStart, iDisplayStart+iDisplayLength);\r
+ }\r
\r
return fnCallback({iTotalRecords: totalSize,\r
iTotalDisplayRecords: filteredSize,\r