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
d30d7b72
Commit
d30d7b72
authored
Sep 16, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
View model helper methods for the annotation
Reduce the template logic and remove a use of 'group:__world__'.
parent
17b05012
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
11 deletions
+31
-11
annotation.coffee
h/static/scripts/directives/annotation.coffee
+31
-11
No files found.
h/static/scripts/directives/annotation.coffee
View file @
d30d7b72
...
...
@@ -52,19 +52,41 @@ AnnotationController = [
model = $scope.annotationGet()
original = null
###
*
# @ngdoc method
# @name annotation.AnnotationController#isComment.
# @returns {boolean} True if the annotation is a comment.
###
this.isComment = ->
not (model.target.length or model.references)
###
*
# @ngdoc method
# @name annotation.AnnotationController#isHighlight.
# @returns {boolean} True if the annotation is a highlight.
###
this.isHighlight = ->
not (model.text or model.deleted or model.tags.length)
###
*
# @ngdoc method
# @name annotation.AnnotationController#isPrivate
# @returns {boolean} True if the annotation is private to the current user.
###
this.isPrivate = ->
model.user and angular.equals(model.permissions?.read or [], [model.user])
###
*
# @ngdoc method
# @name annotation.AnnotationController#authorize
# @param {string} action The action to authorize.
# @param {string=} principal Defaults to the current user.
# @returns {boolean} True if the action is authorized for the principal.
# @description Checks whether the given principal can perform an action
# on the annotation.
# @returns {boolean} True if the action is authorized for the current user.
# @description Checks whether the current user can perform an action on
# the annotation.
###
this.authorize = (action
, principal
) ->
this.authorize = (action) ->
return false unless model?
return true if 'group:__world__' in (model.permissions?[action] or [])
annotator.plugins.Permissions?.authorize action, model, principal
annotator.plugins.Permissions?.authorize action, model
###
*
# @ngdoc method
...
...
@@ -188,7 +210,7 @@ AnnotationController = [
# Update once logged in.
$scope.$watch (-> model.user), (user) =>
if highlight and
not model.references
if highlight and
this.isHighlight()
if user
annotator.publish 'annotationCreated', model
else
...
...
@@ -197,9 +219,7 @@ AnnotationController = [
this.render()
# Start editing brand new annotations immediately
unless model.id?
if model.references or not highlight or not model.target.length
this.edit()
unless model.id? or this.isHighlight() then this.edit()
this
]
...
...
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