Move the labels event logic into ide/labels/LabelsManager

This commit is contained in:
Shane Kilkelly 2017-06-13 13:29:03 +01:00
parent a04eb1197d
commit 954c53aec6
2 changed files with 18 additions and 8 deletions

View file

@ -9,6 +9,7 @@ define [
"ide/pdf/PdfManager"
"ide/binary-files/BinaryFilesManager"
"ide/references/ReferencesManager"
"ide/labels/LabelsManager"
"ide/review-panel/ReviewPanelManager"
"ide/SafariScrollPatcher"
"ide/FeatureOnboardingController"
@ -45,6 +46,7 @@ define [
PdfManager
BinaryFilesManager
ReferencesManager
LabelsManager
ReviewPanelManager
SafariScrollPatcher
) ->
@ -126,16 +128,10 @@ define [
ide.pdfManager = new PdfManager(ide, $scope)
ide.permissionsManager = new PermissionsManager(ide, $scope)
ide.binaryFilesManager = new BinaryFilesManager(ide, $scope)
ide.labelsManager = new LabelsManager(ide, $scope, labels)
# Set up labels
# TODO: figure out angular init order and move this
# code somewhere more appropriate
ide.socket.on 'broadcastDocLabels', (data) ->
labels.onBroadcastDocLabels(data)
$scope.$on 'entity:deleted', labels.onEntityDeleted
$scope.$on 'file:upload:complete', labels.fileUploadComplete
$timeout () ->
labels.loadProjectLabelsFromServer()
ide.labelsManager.loadProjectLabelsFromServer()
inited = false
$scope.$on "project:joined", () ->

View file

@ -0,0 +1,14 @@
define [
], () ->
class LabelsManager
constructor: (@ide, @$scope, @labels) ->
@ide.socket.on 'broadcastDocLabels', (data) =>
@labels.onBroadcastDocLabels(data)
@$scope.$on 'entity:deleted', @labels.onEntityDeleted
@$scope.$on 'file:upload:complete', @labels.fileUploadComplete
loadProjectLabelsFromServer: () ->
@labels.loadProjectLabelsFromServer()