From 4c623532d76cd92acf6864b8d3cf35afc4c3806b Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 30 Jun 2014 15:56:52 +0200 Subject: [PATCH] Using $q in stead of q so now details are actually displayed. --- app/assets/javascripts/angular/hal/api-resource.js | 12 ++++-------- .../angular/services/work-package-service.js | 3 --- .../controllers/work-package-details-controller.js | 8 ++++++-- app/assets/javascripts/application.js.erb | 1 - public/templates/work_packages.list.details.html | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/angular/hal/api-resource.js b/app/assets/javascripts/angular/hal/api-resource.js index dc242aeee6..aa2be73616 100644 --- a/app/assets/javascripts/angular/hal/api-resource.js +++ b/app/assets/javascripts/angular/hal/api-resource.js @@ -1,25 +1,21 @@ angular.module('openproject.hal') -.factory('HALAPIResource', function HALAPIResource() { +.factory('HALAPIResource', ['$q', function HALAPIResource($q) { 'use strict'; var HALAPIResource = { configure: function() { - Hyperagent.configure('ajax', function ajax(options) { - // options.dataType = "json"; - - return jQuery.ajax(options); - }); + Hyperagent.configure('defer', $q.defer); }, setup: function(uri) { HALAPIResource.configure(); return new Hyperagent.Resource({ url: 'http://opapi.apiary-mock.com/' + uri, - }); + }); } } return HALAPIResource; -}); \ No newline at end of file +}]); \ No newline at end of file diff --git a/app/assets/javascripts/angular/services/work-package-service.js b/app/assets/javascripts/angular/services/work-package-service.js index eda19e1b28..d4522f4a37 100644 --- a/app/assets/javascripts/angular/services/work-package-service.js +++ b/app/assets/javascripts/angular/services/work-package-service.js @@ -45,9 +45,6 @@ angular.module('openproject.services') return resource.fetch().then(function (wp) { workPackage = wp; return workPackage; - }).fail(function(error){ - var err = error; - // Do something sensible }); }, diff --git a/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js b/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js index ea8a228fa8..a999a66441 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js @@ -35,8 +35,12 @@ angular.module('openproject.workPackages.controllers') function($scope, $stateParams, WorkPackageService) { $scope.workPackageId = $stateParams.workPackageId; - WorkPackageService.getWorkPackage($scope.workPackageId).then(function(workPackage) { - $scope.workPackage = workPackage; + $scope.$watch('rows', function(rows) { + if (rows && rows.length > 0) { + WorkPackageService.getWorkPackage($scope.workPackageId).then(function(workPackage) { + $scope.workPackage = workPackage; + }); + } }); } ]); diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 7c8312603a..58eb374f7b 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -53,7 +53,6 @@ //= require warn_leaving_unsaved //= require openproject_plugins //= require versions -//= require q/q //= require uri.js/src/URI //= require uri.js/src/URITemplate //= require hyperagent/dist/hyperagent diff --git a/public/templates/work_packages.list.details.html b/public/templates/work_packages.list.details.html index a3be869884..c01954fd82 100644 --- a/public/templates/work_packages.list.details.html +++ b/public/templates/work_packages.list.details.html @@ -1,4 +1,4 @@ -
+

{{ workPackage.props.type }} {{ workPackage.props.subject }}