recordset-debug.js revision 35efc9511ecb6deca970c97d13bc6c3fb9cb9a28
/**
* Class name.
*
* @property NAME
* @type String
* @static
* @final
* @value "record"
*/
_setId: function() {
return Y.guid();
},
initializer: function(o) {
},
destructor: function() {
},
return this.get("data");
}
else {
}
return null;
}
},
{
ATTRS: {
id: {
valueFn: "_setId",
writeOnce: true
},
data : {
value: null
}
}
});
initializer: function() {
//set up event listener to fire events when recordset is modified in anyway
this._recordsetChanged();
},
destructor: function() {
},
/**
* Helper method called upon by add() - it is used to create a new record(s) in the recordset
*
* @method _defAddFn
* @param aRecord {Y.Record} A Y.Record instance
* @param index {Number} (optional) Index at which to add the record(s)
* @return {Y.Record} A Record instance.
* @private
*/
_defAddFn: function(e) {
//index = (Y.Lang.isNumber(index) && (index > -1)) ? index : len;
}
else {
}
Y.log('add Fired');
},
_defRemoveFn: function(e) {
if (e.index === 0) {
}
else {
}
Y.log('remove fired');
},
_defEmptyFn: function(e) {
this._items = [];
Y.log('empty fired');
},
_defUpdateFn: function(e) {
}
},
/**
* Helper method - it takes an object bag and converts it to a Y.Record
*
* @method _changeToRecord
* @param obj {Object || Y.Record} Any objet literal or Y.Record instance
* @return {Y.Record} A Record instance.
* @private
*/
_changeToRecord: function(obj) {
var oRec;
}
else {
}
return oRec;
},
//---------------------------------------------
// Events
//---------------------------------------------
/**
* Event that is fired whenever the recordset is changed. Note that multiple simultaneous changes still fires this event once.
* (ie: Adding multiple records via an array will only fire this event once at the completion of all the additions)
*
* @method _recordSetUpdated
* @private
*/
_recordsetChanged: function() {
Y.log('change fire');
this.fire('change', {});
});
},
//---------------------------------------------
// Public Methods
//---------------------------------------------
/**
* Returns the record at a particular index
*
* @method getRecord
* @param i {Number} Index at which the required record resides
* @return {Y.Record} An Y.Record instance
* @public
*/
getRecord: function(i) {
return this._items[i];
},
/**
* Returns a range of records beginning at particular index
*
* @method getRecord
* @param index {Number} Index at which the required record resides
* @param range {Number} (Optional) Number of records to retrieve. The default is 1
* @return {Array} An array of Y.Record instances
* @public
*/
var i=0, returnedRecords = [];
//Range cannot take on negative values
for(; i<range; i++) {
}
return returnedRecords;
},
getLength: function() {
return this.size();
},
/**
* Returns an array of values for a specified key in the recordset
*
* @method getRecord
* @param index {Number} (optional) Index at which the required record resides
* @return {Array} An array of values for the given key
* @public
*/
getValuesByKey: function(key) {
for( ; i < len; i++) {
}
return retVals;
},
/**
* Adds one or more Records to the RecordSet at the given index. If index is null,
* then adds the Records to the end of the RecordSet.
*
* @method add
* @param oData {Y.Record, Object Literal, Array} A Y.Record instance, An object literal of data or an array of object literals
* @param index {Number} (optional) Index at which to add the record(s)
* @return {object} An object literal with two properties: "data" which contains array of Y.Record(s) and "index" which contains the index where the Y.Record(s) were added
* @public
*/
var newRecords=[], idx, i;
//Passing in array of object literals for oData
newRecords = [];
}
}
//If it is an object literal of data or a Y.Record
}
return this;
},
/**
* Removes one or more Records to the RecordSet at the given index. If index is null,
* then removes a single Record from the end of the RecordSet.
*
* @method remove
* @param index {Number} (optional) Index at which to remove the record(s) from
* @param range {Number} (optional) Number of records to remove (including the one at the index)
* @return {object} An object literal with two properties: "data" which contains the removed set {Y.Record or Y.Recordset} and "index" which contains the index where the Y.Record(s) were removed from
* @public
*/
var remRecords=[];
//Default is to only remove the last record - the length is always 1 greater than the last index
//this._recordRemoved(remRecords, index);
//return ({data: remRecords, index:index});
return this;
},
/**
* Empties the recordset
*
* @method empty
* @public
*/
empty: function() {
this.fire('empty', {});
return this;
},
//Whatever is passed in, we are changing it to an array so that it can be easily iterated in the _defUpdateFn method
return this;
}
},
{
ATTRS: {
records: {
getter: function () {
// give them a copy, not the internal object
return Y.Array(this._items);
},
var records = [];
function initRecord(oneData) {
var o;
}
else {
}
}
// ...unless we don't care about live object references
},
//initialization of the attribute must be done before the first call is made.
//see http://developer.yahoo.com/yui/3/api/Attribute.html#method_addAttr for details on this
lazyAdd: false
}
}
});
}
Y.mix(RecordsetSort, {
NS: "sort",
NAME: "recordsetSort",
ATTRS: {
value: {
desc:true,
},
validator: function(v) {
}
},
if(sorted === 0) {
}
else {
return sorted;
}
}
},
isSorted: {
value: false,
valueFn: "_getState"
}
}
});
initializer: function(config) {
},
destructor: function(config) {
},
_getState: function() {
this.set('isSorted',false);
}, this);
this.on("sort", function() {
this.set('isSorted', true);
});
},
_defSortFn: function(e) {
Y.log('sort fired');
this.set('lastSortProperties', e);
//have to work directly with _items here - changing the recordset.
});
},
},
resort: function() {
var p = this.get('lastSortProperties');
},
reverse: function() {
},
//flips the recordset based on the same sort method that user had defined
flip: function() {
var p = this.get('lastSortProperties');
//If a predefined field is not provided by which to sort by, throw an error
}
else {
Y.log('You called flip before setting a field by which to sort by. Maybe you meant to call reverse().');
}
}
});
var YArray = Y.Array,
function RecordsetFilter(config) {
}
Y.mix(RecordsetFilter, {
NS: "filter",
NAME: "recordsetFilter",
ATTRS: {
}
});
initializer: function(config) {
//this.publish("filter", {defaultFn: Y.bind("_defFilterFn", this)});
},
destructor: function(config) {
},
filter: function(f,v,n) {
i = 0,
oRecs = [],
func = f;
//If a key-value pair is passed in, generate a custom function
return true;
}
else {
return false;
}
};
}
//return new host.constructor({records:arr});
},
reject: function(f) {
},
}
});
YUI.add('recordset', function(Y){}, '@VERSION@' ,{use:['recordset-base','recordset-sort','recordset-filter']});