Prevent from setting a blank query title. Fixes #34

This commit is contained in:
Arik Fraimovich 2013-12-23 21:56:01 +02:00
parent 3cb8365ef3
commit 5c78760649
3 changed files with 12 additions and 5 deletions

View File

@ -262,7 +262,6 @@
return $filter('refreshRateHumanize')(value);
}
}
// id: 672,
]
$scope.tabs = [{"name": "My Queries", "key": "my"}, {"key": "all", "name": "All Queries"}, {"key": "drafts", "name": "Drafts"}];

View File

@ -158,7 +158,10 @@ directives.directive('newWidgetForm', ['$http', function($http) {
directives.directive('editInPlace', function () {
return {
restrict: 'E',
scope: { value: '=' },
scope: {
value: '=',
ignoreBlanks: '='
},
template: '<span ng-click="edit()" ng-bind="value"></span><input ng-model="value"></input>',
link: function ($scope, element, attrs) {
// Let's get a reference to the input element, as we'll want to reference it.
@ -172,6 +175,10 @@ directives.directive('editInPlace', function () {
// ng-click handler to activate edit-in-place
$scope.edit = function () {
if ($scope.ignoreBlanks) {
$scope.oldValue = $scope.value;
}
$scope.editing = true;
// We control display through a class on the directive itself. See the CSS.
@ -184,6 +191,9 @@ directives.directive('editInPlace', function () {
};
$(inputElement).blur(function() {
if ($scope.ignoreBlanks && _.isEmpty($scope.value)) {
$scope.value = $scope.oldValue;
}
$scope.editing = false;
element.removeClass('active');
})

View File

@ -3,14 +3,12 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<span class="glyphicon glyphicon-pencil"></span> <edit-in-place value="query.name"></edit-in-place>
<span class="glyphicon glyphicon-pencil"></span> <edit-in-place ignore-blanks='true' value="query.name"></edit-in-place>
</h3>
</div>
<div class="panel-body">
<textarea ui-codemirror="editorOptions" ng-model="query.query"></textarea>
<div>
<a class="btn btn-default" ng-disabled="queryExecuting || !queryResult.getData()" ng-href="{{dataUri}}" download="{{dataFilename}}" target="_self">
<span class="glyphicon glyphicon-floppy-disk"></span> Download Data Set