Commit 649fa61d authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

ui: Additional storage_attrs funcionality

allow custom model id resolver
parent e956e8d4
......@@ -135,6 +135,12 @@
var store, key, attr_name;
store = synnefo.storage[params[0]];
key = params[1];
attr_resolver = params[2];
if (!attr_resolver) {
attr_resolver = function(model, attr) {
return model.get(attr);
}
}
attr_name = attr;
var resolve_related_instance = function(storage, attr_name, val) {
......@@ -165,17 +171,19 @@
self.trigger("change:" + attr_name, obj);
clearInterval(retry);
}
}, 10);
}, 500);
}
}
var self = this;
this.bind('change:' + attr, function(model) {
resolve_related_instance.call(model, store, key, attr_resolver(model, attr));
}, this);
this.bind('change:' + attr, function() {
resolve_related_instance.call(this, store, key, this.get(attr))
});
this.bind('add', function() {
resolve_related_instance.call(this, store, key, this.get(attr))
});
this.bind('add', function(model) {
resolve_related_instance.call(model, store, key, attr_resolver(model, attr));
}, this);
resolve_related_instance.call(this, store, key, attr_resolver(this, attr));
}, this);
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment