diff --git a/src/Umbraco.Web.UI.Client/src/app.js b/src/Umbraco.Web.UI.Client/src/app.js index df6099dd7f..921d490c19 100644 --- a/src/Umbraco.Web.UI.Client/src/app.js +++ b/src/Umbraco.Web.UI.Client/src/app.js @@ -4,4 +4,4 @@ var app = angular.module('umbraco', [ 'umbraco.resources', 'umbraco.services', 'umbraco.security' -]); \ No newline at end of file +]); diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_module.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_module.js index 86d23a8b13..ac14bd4a6a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_module.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_module.js @@ -1 +1 @@ -angular.module("umbraco.mocks", ['ngMockE2E']); \ No newline at end of file +angular.module("umbraco.mocks", []); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js index fd35057b44..4e35d03085 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js @@ -21,8 +21,9 @@ angular.module('umbraco.mocks'). } function returnNodebyId(status, data, headers) { - var id = mocksUtills.getParameterByName(data, "id") || 1234; - + var id = mocksUtills.getParameterByName(data, "id") || "1234"; + id = parseInt(id, 10); + var node = { name: "My content with id: " + id, updateDate: new Date(), diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js index ad95e6e15f..d09a44c6f8 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js @@ -21,5 +21,4 @@ function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTy } - umbracoAppDev.run(initBackEnd); diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 9ab49814a8..466ba5bb9f 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -33,9 +33,26 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { return { getById: function (id) { + return $http.get(getContentUrl(id)) + .then(function(response) { + + _.each(response.data.tabs, function (item) { + item.active = false; + }); + if (response.data.tabs.length > 0){ + response.data.tabs[0].active = true; + } + + return response.data; + },function(response) { + throw new Error('Failed to retreive data for content id ' + id); + }); + + /* + var deferred = $q.defer(); - + //go and get the data $http.get(getContentUrl(id)). success(function (data, status, headers, config) { @@ -53,7 +70,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { deferred.reject('Failed to retreive data for content id ' + id); }); - return deferred.promise; + return deferred.promise;*/ }, getByIds: function (ids) { diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index b9baa4655d..d2d6503249 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -3,7 +3,7 @@ * @name umbraco.resources.contentTypeResource * @description Loads in data for content types **/ -function contentTypeResource($q, $http) { +function contentTypeResource($q, $http, $rootScope) { /** internal method to get the api url */ function getChildContentTypesUrl(contentId) { @@ -43,15 +43,15 @@ function contentTypeResource($q, $http) { //return all types allowed under given document getAllowedTypes: function (contentId) { - var deferred = $q.defer(); - $http.get(getChildContentTypesUrl(contentId)) - .success(function (data, status, headers, config) { - deferred.resolve(data); - }). - error(function (data, status, headers, config) { - deferred.reject('Failed to retreive data for content id ' + contentId); + //var deferred = $q.defer(); + //getChildContentTypesUrl(contentId)) + + return $http.get(getChildContentTypesUrl(contentId)) + .then(function(response) { + return response.data; + },function(response) { + throw new Error('Failed to retreive data for content id ' + contentId); }); - return deferred.promise; } }; diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js index 4eb229b1d2..51d0d49a8d 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js @@ -3,7 +3,7 @@ describe('content factory tests', function () { beforeEach(module('umbraco.services')); beforeEach(module('umbraco.resources')); - beforeEach(module('umbraco.httpbackend')); + beforeEach(module('umbraco.mocks')); beforeEach(inject(function ($injector) { $rootScope = $injector.get('$rootScope'); @@ -21,6 +21,8 @@ describe('content factory tests', function () { describe('global content factory crud', function () { + + it('should return a content object, given an id', function () { var doc; contentFactory.getById(1234).then(function(result){ @@ -28,6 +30,7 @@ describe('content factory tests', function () { }); $rootScope.$digest(); + $httpBackend.flush(); expect(doc).toNotBe(undefined); expect(doc.id).toBe(1234); @@ -36,10 +39,15 @@ describe('content factory tests', function () { it('should return a content children collection given an id', function () { var collection = contentFactory.getChildren(1234, undefined); + $rootScope.$digest(); + $httpBackend.flush(); expect(collection.resultSet.length).toBe(10); collection = contentFactory.getChildren(1234,{take: 5, offset: 1, filter: ""}); + $rootScope.$digest(); + $httpBackend.flush(); + expect(collection.resultSet.length).toBe(5); - }); + }); }); }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js index 92dadb7158..390820552c 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js @@ -1,48 +1,46 @@ describe('content type factory tests', function () { var $rootScope, $httpBackend, contentTypeResource, m; - beforeEach(module('ngMockE2E')); + // beforeEach(module('ngMockE2E')); beforeEach(module('umbraco.resources')); - beforeEach(module('umbraco.httpbackend')); + beforeEach(module('umbraco.mocks')); - beforeEach(inject(function ($injector, contentTypeMocks) { - $rootScope = $injector.get('$rootScope'); - $httpBackend = $injector.get('$httpBackend'); - m = contentTypeMocks; - m.register(); - - contentTypeResource = $injector.get('contentTypeResource'); + beforeEach(inject(function ($injector) { + $rootScope = $injector.get('$rootScope'); + $httpBackend = $injector.get('$httpBackend'); + mocks = $injector.get("contentTypeMocks"); + mocks.register(); + contentTypeResource = $injector.get('contentTypeResource'); })); - describe('global content type factory crud', function () { - /* + it('should return a content type object, given an id', function () { - var ct1; contentTypeResource.getContentType(1234).then(function(result){ ct1 = result; }); - $rootScope.$digest(); - $rootScope.$digest(); - - console.log("ct1:", ct1); + $rootScope.$digest(); expect(ct1).toNotBe(undefined); expect(ct1.id).toBe(1234); }); -*/ + it('should return a allowed content type collection given a document id', function(){ - m.expectAllowedChildren(); + // m.expectAllowedChildren(); var collection; contentTypeResource.getAllowedTypes(1234).then(function(result){ collection = result; }); + + $rootScope.$digest(); + $httpBackend.flush(); + expect(collection.length).toBe(3); }); }); diff --git a/src/Umbraco.Web.UI/umbraco/Views/Default.cshtml b/src/Umbraco.Web.UI/umbraco/Views/Default.cshtml index b15b462841..824d8f906b 100644 --- a/src/Umbraco.Web.UI/umbraco/Views/Default.cshtml +++ b/src/Umbraco.Web.UI/umbraco/Views/Default.cshtml @@ -47,9 +47,7 @@ *@ -
-
@@ -57,6 +55,7 @@
+ diff --git a/src/Umbraco.Web.UI/umbraco/index.html b/src/Umbraco.Web.UI/umbraco/index.html index d715deb792..cd60633009 100644 --- a/src/Umbraco.Web.UI/umbraco/index.html +++ b/src/Umbraco.Web.UI/umbraco/index.html @@ -1,30 +1,30 @@ - - - - - - - - Umbraco - - - - -
- - - -
-
-
-
-
-
- - - - - - - - + + + + + + + + Umbraco + + + + +
+ + + +
+
+
+
+
+
+ + + + + + + +