Commit b3281dc9 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

minor fixes to text range (no unnecessary API calls) and vocabulary check...

minor fixes to text range (no unnecessary API calls) and vocabulary check (update corpus display after corpus change)
parent ebe582b7
{
"name": "mc_frontend",
"version": "0.9.2",
"version": "0.9.4",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......
......@@ -330,7 +330,7 @@ export class CorpusService {
this.currentCorpus = HelperService.mostRecentSetup.currentCorpus;
this.currentTextRange = HelperService.mostRecentSetup.currentTextRange;
this.isTextRangeCorrect = true;
if (Object.keys(this.annisResponse.graph).length) {
if (this.annisResponse && Object.keys(this.annisResponse.graph).length) {
this.processAnnisResponse(this.annisResponse, false);
}
// check if the data is already present
......
......@@ -151,7 +151,9 @@ export class HelperService {
}
static goToVocabularyCheckPage(navCtrl: NavController) {
navCtrl.navigateForward('/vocabulary-check').then();
navCtrl.navigateForward('/vocabulary-check').then(() => {
HelperService.isVocabularyCheck = true;
});
}
static loadTranslations(translate: TranslateService) {
......
......@@ -78,14 +78,14 @@ export class TextRangePage {
}
private addReferences(targetCitationLevel: string, relevantCitations: Citation[] = []) {
if (relevantCitations.some(x => !x)) {
return new Promise((resolve) => resolve());
}
const urnLastPart: string = relevantCitations.map(x => x.value.toString()).join('.');
const fullUrn: string = this.corpusService.currentCorpus.source_urn + (urnLastPart ? ':' + urnLastPart : '');
HelperService.currentError = null;
HelperService.isLoading = true;
return new Promise((resolve, reject) => {
if (relevantCitations.some(x => !x)) {
resolve();
}
const urnLastPart: string = relevantCitations.map(x => x.value.toString()).join('.');
const fullUrn: string = this.corpusService.currentCorpus.source_urn + (urnLastPart ? ':' + urnLastPart : '');
HelperService.currentError = null;
HelperService.isLoading = true;
this.corpusService.getCTSvalidReff(fullUrn).subscribe((result: string[]) => {
HelperService.isLoading = false;
const newCitations: Citation[] = [];
......@@ -319,7 +319,8 @@ export class TextRangePage {
this.resetCitations();
return new Promise(resolve => {
const baseCit: Citation = this.corpusService.currentCorpus.citations[relTextRangePart[0]];
if (baseCit && Object.keys(baseCit.subcitations).length) {
if (baseCit && (Object.keys(baseCit.subcitations).length ||
this.corpusService.currentCorpus.citation_level_2 === CitationLevel[CitationLevel.default])) {
resolve();
} else {
this.addReferences(this.corpusService.currentCorpus.citation_level_2, [baseCit]).then(() => {
......
import {NavController, ToastController} from '@ionic/angular';
import {Component, OnInit} from '@angular/core';
import {AfterViewInit, Component, OnInit} from '@angular/core';
import {VocabularyCorpus, VocabularyCorpusTranslation} from 'src/app/models/enum';
import {VocabularyService} from 'src/app/vocabulary.service';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
......@@ -14,7 +14,7 @@ import {CorpusService} from 'src/app/corpus.service';
templateUrl: './vocabulary-check.page.html',
styleUrls: ['./vocabulary-check.page.scss'],
})
export class VocabularyCheckPage implements OnInit {
export class VocabularyCheckPage implements AfterViewInit {
HelperService = HelperService;
invalidSentenceCountString: string;
ObjectKeys = Object.keys;
......@@ -85,6 +85,15 @@ export class VocabularyCheckPage implements OnInit {
return this.vocService.refVocMap[this.vocService.currentReferenceVocabulary].possibleSubcounts[0];
}
ngAfterViewInit(): void {
// dirty hack to avoid ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
this.currentCorpusString = this.corpusService.currentCorpus.author + ': ' + this.corpusService.currentCorpus.title + ' ' +
this.corpusService.currentTextRange.start.filter(x => x).join('.') + '-' +
this.corpusService.currentTextRange.end.filter(x => x).join('.');
}, 0);
}
private processSentences(sentences: Sentence[]) {
if (sentences.length > this.vocService.desiredSentenceCount) {
this.currentRankingUnits.push([]);
......@@ -111,12 +120,6 @@ export class VocabularyCheckPage implements OnInit {
this.vocService.ranking = this.currentRankingUnits;
}
ngOnInit(): void {
this.currentCorpusString = this.corpusService.currentCorpus.author + ': ' + this.corpusService.currentCorpus.title + ' ' +
this.corpusService.currentTextRange.start.filter(x => x).join('.') + '-' +
this.corpusService.currentTextRange.end.filter(x => x).join('.');
}
updateReferenceRange() {
const hasFreq: boolean = this.vocService.refVocMap[this.vocService.currentReferenceVocabulary].hasFrequencyOrder;
this.vocService.frequencyUpperBound = hasFreq ? 500 : this.getPossibleSubCount();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment