Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
7112851f
Commit
7112851f
authored
Mar 23, 2017
by
Sean Hammond
Committed by
GitHub
Mar 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #297 from hypothesis/group-list-component
Convert `<group-list>` to a component
parents
def2864a
8703c317
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
24 deletions
+68
-24
app.js
src/sidebar/app.js
+1
-1
group-list.js
src/sidebar/components/group-list.js
+44
-0
group-list-test.js
src/sidebar/components/test/group-list-test.js
+2
-2
group_list.html
src/sidebar/templates/group_list.html
+21
-21
No files found.
src/sidebar/app.js
View file @
7112851f
...
...
@@ -140,6 +140,7 @@ module.exports = angular.module('h', [
.
component
(
'annotationShareDialog'
,
require
(
'./components/annotation-share-dialog'
))
.
component
(
'annotationThread'
,
require
(
'./components/annotation-thread'
))
.
component
(
'dropdownMenuBtn'
,
require
(
'./components/dropdown-menu-btn'
))
.
component
(
'groupList'
,
require
(
'./components/group-list'
))
.
component
(
'helpLink'
,
require
(
'./components/help-link'
))
.
component
(
'helpPanel'
,
require
(
'./components/help-panel'
))
.
component
(
'loggedoutMessage'
,
require
(
'./components/loggedout-message'
))
...
...
@@ -159,7 +160,6 @@ module.exports = angular.module('h', [
.
component
(
'timestamp'
,
require
(
'./components/timestamp'
))
// These should use `component()` but will require some changes.
.
directive
(
'groupList'
,
require
(
'./directive/group-list'
).
directive
)
.
directive
(
'markdown'
,
require
(
'./directive/markdown'
))
.
directive
(
'topBar'
,
require
(
'./directive/top-bar'
))
...
...
src/sidebar/
directive
/group-list.js
→
src/sidebar/
components
/group-list.js
View file @
7112851f
...
...
@@ -4,12 +4,18 @@ var persona = require('../filter/persona');
var
serviceConfig
=
require
(
'../service-config'
);
// @ngInject
function
GroupListController
(
$scope
,
$window
,
groups
,
settings
)
{
$scope
.
isThirdPartyUser
=
function
()
{
return
persona
.
isThirdPartyUser
(
$scope
.
auth
.
userid
,
settings
.
authDomain
);
function
GroupListController
(
$window
,
groups
,
settings
,
serviceUrl
)
{
this
.
groups
=
groups
;
this
.
createNewGroup
=
function
()
{
$window
.
open
(
serviceUrl
(
'groups.new'
),
'_blank'
);
};
this
.
isThirdPartyUser
=
function
()
{
return
persona
.
isThirdPartyUser
(
this
.
auth
.
userid
,
settings
.
authDomain
);
};
$scope
.
leaveGroup
=
function
(
groupId
)
{
this
.
leaveGroup
=
function
(
groupId
)
{
var
groupName
=
groups
.
get
(
groupId
).
name
;
var
message
=
'Are you sure you want to leave the group "'
+
groupName
+
'"?'
;
...
...
@@ -18,42 +24,21 @@ function GroupListController($scope, $window, groups, settings) {
}
};
$scope
.
focusGroup
=
function
(
groupId
)
{
this
.
focusGroup
=
function
(
groupId
)
{
groups
.
focus
(
groupId
);
};
var
svc
=
serviceConfig
(
settings
);
if
(
svc
&&
svc
.
icon
)
{
$scope
.
thirdPartyGroupIcon
=
svc
.
icon
;
this
.
thirdPartyGroupIcon
=
svc
.
icon
;
}
}
/**
* @ngdoc directive
* @name groupList
* @restrict E
* @description Displays a list of groups of which the user is a member.
*/
// @ngInject
function
groupList
(
$window
,
groups
,
serviceUrl
)
{
return
{
module
.
exports
=
{
controller
:
GroupListController
,
link
:
function
(
$scope
)
{
$scope
.
groups
=
groups
;
$scope
.
createNewGroup
=
function
()
{
$window
.
open
(
serviceUrl
(
'groups.new'
),
'_blank'
);
};
},
restrict
:
'E'
,
scope
:
{
controllerAs
:
'vm'
,
bindings
:
{
auth
:
'<'
,
},
template
:
require
(
'../templates/group_list.html'
),
};
}
module
.
exports
=
{
directive
:
groupList
,
Controller
:
GroupListController
,
};
src/sidebar/
directive
/test/group-list-test.js
→
src/sidebar/
components
/test/group-list-test.js
View file @
7112851f
...
...
@@ -3,7 +3,7 @@
var
angular
=
require
(
'angular'
);
var
groupList
=
require
(
'../group-list'
);
var
util
=
require
(
'./util'
);
var
util
=
require
(
'.
./../directive/test
/util'
);
describe
(
'groupList'
,
function
()
{
var
$window
;
...
...
@@ -17,7 +17,7 @@ describe('groupList', function () {
before
(
function
()
{
angular
.
module
(
'app'
,
[])
.
directive
(
'groupList'
,
groupList
.
directive
)
.
component
(
'groupList'
,
groupList
)
.
factory
(
'groups'
,
function
()
{
return
fakeGroups
;
});
...
...
src/sidebar/templates/group_list.html
View file @
7112851f
<span
ng-if=
"auth.status === 'logged-out'"
ng-switch
on=
"groups.focused().public"
>
<span
ng-if=
"
vm.
auth.status === 'logged-out'"
ng-switch
on=
"
vm.
groups.focused().public"
>
<img
class=
"group-list-label__icon group-list-label__icon--third-party"
ng-src=
"{{ thirdPartyGroupIcon }}"
ng-if=
"thirdPartyGroupIcon"
ng-src=
"{{
vm.
thirdPartyGroupIcon }}"
ng-if=
"
vm.
thirdPartyGroupIcon"
ng-switch-when=
"true"
>
<!-- nospace
!-->
<i
class=
"group-list-label__icon h-icon-public"
ng-if=
"!thirdPartyGroupIcon"
ng-if=
"!
vm.
thirdPartyGroupIcon"
ng-switch-when=
"true"
></i>
<!-- nospace
!-->
<i
class=
"group-list-label__icon h-icon-group"
ng-switch-default
></i>
<span
class=
"group-list-label__label"
>
{{groups.focused().name}}
</span>
<span
class=
"group-list-label__label"
>
{{
vm.
groups.focused().name}}
</span>
</span>
<div
class=
"pull-right"
ng-if=
"auth.status === 'logged-in'"
ng-if=
"
vm.
auth.status === 'logged-in'"
dropdown
keyboard-nav
>
<div
class=
"dropdown-toggle"
dropdown-toggle
data-toggle=
"dropdown"
role=
"button"
ng-switch
on=
"groups.focused().public"
ng-switch
on=
"
vm.
groups.focused().public"
title=
"Change the selected group"
>
<img
class=
"group-list-label__icon group-list-label__icon--third-party"
ng-src=
"{{ thirdPartyGroupIcon }}"
ng-if=
"thirdPartyGroupIcon"
ng-src=
"{{
vm.
thirdPartyGroupIcon }}"
ng-if=
"
vm.
thirdPartyGroupIcon"
ng-switch-when=
"true"
>
<!-- nospace
!-->
<i
class=
"group-list-label__icon h-icon-public"
ng-switch-when=
"true"
ng-if=
"!thirdPartyGroupIcon"
></i>
<!-- nospace
ng-if=
"!
vm.
thirdPartyGroupIcon"
></i>
<!-- nospace
!-->
<i
class=
"group-list-label__icon h-icon-group"
ng-switch-default
></i>
<span
class=
"group-list-label__label"
>
{{groups.focused().name}}
</span>
<!-- nospace
<span
class=
"group-list-label__label"
>
{{
vm.
groups.focused().name}}
</span>
<!-- nospace
!-->
<i
class=
"h-icon-arrow-drop-down"
></i>
</div>
<div
class=
"dropdown-menu__top-arrow"
></div>
<ul
class=
"dropdown-menu pull-none"
role=
"menu"
>
<li
class=
"dropdown-menu__row dropdown-menu__row--unpadded "
ng-repeat=
"group in groups.all()"
>
<div
ng-class=
"{'group-item': true, selected: group.id == groups.focused().id}"
ng-click=
"focusGroup(group.id)"
>
ng-repeat=
"group in
vm.
groups.all()"
>
<div
ng-class=
"{'group-item': true, selected: group.id ==
vm.
groups.focused().id}"
ng-click=
"
vm.
focusGroup(group.id)"
>
<!-- the group icon !-->
<div
class=
"group-icon-container"
ng-switch
on=
"group.public"
>
<img
class=
"group-list-label__icon group-list-label__icon--third-party"
ng-src=
"{{ thirdPartyGroupIcon }}"
ng-if=
"thirdPartyGroupIcon"
ng-src=
"{{
vm.
thirdPartyGroupIcon }}"
ng-if=
"
vm.
thirdPartyGroupIcon"
ng-switch-when=
"true"
>
<i
class=
"h-icon-public"
ng-if=
"!thirdPartyGroupIcon"
ng-switch-when=
"true"
></i>
<i
class=
"h-icon-public"
ng-if=
"!
vm.
thirdPartyGroupIcon"
ng-switch-when=
"true"
></i>
<i
class=
"h-icon-group"
ng-switch-default
></i>
</div>
<!-- the group name and share link !-->
...
...
@@ -67,13 +67,13 @@
<div
class=
"group-cancel-icon-container"
ng-click=
"$event.stopPropagation()"
>
<i
class=
"h-icon-cancel-outline btn--cancel"
ng-if=
"!group.public"
ng-click=
"leaveGroup(group.id)"
ng-click=
"
vm.
leaveGroup(group.id)"
title=
"Leave '{{group.name}}'"
></i>
</div>
</div>
</li>
<li
ng-if=
"!isThirdPartyUser()"
class=
"dropdown-menu__row dropdown-menu__row--unpadded new-group-btn"
>
<div
class=
"group-item"
ng-click=
"createNewGroup()"
>
<li
ng-if=
"!
vm.
isThirdPartyUser()"
class=
"dropdown-menu__row dropdown-menu__row--unpadded new-group-btn"
>
<div
class=
"group-item"
ng-click=
"
vm.
createNewGroup()"
>
<div
class=
"group-icon-container"
><i
class=
"h-icon-add"
></i></div>
<div
class=
"group-details"
>
<a
href=
""
class=
"group-name-link"
title=
"Create a new group to share annotations"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment