Reloading left projects when necesary

stable
Alejandro Alonso 2014-08-13 09:26:07 +02:00
parent a5cd995da7
commit 81a4a75ec4
4 changed files with 17 additions and 9 deletions

View File

@ -85,7 +85,7 @@ module.controller("ProjectProfileController", ProjectProfileController)
## Project Profile Directive
#############################################################################
ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley({"onlyOneErrorElement": true})
submit = =>
@ -95,7 +95,7 @@ ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
promise.then ->
$confirm.notify("success")
$location.path("/project/#{$scope.project.slug}/admin/project-profile/details")
$rootscope.$broadcast("projects:reload")
$rootscope.$broadcast("project:loaded", $scope.project)
promise.then null, (data) ->
form.setErrors(data)
@ -116,7 +116,7 @@ ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
## Project Features Directive
#############################################################################
ProjectFeaturesDirective = ($log, $repo, $confirm) ->
ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley()
submit = =>
@ -125,7 +125,7 @@ ProjectFeaturesDirective = ($log, $repo, $confirm) ->
promise = $repo.save($scope.project)
promise.then ->
$confirm.notify("success")
$scope.$emit("project:loaded", $scope.project)
$rootscope.$broadcast("project:loaded", $scope.project)
promise.then null, (data) ->
$confirm.notify("error", data._error_message)
@ -154,5 +154,5 @@ ProjectFeaturesDirective = ($log, $repo, $confirm) ->
return {link:link}
module.directive("tgProjectProfile", ["$log", "$tgRepo", "$rootScope", "$tgConfirm", "$location", ProjectProfileDirective])
module.directive("tgProjectFeatures", ["$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$location", ProjectProfileDirective])
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])

View File

@ -180,7 +180,7 @@ module.directive("tgNewRole", ["$tgRepo", "$tgConfirm", NewRoleDirective])
# Use category-config.scss styles
RolePermissionsDirective = ($repo, $confirm) ->
RolePermissionsDirective = ($rootscope, $repo, $confirm) ->
resumeTemplate = _.template("""
<div class="resume-title"><%- category.name %></div>
<div class="count"><%- category.activePermissions %>/<%- category.permissions.length %></div>
@ -313,6 +313,7 @@ RolePermissionsDirective = ($repo, $confirm) ->
categories = generateCategoriesFromRole(role)
categoryId = target.parents(".category-config").data("id")
renderResume(target.parents(".category-config"), categories[categoryId])
$rootscope.$broadcast("projects:reload")
onError = ->
$confirm.notify("error")
@ -332,4 +333,4 @@ RolePermissionsDirective = ($repo, $confirm) ->
return {link:link}
module.directive("tgRolePermissions", ['$tgRepo', '$tgConfirm', RolePermissionsDirective])
module.directive("tgRolePermissions", ["$rootScope", "$tgRepo", "$tgConfirm", RolePermissionsDirective])

View File

@ -37,9 +37,14 @@ class ProjectsNavigationController extends taiga.Controller
console.log "FAIL"
# TODO
# Listen when someone wants to reload all the projects
@scope.$on "projects:reload", =>
@.loadInitialData()
# Listen when someone has reloaded a project
@scope.$on "project:loaded", (ctx, project) =>
@.loadInitialData()
loadInitialData: ->
return @rs.projects.list().then (projects) =>
for project in projects

View File

@ -3,7 +3,7 @@ bindOnce = @.taiga.bindOnce
module = angular.module("taigaProject")
CreateProject = ($repo, $confirm, $location, $navurls, $rs, lightboxService) ->
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, lightboxService) ->
link = ($scope, $el, attrs) ->
$scope.data = {}
$scope.templates = []
@ -18,6 +18,7 @@ CreateProject = ($repo, $confirm, $location, $navurls, $rs, lightboxService) ->
fullUrl = $navurls.formatUrl(url, {'project': response.slug})
$location.url(fullUrl)
$rootscope.$broadcast("projects:reload")
onErrorSubmit = (response) ->
$confirm.notify("light-error", "According to our Oompa Loompas, project name is
@ -47,6 +48,7 @@ CreateProject = ($repo, $confirm, $location, $navurls, $rs, lightboxService) ->
return {link:link}
module.directive("tgLbCreateProject", [
"$rootScope",
"$tgRepo",
"$tgConfirm",
"$location",