Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// typeN: function || object
// }
// Where if it is a function, it is assumed to be an object constructor that takes the
// value of _value as the initialization parameters. It is serialized assuming object.toString()
// serialization. If it is an object, then it is assumed
// to be an object of general form:
// {
// type: function, //constructor.
// deserialize: function(value) //The function that parses the value and constructs the object defined by type appropriately.
// serialize: function(object) //The function that converts the object back into the proper file format form.
// }
// AndOrWriteStore duplicates ItemFileWriteStore, except extends AndOrReadStore, which offers complex queries.
// ItemFileWriteStore extends ItemFileReadStore to implement these additional dojo.data APIs
this._features['dojo.data.api.Write'] = true;
this._features['dojo.data.api.Notification'] = true;
// For keeping track of changes so that we can implement isDirty and revert
this._pending = {
_newItems:{},
_modifiedItems:{},
_deletedItems:{}
};
if(!this._datatypeMap['Date'].serialize){
this._datatypeMap['Date'].serialize = function(obj){
return dojo.date.stamp.toISOString(obj, {zulu:true});
};
}
//Disable only if explicitly set to false.
if(keywordParameters && (keywordParameters.referenceIntegrity === false)){
this.referenceIntegrity = false;
postMixInProperties: function(){
// setup to handle events from tree
// if the store supports Notification, subscribe to the notifcation events
if (this.store.getFeatures()['dojo.data.api.Notification']){
dojo.connect(this.store, "onNew", this, "onNew");
dojo.connect(this.store, "onDelete", this, "onDelete");
dojo.connect(this.store, "onSet", this, "onSet");
}
// setup to handle events from tree
dojo.subscribe(this.treeId, this, "_listener");
},
startup: function(){
if(this._started){ return; }
if(this.store && this.store.getFeatures()["dojo.data.api.Notification"]){
window.setTimeout(dojo.hitch(this, function(){
// Set connections after a slight timeout to avoid getting in the
// condition where we are setting them while events are still
// being fired
this.connect(this.store, "onSet", "_onSetItem");
this.connect(this.store, "onNew", "_onNewItem");
this.connect(this.store, "onDelete", "_onDeleteItem");
}), 1);
}
this.connect(this.focusNode||this.domNode, "onkeypress", "_focusKey");
this.parentWidget._updateClass(this.domNode, "Pane");
this.inherited(arguments);
this._onMinWidthChange(this.minWidth);
},
constructor: function(inFields, inData, args){
this.count = 1;
this._rowIdentities = {};
if(args){
dojo.mixin(this, args);
}
if(this.store){
// NOTE: we assume Read and Identity APIs for all stores!
var f = this.store.getFeatures();
this._canNotify = f['dojo.data.api.Notification'];
this._canWrite = f['dojo.data.api.Write'];
this._canIdentify = f['dojo.data.api.Identity'];
if(this._canNotify){
dojo.connect(this.store, "onSet", this, "_storeDatumChange");
}
}
},
markupFactory: function(args, node){
getFeatures: function(){
// summary:
// return the store feature set
var features = this.inherited(arguments);
features["dojo.data.api.Write"] = true;
features["dojo.data.api.Notification"] = true;
return features;
},
// it or something.
// store: dojo.data.api.Identity
// The store you would like to use - it MUST implement Identity,
// and MAY implement Notification.
// selectedValue: anything?
// The value that this widget should set itself to *after* the store
// has been loaded
// fetchArgs: Object?
// The arguments that will be passed to the store's fetch() function
var oStore = this.store;
fetchArgs = fetchArgs || {};
if(oStore !== store){
// Our store has changed, so update our notifications
dojo.forEach(this._notifyConnections || [], dojo.disconnect);
delete this._notifyConnections;
if(store && store.getFeatures()["dojo.data.api.Notification"]){
this._notifyConnections = [
dojo.connect(store, "onNew", this, "_onNewItem"),
dojo.connect(store, "onDelete", this, "_onDeleteItem"),
dojo.connect(store, "onSet", this, "_onSetItem")
];
}
this.store = store;
}
// Turn off change notifications while we make all these changes
this._onChangeActive = false;
// Remove existing options (if there are any)
if(this.options && this.options.length){
this.removeOption(this.options);
}
// summary:
// Passed the arguments listed above (store, etc)
// tags:
// private
lang.mixin(this, args);
this.connects = [];
var store = this.store;
if(!store.getFeatures()['dojo.data.api.Identity']){
throw new Error("dijit.tree.TreeStoreModel: store must support dojo.data.Identity");
}
// if the store supports Notification, subscribe to the notification events
if(store.getFeatures()['dojo.data.api.Notification']){
this.connects = this.connects.concat([
aspect.after(store, "onNew", lang.hitch(this, "onNewItem"), true),
aspect.after(store, "onDelete", lang.hitch(this, "onDeleteItem"), true),
aspect.after(store, "onSet", lang.hitch(this, "onSetItem"), true)
]);
}
},
root: true,
checked: this.checkedState,
id: this.rootId,
label: this.rootLabel,
children: params.rootChildren // optional param
};
// Compose a list of attribute names included in the store query.
if (this.query) {
var attr;
for (attr in this.query) {
this._queryAttrs.push(attr);
}
}
if (this.store.getFeatures()['dojo.data.api.Notification']){
this.connects = this.connects.concat([
aspect.after(this.store, "onRoot", lang.hitch(this, "onRootChange"), true)
]);
}
},
_setStore: function(store){
if(this.store && this._store_connects){
array.forEach(this._store_connects, this.disconnect, this);
}
this.store = store;
if(this.store){
var f = this.store.getFeatures();
var h = [];
this._canEdit = !!f["dojo.data.api.Write"] && !!f["dojo.data.api.Identity"];
this._hasIdentity = !!f["dojo.data.api.Identity"];
if(!!f["dojo.data.api.Notification"] && !this.items){
h.push(this.connect(this.store, "onSet", "_onSet"));
h.push(this.connect(this.store, "onNew", "_onNew"));
h.push(this.connect(this.store, "onDelete", "_onDelete"));
}
if(this._canEdit){
h.push(this.connect(this.store, "revert", "_onRevert"));
}
this._store_connects = h;
}
},
_setStore: function(store){
if(this.store && this._store_connects){
dojo.forEach(this._store_connects, this.disconnect, this);
}
this.store = store;
if(this.store){
var f = this.store.getFeatures();
var h = [];
this._canEdit = !!f["dojo.data.api.Write"] && !!f["dojo.data.api.Identity"];
this._hasIdentity = !!f["dojo.data.api.Identity"];
if(!!f["dojo.data.api.Notification"] && !this.items){
h.push(this.connect(this.store, "onSet", "_onSet"));
h.push(this.connect(this.store, "onNew", "_onNew"));
h.push(this.connect(this.store, "onDelete", "_onDelete"));
}
if(this._canEdit){
h.push(this.connect(this.store, "revert", "_onRevert"));
}
this._store_connects = h;
}
},