Skip to content

Commit

Permalink
Removed getFeatures() in favor of has()
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Jekel committed Apr 6, 2012
1 parent e6f720b commit 0f2e7f5
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions StoreModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ define([
"dojo/_base/lang",
"dojo/_base/window",
"dojo/aspect",
"dojo/has",
"./ItemWriteStoreEX" // ItemFileWriteStore extensions.
], function (TreeStoreModel, array, declare, lang, win, aspect, ItemWriteStoreEX) {
], function (TreeStoreModel, array, declare, lang, win, aspect, has, ItemWriteStoreEX) {

return declare([TreeStoreModel], {
// checkedAll: Boolean
Expand Down Expand Up @@ -104,11 +105,14 @@ define([
// tags:
// extension

this._features = {'tree.model.getItemAttr':true, 'tree.model.setItemAttr':true};
has.add("tree-model-getItemAttr", 1);

if (!this.store.getFeatures()['dojo.data.api.Write']){
console.warn(this.declaredClass+"::constructor(): store is not write enabled.");
this._features["tree.model.setItemAttr"] = false;
this._writeEnabled = false;
} else {
has.add("tree-model-setItemAttr", 1);
this._writeEnabled = true;
}
// Make dummy root item
this.root = {
Expand Down Expand Up @@ -416,7 +420,7 @@ define([
} catch(e) {
console.log(e);
}
if (this._features["tree.model.setItemAttr"]) {
if (has("tree-model-setItemAttr")) {
lang.hitch( this, this._validateStore ) ( storeItem ? storeItem : this.root );
this._updateCheckedParent( storeItem );
} else {
Expand Down Expand Up @@ -511,23 +515,6 @@ define([
throw new Error( this.declaredClass+"::get(): Attribute must be of type string" );
},

getFeatures: function(){
// summary:
// Returns the current supported feature set for the model. This method
// is provided to mimic the dojo.data.store getFeatures() method.
// (see also _getFeaturesAttr() )
return this._features; //Object
},

_getFeaturesAttr: function(){
// summary:
// Returns the current supported feature set for the model. This method
// is the hook for get("features").
// tag:
// private
return this._features; //Object
},

_getLabelAttrAttr: function() {
// summary:
// Return the label attribute associated with the store, if available.
Expand Down Expand Up @@ -712,7 +699,7 @@ define([
// value:
// Value to be applied.

if (this._features["tree.model.setItemAttr"]) {
if (this._writeEnabled ) {
var attr = (attribute == this.checkedAttr ? "checked" : attribute);
if (this.isItem( storeItem )) {
var func = this._getFuncNames( "Item", attr );
Expand Down

0 comments on commit 0f2e7f5

Please sign in to comment.