From 56cdea854f09171056650f87273317ca3aa39180 Mon Sep 17 00:00:00 2001 From: Michael BAILLY Date: Fri, 18 Sep 2020 14:35:00 +0200 Subject: [PATCH] #138 Remove useless avatar-list component --- src/frontend/css/styles.less | 1 - src/frontend/index.js | 2 - src/frontend/js/modules/avatar.js | 2 - .../avatar/list/avatar-list.component.js | 20 --- .../avatar/list/avatar-list.controller.js | 40 ------ .../list/avatar-list.controller.spec.js | 124 ------------------ .../js/modules/avatar/list/avatar-list.less | 35 ----- .../js/modules/avatar/list/avatar-list.pug | 6 - 8 files changed, 230 deletions(-) delete mode 100644 src/frontend/js/modules/avatar/list/avatar-list.component.js delete mode 100644 src/frontend/js/modules/avatar/list/avatar-list.controller.js delete mode 100644 src/frontend/js/modules/avatar/list/avatar-list.controller.spec.js delete mode 100644 src/frontend/js/modules/avatar/list/avatar-list.less delete mode 100644 src/frontend/js/modules/avatar/list/avatar-list.pug diff --git a/src/frontend/css/styles.less b/src/frontend/css/styles.less index 74b0ddd3..a957ef26 100644 --- a/src/frontend/css/styles.less +++ b/src/frontend/css/styles.less @@ -157,7 +157,6 @@ @import "../js/modules/collaboration/members/collaboration-members.less"; @import "../js/modules/collaboration/invite/collaboration-invite-users.less"; @import "../js/modules/collaboration/members/collaboration-members-widget.less"; -@import "../js/modules/avatar/list/avatar-list"; @import "../js/modules/oauth-application/oauth-application"; @import "../js/modules/header/profile-menu/profile-menu"; @import "../js/modules/search/search"; diff --git a/src/frontend/index.js b/src/frontend/index.js index 341f46d6..3b0bf674 100644 --- a/src/frontend/index.js +++ b/src/frontend/index.js @@ -65,8 +65,6 @@ require('./js/modules/infinite-list/infinite-list.directive.js'); require('./js/modules/infinite-list/infinite-list.service.js'); require('./js/modules/sidebar.js'); require('./js/modules/avatar.js'); -require('./js/modules/avatar/list/avatar-list.component.js'); -require('./js/modules/avatar/list/avatar-list.controller.js'); require('./js/modules/avatar/avatar-url.service.js'); require('./js/modules/user/user.module.js'); require('./js/modules/user/user.constants.js'); diff --git a/src/frontend/js/modules/avatar.js b/src/frontend/js/modules/avatar.js index be9315ef..82bde0f3 100644 --- a/src/frontend/js/modules/avatar.js +++ b/src/frontend/js/modules/avatar.js @@ -577,8 +577,6 @@ })(angular); require('./avatar/avatar-url.service.js'); -require('./avatar/list/avatar-list.component.js'); -require('./avatar/list/avatar-list.controller.js'); require('../constants.js'); require('./http.js'); diff --git a/src/frontend/js/modules/avatar/list/avatar-list.component.js b/src/frontend/js/modules/avatar/list/avatar-list.component.js deleted file mode 100644 index e89550f7..00000000 --- a/src/frontend/js/modules/avatar/list/avatar-list.component.js +++ /dev/null @@ -1,20 +0,0 @@ -require('./avatar-list.controller.js'); - -(function(angular) { - 'use strict'; - - angular.module('esn.avatar') - .component('esnAvatarList', esnAvatarList()); - - function esnAvatarList() { - return { - template: require('./avatar-list.pug'), - controller: 'ESNAvatarListController', - bindings: { - members: '<', - limit: '=', - profileLink: '@' - } - }; - } -})(angular); diff --git a/src/frontend/js/modules/avatar/list/avatar-list.controller.js b/src/frontend/js/modules/avatar/list/avatar-list.controller.js deleted file mode 100644 index 1d0bfb99..00000000 --- a/src/frontend/js/modules/avatar/list/avatar-list.controller.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(angular) { - 'use strict'; - - angular.module('esn.avatar') - .controller('ESNAvatarListController', ESNAvatarListController); - - function ESNAvatarListController() { - var self = this; - var defaultLimit; - - self.$onInit = $onInit; - self.switchDisplay = switchDisplay; - self.isLimitedDisplay = isLimitedDisplay; - self.canShowButton = canShowButton; - - function $onInit() { - defaultLimit = self.limit; - - if (!self.profileLink) { - self.profileLink = 'profile({user_id: member.id})'; - } - } - - function switchDisplay() { - if (isLimitedDisplay()) { - self.limit = self.members.length; - } else { - self.limit = defaultLimit; - } - } - - function isLimitedDisplay() { - return self.limit === defaultLimit; - } - - function canShowButton() { - return self.members.length > defaultLimit; - } - } -})(angular); diff --git a/src/frontend/js/modules/avatar/list/avatar-list.controller.spec.js b/src/frontend/js/modules/avatar/list/avatar-list.controller.spec.js deleted file mode 100644 index c680bc02..00000000 --- a/src/frontend/js/modules/avatar/list/avatar-list.controller.spec.js +++ /dev/null @@ -1,124 +0,0 @@ -'use strict'; - -/* global chai: false */ - -var { expect } = chai; - -describe('The ESNAvatarListController', function() { - var $controller, $scope, $rootScope, members; - - function addMember(numberOfMembers) { - members = []; - for (var i = 0; i < numberOfMembers; i++) { - members.push({ member: { id: i + 1 } }); - } - - return members; - } - - function initController(members) { - var controller = $controller('ESNAvatarListController', - { $scope: $scope }, - { members: members }); - - controller.limit = 5; - $scope.$digest(); - - return controller; - } - - beforeEach(function() { - members = addMember(7); - - angular.mock.module('esn.avatar'); - }); - - beforeEach(angular.mock.inject(function(_$controller_, _$q_, _$rootScope_) { - $controller = _$controller_; - $rootScope = _$rootScope_; - $scope = $rootScope.$new(); - })); - - describe('the $onInit function', function() { - - it('should set the profile link to default value when it is undefined', function() { - var controller = initController(members); - - controller.$onInit(); - - expect(controller.profileLink).to.be.equal('profile({user_id: member.id})'); - }); - }); - - describe('the isLimitedDisplay function', function() { - - it('should return true when limit is equal to the defaultLimit', function() { - var controller = initController(members); - - controller.$onInit(); - - expect(controller.isLimitedDisplay()).to.be.true; - }); - - it('should return false when switchDisplay is called once', function() { - var controller = initController(members); - - controller.$onInit(); - controller.switchDisplay(); - - expect(controller.isLimitedDisplay()).to.be.false; - }); - - it('should return true when switchDisplay is called twice', function() { - var controller = initController(members); - - controller.$onInit(); - controller.switchDisplay(); - controller.switchDisplay(); - - expect(controller.isLimitedDisplay()).to.be.true; - }); - }); - - describe('the canShowButton function', function() { - - it('should return true when members length is upper than defaultLimit ', function() { - var controller = initController(members); - - controller.$onInit(); - - expect(controller.canShowButton()).to.be.true; - }); - - it('should return false when members length is lower than defaultLimit ', function() { - var members = addMember(2); - var controller = initController(members); - - controller.$onInit(); - - expect(controller.canShowButton()).to.be.false; - }); - }); - - describe('the switchDisplay function', function() { - - it('should set limit to members length if isLimitedDisplay is true', function() { - var controller = initController(members); - - controller.$onInit(); - controller.switchDisplay(); - - expect(controller.limit).to.equal(7); - }); - - it('should set limit to its initial value if isLimitedDisplay is false', function() { - var controller = initController(members); - - controller.$onInit(); - controller.switchDisplay(); - controller.switchDisplay(); - - expect(controller.limit).to.equal(5); - }); - }); -}); diff --git a/src/frontend/js/modules/avatar/list/avatar-list.less b/src/frontend/js/modules/avatar/list/avatar-list.less deleted file mode 100644 index e7784983..00000000 --- a/src/frontend/js/modules/avatar/list/avatar-list.less +++ /dev/null @@ -1,35 +0,0 @@ -.avatar-list-container { - width: 100%; - - .avatar-list { - .flex-wrap; - - .avatar { - .flex-row; - - height:64px; - width: 64px; - margin: 4px; - position: relative; - - img { - .avatar(64px, 2px); - - position: relative; - cursor: pointer; - } - - i { - position: absolute; - padding: 1px; - bottom: 0; - right: 0; - font-size: 11px; - } - } - } - - a { - margin-left: 4px; - } -} diff --git a/src/frontend/js/modules/avatar/list/avatar-list.pug b/src/frontend/js/modules/avatar/list/avatar-list.pug deleted file mode 100644 index a32cea8d..00000000 --- a/src/frontend/js/modules/avatar/list/avatar-list.pug +++ /dev/null @@ -1,6 +0,0 @@ -.avatar-list-container - .avatar-list - .avatar(ng-repeat="member in $ctrl.members | orderBy:'-member.memberName' | limitTo: $ctrl.limit") - img(ng-src='/api/users/{{::member.id}}/profile/avatar', title='{{::member.memberName}}', ui-sref="{{$ctrl.profileLink}}") - a(href="", ng-show="$ctrl.canShowButton() && $ctrl.isLimitedDisplay()", ng-click="$ctrl.switchDisplay()") {{ 'More' | translate }} - a(href="", ng-show="!$ctrl.isLimitedDisplay()", ng-click="$ctrl.switchDisplay()") {{ 'Collapse' | translate }}