for(var f in this.sortedFieldList) {
var field = this.sortedFieldList[f];
if(!field || field.virtual) continue;
- var entry = existing.filter(function(i){return (i.field == field.name)})[0];
+ var entry = existing.filter(
+ function(i){return (i.field == field.name)})[0];
if(entry) entry.name = field.label;
else entry = {field:field.name, name:field.label};
fields.push(entry);
var idents = grid.store.getIdentityAttributes();
var dialog = new openils.widget.EditDialog({
fmObject:fmObject,
- onPostApply : function() {
+ onPostSubmit : function() {
for(var i in fmObject._fields) {
var field = fmObject._fields[i];
if(idents.filter(function(j){return (j == field)})[0])
}
});
dialog.editPane.fieldOrder = this.fieldOrder;
+ dialog.editPane.mode = 'update';
+ dialog.startup();
+ dialog.show();
+ },
+
+ showCreateDialog : function() {
+ var grid = this;
+ var dialog = new openils.widget.EditDialog({
+ fmClass : this.fmClass,
+ onPostSubmit : function(r) {
+ var fmObject = openils.Util.readResponse(r);
+ if(fmObject) {
+ grid.store.newItem(fmObject.toStoreItem());
+ grid.update();
+ }
+ dialog.destroy();
+ }
+ });
+ dialog.editPane.fieldOrder = this.fieldOrder;
+ dialog.editPane.mode = 'create';
dialog.startup();
dialog.show();
}
- }
+ }
);
openils.widget.AutoGrid.markupFactory = dojox.grid.DataGrid.markupFactory;
[dijit.layout.ContentPane, openils.widget.AutoWidget],
{
mode : 'update',
- onPostApply : null, // apply callback
+ onPostSubmit : null, // apply callback
onCancel : null, // cancel callback
hideActionButtons : false,
parentNode : valTd,
orgLimitPerms : this.limitPerms
});
+
widget.build();
this.fieldList.push({name:field.name, widget:widget});
this.applySaveOnEnter(widget);
performAutoEditAction : function() {
var self = this;
self.performEditAction({
- oncomplete:function() {
- if(self.onPostApply)
- self.onPostApply();
+ oncomplete:function(r) {
+ if(self.onPostSubmit)
+ self.onPostSubmit(r);
}
});
},
this.fmObject = new fieldmapper[this.fmClass]();
for(var idx in fields)
this.fmObject[fields[idx]](this.getFieldValue(fields[idx]));
+ if(this.mode == 'create')
+ this.fmObject[fieldmapper[this.fmClass].Identifier](null);
pcrud[this.mode](this.fmObject, opts);
}
}
}
openils.Util.addOnLoad(renderGrid);
</script>
+<button dojoType='dijit.form.Button' onClick='erGrid.showCreateDialog()'>Create</button>
<div dojoType="dijit.layout.ContentPane" layoutAlign="top" style='height:600px;'>
<table jsId="erGrid" dojoType="openils.widget.AutoGrid"
fieldOrder="['id', 'from_currency', 'to_currency', 'ratio']"