Allowing leave project
parent
2a4680b529
commit
b725b6c6e1
|
@ -22,7 +22,7 @@
|
|||
|
||||
taiga = @.taiga
|
||||
|
||||
resourceProvider = ($repo) ->
|
||||
resourceProvider = ($repo, $http, $urls) ->
|
||||
service = {}
|
||||
|
||||
service.get = (id) ->
|
||||
|
@ -46,7 +46,8 @@ resourceProvider = ($repo) ->
|
|||
return $repo.queryOneRaw("projects", "#{projectId}/stats")
|
||||
|
||||
service.leave = (projectId) ->
|
||||
return $repo.queryOneRaw("projects", "#{projectId}/leave")
|
||||
url = "#{$urls.resolve("projects")}/#{projectId}/leave"
|
||||
return $http.post(url)
|
||||
|
||||
service.memberStats = (projectId) ->
|
||||
return $repo.queryOneRaw("projects", "#{projectId}/member_stats")
|
||||
|
@ -59,4 +60,4 @@ resourceProvider = ($repo) ->
|
|||
|
||||
|
||||
module = angular.module("taigaResources")
|
||||
module.factory("$tgProjectsResourcesProvider", ["$tgRepo", resourceProvider])
|
||||
module.factory("$tgProjectsResourcesProvider", ["$tgRepo", "$tgHttp", "$tgUrls", resourceProvider])
|
||||
|
|
|
@ -32,6 +32,7 @@ module = angular.module("taigaTeam")
|
|||
class TeamController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||
@.$inject = [
|
||||
"$scope",
|
||||
"$rootScope",
|
||||
"$tgRepo",
|
||||
"$tgResources",
|
||||
"$routeParams",
|
||||
|
@ -41,7 +42,7 @@ class TeamController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|||
"tgLoader"
|
||||
]
|
||||
|
||||
constructor: (@scope, @repo, @rs, @params, @q, @appTitle, @auth, tgLoader) ->
|
||||
constructor: (@scope, @rootscope, @repo, @rs, @params, @q, @appTitle, @auth, tgLoader) ->
|
||||
@scope.sectionName = "Team"
|
||||
|
||||
promise = @.loadInitialData()
|
||||
|
@ -55,6 +56,12 @@ class TeamController extends mixOf(taiga.Controller, taiga.PageMixin)
|
|||
# On Error
|
||||
promise.then null, @.onInitialDataError.bind(@)
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
@scope.currentUser = @auth.getUser()
|
||||
@scope.projectId = @rootscope.projectId
|
||||
|
||||
>>>>>>> Allowing leave project
|
||||
setRole: (role) ->
|
||||
if role
|
||||
@scope.filtersRole = role
|
||||
|
@ -190,7 +197,7 @@ TeamMemberCurrentUserDirective = () ->
|
|||
<figcaption>
|
||||
<span class="name" tg-bo-bind="currentUser.full_name"></span>
|
||||
<span class="position" tg-bo-bind="currentUser.role_name"></span>
|
||||
<div tg-leave-project></div>
|
||||
<div tg-leave-project projectid="{{projectId}}"></div>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
@ -200,6 +207,7 @@ TeamMemberCurrentUserDirective = () ->
|
|||
return {
|
||||
template: template
|
||||
scope: {
|
||||
projectId: "=projectid",
|
||||
currentUser: "=currentuser",
|
||||
stats: "="
|
||||
}
|
||||
|
@ -242,22 +250,32 @@ module.directive("tgTeamMembers", TeamMembersDirective)
|
|||
## Leave project Directive
|
||||
#############################################################################
|
||||
|
||||
LeaveProjectDirective = ($repo, $confirm, $location) ->
|
||||
LeaveProjectDirective = ($repo, $confirm, $location, $rs, $navurls) ->
|
||||
template= """
|
||||
<a ng-click="leave()" href="" class="leave-project">
|
||||
<span class="icon icon-delete"></span>Leave this project
|
||||
</a>
|
||||
""" #TODO: i18n
|
||||
|
||||
link = ($scope) ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
$scope.leave = () ->
|
||||
$confirm.ask("Leave this project", "Are you sure you want to leave the project?")#TODO: i18n
|
||||
.then (finish) =>
|
||||
console.log "TODO"
|
||||
#TODO: i18n
|
||||
$confirm.ask("Leave this project", "Are you sure you want to leave the project?").then (finish) =>
|
||||
promise = $rs.projects.leave($attrs.projectid)
|
||||
|
||||
promise.then =>
|
||||
finish()
|
||||
$confirm.notify("success")
|
||||
$location.path($navurls.resolve("home"))
|
||||
|
||||
promise.then null, (response) ->
|
||||
finish()
|
||||
$confirm.notify('error', response.data._error_message)
|
||||
|
||||
return {
|
||||
scope: {},
|
||||
template: template,
|
||||
link: link
|
||||
}
|
||||
|
||||
module.directive("tgLeaveProject", ["$tgRepo", "$tgConfirm", "$tgLocation", LeaveProjectDirective])
|
||||
module.directive("tgLeaveProject", ["$tgRepo", "$tgConfirm", "$tgLocation", "$tgResources", "$tgNavUrls", LeaveProjectDirective])
|
||||
|
|
|
@ -26,7 +26,7 @@ section.table-team.basic-table
|
|||
div.popover.attribute-explanation
|
||||
span How far did you go into this Taiga?
|
||||
|
||||
div.hero(tg-team-current-user, stats="stats", currentuser="currentUser")
|
||||
div.hero(tg-team-current-user, stats="stats", currentuser="currentUser", projectid="projectId")
|
||||
|
||||
h2
|
||||
span Team >
|
||||
|
|
Loading…
Reference in New Issue