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)) result.push(referenceKeyToAutocompleteEntry(key))
callback null, result callback null, result
else else
# get keys from the backend callback null, result
referencesSearch = window?._ide?.referencesSearchManager # else
if referencesSearch # # get keys from the backend
referencesSearch.getReferenceKeys (keys) => # referencesSearch = window?._ide?.referencesSearchManager
keys.forEach (key) -> # if referencesSearch
result.push(referenceKeyToAutocompleteEntry(key)) # referencesSearch.getReferenceKeys (keys) =>
callback null, result # keys.forEach (key) ->
# result.push(referenceKeyToAutocompleteEntry(key))
# callback null, result
@editor.completers = [@suggestionManager, SnippetCompleter, ReferencesCompleter] @editor.completers = [@suggestionManager, SnippetCompleter, ReferencesCompleter]

View file

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