"toOne": {
"type": "BankAccountRelation",
"column": "bankaccnt_id",
- "isNested": true
+ "required": true
}
},
{
}
},
{
- "name": "owner",
+ "name": "cashReceipt",
"attr": {
"type": "Number",
"column": "cashrcptitem_cashrcpt_id"
"name": "receivable",
"toOne": {
"isNested": true,
- "type": "ReceivableRelation",
+ "type": "CashReceiptReceivable",
"column": "cashrcptitem_aropen_id"
}
},
"idSequenceName": "cashrcptitem_cashrcptitem_id_seq",
"isRest": true,
"lockable": true,
- "isNestedOnly": true,
"isSystem": true,
"comment": "Pending Cash Receipt Line Item",
"privileges": {
"isRest": true,
"lockable": true,
"comment": "Cash Receipt Relation",
- "isNestedOnly": true,
"isSystem": true,
"privileges": {
"all": {
{
"name": "bankAccount",
"toOne": {
+ "isNested": true,
"type": "BankAccountRelation",
- "column": "bankaccnt_id",
- "isNested": true
+ "column": "bankaccnt_id"
}
},
{
-/*jshint unused:false */
-/* global XG:true */
+// Contributions of status related functionality borrowed from SproutCore:
+// https://github.com/sproutcore/sproutcore
+
+/*jshint indent:2, curly:true, eqeqeq:true, immed:true, latedef:true,
+newcap:true, noarg:true, regexp:true, undef:true, strict:true, trailing:true,
+white:true, expr:true*/
+/*global XT:true, XM:true, Backbone:true, _:true, setInterval:true,
+ clearInterval:true, jsonpatch:true, Globalize:true, XG:true*/
(function () {
- 'use strict';
+ "use strict";
XM.Tuplespace = _.clone(Backbone.Events);
+
+ /*
+ XG.Tuplespace.on('all', function () {
+ //console.log(arguments);
+ });
+ */
+
/**
@class `XM.Model` is an abstract class designed to operate with `XT.DataSource`.
It should be subclassed for any specific implementation. Subclasses should
callback();
}
},
-
+
/**
A function that binds events to functions. It can and should only be called
once by initialize. Any attempt to call it a second time will throw an error.
*/
bindEvents: function () {
- var that = this;
// Bind events, but only if we haven't already been here before.
// We could silently skip, but then that means any overload done
// by anyone else has to do that check too. That's too error prone
// are not immediatley apparent and insidiously hard to pin down.
if (this._eventsBound) { throw "Events have already been bound."; }
- /**
- * Bind all events in the optional 'handlers' hash
- */
- _.each(this.handlers, function (handler, event) {
- if (!_.isFunction(that[handler])) {
- console.warn('Handler '+ handler + 'not found: not binding');
- return;
- }
- that.on(event, that[handler]);
- });
-
this.on('change', this.didChange);
this.on('error', this.didError);
this.on('destroy', this.didDestroy);
_.each(
_.where(this.relations, { type: Backbone.HasMany, includeInJSON: true }),
function (relation) {
- that.on('add:' + relation.key, that.didChange);
- if (!that.isReadOnly()) {
- that.on('add:' + relation.key, that.relationAdded);
+ this.on('add:' + relation.key, this.didChange);
+ if (!this.isReadOnly()) {
+ this.on('add:' + relation.key, this.relationAdded);
}
- });
+ }, this);
this._idx = {};
this._eventsBound = true;
initialize: function (attributes, options) {
attributes = attributes || {};
options = options || {};
- var that = this,
- klass,
+ var klass,
K = XM.Model,
status = this.getStatus(),
idAttribute = this.idAttribute;
}
/**
- * Enable ability to listen for events in a global tuple-space, if
- * required.
- */
+ * Enable ability to listen for events in a global tuple-space, if
+ * required.
+ */
XM.Tuplespace.listenTo(this, 'all', XM.Tuplespace.trigger);
},
parentRelation = _.find(this.relations, function (relation) {
return relation.isAutoRelation;
});
- // #refactor XXX if this is a bona fide Backbone Relational relation,
- // events will propagate automatically from child to parent.
parent.changed[parentRelation.reverseRelation.key] = true;
parent.trigger('change', parent, options);
}
if (options && options.isFetching) { this.status = XM.Model.BUSY_FETCHING; }
};
-})();
+}());