Skip to content

Commit

Permalink
Fix #481
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Aug 19, 2013
1 parent 22fd068 commit 349bc22
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
8 changes: 4 additions & 4 deletions hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -67,7 +67,7 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
<ul class="unstyled">
<li ng-repeat="feature in row.features">
<i class="red clickable icon-remove" title="Delete {{feature}}" ng-click="deleteThing('Feature', 'Features', row.features, feature)"></i>
<editable-property ng-model="row.features" property="{{$index}}" on-save="updateThing('Feature', 'Features', row.features)"></editable-property>
<editable-property ng-model="row.features" property="$index" on-save="updateThing('Feature', 'Features', row.features)"></editable-property>
</li>
<li>
<i class="clickable icon-edit" ng-click="goto('/fabric/profile/{{versionId}}/{{profileId}}/editFeatures')" title="Edit features"></i>
Expand All @@ -81,7 +81,7 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
<ul class="unstyled">
<li ng-repeat="fab in row.fabs">
<i class="red clickable icon-remove" title="Delete {{fab}}" ng-click="deleteThing('Fuse Application Bundle', 'Fabs', row.fabs, fab)"></i>
<editable-property ng-model="row.fabs" property="{{$index}}" on-save="updateThing('Fuse Application Bundle', 'Fabs', row.fabs)"></editable-property>
<editable-property ng-model="row.fabs" property="$index" on-save="updateThing('Fuse Application Bundle', 'Fabs', row.fabs)"></editable-property>

</li>
<li>
Expand All @@ -96,7 +96,7 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
<ul class="unstyled">
<li ng-repeat="bundle in row.bundles">
<i class="red clickable icon-remove" title="Delete {{bundle}}" ng-click="deleteThing('Bundle', 'Bundles', row.bundles, bundle)"></i>
<editable-property ng-model="row.bundles" property="{{$index}}" on-save="updateThing('Bundle', 'Bundles', row.bundles)"></editable-property>
<editable-property ng-model="row.bundles" property="$index" on-save="updateThing('Bundle', 'Bundles', row.bundles)"></editable-property>
</li>
<li>
<i class="clickable icon-plus" ng-click="addNewThing('Bundle', 'Bundles', row.bundles)" title="Add Bundle"></i>
Expand All @@ -112,7 +112,7 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
<ul class="unstyled">
<li ng-repeat="repository in row.repositories">
<i class="red clickable icon-remove" title="Delete {{repository}}" ng-click="deleteThing('Feature Repository', 'Repositories', row.repositories, repository)"></i>
<editable-property ng-model="row.repositories" property="{{$index}}" on-save="updateThing('Feature Repository', 'Repositories', row.repositories)"></editable-property>
<editable-property ng-model="row.repositories" property="$index" on-save="updateThing('Feature Repository', 'Repositories', row.repositories)"></editable-property>
</li>
<li>
<i class="clickable icon-plus" ng-click="addNewThing('Feature Repository', 'Repositories', row.repositories)" title="Add Feature Repository"></i>
Expand Down
69 changes: 33 additions & 36 deletions hawtio-web/src/main/webapp/app/ui/js/editablePropertyDirective.ts
Expand Up @@ -6,52 +6,49 @@ module UI {
public scope = true;
public templateUrl = UI.templatePath + 'editableProperty.html';
public require = 'ngModel';
public link = null;

public link = function (scope, element, attrs, ngModel) {
constructor(private $parse) {

scope.editing = false;
$(element.find(".icon-pencil")[0]).hide();
this.link = (scope, element, attrs, ngModel) => {
scope.editing = false;
$(element.find(".icon-pencil")[0]).hide();

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

scope.showEdit = function () {
$(element.find(".icon-pencil")[0]).show();
};
scope.showEdit = function () {
$(element.find(".icon-pencil")[0]).show();
};

scope.hideEdit = function () {
$(element.find(".icon-pencil")[0]).hide();
};
scope.hideEdit = function () {
$(element.find(".icon-pencil")[0]).hide();
};

scope.doEdit = function () {
scope.editing = true;
};
scope.doEdit = function () {
scope.editing = true;
};

scope.stopEdit = function () {
scope.editing = false;
};
scope.stopEdit = function () {
scope.editing = false;
};

scope.saveEdit = function () {
var value = $(element.find(":input[type=text]")[0]).val();
var obj = ngModel.$viewValue;
if (angular.isDefined(attrs['property'])) {
obj[attrs['property']] = value;
} else {
obj = value;
}
ngModel.$setViewValue(obj);
ngModel.$render();
scope.editing = false;
scope.$parent.$eval(attrs['onSave']);
};
scope.saveEdit = function () {
var value = $(element.find(":input[type=text]")[0]).val();
var obj = ngModel.$viewValue;

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

ngModel.$setViewValue(obj);
ngModel.$render();
scope.editing = false;
scope.$parent.$eval(attrs['onSave']);
};

};
}

}

Expand Down
4 changes: 2 additions & 2 deletions hawtio-web/src/main/webapp/app/ui/js/uiPlugin.ts
Expand Up @@ -26,8 +26,8 @@ module UI {
return new UI.FileUpload();
}).directive('expandable', () => {
return new UI.Expandable();
}).directive('editableProperty', () => {
return new UI.EditableProperty();
}).directive('editableProperty', ($parse) => {
return new UI.EditableProperty($parse);
}).run(function (helpRegistry) {
helpRegistry.addDevDoc("ui", 'app/ui/doc/developer.md');
});
Expand Down

0 comments on commit 349bc22

Please sign in to comment.