Commit 04836b51c0744cc47fe711ede6a0fd7751c8813a
1 parent
cbe750f8
Exists in
master
and in
1 other branch
Get profile boxes and blocks
Showing
11 changed files
with
109 additions
and
12 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +(function() { | |
| 2 | + 'use strict'; | |
| 3 | + | |
| 4 | + angular | |
| 5 | + .module('angular') | |
| 6 | + .directive('noosferoBlock', noosferoBlock); | |
| 7 | + | |
| 8 | + /** @ngInject */ | |
| 9 | + function noosferoBlock($compile) { | |
| 10 | + var directive = { | |
| 11 | + restrict: 'E', | |
| 12 | + scope: { | |
| 13 | + block: '=' | |
| 14 | + }, | |
| 15 | + link: function(scope, element, attrs) { | |
| 16 | + var blockName = scope.block.type.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | |
| 17 | + element.replaceWith($compile('<noosfero-'+blockName+' block="block"></noosfero-'+blockName+'>')(scope)); | |
| 18 | + } | |
| 19 | + }; | |
| 20 | + return directive; | |
| 21 | + } | |
| 22 | + | |
| 23 | +})(); | ... | ... |
src/app/components/noosfero/blocks/link-list.directive.js
0 → 100644
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +(function() { | |
| 2 | + 'use strict'; | |
| 3 | + | |
| 4 | + angular | |
| 5 | + .module('angular') | |
| 6 | + .directive('noosferoLinkListBlock', noosferoLinkListBlock); | |
| 7 | + | |
| 8 | + /** @ngInject */ | |
| 9 | + function noosferoLinkListBlock() { | |
| 10 | + var directive = { | |
| 11 | + restrict: 'E', | |
| 12 | + templateUrl: 'app/components/noosfero/blocks/link-list.html', | |
| 13 | + scope: { | |
| 14 | + block: '=' | |
| 15 | + }, | |
| 16 | + controller: LinkListBlockController, | |
| 17 | + controllerAs: 'vm', | |
| 18 | + bindToController: true | |
| 19 | + }; | |
| 20 | + | |
| 21 | + return directive; | |
| 22 | + | |
| 23 | + /** @ngInject */ | |
| 24 | + function LinkListBlockController(moment) { | |
| 25 | + var vm = this; | |
| 26 | + vm.links = vm.block.settings.links; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + | |
| 30 | +})(); | ... | ... |
src/app/components/noosfero/blocks/profile-image.directive.js
0 → 100644
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +(function() { | |
| 2 | + 'use strict'; | |
| 3 | + | |
| 4 | + angular | |
| 5 | + .module('angular') | |
| 6 | + .directive('noosferoProfileImageBlock', noosferoProfileImageBlock); | |
| 7 | + | |
| 8 | + /** @ngInject */ | |
| 9 | + function noosferoProfileImageBlock() { | |
| 10 | + var directive = { | |
| 11 | + restrict: 'E', | |
| 12 | + templateUrl: 'app/components/noosfero/blocks/profile-image.html', | |
| 13 | + scope: { | |
| 14 | + block: '=' | |
| 15 | + }, | |
| 16 | + controller: ProfileImageBlockController, | |
| 17 | + controllerAs: 'vm', | |
| 18 | + bindToController: true | |
| 19 | + }; | |
| 20 | + | |
| 21 | + return directive; | |
| 22 | + | |
| 23 | + /** @ngInject */ | |
| 24 | + function ProfileImageBlockController(moment) { | |
| 25 | + var vm = this; | |
| 26 | + vm.links = vm.block.settings.links; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + | |
| 30 | +})(); | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +image | ... | ... |
src/app/components/noosfero/noosfero.service.js
| ... | ... | @@ -8,10 +8,5 @@ |
| 8 | 8 | function communities() { |
| 9 | 9 | return $resource('/api/v1/communities/:id'); |
| 10 | 10 | } |
| 11 | - // this.getBoxes = getBoxes; | |
| 12 | - // function getBoxes() { | |
| 13 | - // return [{id: 1, blocks: [{id: 1, type: 'test'}]}, | |
| 14 | - // {id: 2, blocks: [{id: 2, type: 'test2'}]}]; | |
| 15 | - // } | |
| 16 | 11 | } |
| 17 | 12 | })(); | ... | ... |
src/app/main/main.controller.js
| ... | ... | @@ -6,16 +6,16 @@ |
| 6 | 6 | .controller('MainController', MainController); |
| 7 | 7 | |
| 8 | 8 | /** @ngInject */ |
| 9 | - function MainController($timeout, noosfero, toastr) { | |
| 9 | + function MainController($timeout, noosfero, $log) { | |
| 10 | 10 | var vm = this; |
| 11 | 11 | vm.boxes = []; |
| 12 | 12 | activate(); |
| 13 | 13 | |
| 14 | 14 | function activate() { |
| 15 | - var profile = noosfero.communities().get({id: 67, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}, function () { | |
| 16 | - console.log(profile); | |
| 15 | + noosfero.communities().get({id: 67, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { | |
| 16 | + $log.log(profile); | |
| 17 | + vm.boxes = profile.community.boxes; | |
| 17 | 18 | }); |
| 18 | - // vm.boxes = noosfero.getBoxes(); | |
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | })(); | ... | ... |
src/app/main/main.html
| ... | ... | @@ -5,9 +5,7 @@ |
| 5 | 5 | </div> |
| 6 | 6 | |
| 7 | 7 | <div class="row"> |
| 8 | - <div class="col-sm-6 col-md-4" ng-repeat="box in main.boxes"> | |
| 9 | - {{box}} | |
| 10 | - </div> | |
| 8 | + <ng-include ng-repeat="box in main.boxes | orderBy: 'position'" src="'app/views/profile/box.html'"></ng-include> | |
| 11 | 9 | </div> |
| 12 | 10 | |
| 13 | 11 | </div> | ... | ... |