Update corpus analysis extensions to use dynamic id prefixes for elements

This commit is contained in:
Patrick Jentsch 2023-08-08 12:21:47 +02:00
parent 661ac7c509
commit 766c5ba27d
6 changed files with 28 additions and 28 deletions

View File

@ -1,23 +1,22 @@
class CorpusAnalysisConcordance { class CorpusAnalysisConcordance {
name = 'Concordance'; name = 'Concordance';
constructor(app) { constructor(app, idPrefix) {
this.app = app; this.app = app;
this.data = {}; this.data = {};
this.elements = { this.elements = {
// TODO: Prefix elements with "corpus-analysis-app-" container: document.querySelector(`#${idPrefix}-container`),
container: document.querySelector('#concordance-extension-container'), error: document.querySelector(`#${idPrefix}-error`),
error: document.querySelector('#concordance-extension-error'), UIForm: document.querySelector(`#${idPrefix}-ui-form`),
UIForm: document.querySelector('#concordance-extension-ui-form'), form: document.querySelector(`#${idPrefix}-form`),
form: document.querySelector('#concordance-extension-form'), progress: document.querySelector(`#${idPrefix}-progress`),
progress: document.querySelector('#concordance-extension-progress'), subcorpusInfo: document.querySelector(`#${idPrefix}-subcorpus-info`),
subcorpusInfo: document.querySelector('#concordance-extension-subcorpus-info'), subcorpusActions: document.querySelector(`#${idPrefix}-subcorpus-actions`),
subcorpusActions: document.querySelector('#concordance-extension-subcorpus-actions'), subcorpusItems: document.querySelector(`#${idPrefix}-subcorpus-items`),
subcorpusItems: document.querySelector('#concordance-extension-subcorpus-items'), subcorpusList: document.querySelector(`#${idPrefix}-subcorpus-list`),
subcorpusList: document.querySelector('#concordance-extension-subcorpus-list'), subcorpusPagination: document.querySelector(`#${idPrefix}-subcorpus-pagination`)
subcorpusPagination: document.querySelector('#concordance-extension-subcorpus-pagination')
}; };
this.settings = { this.settings = {
@ -383,7 +382,9 @@ class CorpusAnalysisConcordance {
document.getSelection().removeAllRanges(); document.getSelection().removeAllRanges();
document.getSelection().addRange(range); document.getSelection().addRange(range);
}); });
this.app.elements.m.extensionTabs.select('reader-extension-container'); this.app.elements.m.extensionTabs.select(
this.app.extensions.Reader.elements.container.id
);
}); });
} }
for (let selectTriggerElement of this.elements.subcorpusItems.querySelectorAll('.select-trigger')) { for (let selectTriggerElement of this.elements.subcorpusItems.querySelectorAll('.select-trigger')) {

View File

@ -1,19 +1,18 @@
class CorpusAnalysisReader { class CorpusAnalysisReader {
name = 'Reader'; name = 'Reader';
constructor(app) { constructor(app, idPrefix) {
this.app = app; this.app = app;
this.data = {}; this.data = {};
this.elements = { this.elements = {
// TODO: Prefix elements with "corpus-analysis-app-" container: document.querySelector(`#${idPrefix}-container`),
container: document.querySelector('#reader-extension-container'), error: document.querySelector(`#${idPrefix}-error`),
error: document.querySelector('#reader-extension-error'), form: document.querySelector(`#${idPrefix}-form`),
form: document.querySelector('#reader-extension-form'), progress: document.querySelector(`#${idPrefix}-progress`),
progress: document.querySelector('#reader-extension-progress'), corpus: document.querySelector(`#${idPrefix}-corpus`),
corpus: document.querySelector('#reader-extension-corpus'), corpusPagination: document.querySelector(`#${idPrefix}-corpus-pagination`)
corpusPagination: document.querySelector('#reader-extension-corpus-pagination')
}; };
this.settings = { this.settings = {

View File

@ -170,7 +170,7 @@
{# The extension scripts #} {# The extension scripts #}
{% macro scripts(id_prefix) %} {% macro scripts(id_prefix) %}
<script> <script>
const corpusAnalysisConcordance = new CorpusAnalysisConcordance(corpusAnalysisApp); const corpusAnalysisConcordance = new CorpusAnalysisConcordance(corpusAnalysisApp, "{{ id_prefix }}");
{# const concordanceQueryBuilder = new ConcordanceQueryBuilder(); #} {# const concordanceQueryBuilder = new ConcordanceQueryBuilder(); #}
let queryBuilderDisplay = document.getElementById("{{ id_prefix }}-query-builder-display"); let queryBuilderDisplay = document.getElementById("{{ id_prefix }}-query-builder-display");

View File

@ -79,6 +79,6 @@
{# The extension scripts #} {# The extension scripts #}
{% macro scripts(id_prefix) %} {% macro scripts(id_prefix) %}
<script> <script>
const corpusAnalysisReader = new CorpusAnalysisReader(corpusAnalysisApp); const corpusAnalysisReader = new CorpusAnalysisReader(corpusAnalysisApp, "{{ id_prefix }}");
</script> </script>
{% endmacro %} {% endmacro %}

View File

@ -158,7 +158,7 @@
{% macro scripts(id_prefix) %} {% macro scripts(id_prefix) %}
<script> <script>
const corpusAnalysisStaticVisualization = new CorpusAnalysisStaticVisualization(corpusAnalysisApp); const corpusAnalysisStaticVisualization = new CorpusAnalysisStaticVisualization(corpusAnalysisApp, "{{ id_prefix }}");
</script> </script>
{% endmacro %} {% endmacro %}

View File

@ -6,9 +6,9 @@
{% set extensions = {% set extensions =
{ {
'concordance-extension': concordance_extension, 'corpus-analysis-app-concordance-extension': concordance_extension,
'reader-extension': reader_extension, 'corpus-analysis-app-reader-extension': reader_extension,
'static-visualizations-extension': static_visualization_extension 'corpus-analysis-app-static-visualizations-extension': static_visualization_extension
} }
%} %}
@ -42,7 +42,7 @@
{% endfor %} {% endfor %}
</div> </div>
{{ static_visualization_extension.container_content('static-visualizations-extension') }} {{ static_visualization_extension.container_content('corpus-analysis-app-static-visualizations-extension') }}
</div> </div>