diff --git a/services/web/app/views/project/editor/left-menu.jade b/services/web/app/views/project/editor/left-menu.jade index 3588ae8e27..f6f514f8e1 100644 --- a/services/web/app/views/project/editor/left-menu.jade +++ b/services/web/app/views/project/editor/left-menu.jade @@ -68,6 +68,14 @@ aside#left-menu.full-size( option(value='latex') LaTeX option(value='xelatex') XeLaTeX option(value='lualatex') LuaLaTeX + + .form-controls + label(for="rootDoc_id") Main document + select( + name="rootDoc_id", + ng-model="project.rootDoc_id", + ng-options="doc.doc.id as doc.path for doc in docs" + ) .form-controls label(for="spellCheckLanguage") Spell Check diff --git a/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee b/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee index 747c23c136..167efa3005 100644 --- a/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee +++ b/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee @@ -13,6 +13,10 @@ define [ @loadRootFolder() @loadDeletedDocs() @$scope.$emit "file-tree:initialized" + + @$scope.$watch "rootFolder", (rootFolder) => + if rootFolder? + @recalculateDocList() @_bindToSocketEvents() @@ -116,17 +120,21 @@ define [ return @_findEntityByPathInFolder(entity, rest) return null - forEachEntity: (callback = (entity, parent_folder) ->) -> - @_forEachEntityInFolder(@$scope.rootFolder, callback) + forEachEntity: (callback = (entity, parent_folder, path) ->) -> + @_forEachEntityInFolder(@$scope.rootFolder, null, callback) for entity in @$scope.deletedDocs or [] callback(entity) - _forEachEntityInFolder: (folder, callback) -> + _forEachEntityInFolder: (folder, path, callback) -> for entity in folder.children or [] - callback(entity, folder) + if path? + childPath = path + "/" + entity.name + else + childPath = entity.name + callback(entity, folder, childPath) if entity.children? - @_forEachEntityInFolder(entity, callback) + @_forEachEntityInFolder(entity, childPath, callback) getEntityPath: (entity) -> @_getEntityPathInFolder @$scope.rootFolder, entity @@ -195,6 +203,28 @@ define [ type: "doc" deleted: true } + + recalculateDocList: () -> + @$scope.docs = [] + @forEachEntity (entity, parentFolder, path) => + if entity.type == "doc" and !entity.deleted + @$scope.docs.push { + doc: entity + path: path + } + + getEntityPath: (entity) -> + @_getEntityPathInFolder @$scope.rootFolder, entity + + _getEntityPathInFolder: (folder, entity) -> + for child in folder.children or [] + if child == entity + return entity.name + else if child.type == "folder" + path = @_getEntityPathInFolder(child, entity) + if path? + return child.name + "/" + path + return null getCurrentFolder: () -> # Return the root folder if nothing is selected diff --git a/services/web/public/coffee/ide/settings/controllers/SettingsController.coffee b/services/web/public/coffee/ide/settings/controllers/SettingsController.coffee index bc7f18a649..c032ca20ce 100644 --- a/services/web/public/coffee/ide/settings/controllers/SettingsController.coffee +++ b/services/web/public/coffee/ide/settings/controllers/SettingsController.coffee @@ -40,6 +40,12 @@ define [ if oldCompiler? and compiler != oldCompiler settings.saveProjectSettings({compiler: compiler}) + $scope.$watch "project.rootDoc_id", (rootDoc_id, oldRootDoc_id) => + return if @ignoreUpdates + if oldRootDoc_id? and rootDoc_id != oldRootDoc_id + settings.saveProjectSettings({rootDocId: rootDoc_id}) + + ide.socket.on "compilerUpdated", (compiler) => @ignoreUpdates = true $scope.$apply () =>