Set up feature flag for references autocomplete.

This commit is contained in:
Shane Kilkelly 2016-01-26 16:35:58 +00:00
parent d1e53f0cb8
commit 6e3dba52e5
2 changed files with 13 additions and 24 deletions

View file

@ -72,13 +72,15 @@ define [
result.push(referenceKeyToAutocompleteEntry(key))
callback null, result
else
# get keys from the backend
referencesSearch = window?._ide?.referencesSearchManager
if referencesSearch
referencesSearch.getReferenceKeys (keys) =>
keys.forEach (key) ->
result.push(referenceKeyToAutocompleteEntry(key))
callback null, result
callback null, result
# else
# # get keys from the backend
# referencesSearch = window?._ide?.referencesSearchManager
# if referencesSearch
# referencesSearch.getReferenceKeys (keys) =>
# keys.forEach (key) ->
# result.push(referenceKeyToAutocompleteEntry(key))
# callback null, result
@editor.completers = [@suggestionManager, SnippetCompleter, ReferencesCompleter]

View file

@ -24,12 +24,13 @@ define [
)
_storeReferencesKeys: (newKeys) ->
if window._ENABLE_REFERENCES_AUTOCOMPLETE != true
return
console.log '>> storing references keys'
@$scope.$root._references.keys = newKeys
# docIds: List[String]|String('ALL'), shouldBroadcast: Bool
indexReferences: (docIds, shouldBroadcast) ->
if window._ENABLE_REFERENCES_AUTOCOMPLETE != true
return
opts =
docIds: docIds
shouldBroadcast: shouldBroadcast
@ -38,20 +39,6 @@ define [
"/project/#{@$scope.project_id}/references/index",
opts,
(data) =>
console.log ">> done ", data
console.log ">> got keys ", data
@_storeReferencesKeys(data.keys)
)
getReferenceKeys: (callback=(keys)->) ->
if window._ENABLE_REFERENCES_AUTOCOMPLETE != true
return
$.get(
"/project/#{@$scope.project_id}/references/keys",
{
_csrf: window.csrfToken
},
(data) =>
@_storeReferencesKeys(data.keys)
if callback
callback(data.keys)
)