Skip to content

Commit

Permalink
implemented #149
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Oct 6, 2014
1 parent e29da07 commit 3594363
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
21 changes: 21 additions & 0 deletions app/scripts/controllers/function-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$scope.listClass = 'fa-mail-reply';
$scope.logLevel = ""
$scope.isCode = true;
$scope.isDirty = false;
$scope.listClasses = $scope.database.listClasses();
$scope.editorOptions = {
lineWrapping: true,
Expand Down Expand Up @@ -112,6 +113,26 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$rootScope.$on("aside:open", function () {
$scope.listClass = 'fa-mail-reply';
})

$scope.canSave = function (form) {

return !$scope.isDirty || form.$invalid;
}
$scope.$watch("functionToExecute.code", function (newVal, oldVal) {
if (oldVal && oldVal != newVal) {
$scope.isDirty = true;
}
})
$scope.$watch("functionToExecute.name", function (newVal, oldVal) {
if (oldVal && oldVal != newVal) {
$scope.isDirty = true;
}
})
$scope.$watchCollection("functionToExecute.parameters", function (newVal, oldVal) {
if (oldVal && oldVal != newVal) {
$scope.isDirty = true;
}
})
$scope.copyFunction = function () {
if ($scope.functionToExecute != undefined) {

Expand Down
7 changes: 5 additions & 2 deletions app/views/database/functions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="row">
<div class="panel panel-default panel-function panel-orient">
<div class="panel-heading">
<button class="btn btn-xs btn-warning btn-trasparent" ng-click="showAllFunctions()"><i class="fa " ng-class="listClass"></i>
<button class="btn btn-xs btn-warning btn-trasparent" ng-click="showAllFunctions()"><i class="fa "
ng-class="listClass"></i>
</button>
&nbsp;Functions Management
<a href="{{ database.getWiki() }}" class="btn btn-trasparent btn-help"
Expand All @@ -13,11 +14,13 @@
bs-tooltip>
<i class="fa fa-question fa-lg"></i>
</a>

<div class="panel-actions">
<div class="btn-toolbar">

<div class="btn-group">
<button type="submit" class="btn btn-sm btn-primary" ng-disabled="propertyForm.$invalid"
<button type="submit" class="btn btn-sm btn-primary" ng-class="{'btn-success' : isDirty }"
ng-disabled="canSave(functionForm);"
ng-click="saveFunction()"><i class="fa fa-save"></i> Save
</button>
</div>
Expand Down

0 comments on commit 3594363

Please sign in to comment.