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", "name": "mc_frontend",
"version": "0.9.2", "version": "0.9.4",
"author": "Ionic Framework", "author": "Ionic Framework",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"scripts": { "scripts": {
......
...@@ -330,7 +330,7 @@ export class CorpusService { ...@@ -330,7 +330,7 @@ export class CorpusService {
this.currentCorpus = HelperService.mostRecentSetup.currentCorpus; this.currentCorpus = HelperService.mostRecentSetup.currentCorpus;
this.currentTextRange = HelperService.mostRecentSetup.currentTextRange; this.currentTextRange = HelperService.mostRecentSetup.currentTextRange;
this.isTextRangeCorrect = true; this.isTextRangeCorrect = true;
if (Object.keys(this.annisResponse.graph).length) { if (this.annisResponse && Object.keys(this.annisResponse.graph).length) {
this.processAnnisResponse(this.annisResponse, false); this.processAnnisResponse(this.annisResponse, false);
} }
// check if the data is already present // check if the data is already present
......
...@@ -151,7 +151,9 @@ export class HelperService { ...@@ -151,7 +151,9 @@ export class HelperService {
} }
static goToVocabularyCheckPage(navCtrl: NavController) { static goToVocabularyCheckPage(navCtrl: NavController) {
navCtrl.navigateForward('/vocabulary-check').then(); navCtrl.navigateForward('/vocabulary-check').then(() => {
HelperService.isVocabularyCheck = true;
});
} }
static loadTranslations(translate: TranslateService) { static loadTranslations(translate: TranslateService) {
......
...@@ -78,14 +78,14 @@ export class TextRangePage { ...@@ -78,14 +78,14 @@ export class TextRangePage {
} }
private addReferences(targetCitationLevel: string, relevantCitations: Citation[] = []) { 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) => { 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[]) => { this.corpusService.getCTSvalidReff(fullUrn).subscribe((result: string[]) => {
HelperService.isLoading = false; HelperService.isLoading = false;
const newCitations: Citation[] = []; const newCitations: Citation[] = [];
...@@ -319,7 +319,8 @@ export class TextRangePage { ...@@ -319,7 +319,8 @@ export class TextRangePage {
this.resetCitations(); this.resetCitations();
return new Promise(resolve => { return new Promise(resolve => {
const baseCit: Citation = this.corpusService.currentCorpus.citations[relTextRangePart[0]]; 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(); resolve();
} else { } else {
this.addReferences(this.corpusService.currentCorpus.citation_level_2, [baseCit]).then(() => { this.addReferences(this.corpusService.currentCorpus.citation_level_2, [baseCit]).then(() => {
......
import {NavController, ToastController} from '@ionic/angular'; 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 {VocabularyCorpus, VocabularyCorpusTranslation} from 'src/app/models/enum';
import {VocabularyService} from 'src/app/vocabulary.service'; import {VocabularyService} from 'src/app/vocabulary.service';
import {HttpClient, HttpErrorResponse} from '@angular/common/http'; import {HttpClient, HttpErrorResponse} from '@angular/common/http';
...@@ -14,7 +14,7 @@ import {CorpusService} from 'src/app/corpus.service'; ...@@ -14,7 +14,7 @@ import {CorpusService} from 'src/app/corpus.service';
templateUrl: './vocabulary-check.page.html', templateUrl: './vocabulary-check.page.html',
styleUrls: ['./vocabulary-check.page.scss'], styleUrls: ['./vocabulary-check.page.scss'],
}) })
export class VocabularyCheckPage implements OnInit { export class VocabularyCheckPage implements AfterViewInit {
HelperService = HelperService; HelperService = HelperService;
invalidSentenceCountString: string; invalidSentenceCountString: string;
ObjectKeys = Object.keys; ObjectKeys = Object.keys;
...@@ -85,6 +85,15 @@ export class VocabularyCheckPage implements OnInit { ...@@ -85,6 +85,15 @@ export class VocabularyCheckPage implements OnInit {
return this.vocService.refVocMap[this.vocService.currentReferenceVocabulary].possibleSubcounts[0]; 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[]) { private processSentences(sentences: Sentence[]) {
if (sentences.length > this.vocService.desiredSentenceCount) { if (sentences.length > this.vocService.desiredSentenceCount) {
this.currentRankingUnits.push([]); this.currentRankingUnits.push([]);
...@@ -111,12 +120,6 @@ export class VocabularyCheckPage implements OnInit { ...@@ -111,12 +120,6 @@ export class VocabularyCheckPage implements OnInit {
this.vocService.ranking = this.currentRankingUnits; 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() { updateReferenceRange() {
const hasFreq: boolean = this.vocService.refVocMap[this.vocService.currentReferenceVocabulary].hasFrequencyOrder; const hasFreq: boolean = this.vocService.refVocMap[this.vocService.currentReferenceVocabulary].hasFrequencyOrder;
this.vocService.frequencyUpperBound = hasFreq ? 500 : this.getPossibleSubCount(); 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