mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 11:03:40 +00:00
Allow root doc to be set
This commit is contained in:
parent
a3a5aa1c0d
commit
2b85ebf8ec
3 changed files with 49 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 () =>
|
||||
|
|
Loading…
Add table
Reference in a new issue