I try to migrate project form Ember cli 0.1.2 to 0.1.15. Current problem is next:
I have can-helper. It works fine at older ember but at newer version all can-blocks are absent. Can-helper use calculated property in model, so i try to set debugger into calculation function - it work on 0.1.2 and didn't work at 0.1.15
Original ember - 1.7.0-beta.1 Try migrate to ember - 1.9.1
As i found implementation of boundIf helper was changed. Have anybody some ideas / experience with such trouble?
P.S. code of can-helper is below
var get = Ember.get, isGlobalPath = Ember.isGlobalPath, normalizePath = Ember.Handlebars.normalizePath,
IS_BINDING = Ember.IS_BINDING;
var getProp = function(context, property, options) {
if (isGlobalPath(property)) {
return get(property);
} else {
var path = normalizePath(context, property, options.data);
return get(path.root, path.path);
}
};
export default function(permissionName, property, options) {
var attrs, context, key, path, permission;
// property is optional, if we've only got 2 arguments then the property contains our options
if (!options) {
options = property;
property = null;
}
context = (options.contexts && options.contexts[0]) || this;
attrs = {};
// if we've got a property name, get its value and set it to the permission's content
// this will set the passed in `post` to the content eg:
// {{#can editPost post}} ... {{/can}}
if (property) {
attrs.content = getProp(context, property, options);
}
// if we've got any options, find their values eg:
// {{#can createPost project=project user=App.currentUser}} ... {{/can}}
for (key in options.hash) {
if (!options.hash.hasOwnProperty(key)) {
continue;
}
path = options.hash[key];
if (options.hashTypes[key] === 'STRING') {
if (IS_BINDING.test(key)) {
attrs[key.slice(0, -7)] = getProp(context, path, options);
}
else {
attrs[key] = path;
}
}
else {
attrs[key] = getProp(context, path, options);
}
}
// find & create the permission with the supplied attributes
permission = this.get('container').lookup('permissions:main').get(permissionName, attrs);
// ensure boundIf uses permission as context and not the view/controller
// otherwise it looks for 'can' in the wrong place
options.contexts = null;
// bind it all together and kickoff the observers
return Ember.Handlebars.helpers.boundIf.call(permission, "can", options);
}
in template it used as
{{#can read model="contact"}}
<div class="panel">
{{#link-to 'contacts' id="nav-to-contacts" class="main-menu-root-item" title="Contacts"}}
Contacts
{{/link-to}}
</div>
{{/can}}
Can is computed property at permission
can: function() {
var model = get(this, 'model'),
field = get(this, 'field'),
permission = rules.findBy('name', model);
return permission && permission.read &&
(field ? permission.read.contains(field) : permission.read.length);
}.property()
At older version i can stop inside it with debugger statement, but after updating - can't It's possible errors on observers changes of model, but it should be called at least once ( on initial rendering ) - as i understand
The reason in wrong context for getting property Please look here https://github.com/emberjs/ember.js/issues/10692