Skip to content

Commit

Permalink
edit-in-place: set ng-class inside directive
Browse files Browse the repository at this point in the history
  • Loading branch information
amirnissim committed Jan 15, 2014
1 parent f8cc78e commit 9230a77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions rd_ui/app/scripts/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ directives.directive('editInPlace', function () {
template: function(tElement, tAttrs) {
var elType = tAttrs.editor || 'input';
var placeholder = tAttrs.placeholder || 'Click to edit';
return '<span ng-click="editable && edit()" ng-bind="value"></span>' +
'<span ng-click="editable && edit()" ng-show="!value">' + placeholder + '</span>' +
return '<span ng-click="editable && edit()" ng-bind="value" ng-class="{editable: editable}"></span>' +
'<span ng-click="editable && edit()" ng-show="editable && !value" ng-class="{editable: editable}">' + placeholder + '</span>' +
'<{elType} ng-model="value" class="form-control" rows="2"></{elType}>'.replace('{elType}', elType);
},
link: function ($scope, element, attrs) {
Expand Down
4 changes: 2 additions & 2 deletions rd_ui/app/styles/redash.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ a.navbar-brand {
margin-bottom: 5px;
}

.edit-in-place.editable span {
.edit-in-place span.editable {
cursor: pointer;
}

.edit-in-place.editable span:hover {
.edit-in-place span.editable:hover {
background: #FCFCA2;
}

Expand Down
12 changes: 3 additions & 9 deletions rd_ui/app/views/queryfiddle.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
<div class="panel-heading">
<h3 class="panel-title">
<p>
<edit-in-place editable="currentUser.canEdit(query)" ignore-blanks='true'
value="query.name"
ng-class="{editable: currentUser.canEdit(query)}"></edit-in-place>
</p>
<edit-in-place editable="currentUser.canEdit(query)" ignore-blanks='true' value="query.name"></edit-in-place>
</p>
</h3>
<p>
<edit-in-place editable="currentUser.canEdit(query)" editor="textarea"
placeholder="No description" ignore-blanks='false'
value="query.description"
ng-class="{editable: currentUser.canEdit(query)}"
class="text-muted"></edit-in-place>
<edit-in-place editable="currentUser.canEdit(query)" editor="textarea" placeholder="No description" ignore-blanks='false' value="query.description" class="text-muted"></edit-in-place>
</p>
</div>
<div class="panel-body">
Expand Down

0 comments on commit 9230a77

Please sign in to comment.