Move some directives to commons.
parent
3de74a6e3e
commit
938cf024a7
|
@ -75,29 +75,32 @@ DateSelectorDirective =->
|
|||
## User story status directive
|
||||
#############################################################################
|
||||
|
||||
|
||||
# TODO: change to less generic name.
|
||||
|
||||
UsStatusDirective = ($repo) ->
|
||||
### Print the status of a US and a popover to change it.
|
||||
- tg-us-status: The user story
|
||||
- on-update: Method call after US is updated
|
||||
###
|
||||
Print the status of a US and a popover to change it.
|
||||
- tg-us-status: The user story
|
||||
- on-update: Method call after US is updated
|
||||
|
||||
Example:
|
||||
|
||||
div.status(tg-us-status="us" on-update="ctrl.loadSprintState()")
|
||||
a.us-status(href="", title="Status Name")
|
||||
div.status(tg-us-status="us" on-update="ctrl.loadSprintState()")
|
||||
a.us-status(href="", title="Status Name")
|
||||
|
||||
NOTE: This directive need 'usStatusById' and 'project'.
|
||||
###
|
||||
selectionTemplate = _.template("""
|
||||
<ul class="popover pop-status">
|
||||
<% _.forEach(statuses, function(status) { %>
|
||||
<li>
|
||||
<a href="" class="status" title="<%- status.name %>" data-status-id="<%- status.id %>">
|
||||
<%- status.name %>
|
||||
</a>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
""")
|
||||
<ul class="popover pop-status">
|
||||
<% _.forEach(statuses, function(status) { %>
|
||||
<li>
|
||||
<a href="" class="status" title="<%- status.name %>" data-status-id="<%- status.id %>">
|
||||
<%- status.name %>
|
||||
</a>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>""")
|
||||
|
||||
updateUsStatus = ($el, us, usStatusById) ->
|
||||
usStatusDomParent = $el.find(".us-status")
|
||||
|
@ -140,8 +143,94 @@ UsStatusDirective = ($repo) ->
|
|||
return {link: link}
|
||||
|
||||
|
||||
#############################################################################
|
||||
## List directives (Issues List, Search)
|
||||
#############################################################################
|
||||
|
||||
ListItemIssueStatusDirective = ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgListitemIssueStatus)
|
||||
bindOnce $scope, "issueStatusById", (issueStatusById) ->
|
||||
$el.html(issueStatusById[issue.status].name)
|
||||
|
||||
return {link:link}
|
||||
|
||||
|
||||
ListItemAssignedtoDirective = ->
|
||||
template = """
|
||||
<figure class="avatar">
|
||||
<img src="" alt="username"/>
|
||||
<figcaption>--</figcaption>
|
||||
</figure>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgListitemAssignedto)
|
||||
if issue.assigned_to is null
|
||||
$el.find("figcaption").html("Unassigned")
|
||||
else
|
||||
bindOnce $scope, "membersById", (membersById) ->
|
||||
member = membersById[issue.assigned_to]
|
||||
console.log member
|
||||
$el.find("figcaption").html(member.full_name)
|
||||
$el.find("img").attr("src", member.photo)
|
||||
|
||||
return {
|
||||
template: template
|
||||
link:link
|
||||
}
|
||||
|
||||
|
||||
ListItemPriorityDirective = ->
|
||||
template = """
|
||||
<div class="level"></div>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgListitemPriority)
|
||||
bindOnce $scope, "priorityById", (priorityById) ->
|
||||
priority = priorityById[issue.priority]
|
||||
|
||||
domNode = $el.find("div.level")
|
||||
domNode.css("background-color", priority.color)
|
||||
domNode.addClass(priority.name.toLowerCase())
|
||||
domNode.attr("title", priority.name)
|
||||
|
||||
return {
|
||||
link: link
|
||||
template: template
|
||||
}
|
||||
|
||||
|
||||
ListItemSeverityDirective = ->
|
||||
template = """
|
||||
<div class="level"></div>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgListitemSeverity)
|
||||
bindOnce $scope, "severityById", (severityById) ->
|
||||
severity = severityById[issue.severity]
|
||||
|
||||
domNode = $el.find("div.level")
|
||||
domNode.css("background-color", severity.color)
|
||||
domNode.addClass(severity.name.toLowerCase())
|
||||
domNode.attr("title", severity.name)
|
||||
|
||||
return {
|
||||
link: link
|
||||
template: template
|
||||
}
|
||||
|
||||
|
||||
module = angular.module("taigaCommon")
|
||||
module.directive("tgDateRange", DateRangeDirective)
|
||||
module.directive("tgSprintProgressbar", SprintProgressBarDirective)
|
||||
module.directive("tgDateSelector", DateSelectorDirective)
|
||||
module.directive("tgUsStatus", ["$tgRepo", UsStatusDirective])
|
||||
|
||||
module.directive("tgListitemIssueStatus", ListItemIssueStatusDirective)
|
||||
module.directive("tgListitemAssignedto", ListItemAssignedtoDirective)
|
||||
module.directive("tgListitemPriority", ListItemPriorityDirective)
|
||||
module.directive("tgListitemSeverity", ListItemSeverityDirective)
|
||||
|
||||
|
|
|
@ -235,82 +235,4 @@ IssuesDirective = ($log, $location) ->
|
|||
return {link:link}
|
||||
|
||||
|
||||
IssueStatusDirective = ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgIssueStatus)
|
||||
bindOnce $scope, "issueStatusById", (issueStatusById) ->
|
||||
$el.html(issueStatusById[issue.status].name)
|
||||
|
||||
return {link:link}
|
||||
|
||||
|
||||
IssueAssignedtoDirective = ->
|
||||
template = """
|
||||
<figure class="avatar">
|
||||
<img src="http://thecodeplayer.com/u/uifaces/12.jpg" alt="username"/>
|
||||
<figcaption>--</figcaption>
|
||||
</figure>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgIssueAssignedto)
|
||||
if issue.assigned_to is null
|
||||
$el.find("figcaption").html("Unassigned")
|
||||
else
|
||||
bindOnce $scope, "membersById", (membersById) ->
|
||||
memberName = membersById[issue.assigned_to].full_name_display
|
||||
$el.find("figcaption").html(memberName)
|
||||
|
||||
return {
|
||||
template: template
|
||||
link:link
|
||||
}
|
||||
|
||||
|
||||
IssuePriorityDirective = ->
|
||||
template = """
|
||||
<div class="level"></div>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgIssuePriority)
|
||||
bindOnce $scope, "priorityById", (priorityById) ->
|
||||
priority = priorityById[issue.priority]
|
||||
|
||||
domNode = $el.find("div.level")
|
||||
domNode.css("background-color", priority.color)
|
||||
domNode.addClass(priority.name.toLowerCase())
|
||||
domNode.attr("title", priority.name)
|
||||
|
||||
return {
|
||||
link: link
|
||||
template: template
|
||||
}
|
||||
|
||||
|
||||
IssueSeverityDirective = ->
|
||||
template = """
|
||||
<div class="level"></div>
|
||||
"""
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
issue = $scope.$eval($attrs.tgIssueSeverity)
|
||||
bindOnce $scope, "severityById", (severityById) ->
|
||||
severity = severityById[issue.severity]
|
||||
|
||||
domNode = $el.find("div.level")
|
||||
domNode.css("background-color", severity.color)
|
||||
domNode.addClass(severity.name.toLowerCase())
|
||||
domNode.attr("title", severity.name)
|
||||
|
||||
return {
|
||||
link: link
|
||||
template: template
|
||||
}
|
||||
|
||||
|
||||
module.directive("tgIssues", ["$log", "$tgLocation", IssuesDirective])
|
||||
module.directive("tgIssueStatus", IssueStatusDirective)
|
||||
module.directive("tgIssueAssignedto", IssueAssignedtoDirective)
|
||||
module.directive("tgIssuePriority", IssuePriorityDirective)
|
||||
module.directive("tgIssueSeverity", IssueSeverityDirective)
|
||||
|
|
|
@ -6,10 +6,10 @@ section.issues-table.basic-table
|
|||
div.issue-field Status
|
||||
div.assigned-field Assigned to
|
||||
div.row.table-main(ng-repeat="issue in issues track by issue.id")
|
||||
div.level-field(tg-issue-severity="issue")
|
||||
div.level-field(tg-issue-priority="issue")
|
||||
div.level-field(tg-listitem-severity="issue")
|
||||
div.level-field(tg-listitem-priority="issue")
|
||||
div.subject
|
||||
a(href="", tg-nav="project-issues-detail:project=project.slug,ref=issue.ref",
|
||||
tg-bo-html="issue.subject")
|
||||
div.issue-field(tg-issue-status="issue")
|
||||
div.assigned-field(tg-issue-assignedto="issue")
|
||||
div.issue-field(tg-listitem-issue-status="issue")
|
||||
div.assigned-field(tg-listitem-assignedto="issue")
|
||||
|
|
Loading…
Reference in New Issue