Refresh the references when the bib file is closed.

This commit is contained in:
Shane Kilkelly 2015-12-17 15:13:02 +00:00
parent 249dd638ec
commit 1ea13a74dd
4 changed files with 25 additions and 4 deletions

View file

@ -21,9 +21,6 @@ module.exports = ReferencesSearchController =
logger.err {err, project_id, user_id, doc_id}, "error finding element for downloading file"
return res.send 500
doc_url = ReferencesSearchController._buildDocUrl project_id, doc_id
console.log ">>"
console.log doc, doc_url
console.log "<<"
ReferencesSearchHandler.indexFile user_id, doc_url, (err) ->
if err
logger.err {err, project_id, user_id, doc_id}, "error indexing references file"

View file

@ -8,6 +8,7 @@ define [
"ide/permissions/PermissionsManager"
"ide/pdf/PdfManager"
"ide/binary-files/BinaryFilesManager"
"ide/references-search/ReferencesSearchManager"
"ide/settings/index"
"ide/share/index"
"ide/chat/index"
@ -37,6 +38,7 @@ define [
PermissionsManager
PdfManager
BinaryFilesManager
ReferencesSearchManager
) ->
App.controller "IdeController", ($scope, $timeout, ide, localStorage) ->
@ -80,6 +82,7 @@ define [
ide.pdfManager = new PdfManager(ide, $scope)
ide.permissionsManager = new PermissionsManager(ide, $scope)
ide.binaryFilesManager = new BinaryFilesManager(ide, $scope)
ide.referencesSearchManager = new ReferencesSearchManager(ide, $scope)
inited = false
$scope.$on "project:joined", () ->

View file

@ -36,6 +36,7 @@ define [
@doc?.detachFromAce()
editorDoc = @ace?.getSession().getDocument()
editorDoc?.off "change", @_checkConsistency
@ide.$scope.$emit 'document:closed', @doc
_checkConsistency: () ->
# We've been seeing a lot of errors when I think there shouldn't be

View file

@ -0,0 +1,20 @@
define [
], () ->
class ReferencesSearchManager
constructor: (@ide, @$scope) ->
console.log ">> yay"
@$scope.$on 'document:closed', (e, doc) =>
if doc.doc_id
entity = @ide.fileTreeManager.findEntityById doc.doc_id
if entity?.name?.match /.*\.bib$/
@$scope.$emit 'references:changed', entity
console.log ">> references changed"
@indexReferences doc.doc_id
indexReferences: (doc_id) ->
console.log ">> doc id #{doc_id}"
$.post("/project/#{@$scope.project_id}/references", {
docId: doc_id,
_csrf: window.csrfToken
}, (data) => console.log(data))