Reloading left projects when necesary
parent
a5cd995da7
commit
81a4a75ec4
|
@ -85,7 +85,7 @@ module.controller("ProjectProfileController", ProjectProfileController)
|
||||||
## Project Profile Directive
|
## Project Profile Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
|
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $location) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
form = $el.find("form").checksley({"onlyOneErrorElement": true})
|
form = $el.find("form").checksley({"onlyOneErrorElement": true})
|
||||||
submit = =>
|
submit = =>
|
||||||
|
@ -95,7 +95,7 @@ ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
|
||||||
promise.then ->
|
promise.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$location.path("/project/#{$scope.project.slug}/admin/project-profile/details")
|
$location.path("/project/#{$scope.project.slug}/admin/project-profile/details")
|
||||||
$rootscope.$broadcast("projects:reload")
|
$rootscope.$broadcast("project:loaded", $scope.project)
|
||||||
|
|
||||||
promise.then null, (data) ->
|
promise.then null, (data) ->
|
||||||
form.setErrors(data)
|
form.setErrors(data)
|
||||||
|
@ -116,7 +116,7 @@ ProjectProfileDirective = ($log, $repo, $rootscope, $confirm, $location) ->
|
||||||
## Project Features Directive
|
## Project Features Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
ProjectFeaturesDirective = ($log, $repo, $confirm) ->
|
ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
form = $el.find("form").checksley()
|
form = $el.find("form").checksley()
|
||||||
submit = =>
|
submit = =>
|
||||||
|
@ -125,7 +125,7 @@ ProjectFeaturesDirective = ($log, $repo, $confirm) ->
|
||||||
promise = $repo.save($scope.project)
|
promise = $repo.save($scope.project)
|
||||||
promise.then ->
|
promise.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$scope.$emit("project:loaded", $scope.project)
|
$rootscope.$broadcast("project:loaded", $scope.project)
|
||||||
|
|
||||||
promise.then null, (data) ->
|
promise.then null, (data) ->
|
||||||
$confirm.notify("error", data._error_message)
|
$confirm.notify("error", data._error_message)
|
||||||
|
@ -154,5 +154,5 @@ ProjectFeaturesDirective = ($log, $repo, $confirm) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgProjectProfile", ["$log", "$tgRepo", "$rootScope", "$tgConfirm", "$location", ProjectProfileDirective])
|
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$location", ProjectProfileDirective])
|
||||||
module.directive("tgProjectFeatures", ["$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
|
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
|
||||||
|
|
|
@ -180,7 +180,7 @@ module.directive("tgNewRole", ["$tgRepo", "$tgConfirm", NewRoleDirective])
|
||||||
|
|
||||||
|
|
||||||
# Use category-config.scss styles
|
# Use category-config.scss styles
|
||||||
RolePermissionsDirective = ($repo, $confirm) ->
|
RolePermissionsDirective = ($rootscope, $repo, $confirm) ->
|
||||||
resumeTemplate = _.template("""
|
resumeTemplate = _.template("""
|
||||||
<div class="resume-title"><%- category.name %></div>
|
<div class="resume-title"><%- category.name %></div>
|
||||||
<div class="count"><%- category.activePermissions %>/<%- category.permissions.length %></div>
|
<div class="count"><%- category.activePermissions %>/<%- category.permissions.length %></div>
|
||||||
|
@ -313,6 +313,7 @@ RolePermissionsDirective = ($repo, $confirm) ->
|
||||||
categories = generateCategoriesFromRole(role)
|
categories = generateCategoriesFromRole(role)
|
||||||
categoryId = target.parents(".category-config").data("id")
|
categoryId = target.parents(".category-config").data("id")
|
||||||
renderResume(target.parents(".category-config"), categories[categoryId])
|
renderResume(target.parents(".category-config"), categories[categoryId])
|
||||||
|
$rootscope.$broadcast("projects:reload")
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
@ -332,4 +333,4 @@ RolePermissionsDirective = ($repo, $confirm) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgRolePermissions", ['$tgRepo', '$tgConfirm', RolePermissionsDirective])
|
module.directive("tgRolePermissions", ["$rootScope", "$tgRepo", "$tgConfirm", RolePermissionsDirective])
|
||||||
|
|
|
@ -37,9 +37,14 @@ class ProjectsNavigationController extends taiga.Controller
|
||||||
console.log "FAIL"
|
console.log "FAIL"
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
# Listen when someone wants to reload all the projects
|
||||||
@scope.$on "projects:reload", =>
|
@scope.$on "projects:reload", =>
|
||||||
@.loadInitialData()
|
@.loadInitialData()
|
||||||
|
|
||||||
|
# Listen when someone has reloaded a project
|
||||||
|
@scope.$on "project:loaded", (ctx, project) =>
|
||||||
|
@.loadInitialData()
|
||||||
|
|
||||||
loadInitialData: ->
|
loadInitialData: ->
|
||||||
return @rs.projects.list().then (projects) =>
|
return @rs.projects.list().then (projects) =>
|
||||||
for project in projects
|
for project in projects
|
||||||
|
|
|
@ -3,7 +3,7 @@ bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
module = angular.module("taigaProject")
|
module = angular.module("taigaProject")
|
||||||
|
|
||||||
CreateProject = ($repo, $confirm, $location, $navurls, $rs, lightboxService) ->
|
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, lightboxService) ->
|
||||||
link = ($scope, $el, attrs) ->
|
link = ($scope, $el, attrs) ->
|
||||||
$scope.data = {}
|
$scope.data = {}
|
||||||
$scope.templates = []
|
$scope.templates = []
|
||||||
|
@ -18,6 +18,7 @@ CreateProject = ($repo, $confirm, $location, $navurls, $rs, lightboxService) ->
|
||||||
fullUrl = $navurls.formatUrl(url, {'project': response.slug})
|
fullUrl = $navurls.formatUrl(url, {'project': response.slug})
|
||||||
|
|
||||||
$location.url(fullUrl)
|
$location.url(fullUrl)
|
||||||
|
$rootscope.$broadcast("projects:reload")
|
||||||
|
|
||||||
onErrorSubmit = (response) ->
|
onErrorSubmit = (response) ->
|
||||||
$confirm.notify("light-error", "According to our Oompa Loompas, project name is
|
$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}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgLbCreateProject", [
|
module.directive("tgLbCreateProject", [
|
||||||
|
"$rootScope",
|
||||||
"$tgRepo",
|
"$tgRepo",
|
||||||
"$tgConfirm",
|
"$tgConfirm",
|
||||||
"$location",
|
"$location",
|
||||||
|
|
Loading…
Reference in New Issue