@@ -11,7 +11,7 @@ import widgets from '../../../widgets'
1111import { renderAutoComplete , AutocompleteDecoration } from './autocompletePicker' // dbpediaParameters
1212
1313import { NamedNode } from 'rdflib'
14- import { wikidataParameters } from './publicData'
14+ // import { wikidataParameters } from './publicData'
1515
1616const WEBID_NOUN = 'Solid ID'
1717
@@ -43,23 +43,29 @@ export async function renderAutocompleteControl (dom:HTMLDocument,
4343 }
4444 return addOneIdAndRefresh ( person , webid )
4545 }
46+
4647 function removeDecorated ( ) {
4748 if ( decoratedAutocomplete ) {
4849 creationArea . removeChild ( decoratedAutocomplete )
4950 decoratedAutocomplete = undefined
5051 }
5152 }
53+
54+ async function displayAutocomplete ( ) {
55+ decoratedAutocomplete = dom . createElement ( 'div' ) as HTMLElement
56+ decoratedAutocomplete . setAttribute ( 'style' , 'display: flex; flex-flow: wrap;' )
57+ decoratedAutocomplete . appendChild ( await renderAutoComplete ( dom , acOptions , decoration , autoCompleteDone ) )
58+ decoratedAutocomplete . appendChild ( acceptButton )
59+ decoratedAutocomplete . appendChild ( cancelButton )
60+ creationArea . appendChild ( decoratedAutocomplete )
61+ }
62+
5263 async function searchButtonHandler ( _event ) {
5364 if ( decoratedAutocomplete ) {
5465 creationArea . removeChild ( decoratedAutocomplete )
5566 decoratedAutocomplete = undefined
5667 } else {
57- decoratedAutocomplete = dom . createElement ( 'div' ) as HTMLElement
58- decoratedAutocomplete . setAttribute ( 'style' , 'display: flex; flex-flow: wrap;' )
59- decoratedAutocomplete . appendChild ( await renderAutoComplete ( dom , acOptions , decoration , autoCompleteDone ) )
60- decoratedAutocomplete . appendChild ( acceptButton )
61- decoratedAutocomplete . appendChild ( cancelButton )
62- creationArea . appendChild ( decoratedAutocomplete )
68+ displayAutocomplete ( )
6369 }
6470 }
6571
@@ -72,8 +78,8 @@ export async function renderAutocompleteControl (dom:HTMLDocument,
7278 // const queryParams = barOptions.queryParameters || wikidataParameters
7379 const acceptButton = widgets . continueButton ( dom )
7480 const cancelButton = widgets . cancelButton ( dom , removeDecorated ) // @@ not in edit case only in temporary case
75- var editButton
76- var editing = true
81+ let editButton
82+ let editing = true
7783
7884 function setVisible ( element :HTMLElement , visible :boolean ) {
7985 element . style . visibility = visible ? 'visible' : 'collapse'
@@ -95,7 +101,7 @@ export async function renderAutocompleteControl (dom:HTMLDocument,
95101 acceptButton, cancelButton, editButton
96102 }
97103
98- var decoratedAutocomplete = undefined as HTMLElement | undefined
104+ let decoratedAutocomplete = undefined as HTMLElement | undefined
99105 // const { dom } = dataBrowserContext
100106 // barOptions = barOptions || {}
101107
@@ -109,17 +115,20 @@ export async function renderAutocompleteControl (dom:HTMLDocument,
109115 const plus = creationArea . appendChild ( widgets . button ( dom , GREEN_PLUS , barOptions . idNoun , greenButtonHandler ) )
110116 widgets . makeDropTarget ( plus , droppedURIHandler , undefined )
111117 }
112- if ( barOptions . dbLookup ) {
118+ if ( barOptions . dbLookup && ! acOptions . currentObject ) {
113119 creationArea . appendChild ( widgets . button ( dom , SEARCH_ICON , barOptions . idNoun , searchButtonHandler ) )
114120 }
115121 if ( barOptions . permanent && barOptions . editable ) {
116- editButton = widgets . button ( dom , icons . iconBase + 'noun_253504.svg' , 'Edit' , _event => {
122+ editButton = widgets . button ( dom , EDIT_ICON , 'Edit' , _event => {
117123 editing = ! editing
118124 syncEditingStatus ( )
119125 } )
120126 creationArea . appendChild ( editButton )
121127 }
122128 }
129+ if ( acOptions . currentObject ) {
130+ displayAutocomplete ( )
131+ }
123132 syncEditingStatus ( )
124133 return creationArea
125134} // renderAutocompleteControl
0 commit comments