Просмотр исходного кода

allow getting doc paths by project id

Brian Gough 8 лет назад
Родитель
Сommit
418bc10a18

+ 6 - 0
services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee

@@ -65,6 +65,12 @@ module.exports = ProjectEntityHandler = self =
 						files.push({path: path.join(folderPath, file.name), file:file})
 						files.push({path: path.join(folderPath, file.name), file:file})
 			callback null, docs, files
 			callback null, docs, files
 
 
+	getAllDocPathsFromProjectById: (project_id, callback) ->
+		ProjectGetter.getProjectWithoutDocLines project_id, (err, project) ->
+			return callback(err) if err?
+			return callback(Errors.NotFoundError("no project")) if !project?
+			self.getAllDocPathsFromProject project, callback
+
 	getAllDocPathsFromProject: (project, callback) ->
 	getAllDocPathsFromProject: (project, callback) ->
 		logger.log project:project, "getting all docs for project"
 		logger.log project:project, "getting all docs for project"
 		self._getAllFoldersFromProject project, (err, folders = {}) ->
 		self._getAllFoldersFromProject project, (err, folders = {}) ->

+ 1 - 1
services/web/app/coffee/Features/Project/ProjectRootDocManager.coffee

@@ -33,7 +33,7 @@ module.exports = ProjectRootDocManager =
 					callback()
 					callback()
 
 
 	setRootDocFromName: (project_id, rootDocName, callback = (error) ->) ->
 	setRootDocFromName: (project_id, rootDocName, callback = (error) ->) ->
-		ProjectEntityHandler.getAllDocPathsFromProject project_id, (error, docPaths) ->
+		ProjectEntityHandler.getAllDocPathsFromProjectById project_id, (error, docPaths) ->
 			return callback(error) if error?
 			return callback(error) if error?
 			# find the root doc from the filename
 			# find the root doc from the filename
 			root_doc_id = null
 			root_doc_id = null

+ 7 - 7
services/web/test/unit/coffee/Project/ProjectRootDocManagerTests.coffee

@@ -83,12 +83,12 @@ describe 'ProjectRootDocManager', ->
 					"doc-id-2": "/main.tex"
 					"doc-id-2": "/main.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
-				@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectRootDocManager.setRootDocFromName @project_id, '/main.tex', done
 				@ProjectRootDocManager.setRootDocFromName @project_id, '/main.tex', done
 
 
 			it "should check the docs of the project", ->
 			it "should check the docs of the project", ->
-				@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
 					.should.equal true
 					.should.equal true
 
 
 			it "should set the root doc to main.tex", ->
 			it "should set the root doc to main.tex", ->
@@ -102,12 +102,12 @@ describe 'ProjectRootDocManager', ->
 					"doc-id-2": "/main.tex"
 					"doc-id-2": "/main.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
-				@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectRootDocManager.setRootDocFromName @project_id, 'main.tex', done
 				@ProjectRootDocManager.setRootDocFromName @project_id, 'main.tex', done
 
 
 			it "should check the docs of the project", ->
 			it "should check the docs of the project", ->
-				@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
 					.should.equal true
 					.should.equal true
 
 
 			it "should set the root doc to main.tex", ->
 			it "should set the root doc to main.tex", ->
@@ -121,12 +121,12 @@ describe 'ProjectRootDocManager', ->
 					"doc-id-2": "/main.tex"
 					"doc-id-2": "/main.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
-				@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectRootDocManager.setRootDocFromName @project_id, 'chapter1a.tex', done
 				@ProjectRootDocManager.setRootDocFromName @project_id, 'chapter1a.tex', done
 
 
 			it "should check the docs of the project", ->
 			it "should check the docs of the project", ->
-				@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
 					.should.equal true
 					.should.equal true
 
 
 			it "should set the root doc using the basename", ->
 			it "should set the root doc using the basename", ->
@@ -140,7 +140,7 @@ describe 'ProjectRootDocManager', ->
 					"doc-id-2": "/main.tex"
 					"doc-id-2": "/main.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-3": "/nested/chapter1a.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
 					"doc-id-4": "/nested/chapter1b.tex"
-				@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
+				@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
 				@ProjectRootDocManager.setRootDocFromName @project_id, "other.tex", done
 				@ProjectRootDocManager.setRootDocFromName @project_id, "other.tex", done