Commit b67a56f15971ee28981a0e9f0e537dc560a9d0a3

Authored by Victor Costa
1 parent 461aaa50

Create boxes directive

src/app/components/boxes/boxes.html 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +{{vm.boxesOrder}}
  2 +{{boxesOrder}}
  3 +<ng-include ng-repeat="box in vm.boxes | orderBy: vm.boxesOrder" src="'app/components/noosfero-boxes/box.html'"></ng-include>
src/app/components/noosfero-boxes/box.html 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +<div ng-class="{'col-md-2-5': box.position!=1, 'col-md-7': box.position==1}">
  2 + <div ng-repeat="block in box.blocks | orderBy: 'position'" class="panel panel-default block" >
  3 + <div class="panel-heading" ng-show="block.title">
  4 + <h3 class="panel-title">{{block.title}}</h3>
  5 + </div>
  6 + <div class="panel-body">
  7 + <noosfero-block block="block" owner="vm.owner"></noosfero-block>
  8 + </div>
  9 + </div>
  10 +</div>
src/app/components/noosfero-boxes/boxes.directive.js 0 → 100644
@@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .directive('noosferoBoxes', noosferoBoxes);
  7 +
  8 + /** @ngInject */
  9 + function noosferoBoxes() {
  10 + var directive = {
  11 + restrict: 'E',
  12 + scope: {
  13 + boxes: '=',
  14 + owner: '='
  15 + },
  16 + templateUrl: 'app/components/noosfero-boxes/boxes.html',
  17 + controller: BoxesController,
  18 + controllerAs: 'vm',
  19 + bindToController: true
  20 + };
  21 +
  22 + return directive;
  23 +
  24 + /** @ngInject */
  25 + function BoxesController() {
  26 + var vm = this;
  27 +
  28 + vm.boxesOrder = function(box) {
  29 + if(box.position==2) return 0;
  30 + return box.position;
  31 + }
  32 + }
  33 + }
  34 +
  35 +})();
src/app/components/noosfero-boxes/boxes.html 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<ng-include ng-repeat="box in vm.boxes | orderBy: vm.boxesOrder" src="'app/components/noosfero-boxes/box.html'"></ng-include>
src/app/components/noosfero-boxes/boxes.scss 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +.col-md-2-5 {
  2 + @extend .col-md-3;
  3 + @media (min-width: 920px) {
  4 + width: 20.83%;
  5 + }
  6 +}
src/app/index.scss
@@ -36,13 +36,6 @@ $page-header-border-color: #eee; @@ -36,13 +36,6 @@ $page-header-border-color: #eee;
36 } 36 }
37 } 37 }
38 38
39 -.col-md-2-5 {  
40 - @extend .col-md-3;  
41 - @media (min-width: 920px) {  
42 - width: 20.83%;  
43 - }  
44 -}  
45 -  
46 /** 39 /**
47 * Do not remove the comments below. It's the markers used by gulp-inject to inject 40 * Do not remove the comments below. It's the markers used by gulp-inject to inject
48 * all your sass files automatically 41 * all your sass files automatically
src/app/profile/profile.controller.js
@@ -14,16 +14,11 @@ @@ -14,16 +14,11 @@
14 14
15 function activate() { 15 function activate() {
16 noosfero.profiles.one().get({identifier: $stateParams.profile}).then(function(profiles) { 16 noosfero.profiles.one().get({identifier: $stateParams.profile}).then(function(profiles) {
17 - vm.owner = profiles[0];  
18 - return noosfero.boxes(vm.owner.id).one().get(); 17 + vm.profile = profiles[0];
  18 + return noosfero.boxes(vm.profile.id).one().get();
19 }).then(function(response) { 19 }).then(function(response) {
20 vm.boxes = response.boxes; 20 vm.boxes = response.boxes;
21 }); 21 });
22 } 22 }
23 -  
24 - vm.boxesOrder = function(box) {  
25 - if(box.position==2) return 0;  
26 - return box.position;  
27 - }  
28 } 23 }
29 })(); 24 })();
src/app/profile/profile.html
1 <div class="profile-container"> 1 <div class="profile-container">
2 <div class="row"> 2 <div class="row">
3 - <ng-include ng-repeat="box in vm.boxes | orderBy: vm.boxesOrder" src="'app/views/profile/box.html'"></ng-include> 3 + <noosfero-boxes boxes="vm.boxes" owner="vm.profile"></noosfero-boxes>
4 </div> 4 </div>
5 </div> 5 </div>
src/app/views/profile/block.html
@@ -1,8 +0,0 @@ @@ -1,8 +0,0 @@
1 -<div class="panel panel-default block" >  
2 - <div class="panel-heading" ng-show="block.title">  
3 - <h3 class="panel-title">{{block.title}}</h3>  
4 - </div>  
5 - <div class="panel-body">  
6 - <noosfero-block block="block" owner="vm.owner"></noosfero-block>  
7 - </div>  
8 -</div>  
src/app/views/profile/box.html
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -<div ng-class="{'col-md-2-5': box.position!=1, 'col-md-7': box.position==1}">  
2 - <ng-include ng-repeat="block in box.blocks | orderBy: 'position'" src="'app/views/profile/block.html'"></ng-include>  
3 -</div>