Skip to content

Commit

Permalink
Fix editable property parsing of property attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Aug 20, 2013
1 parent a1d6d76 commit 940d5f3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions hawtio-web/src/main/webapp/app/ui/js/editablePropertyDirective.ts
Expand Up @@ -14,9 +14,21 @@ module UI {
scope.editing = false;
$(element.find(".icon-pencil")[0]).hide();

ngModel.$render = function () {
scope.getPropertyName = () => {
var propertyName = $parse(attrs['property'])(scope);
scope.text = ngModel.$viewValue[propertyName];
if (!propertyName && propertyName !== 0) {
propertyName = attrs['property'];
}
return propertyName;
}

scope.propertyName = scope.getPropertyName();

ngModel.$render = function () {
if (!ngModel.$viewValue) {
return;
}
scope.text = ngModel.$viewValue[scope.propertyName];
};

scope.showEdit = function () {
Expand All @@ -39,7 +51,7 @@ module UI {
var value = $(element.find(":input[type=text]")[0]).val();
var obj = ngModel.$viewValue;

obj[$parse(attrs['property'])(scope)] = value;
obj[scope.propertyName] = value;

ngModel.$setViewValue(obj);
ngModel.$render();
Expand Down

0 comments on commit 940d5f3

Please sign in to comment.