Editing Meta Data and Tokens

This commit is contained in:
Inga Kirschnick 2023-10-09 16:30:46 +02:00
parent 14c10aeab1
commit d3cfd2cfaf
3 changed files with 48 additions and 7 deletions

View File

@ -128,6 +128,47 @@ class GeneralFunctionsQueryBuilder {
let selection = isEnglishEntType ? this.elements.englishEntTypeSelection : this.elements.germanEntTypeSelection;
this.resetMaterializeSelection([selection], entType);
break;
case 'text-annotation':
this.elements.structuralAttrModal.open();
this.toggleClass(['text-annotation-builder'], 'hide', 'remove');
this.toggleEditingAreaStructureAttrModal('add');
let [textAnnotationSelection, textAnnotationContent] = queryChipElement.dataset.query
.replace(/:: ?match\.text_|"|"/g, '')
.split('=');
this.resetMaterializeSelection([this.elements.textAnnotationSelection], textAnnotationSelection);
this.elements.textAnnotationInput.value = textAnnotationContent;
break;
case 'token':
let [tokenAttr, tokenValue] = queryChipElement.dataset.query.replace(/\[|\]|"/g, '').split('=');
if (tokenAttr === 'pos') {
tokenAttr = this.elements.englishPosSelection.querySelector(`option[value=${tokenValue}]`) ? 'english-pos' : 'german-pos';
}
this.editTokenChipElement(tokenAttr, tokenValue);
break;
default:
break;
}
}
editTokenChipElement(tokenAttr, tokenValue) {
this.resetMaterializeSelection([this.elements.positionalAttrSelection], tokenAttr);
this.elements.positionalAttrModal.open();
switch (tokenAttr) {
case 'word':
this.elements.wordInput.value = tokenValue;
break;
case 'lemma':
this.elements.lemmaInput.value = tokenValue;
break;
case 'english-pos':
this.resetMaterializeSelection([this.elements.englishPosSelection], tokenValue);
break;
case 'german-pos':
this.resetMaterializeSelection([this.elements.germanPosSelection], tokenValue);
break;
case 'simple-pos':
this.resetMaterializeSelection([this.elements.simplePosSelection], tokenValue);
break;
default:
break;
}

View File

@ -82,7 +82,7 @@ class StructuralAttributeBuilderFunctionsQueryBuilder extends GeneralFunctionsQu
}, 3000);
} else {
let queryText = `:: match.text_${textAnnotationOptions.value}="${textAnnotationInput.value}"`;
this.submitQueryChipElement('text-annotation', `${textAnnotationOptions.value}=${textAnnotationInput.value}`, queryText);
this.submitQueryChipElement('text-annotation', `${textAnnotationOptions.value}=${textAnnotationInput.value}`, queryText, null, false, true);
this.elements.structuralAttrModal.close();
}
}

View File

@ -38,7 +38,8 @@ class TokenAttributeBuilderFunctionsQueryBuilder extends GeneralFunctionsQueryBu
this.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'add');
document.querySelector('#corpus-analysis-concordance-positional-attr-selection option[value="word"]').selected = true;
this.elements.wordInput.value = '';
this.elements.lemmaInput.value = '';
this.resetMaterializeSelection([this.elements.englishPosSelection, this.elements.germanPosSelection, this.elements.simplePosSelection]);
this.resetMaterializeSelection([this.elements.positionalAttrSelection], "word");
this.elements.editingModusOn = false;
@ -47,6 +48,7 @@ class TokenAttributeBuilderFunctionsQueryBuilder extends GeneralFunctionsQueryBu
preparePositionalAttrModal() {
let selection = this.elements.positionalAttrSelection.value;
this.toggleClass(['word', 'lemma', 'english-pos', 'german-pos', 'simple-pos'], 'hide', 'add');
if (selection !== 'empty-token') {
this.toggleClass([selection], 'hide', 'remove');
this.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'add');
@ -80,10 +82,8 @@ class TokenAttributeBuilderFunctionsQueryBuilder extends GeneralFunctionsQueryBu
}
optionToggleHandler() {
let input;
input = this.tokenInputCheck();
if (input.value === '' || input.value === 'default') {
let input = this.tokenInputCheck();
if ((input.value === '' || input.value === 'default') && this.elements.editingModusOn === false) {
this.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'add');
} else {
this.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'remove');
@ -182,7 +182,7 @@ class TokenAttributeBuilderFunctionsQueryBuilder extends GeneralFunctionsQueryBu
// isTokenQueryInvalid looks if a valid value is passed. If the input fields/dropdowns are empty (isTokenQueryInvalid === true), no token is added.
if (this.elements.isTokenQueryInvalid === false) {
tokenQueryCQLText = '[' + tokenQueryCQLText + ']';
this.submitQueryChipElement('token', tokenQueryPrettyText, tokenQueryCQLText);
this.submitQueryChipElement('token', tokenQueryPrettyText, tokenQueryCQLText, null, false, true);
this.elements.positionalAttrModal.close();
}
}