Created
February 3, 2015 22:57
-
-
Save AlexFrazer/038f7faa24ed87875e2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('app') | |
.controller('CreateWorkflowCtrl', function($scope, $location, Workflow, Category) { | |
$scope.workflow = new Workflow(); | |
$scope.page = 0; | |
$scope.create = function() { | |
$scope.workflow.$save(function(data) { | |
$location.path("/workflow/" + data.id); | |
}, function(err) { | |
$scope.$broadcast('error', error); | |
}); | |
}; | |
$scope.updateCategories = function() { | |
Category.query({ page: $scope.page }, function(data) { | |
$scope.categories = data; | |
}, function(err) { | |
$scope.$broadcast('error', err); | |
}); | |
} | |
$scope.$watch('page', $scope.updateCategories); | |
$scope.$on('error', function(error) { | |
// TO DO: add validation warnings. | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="form-horizontal container" role="form" ng-submit="create()"> | |
<div class="form-group"> | |
<label for="name">Name</label> | |
<input type="text" name="name" id="name" class="form-control" | |
ng-model="workflow.name" ng-required ng-maxlength="1024" | |
/> | |
</div> | |
<h4>Categories</h4> | |
<hr/> | |
<div ng-switch="categories.num_results"> | |
<div ng-switch-when="0" class="text-center"> | |
<p class="text-muted"> | |
There are currently no categories available. | |
You must make a category before you can make a workflow. | |
</p> | |
<a class="btn btn-default btn-large" href="/#/create/category"> | |
Make one now | |
</a> | |
</div> | |
<div ng-switch-default> | |
<div class="row"> | |
<div class="col-md-4"> | |
<div class="form-group" ng-repeat="category in categories.objects"> | |
<!-- HERE BE THE PROBLEM --> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="text-center paging"> | |
<pagination | |
ng-model="page" | |
num-pages="categories.total_pages" | |
total-items="categories.num_results" | |
> | |
</pagination> | |
</div> | |
<button type="submit" class="btn btn-large btn-success pull-right"> | |
Create | |
</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment