Commit 9d93a631 authored by Robert Knight's avatar Robert Knight

Use more consistent naming for groupList directive

 * Use the singular 'groupList' everywhere

 * Simplify the logic for stopping click propagation
   when toggling the selected group

 * Remove underscore prefix for Controller classes as per the PR
   discussion.

Card 87
parent b2a90531
'use strict';
// @ngInject
function GroupsListController($scope) {
function GroupListController($scope) {
$scope.expandedGroupId = undefined;
// used to keep the dropdown from closing when the user
// interacts with the inline link share pane within the groups list
$scope.stopClickPropagation = function($event) {
$event.stopPropagation();
}
// show the share link for the specified group or clear it if
// null
$scope.toggleShareLink = function (groupId) {
......@@ -41,9 +35,9 @@ function GroupsListController($scope) {
* @description Displays a list of groups of which the user is a member.
*/
// @ngInject
function groupsList(groups, $window) {
function groupList(groups, $window) {
return {
controller: GroupsListController,
controller: GroupListController,
link: function ($scope, elem, attrs) {
$scope.groups = groups;
......@@ -70,6 +64,6 @@ function groupsList(groups, $window) {
};
module.exports = {
directive: groupsList,
_Controller: GroupsListController
directive: groupList,
Controller: GroupListController
};
......@@ -127,5 +127,5 @@ var directive = function () {
module.exports = {
directive: directive,
_Controller: PrivacyController
Controller: PrivacyController
};
'use strict';
var groupsList = require('../group-list');
var groupList = require('../group-list');
describe('GroupsListController', function () {
describe('GroupListController', function () {
var controller;
var $scope;
beforeEach(function () {
$scope = {};
controller = new groupsList._Controller($scope);
controller = new groupList.Controller($scope);
});
it('toggles share links', function () {
......@@ -63,7 +63,7 @@ function isElementHidden(element) {
return element.hasClass('ng-hide');
}
describe('GroupsListDirective', function () {
describe('groupList', function () {
var $compile;
var $scope;
......@@ -80,7 +80,7 @@ describe('GroupsListDirective', function () {
before(function() {
angular.module('app', [])
.directive('groupList', groupsList.directive)
.directive('groupList', groupList.directive)
.factory('groups', function () {
return {
all: function () {
......@@ -100,20 +100,20 @@ describe('GroupsListDirective', function () {
$scope = _$rootScope_.$new();
}));
function createGroupsList() {
function createGroupList() {
var element = $compile('<group-list></group-list>')($scope);
$scope.$digest();
return element;
}
it('should render groups', function () {
var element = createGroupsList();
var element = createGroupList();
var groupItems = element.find('.group-item');
assert.equal(groupItems.length, groups.length + 1);
});
it('should render share links', function () {
var element = createGroupsList();
var element = createGroupList();
var shareLinks = element.find('.share-link-container');
assert.equal(shareLinks.length, 1);
......@@ -123,7 +123,7 @@ describe('GroupsListDirective', function () {
});
it('should toggle share link on click', function () {
var element = createGroupsList();
var element = createGroupList();
var toggleLink = element.find('.share-link-toggle');
var expander = element.find('.share-link-expander');
assert.ok(isElementHidden(expander));
......
'use strict';
var PrivacyController = require('../privacy')._Controller;
var PrivacyController = require('../privacy').Controller;
describe('PrivacyController', function () {
var fakeScope;
......
......@@ -27,7 +27,7 @@
{{group.name}}
</a>
</div>
<div class="share-link-container" ng-click="stopClickPropagation($event)" ng-if="!group.public">
<div class="share-link-container" ng-click="$event.stopPropagation()" ng-if="!group.public">
<div>
<a class="share-link-toggle"
href=""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment