Commit ea70ea8f1a2edae5610a7e948124983e072798f2

Authored by Victor Costa
1 parent 535ae571

Migrate some directives to components

Showing 35 changed files with 285 additions and 372 deletions   Show diff stats
src/app/components/noosfero-activities/activities.component.js 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoActivities', {
  7 + restrict: 'E',
  8 + bindings: {
  9 + activities: '<'
  10 + },
  11 + templateUrl: 'app/components/noosfero-activities/activities.html'
  12 + });
  13 +
  14 +})();
... ...
src/app/components/noosfero-activities/activities.directive.js
... ... @@ -1,20 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoActivities', noosferoActivities);
7   -
8   - /** @ngInject */
9   - function noosferoActivities() {
10   - var directive = {
11   - restrict: 'E',
12   - scope: {
13   - activities: '='
14   - },
15   - templateUrl: 'app/components/noosfero-activities/activities.html'
16   - };
17   - return directive;
18   - }
19   -
20   -})();
src/app/components/noosfero-activities/activities.html
1 1 <timeline>
2   - <timeline-event ng-repeat="activity in activities | orderBy: 'created_at':true">
  2 + <timeline-event ng-repeat="activity in $ctrl.activities | orderBy: 'created_at':true">
3 3 <noosfero-activity activity="activity"></noosfero-activity>
4 4 </timeline-event>
5 5 </timeline>
... ...
src/app/components/noosfero-activities/activity/activity.component.js 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoActivity', {
  7 + restrict: 'E',
  8 + bindings: {
  9 + activity: '<'
  10 + },
  11 + templateUrl: 'app/components/noosfero-activities/activity/activity.html',
  12 + replace: true,
  13 + controller: ActivityController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function ActivityController() {
  18 + var vm = this;
  19 + vm.getActivityTemplate = function(activity) {
  20 + return 'app/components/noosfero-activities/activity/' + activity.verb + '.html';
  21 + }
  22 + }
  23 +
  24 +})();
... ...
src/app/components/noosfero-activities/activity/activity.directive.js
... ... @@ -1,32 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoActivity', noosferoActivity);
7   -
8   - /** @ngInject */
9   - function noosferoActivity() {
10   - var directive = {
11   - restrict: 'E',
12   - scope: {
13   - activity: '='
14   - },
15   - templateUrl: 'app/components/noosfero-activities/activity/activity.html',
16   - replace: true,
17   - controller: ActivityController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   - return directive;
22   -
23   - /** @ngInject */
24   - function ActivityController() {
25   - var vm = this;
26   - vm.getActivityTemplate = function(activity) {
27   - return 'app/components/noosfero-activities/activity/' + activity.verb + '.html';
28   - }
29   - }
30   - }
31   -
32   -})();
src/app/components/noosfero-activities/activity/activity.html
1 1 <div class="activity">
2   - <ng-include src="vm.getActivityTemplate(vm.activity)"></ng-include>
  2 + <ng-include src="$ctrl.getActivityTemplate($ctrl.activity)"></ng-include>
3 3 </div>
... ...
src/app/components/noosfero-activities/activity/add_member_in_community.html
... ... @@ -4,10 +4,10 @@
4 4 <timeline-panel>
5 5 <timeline-heading>
6 6 <h4 class="timeline-title">
7   - <a ui-sref="main.profile.info({profile: vm.activity.user.identifier})"><strong ng-bind="vm.activity.user.name"></strong></a>
  7 + <a ui-sref="main.profile.info({profile: $ctrl.activity.user.identifier})"><strong ng-bind="$ctrl.activity.user.name"></strong></a>
8 8 <span> has joined the community</span>
9 9 </h4>
10   - <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="vm.activity.created_at"></span></small></p>
  10 + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="$ctrl.activity.created_at"></span></small></p>
11 11 </timeline-heading>
12 12 <div class="timeline-body"></div>
13 13 </timeline-panel>
... ...
src/app/components/noosfero-activities/activity/create_article.html
... ... @@ -4,22 +4,22 @@
4 4 <timeline-panel>
5 5 <timeline-heading>
6 6 <h4 class="timeline-title">
7   - <a ui-sref="main.profile.info({profile: vm.activity.user.identifier})"><strong ng-bind="vm.activity.user.name"></strong></a>
  7 + <a ui-sref="main.profile.info({profile: $ctrl.activity.user.identifier})"><strong ng-bind="$ctrl.activity.user.name"></strong></a>
8 8 <span> has published on </span>
9   - <a ui-sref="main.profile.info({profile: vm.activity.target.article.profile.identifier})">
10   - <strong ng-bind="vm.activity.target.article.profile.name"></strong></span>
  9 + <a ui-sref="main.profile.info({profile: $ctrl.activity.target.article.profile.identifier})">
  10 + <strong ng-bind="$ctrl.activity.target.article.profile.name"></strong></span>
11 11 </a>
12 12 </h4>
13   - <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="vm.activity.created_at"></span></small></p>
  13 + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="$ctrl.activity.created_at"></span></small></p>
14 14 </timeline-heading>
15 15 <div class="timeline-body">
16 16 <div class="article">
17 17 <div class="title">
18   - <a ui-sref="main.profile.page({profile: vm.activity.target.article.profile.identifier, page: vm.activity.target.article.path})"
19   - ng-bind="vm.activity.target.article.title"></a>
  18 + <a ui-sref="main.profile.page({profile: $ctrl.activity.target.article.profile.identifier, page: $ctrl.activity.target.article.path})"
  19 + ng-bind="$ctrl.activity.target.article.title"></a>
20 20 </div>
21 21 <div class="lead small">
22   - <div ng-bind-html="vm.activity.target.article.body | stripTags | truncate: 100 : '...': true"></div>
  22 + <div ng-bind-html="$ctrl.activity.target.article.body | stripTags | truncate: 100 : '...': true"></div>
23 23 </div>
24 24 </div>
25 25 </div>
... ...
src/app/components/noosfero-activities/activity/new_friendship.html
... ... @@ -4,15 +4,15 @@
4 4 <timeline-panel>
5 5 <timeline-heading>
6 6 <h4 class="timeline-title">
7   - <a ui-sref="main.profile.info({profile: vm.activity.user.identifier})"><strong ng-bind="vm.activity.user.name"></strong></a>
8   - <span> has made <span ng-bind="vm.activity.params.friend_name.length"></span> new friend(s): </span>
  7 + <a ui-sref="main.profile.info({profile: $ctrl.activity.user.identifier})"><strong ng-bind="$ctrl.activity.user.name"></strong></a>
  8 + <span> has made <span ng-bind="$ctrl.activity.params.friend_name.length"></span> new friend(s): </span>
9 9 <span class="comma-separated">
10   - <a class="separated-item" ui-sref="main.profile.info({profile: vm.activity.params.friend_url[$index].profile})" ng-repeat="friend in vm.activity.params.friend_name">
  10 + <a class="separated-item" ui-sref="main.profile.info({profile: $ctrl.activity.params.friend_url[$index].profile})" ng-repeat="friend in $ctrl.activity.params.friend_name">
11 11 <strong ng-bind="friend"></strong>
12 12 </a>
13 13 </span>
14 14 </h4>
15   - <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="vm.activity.created_at"></span></small></p>
  15 + <p><small class="text-muted"><i class="fa fa-clock-o"></i> <span am-time-ago="$ctrl.activity.created_at"></span></small></p>
16 16 </timeline-heading>
17 17 <div class="timeline-body"></div>
18 18 </timeline-panel>
... ...
src/app/components/noosfero-articles/article/article.directive.js
... ... @@ -11,8 +11,8 @@
11 11 restrict: 'E',
12 12 templateUrl: 'app/components/noosfero-articles/article/article.html',
13 13 scope: {
14   - article: '=',
15   - profile: '='
  14 + article: '<',
  15 + profile: '<'
16 16 },
17 17 controller: ArticleController,
18 18 controllerAs: 'vm',
... ...
src/app/components/noosfero-articles/blog/blog.component.js 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoBlog', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-articles/blog/blog.html',
  9 + bindings: {
  10 + article: '<',
  11 + profile: '<'
  12 + },
  13 + controller: BlogController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function BlogController(noosfero) {
  18 + var vm = this;
  19 + vm.posts = [];
  20 + vm.perPage = 3;
  21 + vm.currentPage = 1;
  22 +
  23 + vm.loadPage = function() {
  24 + noosfero.articles.one(vm.article.id).customGET('children', {
  25 + content_type: 'TinyMceArticle',
  26 + per_page: vm.perPage,
  27 + page: vm.currentPage
  28 + }).then(function(response) {
  29 + vm.totalPosts = response.headers('total');
  30 + vm.posts = response.data.articles;
  31 + });
  32 + }
  33 + vm.loadPage();
  34 + }
  35 +
  36 +})();
... ...
src/app/components/noosfero-articles/blog/blog.directive.js
... ... @@ -1,45 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoBlog', noosferoBlog);
7   -
8   - /** @ngInject */
9   - function noosferoBlog() {
10   - var directive = {
11   - restrict: 'E',
12   - templateUrl: 'app/components/noosfero-articles/blog/blog.html',
13   - scope: {
14   - article: '=',
15   - profile: '='
16   - },
17   - controller: BlogController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function BlogController(noosfero) {
26   - var vm = this;
27   - vm.posts = [];
28   - vm.perPage = 3;
29   - vm.currentPage = 1;
30   -
31   - vm.loadPage = function() {
32   - noosfero.articles.one(vm.article.id).customGET('children', {
33   - content_type: 'TinyMceArticle',
34   - per_page: vm.perPage,
35   - page: vm.currentPage
36   - }).then(function(response) {
37   - vm.totalPosts = response.headers('total');
38   - vm.posts = response.data.articles;
39   - });
40   - }
41   - vm.loadPage();
42   - }
43   - }
44   -
45   -})();
src/app/components/noosfero-articles/blog/blog.html
1 1 <div class="blog">
2   - <div class="blog-cover" ng-show="vm.article.image">
3   - <img ng-src="{{vm.article.image.url}}" class="img-responsive">
4   - <h3 ng-bind="vm.article.title"></h3>
  2 + <div class="blog-cover" ng-show="$ctrl.article.image">
  3 + <img ng-src="{{$ctrl.article.image.url}}" class="img-responsive">
  4 + <h3 ng-bind="$ctrl.article.title"></h3>
5 5 </div>
6 6  
7   - <div class="page-header" ng-show="!vm.article.image">
8   - <h3 ng-bind="vm.article.title"></h3>
  7 + <div class="page-header" ng-show="!$ctrl.article.image">
  8 + <h3 ng-bind="$ctrl.article.title"></h3>
9 9 </div>
10 10  
11 11 <div>
12   - <div ng-repeat="child in vm.posts | orderBy: 'created_at':true">
  12 + <div ng-repeat="child in $ctrl.posts | orderBy: 'created_at':true">
13 13 <div class="page-header">
14   - <a class="title" ui-sref="main.profile.page({profile: vm.profile.identifier, page: child.path})"><h4 ng-bind="child.title"></h4></a>
  14 + <a class="title" ui-sref="main.profile.page({profile: $ctrl.profile.identifier, page: child.path})"><h4 ng-bind="child.title"></h4></a>
15 15 <div class="post-lead" ng-bind-html="child.body | truncate: 500: '...': true"></div>
16 16 </div>
17 17 </div>
18 18 </div>
19 19  
20   - <pagination ng-model="vm.currentPage" total-items="vm.totalPosts" class="pagination-sm center-block"
21   - boundary-links="true" items-per-page="vm.perPage" ng-change="vm.loadPage()"
  20 + <pagination ng-model="$ctrl.currentPage" total-items="$ctrl.totalPosts" class="pagination-sm center-block"
  21 + boundary-links="true" items-per-page="$ctrl.perPage" ng-change="$ctrl.loadPage()"
22 22 first-text="«" last-text="»" previous-text="‹" next-text="›">
23 23 </pagination>
24 24 </div>
... ...
src/app/components/noosfero-blocks/block.directive.js
... ... @@ -10,8 +10,8 @@
10 10 var directive = {
11 11 restrict: 'E',
12 12 scope: {
13   - block: '=',
14   - owner: '='
  13 + block: '<',
  14 + owner: '<'
15 15 },
16 16 link: function(scope, element) {
17 17 var blockName = scope.block.type.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
... ...
src/app/components/noosfero-blocks/link-list/link-list.component.js 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoLinkListBlock', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-blocks/link-list/link-list.html',
  9 + bindings: {
  10 + block: '<',
  11 + owner: '<'
  12 + },
  13 + controller: LinkListBlockController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function LinkListBlockController() {
  18 + this.links = this.block.settings.links;
  19 + }
  20 +
  21 +})();
... ...
src/app/components/noosfero-blocks/link-list/link-list.directive.js
... ... @@ -1,31 +0,0 @@
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/link-list.html',
13   - scope: {
14   - block: '=',
15   - owner: '='
16   - },
17   - controller: LinkListBlockController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function LinkListBlockController() {
26   - var vm = this;
27   - vm.links = vm.block.settings.links;
28   - }
29   - }
30   -
31   -})();
src/app/components/noosfero-blocks/link-list/link-list.html
1 1 <div class="link-list-block">
2   - <div ng-repeat="link in vm.links">
3   - <a ng-href="{{link.address | noosferoTemplateFilter:{profile: vm.owner.identifier} }}">
  2 + <div ng-repeat="link in $ctrl.links">
  3 + <a ng-href="{{link.address | noosferoTemplateFilter:{profile: $ctrl.owner.identifier} }}">
4 4 <i class="fa fa-fw icon-{{link.icon}}"></i> <span>{{link.name}}</span>
5 5 </a>
6 6 </div>
... ...
src/app/components/noosfero-blocks/main-block/main-block.component.js 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoMainBlock', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html',
  9 + bindings: {
  10 + block: '<',
  11 + owner: '<'
  12 + },
  13 + controller: MainBlockController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function MainBlockController() {
  18 + }
  19 +
  20 +})();
... ...
src/app/components/noosfero-blocks/main-block/main-block.directive.js
... ... @@ -1,29 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoMainBlock', noosferoMainBlock);
7   -
8   - /** @ngInject */
9   - function noosferoMainBlock() {
10   - var directive = {
11   - restrict: 'E',
12   - templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html',
13   - scope: {
14   - block: '=',
15   - owner: '='
16   - },
17   - controller: MainBlockController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function MainBlockController() {
26   - }
27   - }
28   -
29   -})();
src/app/components/noosfero-blocks/members-block/members-block.component.js 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoMembersBlock', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-blocks/members-block/members-block.html',
  9 + bindings: {
  10 + block: '<',
  11 + owner: '<'
  12 + },
  13 + controller: MembersBlockController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function MembersBlockController(noosfero) {
  18 + var vm = this;
  19 + vm.members = [];
  20 +
  21 + noosfero.members(noosfero.profiles.one(vm.owner.id)).one().get({per_page: 6}).then(function(response) {
  22 + vm.members = response.data.people;
  23 + });
  24 + }
  25 +
  26 +})();
... ...
src/app/components/noosfero-blocks/members-block/members-block.directive.js
... ... @@ -1,35 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoMembersBlock', noosferoMembersBlock);
7   -
8   - /** @ngInject */
9   - function noosferoMembersBlock() {
10   - var directive = {
11   - restrict: 'E',
12   - templateUrl: 'app/components/noosfero-blocks/members-block/members-block.html',
13   - scope: {
14   - block: '=',
15   - owner: '='
16   - },
17   - controller: MembersBlockController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function MembersBlockController(noosfero) {
26   - var vm = this;
27   - vm.members = [];
28   -
29   - noosfero.members(noosfero.profiles.one(vm.owner.id)).one().get({per_page: 6}).then(function(response) {
30   - vm.members = response.data.people;
31   - });
32   - }
33   - }
34   -
35   -})();
src/app/components/noosfero-blocks/members-block/members-block.html
1 1 <div class="members-block">
2   - <a ng-repeat="member in vm.members" ui-sref="main.profile({profile: member.identifier})" class="member">
  2 + <a ng-repeat="member in $ctrl.members" ui-sref="main.profile({profile: member.identifier})" class="member">
3 3 <noosfero-profile-image profile="member"></noosfero-profile-image>
4 4 </a>
5 5 </div>
... ...
src/app/components/noosfero-blocks/profile-image/profile-image.component.js 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoProfileImageBlock', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-blocks/profile-image/profile-image.html',
  9 + bindings: {
  10 + block: '<',
  11 + owner: '<'
  12 + },
  13 + controller: ProfileImageBlockController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function ProfileImageBlockController() {
  18 + var vm = this;
  19 + vm.profile = vm.owner;
  20 + }
  21 +
  22 +})();
... ...
src/app/components/noosfero-blocks/profile-image/profile-image.directive.js
... ... @@ -1,31 +0,0 @@
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/profile-image.html',
13   - scope: {
14   - block: '=',
15   - owner: '='
16   - },
17   - controller: ProfileImageBlockController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function ProfileImageBlockController() {
26   - var vm = this;
27   - vm.profile = vm.owner;
28   - }
29   - }
30   -
31   -})();
src/app/components/noosfero-blocks/profile-image/profile-image.html
1 1 <div class="center-block text-center profile-image-block">
2   - <a ui-sref="main.profile.info({profile: vm.owner.identifier})">
3   - <noosfero-profile-image profile="vm.owner"></noosfero-profile-image>
  2 + <a ui-sref="main.profile.info({profile: $ctrl.owner.identifier})">
  3 + <noosfero-profile-image profile="$ctrl.owner"></noosfero-profile-image>
4 4 </a>
5   - <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: vm.owner.identifier})">Control panel</a>
  5 + <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: $ctrl.owner.identifier})">Control panel</a>
6 6 </div>
... ...
src/app/components/noosfero-blocks/recent-documents/recent-documents.component.js 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoRecentDocumentsBlock', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero-blocks/recent-documents/recent-documents.html',
  9 + bindings: {
  10 + block: '<',
  11 + owner: '<'
  12 + },
  13 + controller: RecentDocumentsController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function RecentDocumentsController(noosfero, $state) {
  18 + var vm = this;
  19 + vm.profile = vm.owner;
  20 + vm.documents = [];
  21 +
  22 + vm.openDocument = function(article) {
  23 + $state.go("main.profile.page", {page: article.path, profile: article.profile.identifier});
  24 + }
  25 +
  26 + var limit = vm.block.settings.limit || 5;
  27 + //FIXME get all text articles
  28 + noosfero.profiles.one(vm.profile.id).one('articles').get({content_type: 'TinyMceArticle', per_page: limit}).then(function(response) {
  29 + vm.documents = response.data.articles;
  30 + });
  31 + }
  32 +
  33 +})();
... ...
src/app/components/noosfero-blocks/recent-documents/recent-documents.directive.js
... ... @@ -1,42 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoRecentDocumentsBlock', noosferoRecentDocumentsBlock);
7   -
8   - /** @ngInject */
9   - function noosferoRecentDocumentsBlock() {
10   - var directive = {
11   - restrict: 'E',
12   - templateUrl: 'app/components/noosfero-blocks/recent-documents/recent-documents.html',
13   - scope: {
14   - block: '=',
15   - owner: '='
16   - },
17   - controller: RecentDocumentsController,
18   - controllerAs: 'vm',
19   - bindToController: true
20   - };
21   -
22   - return directive;
23   -
24   - /** @ngInject */
25   - function RecentDocumentsController(noosfero, $state) {
26   - var vm = this;
27   - vm.profile = vm.owner;
28   - vm.documents = [];
29   -
30   - vm.openDocument = function(article) {
31   - $state.go("main.profile.page", {page: article.path, profile: article.profile.identifier});
32   - }
33   -
34   - var limit = vm.block.settings.limit || 5;
35   - //FIXME get all text articles
36   - noosfero.profiles.one(vm.profile.id).one('articles').get({content_type: 'TinyMceArticle', per_page: limit}).then(function(response) {
37   - vm.documents = response.data.articles;
38   - });
39   - }
40   - }
41   -
42   -})();
src/app/components/noosfero-blocks/recent-documents/recent-documents.html
1   -<div deckgrid source="vm.documents" class="deckgrid">
2   - <div class="a-card panel media" ng-click="mother.vm.openDocument(card);">
  1 +<div deckgrid source="$ctrl.documents" class="deckgrid">
  2 + <div class="a-card panel media" ng-click="mother.$ctrl.openDocument(card);">
3 3 <div class="author media-left" ng-show="card.author.image">
4 4 <img ng-src="{{card.author.image.url}}" class="img-circle">
5 5 </div>
... ...
src/app/components/noosfero-boxes/box.html
... ... @@ -4,7 +4,7 @@
4 4 <h3 class="panel-title">{{block.title}}</h3>
5 5 </div>
6 6 <div class="panel-body">
7   - <noosfero-block block="block" owner="vm.owner"></noosfero-block>
  7 + <noosfero-block block="block" owner="$ctrl.owner"></noosfero-block>
8 8 </div>
9 9 </div>
10 10 </div>
... ...
src/app/components/noosfero-boxes/boxes.component.js 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoBoxes', {
  7 + restrict: 'E',
  8 + bindings: {
  9 + boxes: '<',
  10 + owner: '<'
  11 + },
  12 + templateUrl: 'app/components/noosfero-boxes/boxes.html',
  13 + controller: BoxesController
  14 + });
  15 +
  16 + /** @ngInject */
  17 + function BoxesController() {
  18 + var vm = this;
  19 +
  20 + vm.boxesOrder = function(box) {
  21 + if(box.position==2) return 0;
  22 + return box.position;
  23 + }
  24 + }
  25 +
  26 +})();
... ...
src/app/components/noosfero-boxes/boxes.directive.js
... ... @@ -1,35 +0,0 @@
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
1   -<ng-include ng-repeat="box in vm.boxes | orderBy: vm.boxesOrder" src="'app/components/noosfero-boxes/box.html'"></ng-include>
  1 +<ng-include ng-repeat="box in $ctrl.boxes | orderBy: $ctrl.boxesOrder" src="'app/components/noosfero-boxes/box.html'"></ng-include>
... ...
src/app/components/noosfero/profile-image/profile-image.component.js 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('angular')
  6 + .component('noosferoProfileImage', {
  7 + restrict: 'E',
  8 + templateUrl: 'app/components/noosfero/profile-image/profile-image.html',
  9 + bindings: {
  10 + profile: '<'
  11 + },
  12 + controller: ProfileImageController
  13 + });
  14 +
  15 + /** @ngInject */
  16 + function ProfileImageController() {
  17 + var vm = this;
  18 + vm.defaultIcon = 'fa-users';
  19 + if(vm.profile && vm.profile.type==='Person') vm.defaultIcon = 'fa-user';
  20 + }
  21 +
  22 +})();
... ...
src/app/components/noosfero/profile-image/profile-image.directive.js
... ... @@ -1,31 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('angular')
6   - .directive('noosferoProfileImage', noosferoProfileImage);
7   -
8   - /** @ngInject */
9   - function noosferoProfileImage() {
10   - var directive = {
11   - restrict: 'E',
12   - templateUrl: 'app/components/noosfero/profile-image/profile-image.html',
13   - scope: {
14   - profile: '='
15   - },
16   - controller: ProfileImageController,
17   - controllerAs: 'vm',
18   - bindToController: true
19   - };
20   -
21   - return directive;
22   -
23   - /** @ngInject */
24   - function ProfileImageController() {
25   - var vm = this;
26   - vm.defaultIcon = 'fa-users';
27   - if(vm.profile && vm.profile.type==='Person') vm.defaultIcon = 'fa-user';
28   - }
29   - }
30   -
31   -})();
src/app/components/noosfero/profile-image/profile-image.html
1   -<span title="{{vm.profile.name}}">
2   - <img ng-if="vm.profile.image" ng-src="{{vm.profile.image.url}}" class="img-responsive profile-image">
3   - <i ng-if="!vm.profile.image" class="fa {{vm.defaultIcon}} fa-5x profile-image"></i>
  1 +<span title="{{$ctrl.profile.name}}">
  2 + <img ng-if="$ctrl.profile.image" ng-src="{{$ctrl.profile.image.url}}" class="img-responsive profile-image">
  3 + <i ng-if="!$ctrl.profile.image" class="fa {{$ctrl.defaultIcon}} fa-5x profile-image"></i>
4 4 </span>
... ...