@@ -149,6 +149,7 @@ const config = {
149149}*/
150150
151151var observer ;
152+ var timeout ;
152153
153154export default class AcademicSubquery extends Morph {
154155 constructor ( ) {
@@ -160,16 +161,21 @@ export default class AcademicSubquery extends Morph {
160161
161162 observer = new MutationObserver ( ( mutations ) => {
162163 mutations . forEach ( mutation => {
163- //nach jeder Änderung erstmal nen Timer
164164 //lively.notify("observation", mutation.type)
165- if ( mutation . type == "characterData" ) {
166- this . textContent = this . viewToQuery ( ) ;
167- }
168- if ( mutation . type == "childList" ) {
169- var div = < div id = "update" > </ div > ;
170- this . appendChild ( div ) ;
171- this . removeChild ( div ) ;
172- }
165+
166+ timeout = setTimeout ( async ( ) => {
167+ if ( mutation . type == "characterData" ) {
168+ this . textContent = await this . viewToQuery ( ) ;
169+ }
170+ if ( mutation . type == "childList" ) {
171+ clearTimeout ( timeout ) ;
172+ //timeout = setTimeout(() => {
173+ var div = < div id = "update" > </ div > ;
174+ this . appendChild ( div ) ;
175+ this . removeChild ( div ) ;
176+ //}, 3000);
177+ }
178+ } , 1000 ) ;
173179 } )
174180 } ) ;
175181
@@ -181,6 +187,8 @@ export default class AcademicSubquery extends Morph {
181187 characterDataOldValue : true ,
182188 } ;
183189
190+ // TODO: Why are we switching focus after editing
191+ // once we start observing?
184192 observer . observe ( this . get ( '#pane' ) , config ) ;
185193 }
186194
@@ -202,7 +210,9 @@ export default class AcademicSubquery extends Morph {
202210 async setQueryObject ( o ) {
203211 this . ui = await this . queryToView ( o ) ;
204212
205- this . updateView ( )
213+ this . updateView ( ) ;
214+
215+ return this ;
206216 }
207217
208218 async updateView ( ) {
@@ -214,14 +224,14 @@ export default class AcademicSubquery extends Morph {
214224 }
215225 }
216226
217- viewToQuery ( ) {
227+ async viewToQuery ( ) {
218228 var query = "... parsed from ui"
219229
220230 if ( this . isComplex ) {
221231 // TODO: Why is this neccessary?
222- if ( this . leftSubquery && this . rightSubquery ) {
223- var left = this . leftSubquery . viewToQuery ( )
224- var right = this . rightSubquery . viewToQuery ( )
232+ if ( await this . leftSubquery && await this . rightSubquery ) {
233+ var left = await this . leftSubquery . viewToQuery ( )
234+ var right = await this . rightSubquery . viewToQuery ( )
225235 var conjunction = this . get ( '#conjunction' ) . textContent
226236 query = conjunction + "(" + left + ", " + right + ")" ;
227237 }
@@ -232,6 +242,12 @@ export default class AcademicSubquery extends Morph {
232242 query = attr + comp + "'" + val + "'" ;
233243 }
234244
245+ if ( query == "... parsed from ui" ) {
246+ lively . notify ( "LEFT" , this . leftSubquery )
247+ lively . notify ( "RIGHT" , this . rightSubquery )
248+ lively . notify ( "COMPLEX" , this . isComplex )
249+ }
250+
235251 return query
236252 }
237253
0 commit comments