{I" class:ETI"ProcessedAsset;FI"logical_path;TI"applicants/spike/app.js;FI" pathname;TI"`/Users/aselder/Development/applicants-engine/app/assets/javascripts/applicants/spike/app.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+Ԍ`VI" length;TiI" digest;TI"%8525790cb9152b2622ebd401632052bb;FI" source;TI"SpikeApp = angular.module("SpikeApp", ["ngResource", "ngRoute", "templates"]); SpikeApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider.when('/search', { templateUrl: 'applicants_search.html', controller: 'SearchController' }); $routeProvider.when('/:state', { templateUrl: 'applicants_index.html', controller: 'ApplicantsController' }); $routeProvider.when('/reviews/:id', { templateUrl: 'reviews_show.html', controller: 'ReviewsController' }); $routeProvider.otherwise({ redirectTo: '/reviewable' }); }]); SpikeApp.service("Applicants", ["$resource", function($resource) { return { url: "/applicants/spike/applicants.json", offset: 0, limit: 50, headers : {'Content-Type': 'application/x-www-form-urlencoded'}, updateState: function(id, event){ q = $resource( '/applicants/spike/applicants/' + id + '/event', null, { update: { method: 'PUT' }} ); return q.update({event: event}); }, search: function(params) { q = $resource(this.url, params); return q.get(); }, nextPage: function(state) { this.offset = this.offset + this.limit; return this.fetch(state, this.offset, this.limit); }, firstPage: function(state) { return this.fetch(state, 0, this.limit); }, get: function(id){ q = $resource('/applicants/spike/applicants/' + id + '.json'); return q.get(); }, fetch: function(state, offset, limit) { q = $resource(this.url, {state: state, offset: offset, limit: limit}); return q.get(); } }; } ]); SpikeApp.controller("MainController",["$scope", "$route", "$routeParams", "$location", "Applicants", function($scope, $route, $routeParams, $location, Applicants) { $scope.$on("state.changed", function(eventDate, state) { $scope.state = state; }); $scope.search = function() { if ($scope.email || $scope.id){ params = { "q[email]": $scope.email, "q[id]": $scope.id }; $scope.email = ''; $scope.id = ''; $location.url('/search?' + $.param(params)); }else{ alert('You must provide search criteria.'); } }; } ]); SpikeApp.controller("ReviewsController", ["$scope", "$route", "$routeParams", "$location", "$sce", "Applicants", function($scope, $route, $routeParams, $location, $sce, Applicants) { $scope.questions = [ I18n.applicants.spike.questions.q1, I18n.applicants.spike.questions.q2, I18n.applicants.spike.questions.q3, I18n.applicants.spike.questions.q4 ]; var query = Applicants.get($routeParams.id); query.$promise.then(function() { $scope.applicant = query; $scope.video = $sce.trustAsResourceUrl($scope.applicant.video_url); }); $scope.setState = function(event){ var query = Applicants.updateState($routeParams.id, event); query.$promise.then(function() { $location.url('/applicants/reviewable'); }); }; } ]); SpikeApp.controller("SearchController", ["$scope", "$route", "$routeParams", "$location", "Applicants", function($scope, $route, $routeParams, $location, Applicants) { var query = Applicants.search($location.search()); query.$promise.then(function() { $scope.applicants = query.applicants; }); } ]); SpikeApp.controller("ApplicantsController", ["$scope", "$route", "$routeParams", "$location", "Applicants", function($scope, $route, $routeParams, $location, Applicants) { $scope.$emit("state.changed", $routeParams.state); $scope.applicants = []; $scope.total = "..."; $scope.stale_count = "..."; var query = Applicants.firstPage($scope.state); updateItems = function(response){ $scope.applicants.push.apply($scope.applicants, response.applicants); $scope.total = response.total; $scope.stale_count = response.stale_count; }; query.$promise.then(function() { updateItems(query); }); $scope.more = function($event) { $event.preventDefault(); var query = Applicants.nextPage($scope.state); query.$promise.then(function() { updateItems(query); }); }; } ]); ;TI"dependency_digest;TI"%1e8c104612a1413013458655c9917534;FI"required_paths;T[I"`/Users/aselder/Development/applicants-engine/app/assets/javascripts/applicants/spike/app.js;FI"dependency_paths;T[{I" path;TI"`/Users/aselder/Development/applicants-engine/app/assets/javascripts/applicants/spike/app.js;FI" mtime;TI"2015-12-03T10:41:24-08:00;TI" digest;TI"%8525790cb9152b2622ebd401632052bb;FI" _version;TI"%2795dc9dcbf801f487b53b99e35b0b74;F