Merge pull request #1024 from taigaio/issue/4206/feedback

Add feedback in points and tags
stable
Juanfran 2016-05-26 09:55:36 +02:00
commit 527713985b
7 changed files with 77 additions and 14 deletions

View File

@ -111,14 +111,19 @@ UsEstimationDirective = ($tgEstimationsService, $rootScope, $repo, $template, $c
if us if us
estimationProcess = $tgEstimationsService.create($el, us, $scope.project) estimationProcess = $tgEstimationsService.create($el, us, $scope.project)
estimationProcess.onSelectedPointForRole = (roleId, pointId, points) -> estimationProcess.onSelectedPointForRole = (roleId, pointId, points) ->
estimationProcess.loading = roleId
estimationProcess.render()
save(points).then () -> save(points).then () ->
estimationProcess.loading = false
$rootScope.$broadcast("object:updated") $rootScope.$broadcast("object:updated")
estimationProcess.render()
estimationProcess.render = () -> estimationProcess.render = () ->
ctx = { ctx = {
totalPoints: @calculateTotalPoints() totalPoints: @calculateTotalPoints()
roles: @calculateRoles() roles: @calculateRoles()
editable: @isEditable editable: @isEditable
loading: estimationProcess.loading
} }
mainTemplate = "common/estimation/us-estimation-points-per-role.html" mainTemplate = "common/estimation/us-estimation-points-per-role.html"
template = $template.get(mainTemplate, true) template = $template.get(mainTemplate, true)
@ -154,6 +159,7 @@ EstimationsService = ($template, $repo, $confirm, $q, $qqueue) ->
@isEditable = @project.my_permissions.indexOf("modify_us") != -1 @isEditable = @project.my_permissions.indexOf("modify_us") != -1
@roles = @project.roles @roles = @project.roles
@points = @project.points @points = @project.points
@loading = false
@pointsById = groupBy(@points, (x) -> x.id) @pointsById = groupBy(@points, (x) -> x.id)
@onSelectedPointForRole = (roleId, pointId) -> @onSelectedPointForRole = (roleId, pointId) ->
@render = () -> @render = () ->
@ -163,6 +169,7 @@ EstimationsService = ($template, $repo, $confirm, $q, $qqueue) ->
$qqueue.add () => $qqueue.add () =>
onSuccess = => onSuccess = =>
deferred.resolve() deferred.resolve()
@render()
onError = => onError = =>
$confirm.notify("error") $confirm.notify("error")
@ -215,7 +222,6 @@ EstimationsService = ($template, $repo, $confirm, $q, $qqueue) ->
pointId = target.data("point-id") pointId = target.data("point-id")
@$el.find(".popover").popover().close() @$el.find(".popover").popover().close()
points = _.clone(@us.points, true) points = _.clone(@us.points, true)
points[roleId] = pointId points[roleId] = pointId

View File

@ -112,7 +112,7 @@ LbTagLineDirective = ($rs, $template, $compile) ->
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
## Render ## Render
renderTags = (tags, tagsColors) -> renderTags = (tags, tagsColors = []) ->
ctx = { ctx = {
tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]}) tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]})
} }
@ -231,6 +231,8 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
link = ($scope, $el, $attrs, $model) -> link = ($scope, $el, $attrs, $model) ->
autocomplete = null autocomplete = null
loading = false
deleteTagLoading = null
isEditable = -> isEditable = ->
if $attrs.requiredPerm? if $attrs.requiredPerm?
@ -243,7 +245,10 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
ctx = { ctx = {
tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]}) tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]})
isEditable: isEditable() isEditable: isEditable()
loading: loading
deleteTagLoading: deleteTagLoading
} }
html = $compile(templateTags(ctx))($scope) html = $compile(templateTags(ctx))($scope)
$el.find("div.tags-container").html(html) $el.find("div.tags-container").html(html)
@ -270,8 +275,10 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
## Aux methods ## Aux methods
addValue = (value) -> addValue = (value) ->
loading = true
value = trim(value.toLowerCase()) value = trim(value.toLowerCase())
return if value.length == 0 return if value.length == 0
renderTags($model.$modelValue.tags, $scope.project?.tags_colors)
transform = $modelTransform.save (item) -> transform = $modelTransform.save (item) ->
if not item.tags if not item.tags
@ -287,6 +294,8 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
onSuccess = -> onSuccess = ->
$rootScope.$broadcast("object:updated") $rootScope.$broadcast("object:updated")
loading = false
renderTags($model.$modelValue.tags, $scope.project?.tags_colors)
onError = -> onError = ->
$confirm.notify("error") $confirm.notify("error")
@ -298,6 +307,8 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
deleteValue = (value) -> deleteValue = (value) ->
value = trim(value.toLowerCase()) value = trim(value.toLowerCase())
return if value.length == 0 return if value.length == 0
deleteTagLoading = value
renderTags($model.$modelValue.tags, $scope.project?.tags_colors)
transform = $modelTransform.save (item) -> transform = $modelTransform.save (item) ->
tags = _.clone(item.tags, false) tags = _.clone(item.tags, false)
@ -307,9 +318,12 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
onSuccess = -> onSuccess = ->
$rootScope.$broadcast("object:updated") $rootScope.$broadcast("object:updated")
renderTags($model.$modelValue.tags, $scope.project?.tags_colors)
deleteTagLoading = null
onError = -> onError = ->
$confirm.notify("error") $confirm.notify("error")
deleteTagLoading = null
return transform.then(onSuccess, onError) return transform.then(onSuccess, onError)
@ -357,6 +371,7 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template
value = target.siblings(".tag-name").text() value = target.siblings(".tag-name").text()
deleteValue(value) deleteValue(value)
$scope.$digest()
bindOnce $scope, "project.tags_colors", (tags_colors) -> bindOnce $scope, "project.tags_colors", (tags_colors) ->
if not isEditable() if not isEditable()

View File

@ -1,11 +1,16 @@
.view-subject .view-subject {{ item.subject }}
| {{ item.subject }}
tg-svg.edit( tg-svg.edit(
svg-icon="icon-edit", svg-icon="icon-edit",
title="{{'COMMON.EDIT' | translate}}" title="{{'COMMON.EDIT' | translate}}"
) )
.edit-subject .edit-subject
input(type="text", ng-model="item.subject", data-required="true", data-maxlength="500", ng-model-options="{ debounce: 200 }") input(
type="text"
ng-model="item.subject"
data-required="true"
data-maxlength="500"
ng-model-options="{ debounce: 200 }"
)
span.save-container span.save-container
a.save(href="") a.save(href="")
tg-svg( tg-svg(

View File

@ -1,11 +1,14 @@
ul.points-per-role ul.points-per-role
<% _.each(roles, function(role) { %> <% _.each(roles, function(role) { %>
li.ticket-role-points.total(class!="<% if(editable){ %>clickable<% } %>", data-role-id!="<%- role.id %>", title!="<%- role.name %>") li.ticket-role-points.total(
class!="<% if(editable){ %>clickable<% } %>"
data-role-id!="<%- role.id %>"
title!="<%- role.name %>"
)
span.points span.points
<%- role.points %> <%- role.points %>
tg-svg(svg-icon="icon-arrow-down") tg-svg(svg-icon="icon-arrow-down")
span.role span.role(tg-loading!="<%- loading == role.id %>") <%- role.name %>
<%- role.name %>
<% }); %> <% }); %>
li.ticket-role-points.total li.ticket-role-points.total
span.points <%- totalPoints %> span.points <%- totalPoints %>

View File

@ -1,9 +1,15 @@
.tags-container .tags-container
a(href="#", class="add-tag hidden", title="{{'COMMON.TAGS.ADD' | translate}}") a.add-tag.hidden(
href="#"
title="{{'COMMON.TAGS.ADD' | translate}}"
)
tg-svg(svg-icon="icon-add") tg-svg(svg-icon="icon-add")
span.add-tag-text(translate="COMMON.TAGS.ADD") span.add-tag-text(translate="COMMON.TAGS.ADD")
span.add-tag-input span.add-tag-input
input(type="text", placeholder="{{'COMMON.TAGS.PLACEHOLDER' | translate}}", class="tag-input hidden") input.tag-input.hidden(
type="text"
placeholder="{{'COMMON.TAGS.PLACEHOLDER' | translate}}"
)
span.save.hidden(title="{{'COMMON.SAVE' | translate}}") span.save.hidden(title="{{'COMMON.SAVE' | translate}}")
tg-svg(svg-icon="icon-save") tg-svg(svg-icon="icon-save")

View File

@ -1,8 +1,16 @@
<% _.each(tags, function(tag) { %> <% _.each(tags, function(tag) { %>
span(class="tag", style!="border-left: 5px solid <%- tag.color %>;") <% if (tag.name == deleteTagLoading) { %>
div(tg-loading="true")
<% } else { %>
span.tag(style!="border-left: 5px solid <%- tag.color %>;")
span.tag-name <%- tag.name %> span.tag-name <%- tag.name %>
<% if (isEditable) { %> <% if (isEditable) { %>
a.remove-tag(href="", title="{{'COMMON.TAGS.DELETE' | translate}}") a.remove-tag(
href=""
title="{{'COMMON.TAGS.DELETE' | translate}}"
)
tg-svg(svg-icon="icon-close") tg-svg(svg-icon="icon-close")
<% } %> <% } %>
<% } %>
<% }); %> <% }); %>
div(tg-loading!="<%- loading %>")

View File

@ -34,8 +34,23 @@
} }
.tags-block { .tags-block {
align-content: center;
display: flex;
flex-wrap: wrap;
.tags-container { .tags-container {
display: inline-block; align-items: center;
display: flex;
flex-wrap: wrap;
}
.add-tag-input {
align-items: flex-start;
display: flex;
flex-grow: 0;
flex-shrink: 0;
width: 250px;
.icon-save {
margin-top: .5rem;
}
} }
input { input {
margin-right: .25rem; margin-right: .25rem;
@ -55,6 +70,9 @@
transition: .2s linear; transition: .2s linear;
} }
} }
.loading-spinner {
margin-right: .5rem;
}
.tag { .tag {
@include font-size(small); @include font-size(small);
margin: 0 .5rem .5rem 0; margin: 0 .5rem .5rem 0;
@ -78,6 +96,8 @@
} }
.icon-add { .icon-add {
@include svg-size(.9rem); @include svg-size(.9rem);
margin-right: .25rem;
margin-top: .5rem;
} }
.add-tag-text { .add-tag-text {
@include font-size(small); @include font-size(small);