Skip to content

Commit eb729dd

Browse files
committed
[academic_query] change observer situation WIP
SQUASHED: AUTO-COMMIT-src-components-widgets-academic-query.js,AUTO-COMMIT-src-components-widgets-academic-subquery.js,
1 parent 729123e commit eb729dd

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/components/widgets/academic-query.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Morph from 'src/components/widgets/lively-morph.js';
22
import AcademicSubquery from "src/components/widgets/academic-subquery.js";
33

4+
var timeout;
5+
46
export default class AcademicQuery extends Morph {
57
constructor() {
68
super();
@@ -16,14 +18,17 @@ export default class AcademicQuery extends Morph {
1618
// irgendwo unter ihm Text ändert
1719
var observer = new MutationObserver((mutations) => {
1820
mutations.forEach(async mutation => {
19-
//lively.notify("SUPER observation", mutation.type)
20-
if (mutation.type == "childList") {
21-
if (this.subquery) {
22-
this.textContent = await this.subquery.viewToQuery();
23-
var input = this.get('#queryInput');
24-
input.value = this.getQuery();
21+
lively.notify("SUPER observation", mutation.type)
22+
clearTimeout(timeout);
23+
timeout = setTimeout(async () => {
24+
if (mutation.type == "childList") {
25+
if (this.subquery) {
26+
this.textContent = await this.subquery.viewToQuery();
27+
var input = this.get('#queryInput');
28+
input.value = this.getQuery();
29+
}
2530
}
26-
}
31+
}, 1000);
2732
})
2833
});
2934

src/components/widgets/academic-subquery.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ s.addOperation(
123123
)
124124

125125
var observer;
126-
var timeout;
127126

128127
export default class AcademicSubquery extends Morph {
129128
constructor() {
@@ -134,22 +133,16 @@ export default class AcademicSubquery extends Morph {
134133
this.updateView()
135134

136135
observer = new MutationObserver((mutations) => {
137-
mutations.forEach(mutation => {
138-
//lively.notify("observation", mutation.type)
139-
clearTimeout(timeout);
140-
timeout = setTimeout(async () => {
141-
if (mutation.type == "characterData") {
142-
this.textContent = await this.viewToQuery();
143-
}
144-
if (mutation.type == "childList") {
145-
clearTimeout(timeout);
146-
//timeout = setTimeout(() => {
147-
var div = <div id="update"></div>;
148-
this.appendChild(div);
149-
this.removeChild(div);
150-
//}, 3000);
151-
}
152-
}, 1000);
136+
mutations.forEach(async mutation => {
137+
if (mutation.type == "characterData") {
138+
this.textContent = await this.viewToQuery();
139+
}
140+
if (mutation.type == "childList") {
141+
// TODO: better propagation to super elements
142+
var div = <div id="update"></div>;
143+
this.appendChild(div);
144+
this.removeChild(div);
145+
}
153146
})
154147
});
155148

@@ -389,13 +382,13 @@ export default class AcademicSubquery extends Morph {
389382
class="button"
390383
click={() => {
391384
this.setQuery(
392-
"And(" + this.textContent + ", A='Placeholder')")
385+
"And(" + this.textContent + ", " + this.textContent + ")")
393386
}}>AND</button>
394387
<button
395388
class="button"
396389
click={() => {
397390
this.setQuery(
398-
"Or(" + this.textContent + ", A='Placeholder')")
391+
"Or(" + this.textContent + ", " + this.textContent + ")")
399392
}}>OR</button>
400393
</span>
401394
</span>;

0 commit comments

Comments
 (0)